โ† All Online Coding Lessons Flashcard Decks

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
  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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).

  6. 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.