Python Quiz For Beginners

34 Questions | Total Attempts: 3412

SettingsSettingsSettings
Python Quiz For Beginners - Quiz

Hey, how much do you know about Python? Will you be able to solve this python quiz that we've created below? Let's find out today. Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation. Try solving the questions of this quiz and get to test your understanding of Python. So, are you ready? Let's start then. Good luck!


Questions and Answers
  • 1. 
    Which two lines of code are valid strings in Python?  
    • A. 

      This is a string

    • B. 

      ‘This is a string’

    • C. 

      (This is a string)

    • D. 

      “This is a string”

  • 2. 
    True or False: A string can be surrounded by three sets of single quotation marks or by three sets of double quotation marks.
    • A. 

      True

    • B. 

      False

  • 3. 
    Which line of code has the proper syntax for the print statement?
    • A. 

      Print( Its’ a rainy day )

    • B. 

      Print( ‘it’s a rainy day’ )

    • C. 

      Print( ‘it’s a rainy day” )

    • D. 

      Print( ‘it\’s a rainy day’ )

  • 4. 
    You have the following code segment: print(“Here we have a line of text \n and \n we can do newlines!”) What is the output of this code?
    • A. 

      Here we have a line of text and we can do newlines!

    • B. 

      Here we have a line of text and we can do newlines!

    • C. 

      Here we have a line of text and we can do newlines!

    • D. 

      Here we have a line of text and we can do newlines!

  • 5. 
    Which value type does input() return?
    • A. 

      Boolean

    • B. 

      String

    • C. 

      Int

    • D. 

      Float

  • 6. 
    True or False: Variables can be assigned only once.
    • A. 

      True

    • B. 

      False

  • 7. 
    You have the following code segment: myString01 = “my“ myString02 = “string” print(myString01 , myString02) What is the output of this code?
    • A. 

      My string

    • B. 

      String

    • C. 

      Mystring

    • D. 

      My

  • 8. 
    You have the following code segment: myString01 = “my“ myString02 = “string” print(myString01 + myString02) What is the output of this code?
    • A. 

      My string

    • B. 

      String

    • C. 

      Mystring

    • D. 

      My

  • 9. 
    True or False: A variable is a placeholder for data.
    • A. 

      True

    • B. 

      False

  • 10. 
    You have the following code segment: myString = “hello world” print( myString.upper() + “ “ + myString ) What is the output of this code?
    • A. 

      HELLO WORLD

    • B. 

      HELLO WORLD hello world

    • C. 

      Hello world hello world

    • D. 

      HELLO WORLD HELLO WORLD

  • 11. 
    Which two code segments output the number 20 to the console window?
    • A. 

      MyValue01 = “10” myValue02 = “10” myValue01 = myValue01 + myValue02 print(myValue02)

    • B. 

      MyValue01 = 10 myValue02 = 10 myValue01 = myValue01 + myValue02 print(myValue01)

    • C. 

      MyValue01 = 10 myValue02 = 10 print(myValue01 + myValue02)

    • D. 

      MyValue01 = “10” myValue02 = “10” print(myValue01 + myValue02)

  • 12. 
    True or False: You can combine a numeric value and a string by using the + symbol. 
    • A. 

      True

    • B. 

      False

  • 13. 
    Which two operators can be used on numeric values in Python?
    • A. 

      @

    • B. 

      %

    • C. 

      +

    • D. 

      #

  • 14. 
    Given the numeric variable myNumber, which lines of code properly prints the value? (Select 2)
    • A. 

      Print(“%d”)

    • B. 

      Print(“%d”, myNumber)

    • C. 

      Print(myNumber)

    • D. 

      Print(“%d” % myNumber)

  • 15. 
     You have the following code segment: testValue = 2 testValue = 10 + (testValue * 2) What is the value of testValue?
    • A. 

      10

    • B. 

      12

    • C. 

      14

    • D. 

      2

  • 16. 
    Which two sections of code print 'Hello World' to the console?
    • A. 

      MyValue = “Hello World” if myValue == “Hello World” : print(“Hello World”)

    • B. 

      MyValue = “Hello World” if myValue == “Hello World” : print(myValue)

    • C. 

      MyValue = “Hello World” if myValue != “Hello World” : print(myValue)

    • D. 

      MyValue = “Hello World” if myValue != “Hello World” : print(“Hello World”)

  • 17. 
    You have the following code segment: myValue = “yes” if myValue != “yes” :     print(“Hello”) print(“World”) What is the output from this code?
    • A. 

      World Hello

    • B. 

      Hello World

    • C. 

      Hello

    • D. 

      World

  • 18. 
    You have the following code segment: currentAmount = 100 itemCost = 100 if currentAmount >= itemCost :     print(“Item Purchased”) else :     print(“Not Enough Funds”) What is the output from this code?
    • A. 

      Not Enough Funds

    • B. 

      Item Purchased Not Enough Funds

    • C. 

      No output is displayed

    • D. 

      Item Puchased

  • 19. 
    Which symbol is used to check whether two variables are the same?
    • A. 

      -

    • B. 

      ==

    • C. 

      |

    • D. 

      =

  • 20. 
    Which code segment will NOT reach its print() function?
    • A. 

      If ‘yes’ != ‘no’ : print(“condition met”)

    • B. 

      If ‘yes’ != ‘yes’ : print(“condition met”)

    • C. 

      If not ‘yes’ == ‘no’ : print(“condition met”)

    • D. 

      If ‘yes’ == ‘yes’ : print(“condition met”)

  • 21. 
    Which line of code produces an error?
    • A. 

      "7" + 'eight'

    • B. 

      3 + 4

    • C. 

      "one" + "2"

    • D. 

      '5' + 6

  • 22. 
    What is the output of this code? >>> print(3 * 'TCS') ANS = '_______'  
  • 23. 
    What is the output of this code? >>> int("3" + "4")
    • A. 

      "7"

    • B. 

      "34"

    • C. 

      34

  • 24. 
    What is the output of this code? >>> float("210" * int(input("Enter a number:" ))) Enter a number: 2
    • A. 

      "420.0"

    • B. 

      "210210"

    • C. 

      420

    • D. 

      210210.0

  • 25. 
    What is the output of this code? num = 7 if num > 3:    print("3")    if num < 5:       print("5")       if num ==7:         print("7")
Back to Top Back to top