L1·Foundations

💬print, input & Comments

Talking to the user and to yourself.

printinputcomments

§ 1print

print(*objects, sep=' ', end='\n'). Change sep or end to customize output.

§ 2input

input(prompt) reads a line as a string. Convert with int()/float() if you need numbers.

§ 3Comments

# for single lines. Triple-quoted strings are usually docstrings, not comments.

Example

1# Ask the user their name
2name = input("Your name: ")
3print("Hello,", name, end="!\n")

Try it live · Python runs in your browser

Loading playground…

Checkpoint quiz

Question 1 / 2
input() returns: