Which of these lines of code will generate a random number between 1 and 50? A. input("1-50") B. print("1-50") C. import random D. num = random.randint(1,50)

Answers

Answer 1

Answer:

D. num = random.randint(1,50)

Explanation:

Answer 2

The option given above will assign a random integer in the range of 1 through 50 to the variable number is: "number = random.randint(1, 50)"

What is a random integer in programming?

This is a random sequence of integers that may be used to imitate things like shuffling a deck of cards or creating distinct behaviors every time a program runs. The RND function in BASIC generates random numbers. This yields a value between 0 and 1.

Random number creation is a technique that generates a series of numbers or symbols that cannot be realistically anticipated better than by random chance, generally using a random number generator (RNG).

Therefore, The option given above will assign a random integer in the range of 1 through 50 to the variable number is: "number = random.randint(1, 50)"

Learn more about random integers:

brainly.com/question/15247918

#SPJ3


Related Questions

beth chooses fresh vegetables every time she does marketing. she pares and cuts right away these vegetable considering that they are fresh. the moment she serves the appetizer, she washes the plate and uses it without drying. what statement best describes the situation inside teh box

Answers

Answer:

spell correctly "teh=the

Explanation:

beth chooses fresh vegetables every time she does marketing. she pares and cuts right away these vegetable considering that they are fresh. the moment she serves the appetizer, she washes the plate and uses it without drying. what statement best describes the situation inside teh box

How do I get fix the code to make it input 3 values and get the correct output
-------------------------------------------------------------
12.20 LAB: Driving costs - functions

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))

Ex: If the input is:

20.0
3.1599

the output is:

1.58
7.90
63.20

Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles.

Ex: If the function is called with:

50 20.0 3.1599

the function returns:

7.89975

def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon)

Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles.
---------------------------------------------------
I need help for this part
Ex: If the function is called with:

50 20.0 3.1599

how do I get it to input the three to get the output of 7.89975?
-------------------------------------
My code:

# Define your function here.
def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):
return (driven_miles/miles_per_gallon) * dollars_per_gallon

if __name__ == '__main__':
# Type your code here.

# Miles per gallon from input
miles_per_gallon = float(input())

#Dollars per gallon from input
dollars_per_gallon = float(input())


# Display the results as output

print('{:.2f}'.format(driving_cost(10, miles_per_gallon,dollars_per_gallon)))
print('{:.2f}'.format(driving_cost(50, miles_per_gallon,dollars_per_gallon)))
print('{:.2f}'.format(driving_cost(400, miles_per_gallon,dollars_per_gallon)))

Answers

Answer:Change your logic to:

for (int i = 0; i < 4; i++) {

System.out.println("Please input a number between zero to 3");

// use input and don't advance the scanner every time

int input = sc.nextInt();

if (input == 0) {

System.out.println("You have selected " + right);

}

if (input == 1) {

System.out.println("You have selected " + left);

}

// so on and so forth

}

By using sc.nextInt() four times, you are looking for the next token of the input which isn't there. So fetch the input for each run of the for-loop and it will work as expected.

Explanation:

Given the following code, what logic would you need to include to print all even values stored within the array:

int[] myArray = {1,2,38,4,54,6,7,8,9,10};

for (int i = 0; i < myArray.length; i++) {
//your code goes here
}
NOTE: Your response should be just the missing logic--not the entire problem set.

Answers

The missing logic whigh would allow all the even numbers stored within the array to be printed is if(myArray[i]%2 == 0)

Even numbers are divisible by 2, and hence, will leave no remainder when divided by 2.

Using the modulo operator, each iterated value in the array should be checked if it has a remainder of 0, when divided by 2.

Hence, if the remainder is 0, then the value is even and the value should be printed.

Learn more : https://brainly.com/question/17330574

Write a program that prompt the user to enter a bank balance. The balance entered by the user is read into a variable named balance. The program then prompts the user to enter the amount to be deposited. The amount entered by the user is read into a variable named deposit. The program that calculates the new balance, which is the present balance plus the deposit. The program then displays the new balance.

Answers

Answer:

ertyuiopoijuhgfdsa hiyoufun tresdfghytrefgytredfg

Explanation:

look for the words

