Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 1.35 KB

File metadata and controls

68 lines (55 loc) · 1.35 KB

Python Basics Quiz

01. What is the correct file extension for Python files?

  • .pyth
  • .pt
  • .py
  • .pyt

02. How do you insert comments in Python code?

  • //
  • #
  • *

03. Which one is NOT a legal variable name?

  • 2myvar
  • my_var
  • _myvar
  • myVar

04. What is the correct syntax to output "Hello World" in Python?

  • echo("Hello World")
  • p("Hello World")
  • msg("Hello World")
  • print("Hello World")

05. How do you create a variable with the numeric value 5?

  • x = 5
  • x = int(5)
  • x = num(5)
  • x = 5.0

06. Which of these collections defines a set?

  • {"name": "John", "age": 36}
  • ["apple", "banana", "cherry"]
  • ("apple", "banana", "cherry")
  • {"apple", "banana", "cherry"}

07. What is the correct way to create a function in Python?

  • function myFunction():
  • def myFunction():
  • create myFunction():
  • define myFunction():

08. What is the output of the following code?

x = "Python"
print(len(x))
  • 7
  • 5
  • 4
  • 6

09. Which keyword is used to create a class in Python?

  • function
  • define
  • method
  • class

10. What is the correct syntax to import a module in Python?

  • import module_name
  • include module_name
  • using module_name
  • require module_name