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...
Summary In this lab, you write a while loop that uses a sentinel value to control...
Summary In this lab, you write a while loop that uses a sentinel value to control a loop in a C++ program that has been provided. You also write the statements that make up the body of the loop. The source code file already contains the necessary variable declarations and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars the patron awards to the Guide’s featured movie of the week. The program...
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 loops (both the for-loop and the while loop). This assignment also...
Write a program that uses loops (both the for-loop and the while loop). This assignment also uses a simple array as a collection data structure (give you some exposure to the concept of data structure and the knowledge of array in Java). In this assignment, you are asked to construct an application that will store and retrieve data. The sequence of data retrieval relative to the input is Last In First Out (LIFO). Obviously, the best data structure that can...
(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...
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 ...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT