mport random import math Which of the following statements will assign a random integer from 30 to 90, inclusive, to var
Q: for (counter=1; counter <=DAYS IN WEEK counter++){ System out print ("Enter rainfall amount for Day…
A: import java.util.Scanner; public class Rain_Fall { public static void main(String[]…
Q: public static int sum(int low, int high) { if (low > high) { return 0; } if (low % 3 == 0 && low % 2…
A: public static int sum(int low, int high){ int total=0; while(low<high){…
Q: What values are returned by each of the following?a. Math.round(2.3)b. Math.round(2.7)c.…
A: Math.round() method In Java, the Math.round() function is used to round numbers to the nearest…
Q: include int main() { int M; printf("Enter the number of chairs you want to…
A: As your question , i run the code i got two issue in the given code:…
Q: Which of the following expressions yields an integer between 50 and 65, inclusive? a.…
A: Given:
Q: usiness that uses functions to calculate the weekly payment amounts of employees in a workplace. you…
A: A business that uses functions to calculate the weekly payment amounts of employees in a…
Q: How many times the statement "Statement" is printed in the following code? void fun(int R)…
A: the answer is as follows
Q: What will be the contents of the variable x after the following statement is executed? x = sqrt(((9…
A: MATLAB stands for matrix laboratory.
Q: Financial Application:• Write a program that computes future investment value at a given interest…
A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named…
Q: The expression intNum * intNum * intNum is equivalent to which of the following expressions? a.…
A: Given expression: intNum * intNum * intNum; In the above expression, the variable “intNum” is…
Q: /** * calculate the product of numbers from start to end inclusive e.g. * calcProductOfRange(3, 6) =…
A: Code in java but if the result of the product is out of range then it will print 0; class…
Q: Write a method for solving a quadratic equationusing the following header:public static int…
A: EXPLANATION: - Quadratic Equation is given as: - ax^2 + bx +c = 0 The input for a,b, and c is…
Q: Question: Write A Program That Compares The Values Of Y1 And Y2 In.. 3. ( Write a program that…
A: Given:
Q: Suppose that the input is 0 5 6 4 9 8 –1. What is the output of the following code? (2, 3) Submit…
A: PROGRAM: //Header file #include <iostream> //Using namespace using namespace std; //Defining…
Q: Flowchart, create. Writing Functions with No Parameters in Python #method to display the discount…
A: The program in given below
Q: The last part of this code I need the gallon round to the nearest number, but it still shows wrong…
A: You should change the round function to ceil() function. Code: #include <iostream>#include…
Q: for the numbers 1-10 write a program that will call a method (called f) to tabulate the folloing…
A: The following are the steps given below for the program to tabulate the function f(x):The code is…
Q: What is the value of the variable count after the function has been called 2 times? void myPrint(…
A: To solve this problem, first of all you need to know what is static variable. Let’s start the…
Q: What will the value of the answer variable be after the code segment below has been run. int…
A: Given Code segment int answer; int number4 = 244, number6 = 37, number11 = 1; answer = (…
Q: Ask the user for a name and for a list of test scores. Show the number of tests taken and the…
A: Here I have taken input from the user for the name and then created a list to store the marks. Next,…
Q: Write an application that inputs three integers from the user and displays the sum, average,…
A: You didn't mention any programming language, hence according to Bartleby policy, I have answered in…
Q: GetContestantNumber - This method gets and returns a valid number of contestants and is called twice…
A: Below is the implemented code for the given problem statement
Q: The following piece of code calculates base to the power of n (base"), please choose the correct…
A: Program public class basen { static void basen(int base,int n) { int result=1;…
Q: What is the value of name after the following steps are executed? float name, x=20.5; float *a = &x;…
A: Here the value of x=20.5 Now *a = &x this means that *a will have the value present at the…
Q: What is the range of values that x can hold after this statement is executed? double x =…
A: Answer:A perform is increasing within the same vary wherever it's spinoff is positive. Now, notice…
Q: What will the value of the answer variable be after the code segment below has been run.…
A: initialize answer to bool number3 =5 number5 =30 if number3<= number5 5<=30 true return 1
Q: Variables limit and n contains integer numbers. Which of the below Python statements correctly print…
A: print() function in python is used to write a variables value on to the console.
Q: 3- How many the number of erTors in the following sub_ program? Hinclude void main( ) intnum, sum -…
A: the answer is option d 7
Q: Write a method named presentValue that performs this calculation. The method should accept the…
A: We know that the amount we get for a principal P after t years is P + PTR/100 So, according to the…
Q: bool result ; int number3 = 17, number7 = 33;
A: bool result ; int number3 = 17, number7 = 33; result = number3 > number7 ; number3 =…
Q: In python. Write a program that calculates the BMI (Body Mass Index) of a person, which is used to…
A: #Taking Inputheight = float(input("Enter height in Meters - ")) weight = float(input("Enter weight…
Q: floor(x) function can round the numbers to * the nearest integer O towards infinity O towards minus…
A: the nearest integer
Q: Replace the following statements with a single statement that initializes sum to 0 at the time it is…
A: GIVEN: Replace the following statements with a single statement that initializes sum to 0 at the…
Q: int numl, num2, num3; double length, width, height; double volume; numl = 6; num2 = 7; num3 = 4; %3D…
A: a. Given statement: volume =box(length, width, height); Here, "box" is the method which is passed…
Q: To obtain the arc sine of 0.5 degree, use Math.asin(0.5) Math.asin(Math.toDegrees(0.5))…
A: arc sin is nothing but inverse of sine This can be calculated using static method asin which is…
Q: Question: Run a program that checks whether the number is even or odd
A: The below code is written in python language that will take one number from user and check the…
Q: Add statements that ask user’s gender. Calculate and print maximum heart rate of the user using the…
A: Given Add statements that ask user’s gender. Calculate and print maximum heart rate of the user…
Q: Financial Application:• Write a program that computes future investment value at a given interest…
A: Program plan:Import necessary packages.Define a class named “Main”.Define a method named…
Q: What will the value of the answer variable be after the code segment below has been run. int answer…
A: The answer is an integer variable which is not initialized. The other integer variables - number3,…
Q: Which of the following statements assigns a random integer between 25 and 60, inclusive, to rn? int…
A: The solution to the given problem is below.
Q: // This program gets student names continuously until XXX is entered. Then, for each student, quiz…
A: All the return boxes should be connected under one box.
Q: What is the final value of q after all statements are executed? Boolean q; int a = 1; q = (a==3);
A: The Solution for the following question is as follows:
Q: What will the value of the answer variable be after the code segment below has been run. int…
A: EXPLANATION: Given that the variables answer, number1 and number8 are of integer data type. The…
Q: int maths(int x, int y, int z) { return x + y + z; } int maths(double x, double y) { return x + y; }…
A: In the above code, the program contains the two functions named math. Both the functions return…
Q: for (int value=3; pow (2, value) <=100; value++) cout << pow (2, value) << ": ";
A: CONCEPT: - pow function It is present in cmath library. It takes two arguments namely base and…
Q: Analyze the following code. Is count < 100 always True, always False, or some times True or…
A: A while loop is executed only when the condition is true.
Q: The program segment has errors. Find as many as you can. // This code should display the sum of two…
A: There are two mistake in the code semi-Colum is missed after the while condition then condition in…
Q: The following code should print out a random number between 1 and 10, why will it not function…
A: first lets understand : randint method: randint method takes two integer values for range as…
Q: What is value of the variables after theif statement? int n = 1; %3D int k = 2; int r = 3; if (r < n…
A: n = 1 k = 6 r = 3
Python Question:
import random
import math
Which of the following statements will assign a random integer from 30 to 90, inclusive, to var? Select all that apply.
A. var = random.randrange(30,91)
B. var = random.randint(30,91)
C. var = math.randint(30,90)
D. var = random.randrange(30,90)
E. var = random.randint(30,90)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps
- The following code should print out a random number between 1 and 10, why will it not function correctly? from random import randint print (randint (10, 1))What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. PLEASE use the code outline given below to answer this question: import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1 # Allow the user to determine class size:print("Please type in how many people are in the class: ")x= int(input()) success = 0 # Simulate:c = 0while(c < 10000) : # Step 1: re-initialize birthday frequency table (it must be re-initialized for each play-through (why?): k = 0 while(k < 365) : ft[k] = 0 k = k+1 # Step 2: randomly get x birthdays and update frequency table: k = 0 while(k < x): # your code…Python - question down below This is my code for a horse racing betting game Code : import randomdef Readysetgo(horses):shuffled = random.sample(horses,len(horses))return shuffled horses = [1,2,3,4]ch=1balance = 200while(ch!=0):print("Please select from the following options 1-6")print("1. Place an exact bet")print("2. Place an exactabox bet")print("3. Place a trifectabet")print("4. Please a trifectabox bet")print("5. See your USD balance")print("6. Exit")ch = int(input())if ch==1:balance -= 10shuffled = Readysetgo(horses)print("Guess the exact winning order of the top two horses.")x,y = input().split()x = int(x)y = int(y)if x==shuffled[0] and y==shuffled[1]:balance += 100elif ch==2:balance -= 5shuffled = Readysetgo(horses)print("Guess the top two horses in any order.")x,y = input().split()x = int(x)y = int(y)if (x==shuffled[0] and y==shuffled[1]) or (x==shuffled[1] and y==shuffled[0]):balance += 50elif ch==3:balance -= 25shuffled = Readysetgo(horses)print("Guess the exact winning…
- int const MULTIPLIER = 5; is a valid way to declare a constant integer variable. Group of answer choices True False ------- Given the following code segment, what is output to the screen? int num1 = 6; int num2 = 4 * num1++; cout << "num1=" << num1 << " num2=" << num2; Group of answer choices num1=7 num2=24 num1=6 num2=24 num1=6 num2=28 Nothing, because the code does not compile.Exercise GradesStatistics (Method): Write a program called GradesStatistics, which reads in n grades (of int between 0 and 100, inclusive) and displays the average, minimum, maximum, median and standard deviation. Display the floating-point values upto 2 decimal places. Your output shall look like:Enter the number of students: 4Enter the grade for student 1: 50Enter the grade for student 2: 51Enter the grade for student 3: 56Enter the grade for student 4: 53{50,51,56,53}The average is: 52.50The median is: 52.00The minimum is: 50The maximum is: 56The standard deviation is: 2.29The formula for calculating standard deviation is:Hints:public class GradesStatistics {public static int[] grades; // Declare an int[], to be allocated later.// This array is accessible by all the methods.public static void main(String[] args) {readGrades(); // Read and save the inputs in int[] gradesprintArray(grades);System.out.println("The average is " + average(grades));System.out.println("The median is " +…By default, which one of the following types of values will be thrown when the below function is executed?def abstractAdd(a,b,c):print(a+b+c) Choose an answer A None B bool C str D int
- The following program have syntax errors. Correct them. On each successive line, assume that any preceeding error has been corrected. public class Exercise25{static final char = STAR = '*'static final int PRIME = 71;public static void main(String[] arg){count = 1;sum = count + PRIME;x := 25.67;newNum = count * ONE + 2;sum + count = sum;x = x + sum * COUNT;System.out.println("count = " + count + ", sum =" + sum + ", PRIME =" + Prime);}}Write pseudo code that will calculate a running sum. A user will enter numbers that will be added to the sum and when a negative number is encountered, stop adding numbers and write out the final result. (Please write a simple pseudo code for beginners, I mean easy to understand, thanks)Write a program that reads a student’s name together with his or her test scores. The program should thencompute the average test score for each student and assign the appropriate grade. The grade scale is asfollows:90-100, A; 80-89, B; 70-79, C; 60-69, D; 0-59, FYour program must use the following methods:(a) A value-returning method, calculateAverage, to determine and return the average of fivetest scores for each student. Use a loop to read and sum the five test scores. (This method doesnot output the average test score. That task must be done in the method main.)(b) A value-returning method, calculateGrade, to determine and return each student’sgrade. (This method does not output the grade. That task must be done in the method main.)Test your program on the following data. Read the data from a file and send the output to a file. Do notuse any global variables. Use the appropriate parameters to pass values in and out of methods.Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78…
- /*** calculate the product of numbers from start to end inclusive e.g.* calcProductOfRange(3, 6) = 3*4*5*6 = 360**/public static int calcProductOfRange(int start, int end) {in python please 1) String methods Ask the user for a name (test with George Washington). Print the name in all uppercase letters. Print the length of the name. Print the 4th character of the name (r). Create a variable called name2. Assign to name2 the name with all "o" characters replaced with "x"s. Print name2. Print the original name. 2) Counting and Finding Assign the text "Believe you can and you're halfway there." to a variable called quote (this is a quote from Theodore Roosevelt). Count how many "a" characters there are, print the result. Print the index of all the "a" characters.Hint: Except for the first find, set the start location for the next find as the previous location found index + 1. The second argument in the find method is the index where the find starts looking.A fuller explanation of the find method is given in string-methods Example output: Enter the name: George Washington GEORGE WASHINGTON 17 r Gexrge Washingtxn George Washington Count = 4 a found at 13…Modify the code to display the current date in the MM/DD/YYYYmode. And, display the number of hours, minutes, and seconds as well as the number of days left to the next New Year’s Day. An example of the needed output is shown in the attached picture (The values are just examples, they are not correct). Thank you. import java.util.Calendar; public class Sample{public static void main(String[] args){Calendar cal = Calendar.getInstance();int dayleft = findNewYearEve() - cal.get(Calendar.DAY_OF_YEAR);String str = "There are " + dayleft + " days left to the next New Year's Day.";System.out.println(str);} public static int findNewYearEve(){Calendar nyEve = Calendar.getInstance(); nyEve.set(nyEve.get(Calendar.YEAR), 11, 31); //days left to next New Yearreturn (nyEve.get(Calendar.DAY_OF_YEAR) + 1);}}