← Complete program

Chapter 4 · Course 1 c04-m01

What kinds of values does Python know?

Your goal Recognize common Python value types and keep text, numbers, yes/no answers, and missing information apart.

The lesson, the vocabulary, the worked example and the mission are separate blocks. You can follow them in order or return to the one you need.

Video explanation

This English explanation has English subtitles. Its examples may use a separate practice dataset; use the data stated in the written mission for your answers.

Avant de commencer le code : comprendre l’ordinateur, le binaire, la mémoire et le système d’exploitation.

01

Story · optional context

The story so far

You are the new data hire at Aster Motors. During the first night test, a car resembling Noctis 01 crashes. Luca, the technician driving it, is injured and receives care. The prototype is missing. A computer record names your ID beside “release authorized,” although you gave no authorization. Mara Sol helps preserve the facts: a line bearing your ID is a claim to investigate, not proof that you acted.

You can start here without earlier episodes. To read the record, first learn what kinds of values Python can represent. You can do the exercise on paper without running code.

02

Before the lesson

Purpose of this course

Recognize common Python value types and keep text, numbers, yes/no answers, and missing information apart.

Topics covered

Identify str, int, float, bool, and None in small examples.; Understand that quotation marks make an apparent number into text.; Read True and False as logical values, not words to display.; Use type() to ask Python what kind of value it sees.

What you will learn

  • Identify str, int, float, bool, and None in small examples.
  • Understand that quotation marks make an apparent number into text.
  • Read True and False as logical values, not words to display.
  • Use type() to ask Python what kind of value it sees.

PART 1 · THE LESSON

Understand step by step

1

Lesson · explanation

A value, its type, and what it can prove

A program works with values. A value may be a word, a number, or a yes/no answer. Imagine labeled storage boxes: the label tells you how to use what is inside. A Python type plays a similar role. It describes how a value is represented and which operations make sense. It does not say where the value came from or whether it is true in real life.

In the Noctis 01 record, 'hero-07' is an ID written as text. Python can read it without trouble. That does not reveal who wrote the row or who actually used the account. A neatly printed receipt can contain an incorrect statement; equally, a correctly typed Python value can carry a claim that still needs checking.

You will meet str for text, int for whole numbers, float for decimal numbers, bool for true/false, and None for an absent value. These short names are Python's vocabulary. You need not memorize them all at once. Look at the symbols around a value and ask what the value describes in the case file.

Here is a counterexample: 0 in the field “human approvals found” does not prove that nobody ever gave an approval. It says the supplied cards report zero approvals found in that field. A type helps us handle the count; understanding the source's limits requires further investigation.

Pause and think

Does the type of 'hero-07' prove that you used the account?

See the explanation

No. A type describes representation; it cannot verify the author of the row or a real sign-in.

2

Lesson · explanation

Text str: quotation marks change the kind

In Python, a value surrounded by single or double quotation marks is text, called str. 'Noctis' and "Noctis" contain the same letters as text. Quotes mark the boundaries of the value; they are not decoration. In Mara's cards, A 'hero-07' and B '23:40' are text, even though B resembles a time.

Compare 7 and '7'. The first is a whole number you can add to three to make ten. The second is one written character. Joining the text '7' to the text '3' gives the text '73', not the number ten. This counterexample shows why looking only at visible digits is not enough: quotes change the value's kind.

An ID such as 'hero-07' is text because the letters, hyphen, and digits form an account name. It does not mean “hero minus seven.” The time '23:40' is text in this introductory lesson too: the colon belongs to the string. Later tools will let you work with times as moments rather than just written characters.

Text in a record may be accurate or misleading. 'release authorized' is a str whether an authorization happened or not. The card carrying your ID is information to preserve and compare with access records, not a verdict about your responsibility.

Pause and think

Why is card B '23:40' a str despite containing digits?

See the explanation

The characters are inside quotation marks. In this exercise, the time is represented as text.

3

Lesson · explanation

Whole number int: counting, including zero

A whole number has no decimal part. Python calls this type int. The values 7, 0, and -2 are whole numbers; a minus sign can show a negative number. In the mission, C is 0 for human approvals found in the supplied cards. There are no quotation marks, so this is the number zero rather than the text '0'.

Whole numbers are useful for counts: zero records found, one part checked, seven sensors received. Imagine marbles in a box. If you count and find none, the result is zero. If you have not opened the box yet, the count is unknown. Those are different situations. Zero is a value; unknown must remain unknown.

