Programs talk to people. print() sends output to the screen; input() reads a line the user types. Together they make your first interactive scripts.
name = input("What's your name? ") # always returns a STRINGprint("Hello,", name)# input is always a string — convert when you need a numberage = int(input("Your age? "))print(f"Next year you'll be {age + 1}")# print optionsprint("a", "b", "c", sep="-") # a-b-cprint("no newline", end=" ") # keeps the cursor on the same line
Key takeaways
- 01print() displays output; use sep and end to control formatting.
- 02input() reads a line and always returns a string.
- 03Convert input with int()/float() when you need a number.
- 04f-strings are the cleanest way to build output from values.
