Module 1 ยท Your first program Lesson 3 of 15
Input, output and f-strings
input() ALWAYS returns text. Converting it to a number is the first real bug every beginner meets, and knowing why it happens is the difference between guessing and debugging.
The concept
input() asks the person at the keyboard for a value, and print() shows one back. Notice the word "text": input ALWAYS returns a string, even when the person types 25. That single fact causes most beginner errors, and once you know it, converting with int() or float() becomes an automatic step rather than a mystery.
An f-string is a string with a value slotted in: print(f"{name}, you turn {age + 1} in {year}"). Everything inside the braces is evaluated as code, so no messy joining with + and no converting numbers to text by hand. Use f-strings from the start; they are what the industry writes.
name = input("Your name: ")
year = int(input("Your birth year: ")) # input() gives TEXT; int() converts it
print(f"{name}, you turn {2026 - year} in 2026")Common mistakes
The mistake to watch for is mixing the two styles, "Your age is " + age, which fails because a string and a number cannot be joined. If a line gives you "can only concatenate str (not int) to str", that is this bug, and the fix is either str(age) or โ better โ an f-string.
Worked example
age = int(input("Your age: ")) โ drop the int() and the next line, age + 5, fails with "can only concatenate str".
Your practice task
Ask for a name and a birth year, then print a sentence like "Asha, you turn 22 in 2027" using one f-string.
Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.
Key takeaway
input() asks the person at the keyboard for a value, and print() shows one back.
Keep your place in this course
A free account saves which lessons you have finished and unlocks the certificate. The lesson itself stays free to read.
Create free account or sign inCourse complete
You finished every lesson.
Your certificate is ready, and the projects you built are the proof to attach to an application.
Almost there
15 lessons left of 15
Finish every lesson to unlock the certificate. Each one ends in a practice task โ do them and the final project brief writes itself.