Arithmetic works on numbers, but you should only add quantities that describe compatible things. 2 + 3 can count five marbles. You should not add two batteries received and one battery installed and announce three distinct batteries. The same battery may have been counted at two different stages.

In the investigation, C's 0 means “zero human approvals found in this field.” It does not automatically prove no hidden action took place or that the ID was used legitimately. Check how the records were searched and where the computer row came from before turning a count into an accusation.

Pause and think

Card C is 0. Is that an absent value?

See the explanation

No. It is the whole number zero, a count recorded in the examined data.

4

Lesson · explanation

Decimal float: measurements and their limits

A measurement may have a decimal part. Python often represents this kind of number with float. It writes decimals with a dot: 1.5, not a comma. In the mission, D is 1.5 for an estimated duration. There are no quotation marks, and the decimal dot helps you recognize a float.

Imagine a stopwatch showing one and a half seconds. That duration is neither an account name nor a yes/no answer. You can compare 1.5 with 2.0 or calculate with it when that makes sense. Notice that 2.0 is still written as a float: the decimal dot describes its representation even though the amount equals two whole units.

A measurement can be an estimate. The type float tells us how Python holds 1.5; it does not tell us whether the stopwatch was accurate or how precise the estimate was. If a report gives 1.5 minutes, do not claim it was measured exactly to the millisecond. Meaning and source quality are not built into the type.

Also compare 1.5 with '1.5'. The first is a decimal number; the second is a sequence of characters. Someone might read them aloud the same way, but Python treats them differently. To sort card D, inspect its written form, then separately note that the duration is estimated.

Pause and think

Is 2.0 an int because its amount is two?

See the explanation

No. With the decimal dot, 2.0 is represented as a float.

5

Lesson · explanation

Boolean bool: true or false for one question

A Boolean value has two possibilities: True or False. Python spells these with capital letters and no quotation marks. In card E, False belongs to the field “check confirmed.” It means the supplied data does not mark that check as confirmed. It cannot by itself reconstruct everything that happened in the garage.

Think of a closed question: “Is this door marked as checked?” Its answer may be yes or no. A Boolean represents such an answer. But if nobody ever filled in the field, writing False would hide missing information. Find out whether the system recorded a negative answer or whether no answer was provided.

False and 'False' are not the same. Without quotes, False is a Boolean. With quotes, 'False' is text made of five letters. Text may be displayed in a message; a Boolean can act directly as a logical answer in a program. Likewise, True is not a quoted word meaning “true.”

Even True in a “release authorized” column would be a recorded claim, not sufficient proof that the authorization came from you. Voss wants to draw a conclusion from one row. Read the value accurately and seek independent confirmation before assigning an action to a person.

Pause and think

Card E contains unquoted False. Is it text?

See the explanation

No. It is a bool, a logical answer for the “check confirmed” field.

6

Lesson · explanation

None: no value, not zero or false

Python uses None when no value was supplied in a particular place. In card F, the witness name is None: that field contains no name. This is not the string 'None', which would be text, and not the number 0, which would be a count. None is a special marker whose type is called NoneType.

Imagine a library form. “Zero books borrowed” is a known count. A book-count box with no value does not let you say zero: nobody has supplied the count yet. Likewise, a missing witness name is not “zero witnesses.” It means this field has no recorded name.

None, False, and '' differ too. False is a negative logical answer to a defined question. '' is empty text between quotes: it exists as text even though it has no characters. None means no value was supplied. To learn why, inspect another field or ask whoever produced the record.

Do not replace F with C just to simplify your table. Writing zero where a witness name is absent would change the record's meaning. Report “witness name not entered” and keep separate the finding of zero human approvals in the supplied cards. These facts answer different questions.

Pause and think

How do C 0 and F None differ?

See the explanation

C contains a whole-number count equal to zero; F has no witness name. Zero and missing are not interchangeable.

7

Lesson · explanation

type() checks representation, not the case facts

If you are unsure about a value, Python offers type(). This function asks, “What kind of value is this in this program?” For example, type(7) reports int, type('7') reports str, type(False) reports bool, and type(None) reports the special NoneType. Python may surround these names with its own display notation; focus on the type name.

Practice on paper before running code. Copy cards A through F. Circle the quotation marks on A and B, the decimal dot on D, and the special words E and F. For C, note that 0 is a whole number without quotes. Predict what type() would report for each card and compare with the worked answer.

This function cannot read access logs or interview a witness. type('hero-07') reports str even if the ID was copied by mistake. type(False) reports bool even if a check happened elsewhere but was not recorded here. Representation and reality call for separate checks.

