Programming for Everybody (Getting Started with Python) Quiz Answers 2023

All Weeks Programming for Everybody (Getting Started with Python) Quiz Answers

Programming for Everybody (Getting Started with Python) Week 03 Quiz Answers

Q1. When Python is running in the interactive mode and displaying the chevron prompt (>>>) – what question is Python asking you?

  • What is your favourite color?
  • What would you like to do?
  • What Python script would you like me to run?
  • What is the next machine language instruction to run?

Q2. What will the following program print out:

1.>>> x = 15
2.>>> x = x + 5
3.>>> print(x)
  • 20
  • 5
  • 15
  • “print x”
  • x + 5

Q3. Python scripts (files) have names that end with:

  • .doc
  • .exe
  • .png
  • .py

Q4. Which of these words are reserved words in Python ?

  • todo
  • if
  • machine
  • break
  • concat

Q5. What is the proper way to say “good-bye” to Python?

  • while
  • #EXIT
  • // stop
  • quit()

Q6. Which of the parts of a computer actually executes the program instructions?

  • Secondary Memory
  • Central Processing Unit
  • Input/Output Devices
  • Main Memory

Q7. What is “code” in the context of this course?

  • A way to encrypt data during World War II
  • A sequence of instructions in a programming language
  • A password we use to unlock Python features
  • A set of rules that govern the style of programs

Q8. A USB memory stick is an example of which of the following components of computer architecture?

  • Output Device
  • Secondary Memory
  • Main Memory
  • Central Processing Unit

Q9. What is the best way to think about a “Syntax Error” while programming?

  • The computer needs to have its software upgraded
  • The computer did not understand the statement that you entered
  • The computer is overheating and just wants you to stop to let it cool down
  • The computer has used GPS to find your location and hates everyone from your town

Q10. Which of the following is not one of the programming patterns covered in Chapter 1?

  • Repeated Steps
  • Conditional Steps
  • Sequential Steps
  • Random steps

Programming for Everybody (Getting Started with Python) Week 04 Quiz Answers

Q1. In the following code,

1.  print(98.6)

What is “98.6”?

  • An iteration / loop statement
  • A variable
  • A constant
  • A conditional statement

Q2. What does the following code print out?

1. print("123" + "abc")
  • 123abc
  • 123+abc
  • This is a syntax error because you cannot add strings
  • hello world

Q3. Which of the following is a bad Python variable name?

  • Spam
  • 23spam
  • _spam
  • SPAM23

Q4. Which of the following is not a Python reserved word?

  • speed
  • else
  • for
  • if

Q5. Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?

1. x = x + 2
  • This would fail as it is a syntax error
  • Create a function called “x” and put the value 2 in the function
  • Produce the value “false” because “x” can never equal “x+2”
  • Retrieve the current value for x, add two to it and put the sum back into x

Q6. Which of the following elements of a mathematical expression in Python is evaluated first?

  • Multiplication *
  • Subtraction –
  • Parentheses ( )
  • Addition +

Q7. What is the value of the following expression

1.  42 % 10

Hint – the “%” is the remainder operator

  • 10
  • 0.42
  • 2
  • 4210

Q8. What will be the value of x after the following statement executes:

1.  x = 1 + 2 * 3 - 8 / 4
  • 2
  • 3
  • 5.0
  • 1.0

Q9. What will be the value of x when the following statement is executed:

1.  x = int(98.6)
  • 100
  • 6
  • 98
  • 99

Q10. What does the Python input() function do?

  • Pause the program and read data from the user
  • Connect to the network and retrieve a web page.
  • Read the memory of the running program
  • Take a screen shot from an area of the screen

Programming for Everybody (Getting Started with Python) Week 05 Quiz Answers

