Skip to main content

Function

Functions Quiz

  1. How to define a function?
    def myfunc():
    function myfunc()
    func myfunc()
    define myfunc()
  2. What keyword exits a function?
    return
    exit
    stop
    end
  3. How do you call a function named greet?
    call greet()
    greet()
    run greet()
    execute greet()
  4. What is the default return value of a function without return?
    None
    0
    Error
    ""
  5. Can functions have parameters?
    Yes
    No
  6. What does this code print?
    def f():  
    
        print("Hi")  
    
    f()
    Hi f Error None
  7. Which of these is a built-in function?
    def()
    print()
    function()
    var()
  8. How to send info into a function?
    Arguments
    Parameters
    Inputs
    Both a and b
  9. What is the output?
    def add(a, b):  
    
        return a + b  
    
    print(add(2,3))
    5 23 None Error
  10. Can functions return multiple values?
    Yes
    No

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