Print & Input
Strings & Formatting
Operators & Expressions
Loops & Conditionals
Random, Files, & Modules
100

What Python function is used to display text on the screen?

print()

100

What character is used to create a new line in a string?

\n

100

What operator is used for exponentiation (powers)?

**

100

What loop is used to repeat something a certain number of times?

for loop

100

What module lets you generate random numbers in Python?

random

200

What function lets the user type something into the program?

input()

200

What does this print: print("Python\tRocks")?

It prints with a tab between words: Python    Rocks

200

What is the result of 5 // 2?

2 (integer division)

200

What loop runs while a condition is true?

while loop

200

What function gives a random number between 1 and 10 (inclusive)?

random.randint(1, 10)

300

How do you print a string with a quote inside it, like: He said "hello"?

Use escape character: print("He said \"hello\"")

300

How can you insert a variable into a string using f-strings?

Use f"Hello {name}"

300

What operator checks if two values are equal?

==

300

What keyword is used to stop a loop early?

break

300

What statement is used to handle exceptions in Python?

try and except

400

What symbol is used to combine strings in a print statement?

The + operator (concatenation)

400

What method turns a string to uppercase?

.upper()

400

What does != mean?

Not equal to

400

What keyword skips the rest of the loop and goes to the next iteration?

continue

400

How do you open a file for reading using with?

with open("filename.txt", "r") as f:

500

What does the end parameter in print() do?

It changes what is printed at the end (default is a newline)

500

What method removes whitespace from the beginning and end of a string?

.strip()

500

What is the result of True and False?

False

500

What keyword do you use to check a condition after an if?

elif

500

What keyword is used to include code from another Python file?

import