Skip to main content

Control Structures

Control Structures Quiz

  1. What keyword starts a conditional statement?
    if
    else
    then
    for
  2. What does else mean?
    If not
    Loop
    Function
    End
  3. Which of these is the correct syntax for if in Python?
    if x > 0:
    if x > 0 then
    if (x > 0)
    if x > 0 endif
  4. What is the output of this code?
    if 10 > 5:  
    
      print("Yes")  
    
    else:  
    
      print("No")
    Yes No Error Nothing
  5. What will this output?
    if 3 == 3:  
    
      print("Equal")
    Equal Not Equal Error No output
  6. What is elif used for?
    As an additional if condition
    Looping
    Ending program
    Printing
  7. Can if statement be used without else?
    Yes
    No
  8. What is the output?
    x = 10  
    
    if x > 5 and x < 15:  
    
      print("OK")
    OK Error Nothing 10
  9. Which keyword is NOT used in control flow?
    if
    else
    elif
    else if
  10. What will this print?
    if False:  
    
      print("Hi")  
    
    else:  
    
      print("Bye")
    Hi Bye Nothing Error

Comments

Popular posts from this blog

Fun time

Projects and Fun Activities Quiz Which module helps in drawing shapes? turtle draw graphics paint What is a simple project idea for beginners? Calculator Operating system Database Web browser Which helps create interactive quizzes? input() print() loops all of these What does the turtle.forward() command do? Moves turtle forward Turns turtle right Pauses program Changes color What structure stores quiz questions? List Tuple String Integer What can you use to track scores? Variable List Function Module Turtle graphics is used for: Drawing Networking File handling Calculations What command clears the screen in turtle? turtle.clear() turtle.reset() turtle.er...

Answers in detail

 Introduction to Python (10 Questions)Who developed Python? a) Dennis Ritchie b) Guido van Rossum c) James Gosling d) Bjarne Stroustrup Answer: bWhich year was Python created? a) 1989 b) 1991 c) 2000 d) 2010 Answer: bWhat type of language is Python? a) Compiled b) Interpreted c) Assembly d) Machine Answer: bWhich is the correct extension for Python files? a) .py b) .java c) .txt d) .exe Answer: aWhat is the first command used to print in Python? a) print() b) echo() c) console.log() d) output() Answer: aPython is named after: a) A snake b) Monty Python's Flying Circus c) A programmer d) A city Answer: bWhich symbol is used to comment in Python? a) // b) -- c) # d) /* Answer: cWhat does PEP stand for in Python? a) Python Enhancement Proposal b) Python Easy Programming c) Programming Environment Protocol d) Programmer’s Education Path Answer: aWhich IDE is commonly used for Python coding? a) Visual Studio Code b) Eclipse c) PyCharm d) Notepad Answer: cWhat will print("Hello...

Variables & Data Types (Questions 11–20)

Variables & Data Types Quiz Which is a valid variable name? 1var var_1 var-2 @var Choose the correct data type for: 45 String Integer Float Boolean True or False values are called: Strings Booleans Integers Floats What will type("Hello") return? int float str bool Which of these is a floating-point number? 10 '10' 10.5 True How to take input from user in Python? input() scan() get() read() What is the value of variable x after x = 5 + 2? 7 "7" 52 Error Can variable names start with a number? Yes No Which is NOT a Python data type? List Set Number Array Is Python case-sensitive i...