For Mara and the investigator, make two columns: “Python type” and “what this card actually supports.” After sorting, suggest checking sign-in logs, the origin of the row, and signed permissions. These are additional sources of evidence. A Python type alone cannot identify the person responsible for the crash.

Pause and think

What does type(None) report, and can it explain why a witness name is missing?

See the explanation

It reports NoneType. It cannot explain the missing name; you must examine the record’s source.

PART 2 · WATCH IT WORK

A complete worked example

Follow each step, then the result

Worked example: read one record

Mara shows five separate values: '07:10', 0, 2.5, False, and None. They stand for a written time, a count of known approvals, a distance, a confirmation, and an unfilled name.

  1. '07:10' has quotes, so it is text str. The colon is part of that text.
  2. 0 has no quotes or decimal part, so it is int. Zero is a value, not absence.
  3. 2.5 has a decimal dot, so it is float.
  4. False is a bool. None marks absence and has its special type.
  5. Mara asks what this proves. The types tell us how values are represented, not who really authorized a release.
What this shows

Types help separate 0, '0', and None; a record's source and truth need a separate investigation.

How this helps with your mission

The worked example separates a written time '07:10', a count 0, a measurement 2.5, the Boolean False, and None. In the mission, sort A through F the same way: the ID and time are text, the approval count an integer, the duration a decimal, the check a Boolean, and the missing name None. This gives the investigator an accurate inventory without treating the row carrying your ID as proof of authorization. It also shows why access logs and the row's origin need checking.

PART 3 · YOUR TURN

Use the lesson to solve the mission

Story scene · practical task

Mission: sort the night's values

An independent investigator asks for a readable inventory of record fields. Mara gives you six cards: A 'hero-07', an ID written in a row; B '23:40', a time; C 0, human approvals found; D 1.5, an estimated duration; E False, “check confirmed”; F None, a witness name not entered. Voss wants to treat A as proof against you. Describe the values without exceeding the evidence.

Your task

  1. Match A through F to Python types or the special absence None.
  2. Explain the difference between A as text and evidence that a person really used an account.
  3. Compare C and F: why are 0 and None different?
  4. Give the investigator a careful sentence and one further check.

How to know you have succeeded

  • You identify A and B as str, C as int, D as float, E as bool, and F as None.
  • You treat A's ID as a claim in a record, not proof of action.
  • You explain that C is a count equal to zero while F has no recorded value.
  • You ask for independent sign-in or authorization evidence before blaming anyone.
Open this mission in the browser workspace

Try code or SQL and keep a local draft. The mission questions are checked separately below.

Check the facts in your mission

Answer each factual question, then write your report in your own words. The program checks the choices; compare the report with the worked answer below.

1. What is the type of cards A `'hero-07'` and B `'23:40'`?
2. How should you classify C `0` and D `1.5`?
3. What do E `False` and F `None` represent?
4. Why must C `0` and F `None` stay distinct?
5. A contains the ID `'hero-07'`. Which conclusion is justified?
See the worked answer
  1. A and B are str; C is int; D is float; E is bool; F is None, with type NoneType.
  2. A only says a row contains hero-07. Find who wrote the row, with what permission, and when.
  3. 0 is the reported count in that field. None says no witness name was entered. Do not turn one into the other.
  4. Possible statement: “This ID appears in the record, but these cards show no human approval. We must check access logs and the row's provenance before drawing a conclusion.”

You can recognize value types. Next, you will give values clear names so the case fields cannot be mixed up.

Before you leave

Remember this

  • A type describes how Python represents a value; it does not prove the claim is true.
  • Quotes make '7' and '23:40' text values of type str.
  • An int is a whole number; 0 is a known count, not absence.
  • A float represents a number with a decimal dot, such as 1.5.
  • Unquoted True and False are Booleans tied to a particular question.
  • None marks a value not supplied and differs from 0, False, and empty text.
  • type() checks a value’s kind; origin and truth need other evidence.
A–Z

Part of the lesson · keep nearby

New words, explained

These are the names of ideas used in the lesson above. Return here whenever a word feels unfamiliar.

Value
Information handled by code, such as 7 or 'Noctis'.
Type
A value's kind: text, whole number, decimal number, or yes/no answer.
str
Text in quotes, such as '07:10'. It is short for string.
int
A whole number without decimals, such as 7 or 0.
float
A number with a decimal part, written with a dot in Python, such as 2.5.
bool
A logical value: True or False.
None
Python's marker for no value supplied here. It is not zero.