Q1. What do we do to a Python statement that is immediately after an if statement to indicate that the statement is to be executed only when the if statement is true?

  • Indent the line below the if statement
  • Underline all of the conditional code
  • Begin the statement with a curly brace {
  • Start the statement with a “#” character

Q2. Which of these operators is not a comparison / logical operator?

  • ==
  • <
  • !=
  • >=
  • =

Q3. What is true about the following code segment:

1. if x == 5 :
2. print('Is 5')
3. print('Is Still 5')
4. print('Third 5')
  • Depending on the value of x, either all three of the print statements will execute or none of the statements will execute
  • The string ‘Is 5’ will always print out regardless of the value for x.
  • The string ‘Is 5’ will never print out regardless of the value for x.
  • Only two of the three print statements will print out if the value of x is less than zero.

Q4. When you have multiple lines in an if block, how do you indicate the end of the if block?

  • You de-indent the next line past the if block to the same level of indent as the original if statement
  • You omit the semicolon ; on the last line of the if block
  • You capitalize the first letter of the line following the end of the if block
  • You use a curly brace { after the last line of the if block

Q5. You look at the following text:

1.if x == 6 :
2.    print('Is 6')
3.    print('Is Still 6')
4.    print('Third 6')

It looks perfect but Python is giving you an ‘Indentation Error’ on the second print statement. What is the most likely reason?

  • You have mixed tabs and spaces in the file
  • In order to make humans feel inadequate, Python randomly emits ‘Indentation Errors’ on perfectly good code – after about an hour the error will just go away without any changes to your program
  • Python thinks ‘Still’ is a mis-spelled word in the string
  • Python has reached its limit on the largest Python program that can be run

Q6. What is the Python reserved word that we use in two-way if tests to indicate the block of code that is to be executed if the logical test is false?

  • iterate
  • break
  • except
  • else

Q7. What will the following code print out?

1. x = 0
2. if x < 2 :
3. print('Small')
4. elif x < 10 :
5. print('Medium')
6. else :
7. print('LARGE')
8. print('All done')
  • Medium All done
  • Small All done
  • Small Medium LARGE All done
  • Small

Q8. For the following code,

1. if x < 2 :
2.    print('Below 2')
3. elif x >= 2 :
4.     print('Two or more')
5. else :
6.    print('Something else')

What value of ‘x’ will cause ‘Something else’ to print out?

  • x = 2.0
  • This code will never print ‘Something else’ regardless of the value for ‘x’
  • x = 2
  • x = -2

Q9. In the following code (numbers added) – which will be the last line to execute successfully?

1. astr = 'Hello Bob'
2. istr = int(astr)
3. print('First', istr)
4. astr = '123'
5. istr = int(astr)
6. print('Second', istr)
  • 1
  • 5
  • 2
  • 4

Q10. For the following code:

1.astr = 'Hello Bob'
2.istr = 0
4.    istr = int(astr)
6.    istr = -1
What will the value be for istr after this code executes?
  • It will be the ‘Not a number’ value (i.e. NaN)
  • It will be a random number depending on the operating system the program runs on
  • false
  • -1

Programming for Everybody (Getting Started with Python) Week 07 Quiz Answers

Q1. Which Python keyword indicates the start of a function definition?

  • break
  • sweet
  • def
  • help

Q2. In Python, how do you indicate the end of the block of code that makes up the function?

  • You de-indent a line of code to the same indent level as the def keyword
  • You put the “END” keyword in column 7 of the line which is to be the last line of the function
  • You put the colon character (:) in the first column of a line
  • You add a line that has at least 10 dashes

Q3. In Python what is the input() feature best described as?

  • A built-in function
  • The central processing unit
  • A user-defined function
  • A conditional statement

Q4. What does the following code print out?

1. def thing():    print('Hello')
2. print('There')
  • thing Hello There
  • There
  • def thing
  • Hello

Q5. In the following Python code, which of the following is an “argument” to a function?

1.x = 'banana'
2.y = max(x)
  • ‘banana’
  • max
  • print
  • x

Q6. What will the following Python code print out?

1.def func(x):
2.    print(x)
  • def ,x ,func ,func
  • x 10 x 20
  • x 20
  • 10 20

Q7. Which line of the following Python program will never execute?

1.def stuff():
  • return
  • def stuff():
  • stuff()
  • print (‘World’)
  • print(‘Hello’)

Q8. What will the following Python program print out?

1.def greet(lang):
2.if lang == 'es':
3.return 'Hola'
4.elif lang == 'fr':
5.return 'Bonjour'
7.return 'Hello'
  • Bonjour Michael
  • Hola Michael
  • Hello Michael
  • def Hola Bonjour Hello Michael

Q9. What does the following Python code print out? (Note that this is a bit of a trick question and the code has what many would consider to be a flaw/bug – so read carefully).

1.def addtwo(a, b):
2.    added = a + b
3.return a
4.x = addtwo(2, 7)
  • 2
  • addtwo
  • 7
  • 14

Q10. What is the most important benefit of writing your own functions?

  • To avoid having more than 10 lines of sequential code without an indent or de-indent
  • Following the rule that whenever a program is more than 10 lines you must use a function
  • Following the rule that no function can have more than 10 statements in it
  • Avoiding writing the same non-trivial code more than once in your program

Programming for Everybody (Getting Started with Python) Week 07 Quiz Answers

Q1. What is wrong with this Python loop:

1.n = 5
2.while n > 0 :
4.print('All done')
  • This loop will run forever
  • The print(‘All done’) statement should be indented four spaces
  • There should be no colon on the while statement
  • while is not a Python reserved word

Q2. What does the break statement do?

  • Exits the program
  • Resets the iteration variable to its initial value
  • Exits the currently executing loop
  • Jumps to the “top” of the loop and starts the next iteration

Q3. What does the continue statement do?

  • Exits the currently executing loop
  • Jumps to the “top” of the loop and starts the next iteration
  • Resets the iteration variable to its initial value
  • Exits the program

Q4. What does the following Python program print out?

1.tot = 0
2.for i in [5, 4, 3, 2, 1] :
3.tot = tot + 1
  • 10
  • 5
  • 15
  • 0

Q5. What is the iteration variable in the following Python code:\

1.friends = ['Joseph', 'Glenn', 'Sally']
2.for friend in friends :
3.print('Happy New Year:', friend)
  • friend
  • Glenn
  • Sally
  • friends

Q6. What is a good description of the following bit of Python code?

1.zork = 0
2.for thing in [9, 41, 12, 3, 74, 15] :
3.zork = zork + thing
4.print('After', zork)
  • Count all of the elements in a list
  • Find the smallest item in a list
  • Find the largest item in a list
  • Sum all the elements of a list

Q7. What will the following code print out?

1.smallest_so_far = -1
2.for the_num in [9, 41, 12, 3, 74, 15] :
3.if the_num < smallest_so_far :
4.smallest_so_far = the_num

Hint: This is a trick question and most would say this code has a bug – so read carefully

  • -1
  • 74
  • 42
  • 3

Q8. What is a good statement to describe the is operator as used in the following if statement:

1.if smallest is None :
2.smallest = value
  • Is true if the smallest variable has a value of -1
  • matches both type and value
  • Looks up ‘None’ in the smallest variable if it is a string
  • The if statement is a syntax error

Q9. Which reserved word indicates the start of an “indefinite” loop in Python?

  • def
  • indef
  • while
  • break
  • for

Q10. How many times will the body of the following loop be executed?

1.n = 0
2.while n > 0 :
5.print('Dry off!')
  • 5
  • 0
  • This is an infinite loop
  • 1
Get All Course Quiz Answers of Python for Everybody Specialization

Course 01: Programming for Everybody (Getting Started with Python)

Course 02: Python Data Structures

Course 03: Using Python to Access Web Data

Course 04: Using Databases with Python

Team Networking Funda
Team Networking Funda

Welcome to the official Author Page of Team Networking Funda! Here, we are dedicated to unraveling the intricate world of networking, connectivity, and team dynamics. Our mission is to provide you with insightful, actionable advice and solutions that will help you build strong connections, foster collaboration, and achieve success in all aspects of your professional life.

🌐 Networking Insights: Dive into the art of networking with us, as we explore strategies, tips, and real-world examples that can elevate your networking game. Whether you're a seasoned pro or just starting, we have valuable insights to offer.

🤝 Team Synergy: Discover the secrets to creating high-performing teams. We delve into team dynamics, leadership, and communication to help you unlock the full potential of your team and achieve outstanding results.

🚀 Professional Growth: Explore the tools and techniques that can accelerate your professional growth. From career development to personal branding, we're here to guide you toward achieving your goals.

🌟 Success Stories: Be inspired by success stories, case studies, and interviews with experts who have mastered the art of networking and teamwork. Learn from their experiences and apply their insights to your journey.

💬 Engage and Connect: Join the conversation, leave comments, and share your own networking and team-building experiences. Together, we can create a vibrant community of like-minded professionals dedicated to growth and success.

Stay tuned for a wealth of resources that will empower you to excel in your professional life. We're here to provide you with the knowledge and tools you need to thrive in today's interconnected world.

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in the world of networking and team building. With backgrounds in [Your Background or Expertise], we bring a diverse range of perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!