Question

Python Programming questions, Multiple Choice Questions: 5) MCQ What function call will generate a random number...

Python Programming questions, Multiple Choice Questions:

5) MCQ

What function call will generate a random number in the range of 1 through 6 using the random module?

a. random.randnum(1, 6)

b. random.randint(range(1-6))

c. random.randint(1, 6)

d. random.random(1, 6)

6) MCQ

In a conditional iteration loop, such as a while loop, what is a sentinel value?

a. A sentinel value is a user-provided input value that proceeds to the next loop.

b. A sentinel value is a user-provided input value that changes the structure of the loop.

c. A sentinel value is a special value provided by the user to terminate the loop.

d. A sentinel value is a special value provided by the user to restart the loop.

7) MCQ

What is NOT a Boolean or logical operator used in the Python language?

a. and

b. or

c. not

d. xor

8) MCQ

Assuming that the value of x is 4, and the value of y is 6, what is the value of the following expression? (x - y)**2 > y

a. True

b. False

c. Undefined

d. TypeError

Homework Answers

Answer #1

5) random.randint(1,6) --- generated random number in the range of 1 through 6.(1 and 6 Both included)

other options are incorrect, since random has no attribute or method named randnum,randint expects two integers not a range instance.

6) A sentinel value is a user-provided input which is used as a signal to terminate a loop

Assume that a code expects continuous string inputs. lets say We use while loop to get continuous names untill we receive -1. The moment user enters -1 we come to know that user has entered all the data so we terminate while loop. Here -1 is the sentinel value.

7) xor isn't a boolean operator in python

8) Result will be False

x-y will be -2

(x-y)**2 will be -2 to the power of 2 which is 4

since 4 is not greater than 6 the answer will be False

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. What will the following python code display? num = list(range(5)) print(num) 2. Answer the following...
1. What will the following python code display? num = list(range(5)) print(num) 2. Answer the following questions using the list below. You can record your answers in the essay textbox. data = [5,3,7] A. Write code to replace the value in the 0 position with the number 8. B. Add the value 10 to the end of the list. C. Insert the value 22 after position 1 in the list. D. Remove the value at position 2. E. Sort the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the...
Written in MASM Assembly Problem Definition: Write a program to calculate Fibonacci numbers. • Display the program title and programmer’s name. Then get the user’s name, and greet the user. • Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46]. • Get and validate the user input (n). • Calculate and display all of the Fibonacci numbers up to and including the nth...
python programming Question #4: # Years ago the Romans used a different system to represent numbers....
python programming Question #4: # Years ago the Romans used a different system to represent numbers. # Instead of using the digits (0, 1, 2, 3, 4, 5, 6, etc.), the Romans # formed numbers by joining combinations of the characters # (I, V, X, L, C, D, and M). # Roman Numeral characters and their integer values are: # I = 1, V = 5, X = 10, L = 50, C = 100, D = 500, and M...
Questions 1-5 are related to the following You own a local company that has special equipment...
Questions 1-5 are related to the following You own a local company that has special equipment for moving pianos. Your company has enough equipment to handle three pianos in a day. The number of requests to move pianos is a random variable with following distribution. x f(x) 0 0.40 1 0.40 2 0.10 3 0.1 4 0.02 5 0.02 6 0.01 1 The probability of three (3) requests to move pianos is _______. a 0.04 b 0.05 c 0.06 d...
Please answer the following 5 multiple choice questions In a small open economy, when foreign governments...
Please answer the following 5 multiple choice questions In a small open economy, when foreign governments reduce national saving in their countries, the equilibrium real exchange rate (measured in units of the home currency divided by units of foreign currency): A.rises, and home country net exports rise. B.falls, and home country net exports rise. C.rises, and home country net exports fall. D.falls, and home country net exports fall. Compared to typical open-market operations, when engaging in quantitative easing operations conducted...
Answer the correlation questions using the data below. Use α = 0.01. x y 5 6...
Answer the correlation questions using the data below. Use α = 0.01. x y 5 6 4 7 3 8 9 1 0 1 0 1 0 0 a) Compute the correlation. r = b) Compute the appropriate test statistic(s) for H1: ρ > 0. critical value =  ; test statistic = Decision:  ---Select--- Reject H0 Fail to reject H0 c) Compute the corresponding effect size(s) and indicate magnitude(s). If not appropriate, input and/or select "na" below. effect size =  ;  ---Select--- na trivial...
Here are ten multiple-choice questions. Thanks!!! 1. To incentivize young people to go to college within...
Here are ten multiple-choice questions. Thanks!!! 1. To incentivize young people to go to college within their home state, state universities can: A) charge higher tuition to in-state students. B) award special scholarships to out-of-state students. C) offer high-interest loans to in-state students. D) offer lower tuition to in-state students. 2.Adam Smith’s concept of the invisible hand refers to his belief that: A) market failure is a myth. B) self-interest can lead to a “prisoner’s dilemma” where everyone is worse...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue...
QUESTION 1 What does the following code segment output? int red, blue; red = 7; blue = red + 2 * 5 red++; blue = blue + red; cout << blue; 4 points    QUESTION 2 Is the following statement true or false? The Boolean expression in the following if statement will be true for all values of x in the range from 10 to 20 (including the endpoints) and false for all other values: int x; if (x >=...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21,...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21, all players who are still standing win. But the players that are not standing have already lost. If the Dealer does not go over 21 but stands on say 19 points then all players having points greater than 19 win. All players having points less than 19 lose. All players having points equal to 19 tie. The program should stop asking to hit if...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT