What is the purpose of a variable in Python?
To store data that can be used and manipulated in a program.
What are the four main data types in Python?
int, float, string, boolean
What is the result of 5 + 3?
8
What does the == operator do?
It checks if two values are equal.
How do you read input from the user in Python?
input()
How do you assign a value to a variable named "x" ?
x = value
What data type is the value True?
boolean
What does the % operator do in Python?
It returns the remainder of a division (modulus).
What is the result of 5 < 3?
False
What function is used to display output in Python?
print()
What will be the output of the following code?
x = 10
y = x + 5
print
15
What is the difference between 10 and 10.0 in Python?
10 is an integer (int) and 10.0 is a float.
Evaluate 10 / 3. What type is the result?
3.3333333333333335 (float)
What does != mean in Python?
Not equal
Write a code snippet to read a user's name and print a greeting.
name = input("Enter your name: ")
print(f"Hello, {name}!")
How can you swap the values of two variables a and b in Python?
a, b = b, a
How do you find the data type of a variable x?
type(x)
What is the result of 2 ** 3?
8
Evaluate the following expression: 7 >= 7
True
How do you read an integer input from the user?
int(input())
Is it possible to change the type of a variable after it has been assigned a value? Give an example.
Yes, Python is dynamically typed
x = 10 # int
x = "Hello" # now a string
Convert the string "123" to an integer.
int("123")
Simplify the following expression: 2 + 3 * 4
14
What is the result of not (4 > 5)?
True
What will be the output of the following code?
x = input("Enter a number: ")
print("You entered:", x)
It will print "You entered:" followed by the user's input as a string.