FC0-U71 ยท Software development concepts
Data types
Characters, strings, integers, floats and Booleans, and choosing the right type for a value.
Key points
- A data type tells the computer what kind of value a piece of data is and what you can do with it.
- Character: one letter, digit or symbol ('A').
- String: text made of characters ('Hello').
- Integer: whole number (42).
- Float: number with a fractional part (3.14).
- Boolean: only true or false.
- Pick the type that matches the meaning of the value: digits in quotes are a string, not a number.
Source: https://docs.python.org/3/tutorial/introduction.html
Practice questions
Which data type can hold only the values true or false?
- Integer
- Boolean
- Float
- String
Show answer
Answer: B. Boolean
A Boolean has exactly two possible values, true and false, which makes it ideal for flags and conditions. The other types hold numbers or text.
Which of these values are floats?
- 3.14
- -0.5
- 2.0
- "7.5" (in quotes)
- 7
Show answer
Answer: A. 3.14, B. -0.5, C. 2.0
Values with a fractional part, including 2.0, are floats. "7.5" in quotes is a string, and 7 is an integer.
True or false: the value "25" written in quotes is an integer because it contains only digits.
Show answer
Answer: False
False. Quotes make it a string, so it is treated as text. It must be converted to an integer before you can do arithmetic with it.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
