Python Coding Basics Flashcards
6 cards from real Online Coding Lessons practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Python Coding Basics flashcards as text
What is the output of: print(2 ** 3) in Python?
Answer: 8
The ** operator in Python performs exponentiation, so 2 ** 3 equals 2 raised to the power of 3, which is 8.
Which loop is used to iterate over a sequence in Python?
Answer: for loop
The 'for' loop in Python is used to iterate over sequences like lists, strings, or ranges.
What does 'input()' do in Python?
Answer: Reads user input from the keyboard
The input() function pauses program execution and waits for the user to type something, then returns the entered text as a string.
Which of the following is a valid Python variable name?
Answer: my_var
Python variable names can contain letters, numbers, and underscores, but cannot start with a number or contain hyphens or spaces.
What is the result of: type(3.14) in Python?
Answer:
The value 3.14 is a decimal number, so Python classifies it as a 'float' (floating-point number).
What keyword is used to handle exceptions in Python?
Answer: except
Python uses the 'except' keyword in a try-except block to catch and handle exceptions.