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 =...
JAVA Write a for loop which will display this set of values 1,3,5,7,9.
JAVA Write a for loop which will display this set of values 1,3,5,7,9.
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 while loop that will let the user enter a series of integer values and...
Write a while loop that will let the user enter a series of integer values and compute the total values and number of values entered. An odd number will stop the loop. Display the number of iterations and the total of the values after the loop terminates. for Loop Write a for loop to display all numbers from 13 - 93 inclusive, ending in 3. Write a for loop to display a string entered by the user backwards. do Loop...
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 code that does the following: Opens a file named output.txt, uses a loop to write...
Write code that does the following: Opens a file named output.txt, uses a loop to write the even number from 2 through 100 to the file and then close the file. java based code please.
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 program that uses a for loop output a string in reverse printing it character...
Write a program that uses a for loop output a string in reverse printing it character by character. C++ Program Example: "Enter some text:" this is a test "your text in reverse is:" tset a si siht Please note that you can find the length of the string by using the length function: string str = "hello" cout << str.length(); Also you can et a character in a string by providing an index to the function string str = "hello"...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT