Daily set: three random terms.
-
What this creature is
A variable is a name you give to a value stored in memory. You assign a value with = and can use that name later in your program.
Why you will regret ignoring it
Variables let you reuse values, update them, and keep your code readable. Without them, you would repeat the same literals everywhere.
Example
name = "Alex"
age = 20
Common disgrace
Using the same variable name for different things in one program, then getting confused when the value is not what you expect.
Trial by code
Create two variables: one for a word (string) and one for a number. Print both on one line.
-
What this creature is
An if statement runs a block of code only when a condition is true. You can add elif for other tests and else for a default.
Why you will regret ignoring it
Programs need to choose what to do. if lets you branch based on values, user input, or errors.
Example
score = 80
if score >= 50:
print("Pass")
else:
print("Review")
Common disgrace
Forgetting the colon (:) after if / elif / else, or not indenting the block under the condition — both cause syntax errors.
Trial by code
Write an if/else that prints one message if a number is greater than 0 and another if it is not.
-
What this creature is
input() reads one line of text from the user (usually the terminal) and returns it as a string.
Why you will regret ignoring it
It lets programs respond to what the user types, which is essential for simple interactive programs.
Example
name = input("Your name: ")
print("Welcome,", name)
Common disgrace
Treating input as a number without converting — input always returns a string until you convert with int(), float(), etc.
Trial by code
Ask for two words using input() and print them on one line with a space between them.