Question

In: Computer Science

write a for loop that uses the loop control variable to take on the values 0...

write a for loop that uses the loop control variable to take on the values 0 through 10. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Execute the program by clicking the Run button at the bottom of the screen. Is the output the same?

Solutions

Expert Solution

KINDLY GIVE THUMBS UP IF SOLUTION IS HELPFUL TO YOU.

#IF YOU HAVE ANY DOUBT THEN PLEASE LET ME INFORM IN COMMENT BOX.

CODE-

#we will use num as loop control variable
#we will use range function with for loop.
#range function iterates from a given starting number to end number-1.
#for example range(0,5) will iterate through numbers 0,1,2,3,4.It will exlude 5.
#Program-
for num in range(0,11):
#print the numbers
print("number is :",num)
#print the number multiply by 2
print("after multiplying the number by 2,the number is :",num*2)
#print the number multiply by 10
print("after multiplying the number by 10,the number is :",num*10)

output-


Related Solutions

The random variable X can take on the values -5, 0, and 5, and the random...
The random variable X can take on the values -5, 0, and 5, and the random variable Y can take on the values 20, 25, and 30. The joint probability distribution of X and Y is given in the following table: Y 20 25 30 X -5 0.15 0.02 0.06 0 0.08 0.05 0.05 5 0.32 0.10 0.17 a. Describe in words and notation the event that has probability 0.17 in the table. . b. Calculate the marginal distribution of...
Problem description Write a program that uses a loop to read integer values from the standard...
Problem description Write a program that uses a loop to read integer values from the standard input stream. Each non-zero value, x, is the first number of a sequence. Define a0 = x; an+1 = an / 2 if an is even; an+1 = 3 * an + 1 if an is odd. Then there exists an integer k such that ak = 1. For each non-zero value of x, the program outputs the integer k such that ak =...
Write a program that uses a for loop to print One of the months of the...
Write a program that uses a for loop to print One of the months of the year is January One of the months of the year is February ...
(2pt) A variable that takes on the values of 0 or 1 and is used to...
(2pt) A variable that takes on the values of 0 or 1 and is used to incorporate the effect of categorical variables in a regression model is called a. a constant variable b. a dummy variable c. an interaction d. None of these alternatives are correct. (1pt) The model y= β0+β1x1+β2x12+ε is called a. First-order model with one predictor variable b. Second-order model with two predictor variables c. Second-order model with one predictor variable d. None of these alternatives is...
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write a program that uses a while loop with a priming read to ask the user...
Write a program that uses a while loop with a priming read to ask the user to input a set positive integers. As long as the user enters a number greater than -1, the program should accumulate the total, keep track of the number of numbers being entered and then calculate the average of the set of numbers after the user enters a -1. This is a sentinel controlled-loop. Here is what a sample run should look like: Enter the...
Write a for loop from 1 to 3 using i as the variable. For each value...
Write a for loop from 1 to 3 using i as the variable. For each value of i: Create a vector x of 10 random numbers between 0 and 1. Create a second vector t which is equal to ten integers from 1 to 10. Plot x versus t in figure 1. Use hold on to keep each plot. Use a different color for the line for each value of i. At the very end, add the text 'time' using...
The random variable X can take on the values 1, 2 and 3 and the random...
The random variable X can take on the values 1, 2 and 3 and the random variable Y can take on the values 1, 3, and 4. The joint probability distribution of X and Y is given in the following table: Y 1 3 4 X 1 0.1 0.15 0.1 2 0.1 0.1 0.1 3 0.1 0.2 a. What value should go in the blank cell? b. Describe in words and notation the event that has probability 0.2 in the...
Python Exercises = Sentinel Values and While Loops #Exercise 1 #Write a while loop with a...
Python Exercises = Sentinel Values and While Loops #Exercise 1 #Write a while loop with a sentinel value #This while loop ends when the user enters a 1, the sentinel value #Assign the number 8 to a variable which will serve as the sentinel value #Condition: while variable is not equal to 1 #Action: display the number assigned to the variable #Use an input statement (no prompt) to ask the user for a number and assign this number to the...
Write a C program that meets the following requirements. Uses a while loop to display the...
Write a C program that meets the following requirements. Uses a while loop to display the first 10 natural numbers (on one row, with a tab separating each number) Uses a while loop to find the sum of the second set of 10 natural numbers. Reads a user entry and displays all the natural numbers up to the user entry (on a column list with a new line separating each number). Finds and displays the sum of all natural numbers...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT