Вопрос 4 which of the following is not a python reserved word

Programming for Everybody (Getting Started with Python)

Coursera

Programming for Everybody (Getting Started with Python)

Week 4

Chapter 2

Graded Quiz • 30 min

1. Which of the following is a comment in Python?

  • # This is a test
  • // This is a test
  • /* This is a test */
  • * This is a test

1.In the following code,

What is “98.6”?

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

2.What does the following code print out?

  • This is a syntax error because you cannot add strings
  • hello world
  • 123abc
  • 123+abc

2. In the following code,

What is “x”?

  • A variable
  • A constant
  • A function
  • A Central Processing Unit

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

  • Spam
  • 23spam
  • SPAM23
  • _spam

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

  • spam
  • break
  • continue
  • iterate
  • for
  • Speed

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

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

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

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

7. What is the value of the following expression

Hint – the “%” is the remainder operator

  • 420
  • 2
  • 1042
  • 10

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

  • 8
  • 2.0
  • 5.0
  • 4

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

  • 6
  • 98
  • 99
  • 100

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

Do Not Only Use These Quizzes For Getting Certificates.You Can Take Help From These Quizzes Answer. All Quizzes & Contents Are Free Of Charge. ✅

If You Want Any Quiz Answers Then Please Contact Us

Python Data Structures Week 2 Quiz Answers

Hello Friends in this article i am gone to share Coursera Course: Python Data Structures Week 2 Quiz Answers with you..

Python Data Structures

Go to this Course: Python Data Structures


Python Data Structures Week 2 Quiz Answers

Question 1) Which of the following is a comment in Python?

  • * This is a test
  • /* This is a test */
  • // This is a test
  • # This is a test

Question 2) What does the following code print out?

print “123” + “abc”

  • 123abc
  • 123+abc
  • hello world
  • This is a syntax error because you cannot add strings

Question 3) Which of the following is a bad Python variable name?

  • spam23
  • SPAM23
  • spam_23
  • 23spam

Question 4) Which of the following is not a Python reserved word?

  • for
  • if
  • spam</span >
  • else

Question 5) What does the following statement do?

x = x + 2

  • Exit the program
  • This would fail as it is a syntax error</span >
  • Increase the speed of the program by a factor of 2</span >
  • Retrieve the current value for x, add two to it and put the sum back into x</span >

Question 6) Which of the following elements of a mathematical expression in Python is evaluated first?

  • Addition +
  • Parenthesis ( )</span >
  • Subtraction –
  • Multiplication *

Question 7) What is the value of the following expression

42 % 10

Hint – the “%” is the remainder operator

  • 2
  • 0.42
  • 420
  • 1042

Question 8) What is the value in x after the following statement executes:

x = 1 + 2 * 3 – 8 / 4

  • 8
  • 5
  • 4
  • 15

Question 9) What value be in the variable x when the following statement is executed

x = int(98.6)

  • 6
  • 100
  • 99
  • 98

Question 10) What does the Python raw_input() function do?

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

Week 2  Assignment 1

python

name = raw_input(“Enter your name”)

print (“Hello” + ‘ ‘ + name) # ‘space’ to add space between words, and () to make python 3 print statement

Assignment 2

# 2.3 Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay.

# Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). 

# You should use raw_input to read a string and float() to convert the string to a number.

# Do not worry about error checking or bad user data.

# This first line is provided for you</i >

hrs = raw_input(“Enter Hours:”)

rate = raw_input(“Enter Rate:”)

hrs = float(hrs)

rate = float(rate)

pay = hrs*rate

print pay

These solutions are for reference only.

It is recommended that you should solve the assignment and quiz by yourself honestly then only it makes sense to complete the course.

but if you cant figure out some part of it than you can refer these solutions

make sure you understand the solution  

dont just copy paste it

——————————————

1.) In the following code, print 98.6. What is “98.6”?

answer-  A constant

2)In the following code, x = 42. What is “x”?

A variable

3)Which of the following variables is the “most mnemonic”?

hours

4)Which of the following is not a Python reserved word?

speed

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

Retrieve the current value for x, add two to it and put the sum back into x

6)Which of the following elements of a mathematical expression in Python is evaluated first?

–Parenthesis()

7)What is the value of the following expression

2

8)What will be the value of x after the following statement executes: x = 1 + 2 * 3 – 8 / 4

5

9)What will be the value of x when the following statement is executed: x = int(98.6)

98

10)What does the Python raw_input() function do?

Pause the program and read data from the user

—————————-

reference :coursera.org

Table of Contents

All Weeks Programming for Everybody (Getting Started with Python) 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
3.try:
4.    istr = int(astr)
5.except:
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)
3.print(y)
  • ‘banana’
  • max
  • print
  • x

Q6. What will the following Python code print out?

1.def func(x):
2.    print(x)
3.func(10)
4.func(20)
  • 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():
2.print('Hello')
3.return
4.print('World')
5.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'
6.else:
7.return 'Hello'
8.print(greet('fr'),'Michael')
  • 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)
5.print(x)
  • 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 :
3.print(n)
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
4.print(tot)
  • 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)
4.print('Done!')
  • 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
5.print(smallest_so_far)

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 :
3.print('Lather')
4.print('Rinse')
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

Question

Step by Step Answer:

 

Step 1/2
— Spam: This is not a reserved word in Python. It is a common term used in programming to refer to unwanted or irrelevant data.
— Break: This is a reserved word in Python. It is used to exit a loop prematurely.
— Continue: This is a reserved word in Python. It is used to skip the current iteration of a loop and move on to the next one.
— For: This is a reserved word in Python. It is used to create a loop that iterates over a sequence of values.


Best Match Video Recommendation:

Solved by verified expert

preview

Numerade Logo

This problem has been solved!

Try Numerade free for 7 days

Best Match Question

(this is actually programming) Assume a break statement is executed inside a loop and that the loop is inside a function. Which of the following is correct? The program might immediately terminate. The function might immediately terminate. The loop will always immediately terminate. All of the above. None of the above.

Понравилась статья? Поделить с друзьями:
  • Возможность расчетов в таблице word
  • Возможность работы с несколькими документами в word
  • Возможность работы с базой данных ms excel
  • Возможность просмотра файлов excel
  • Возможность программы microsoft word это