CIS115 WEEK 3 QUIZ September 2020

Question # 00778040 Posted By: rey_writer Updated on: 09/21/2020 06:47 AM Due on: 09/21/2020
Subject Education Topic General Education Tutorials:
Question
Dot Image

(CO 1) A web application runs

through a browser

via a command prompt

with a GUI

through another application

Chapter 1.

Question 2(CO 3) Pseudocode and/or flowcharts are used in which of the following steps in program development?

Understand the problem

Plan and design the logic

Develop the logical solution

Desk-check the solution

Question 3(CO 1) The following is an example of __________.

#!/usr/bin/env python 3

executable code

byte code

source code

a shebang line

Question 4(CO 8) The goal of __________ is to find all the errors in a program.

editing

testing

debugging

interpreting

Chapter 2.

Question 5(CO 1) Given that pi = 3.1415926535, which of the following print() functions displays:

pi = 3.14

print("pi =", round(pi, 2))

print("pi = " + round(pi, 2))

print("pi = ", float(pi, 2))

print("pi = ", round(pi))

Chapter 2.

Question 6(CO 1) Python comments are represented by the following symbol:

!

$

?

#

Question 7(CO 1) The new line character in python is:

\\

\t

\n

\”

 Question 8(CO 1) What, if anything, is wrong with this code?

     student_score = int(input("Enter this student's score: "))

     score = student_score + 5

     print("With the 5-point curve, the student’s score is ", scores, ".")

nothing is wrong with this code

a string variable is used in an arithmetic expression

an undeclared variable name is used in the print() function

the input() function is chained with the int() function

Chapter 2

Question 9(CO 4) Which of the following creates a Boolean variable?

flag = True or False

if flag == True:

flag = True

flag == "False"

Chapter 3

 

Question 10(CO 4) A for loop that uses a range() function is executed

once for each integer in the collection returned by the range() function

until the for condition is equal to the value returned by the range() function

while the for condition is less than the value returned by the range() function

until the range() function returns a false value

Question 11 (CO 4) Which of the following is true for an if statement that has both elif and else clauses?

If the condition in an elif clause is true, the statements in that clause are executed.

If the condition in the if clause is true, the statements in that clause are executed.

If the condition in the else clause is true, the statements in that clause are executed.

The statements in the else clause are always executed.

Question 12(CO 4) If you want to code an if clause, but you don’t want to perform any action, you can code

an end statement

a pass statement

a break statement

a skip statement

Chapter 3

Question 13(CO 4) Given the following code, select the compound condition that makes sure that the input is an integer greater than 0 and less than 1,000.

my_num = input("Enter a number between 1 and 999:")

check_num = int(my_num)

while _________________________:

    my_num = input("Try again. The number must be between 1 and 999")

    check_num = int(my_num)

check_num<= 0 and check_num != 1000

check_num< 0 and > 1000

check_num<= 0 or check_num> 1000

check_num<= 0 or check_num>= 1000

Chapter 3

 

Question 14(CO 4)

num_widgets = 0

while True:

    choice = input("Would you like to buy a widget? (y/n): ")

    if choice.lower() == "y":

        num_widgets += 1

    else:

        break

print("You bought", num_widgets , "widget(s).")

Based on the above code example, if the user enters “no” at the prompt, what does the program print to the console?

You bought 0 widget(s) today.

You bought 1 widget(s) today.

You bought no widget(s) today.

Nothing, the break statement will cause the program to end

Question 15(CO 7) Which type of error throws an exception that stops execution of the program?

exceptional

syntax

runtime

logic

Chapter 5

Question 16(COs 1 and 8) Create a program that calculates the total for a purchase at a bookstore. Put the lines of code in order to create the following program.

SAMPLE OUTPUT:

Bookstore Calculator

Price of Book     29.99

Tax percent        8.75

Tax amount        2.63

Total amount     32.61

tax_amount = round(book_price * (tax_percent / 100), 2)

 7

print("Bookstore Calculator")

 2

print("Tax amount: ", tax_amount)

 10

tax_percent = float(input("Tax percent: "))

 5

# get input from the user

# display a welcome message

total = round(book_price + tax_amount, 2)

8

print("Total amount:", total)

11

# display the results

 9

book_price = float(input("Price of book: "))

 4

# calculate tip and total amount

 6

1.            # display a welcome message

2.            print("Bookstore Calculator")

3.            # get input from the user

4.            book_price = float(input("Price of book: "))

5.            tax_percent = float(input("Tax percent:  "))

6.            # calculate tip and total amount

7.            tax_amount = round(book_price * (tax_percent / 100), 2)

8.            total = round(book_price + tax_amount, 2)

9.            # display the results

10.          print("Tax amount:  ", tax_amount)

11.          print("Total amount:", total)

Question 17(CO 4 and 8) Create a program that prompt the user to enter five positive numbers and calculate the average. When a negative number is entered, program will be terminated. Put the lines of code in order to create the following program.

SAMPLE OUTPUT:

Please provide five nonnegative numbers when prompted

Enter number: 23

Enter number: 12

Enter number: 14

Enter number: 10

Enter number: 11

Average = 14.0

print('Average =', sum/count)

count = sum = 0

 2count += 1

 9

# Add five nonnegative numbers supplied by the user

 1

print('Negative numbers not acceptable! Terminating')

 7

sum += val

 10

print('Please provide five nonnegative numbers when prompted')

 3

break

 8

while count < 5:

 

4

if val< 0:

6

val = float(input('Enter number: '))

 5

1. # Add five nonnegative numbers supplied by the user

2. count = sum = 0

3. print('Please provide five nonnegative numbers when prompted')

4. while count < 5:

5. val = float(input('Enter number: '))

6. if val< 0:

7. print('Negative numbers not acceptable! Terminating')

8. break

9. count += 1

10. sum += val

11. print('Average =', sum/count)

 

Dot Image
Tutorials for this Question
  1. Tutorial # 00777831 Posted By: rey_writer Posted on: 09/21/2020 06:47 AM
    Puchased By: 2
    Tutorial Preview
    The solution of CIS115 WEEK 3 QUIZ September 2020...
    Attachments
    CIS115_WEEK_3_QUIZ_September_2020_graded.docx (117.39 KB)

Great! We have found the solution of this question!

Whatsapp Lisa