Your worksheet contains a price in cell A5 and many formulas refer to that price how would you refer to that price in the formula

Answers

Answer:

$A$5

Explanation:

The A$5 would allow the row part of the reference to stay in place but would allow the column to change.

What does '$' mean in Excel formula?

An absolute reference in Excel exists as a cell address with the dollar symbol ($) in the row or column coordinates, like $A$1. The dollar sign specifies the connection to a given cell so that it stays unchanged no matter where the formula moves.

The A$5 would permit the row position of the authority to remain in place but would permit the column to modify. The location of the $ before either the row or column or both exists what specifies what component stands frozen. Therefore, the correct answer is option b) $A$5.

Complete question:

Your worksheet contains a price in cell A5, and many formulas refer to that price. How would you refer to that price in the formulas?

a. A5

b. $A$5

c. $A5

d. A$5

To learn more about Excel formula

https://brainly.com/question/26276255

#SPJ2

Other Questions
1 trig review please please help Pieces of Earth's crust move on top of the: Group of answer choices outer core ocean inner core mantle True or FalseLow, gray, layered clouds that cover the sky and bring steady rain are nimbostratus clouds. Which organelle in a plant cell is most affected when a plant has not received any water? Explain your reasoning. Segments BF, CD, and AE are medians for triangle ABC. Point K is the intersection of all three medians. The measure of segment FK is 3.40 cm and segment EK = 1.63 cm. Find the sum of the lengths of segments AK and BK. When applying the lower cost or market rule to the valuation of inventory, the allowance method is considered preferable to the direct method becauseA. the allowance method reports a higher inventory net valuation for balance sheet purposes than the direct methodB. the allowance method reports the inventory loss or loss recover in a separate income statement accountC. the allowance method, unlike the direct method, reduces the value of inventory reported on the balance sheetD. the allowance method reports smaller losses than the direct method Question 4 (1 point)The United States has the most free trade agreement with which continent?aAsiabAfricaEuropeThe AmericasdNext PageOnce you click Next Page you will not be able to change your answer Si caminara 1 2/3 alrededor de la jardinera triangular,Cuantos metros recorrera? A right triangle is one that contains a ______ degree angle Where does the energy of a hurricane come from? (1 point)O the SunO strong windsO Earth's spinO Earth's moon Drag the events below into chronological order from top to bottom. Hawaii is pressured to allow the United States to use Pearl Harbor as a naval base.Hawaii is allowed to export sugar to the United States on a duty-free basisThe United States proclaims Hawaii a United States territory American missionaries form Christian schools and churches in Hawaii. simplify root 12 over root 3 what is the answer, i tried everything but i cant seem to get the right answer HELP1!!1!!1!Solve your word problem using a model. Use complete sentences to describe your model, and interpret the quotient in the context of your word problem. If you wish, you may upload a copy of your model. Three sisters have ages that are consecutive odd integers. The sum of the age of the youngest and three times the age of the oldest is five less than five times the middle sisters age. -aidez moi c'est urgent pour lundi-Chagrin d'enfance (Sarraute) : relis le sujet, et raconte trs simplement en suivant les cinq tapes fournies par le sujet. C'est vraiment le sujet le plus SIMPLE et accessible pour toi. Essaie de faire des phrases simples en suivant les cinq tapes.1:(situation initiale)="le jour de mon anniversaire"2:(lment dclencheur)="surprise",allgresse et joie intenses3:(pripties)=les jeux avec le petit chiot,qui gradit :passeges l'imparfait d'habitude,expression de la joie,du bonheur,de l'affection.4:(Pripties)=la promende "du cte de la voie ferre"-pass simple principalement.5:(Rsolution et situation finale)=un ou deux passages descriptifs:-les "splendeurs" d'une scne d'horreur-l'expression de la souffrance. CompletarFill in the blanks with the present progressive form of verbs from the list. Use each verb only once.Los turistas ______________ fotos con sus cmaras digitales. Which of the following best explains the porpoise of the details in pharagraph 13 and 14? Michelle owns an independent bookstore and has observed that college graduates read more than people without degrees. She is considering offering a 10% discount on book purchases to customers who have a postsecondary degree. Why might Michelle's plan hurt rather than help her business What chemical in the chloroplast captures sunlight for photosynthesis to take place?