Printing with Python
Variables and Types
User Input
Mathematical Operators
String Operators
100

What function is used to display output in Python?

 print()

100

What is a variable in Python?

A named location in memory used to store data.

100

Which function is used to get user input in Python?

input()

100

What is the symbol for addition in Python?

+

100

How do you concatenate two strings in Python?

 Use +.

200

How do you print multiple items in one line?

 Use commas or sep parameter in print().

200

List three different data types in Python.

 Integer, Float, String.

200

How do you ensure that the input received is treated as an integer?

Wrap input in int(): age = int(input("Enter your age: ")).

200

How do you denote exponentiation in Python?

Use **.

200

What method would you use to find the length of a string?

Use len(string).

300

How can you format strings when printing, using placeholders?

Use formatted strings or f-strings: print(f"My name is {name}").

300

How do you convert a string to an integer in Python?

int(variable_name).

300

Write a line of code that prompts the user for their name and stores it in a variable.

name = input("What is your name? ").

300

What is the output of the expression 7 % 3?

1 (remainder of 7 divided by 3).

300

How can you convert a string to all uppercase letters?

Use upper(): string.upper().

400

What is the purpose of the end parameter in the print() function?

It changes the string printed at the end of the output; default is a new line.

400

What is the difference between a list and a tuple in Python?

 Lists are mutable; tuples are immutable.

400

What happens if you try to convert a non-numeric string to an integer using int()?

 It will raise a ValueError.

400

How can you use the // operator, and what does it do?

It performs floor division, returning the largest integer less than or equal to the division.

400

What is the result of "hello".replace("l", "x")?

"hexo".

500

Explain how to print a string that includes both single and double quotes.

Use escape characters: print("He said, \"Hello!\"").

500

Explain what dynamic typing means in Python.

Variables can change types without explicit declaration.

500

Explain how to handle exceptions when user input is not as expected.

Use try-except blocks to handle exceptions.

500

Explain the difference between = and == in Python.

= is assignment, == is comparison.

500

Explain how string slicing works with an example.

string[start:end].

M
e
n
u