Python Programming Flashcards
What is a string in Python?
A sequence of characters surrounded by quotation marks.
Which of the following is an integer?
“123”
123
12.3
‘123’
123
How do you print the phrase “Hello, World!” in Python?
print(“Hello, World!”)
Which symbol is used for multiplication in Python?
*
What will print(“Fish”, 4) output?
Fish 4
What does the \n character do in a print statement?
It creates a new line.
What is the correct way to assign a string to a variable named ‘animal’ and print it in Python?
animal = “Cat”; print(animal)
How do you concatenate a variable a with a string “ is great” in a print statement?
print(a + “ is great”)
Which of the following correctly reads input from the user and stores it in a variable named user_age as an integer?
user_age = int(input(“Enter your age:”))
What will len(“Python”) return?
6
How do you start a comment in Python?
Comment
Which operator checks if two values are equal?
==
What is the result of 10 != 10?
False
What does the following code snippet do? if x > 10: print(“Big”) else: print(“Small”)
Prints “Big” if x is greater than 10, otherwise prints “Small”.
What will print(“Hello”[1]) output?
e