Question

Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....

Create a new file named quiz_loops.py.
b. Write your name and date in a comment.
c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16.
d. Write a while which will display this set of values 16,13,10,7,4,1,-2.
e. Write a for loop which will print ‘Loops are fun’ three times.
f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number. (Hint: set power=1 before the loop, use power = power ** number in the loop). Print out the product when the loop exits.
g. Prompt the user to enter the number of gyros to purchase. As long as the user enters a number greater than 0, continue to prompt for the number of gyros purchased. Print out the total number of gyros purchased once the loop exits.
(Hint: Use sentinel control and have a priming read and a loop read.)

Homework Answers

Answer #1

a. first create a file whose name should be quiz_loops.py

b. To writ eyour name and date in a comment start with #. as

# Name:           Date:                

c.

for i in range(1,17):
     if(i%2==0):
         print(i)

d.

i=16
while(i>=-2):
    print(i)
    i=i-3

e.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b....
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b. Print out the elements in the week_tuple. 2-a. The following list has been declared as follows: credit_list = [24,3,15] b. Convert the credit_list to a tuple named credit_tuple. c. Print out the elements in the credit_tuple. 3-a. Write an initialize_list_values function that takes in a number for the number of elements in a list and an initial value for each element. The function creates...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a...
C LANGUAGE Create your own library named cis340yourlastname. Create a header file named cis340yourlastname. Write a program that receives two numbers from the user and uses your written library to calculate the reminder after division, the addition, and the subtraction of these two input numbers. (Hint your library should include three functions. Your header file should not contain the code for any of these functions, it should contain only the instructions for how to use the library).
Write a program in C++ coding that asks the user to input an integer between 25...
Write a program in C++ coding that asks the user to input an integer between 25 and 50, inclusive. Utilize a WHILE loop to test for INVALID input. If the input is INVALID, the loop will repeat, and ask the user to try again. The pseudocode looks like this: Prompt user to input an integer between 25 and 50 Accept the input from the user Test for invalid input (HINT: use a while loop and the OR operator with 2...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file....
Create a client for your BankAccount classcalled BankAccountClient.java.    This a separate file from the BankAccount file. Both files must be in the same directory to compile. Display all dollar amounts using the DecimalFormat class. Create an account Ask the user for the type of account, the bank account number, the amount that they will deposit to start the account. Set interest earned to 0. Print the account information using an implicit or explicit call to toString Update an account Use...
1. Write a function called compute_discount which takes a float as the cost and a Boolean...
1. Write a function called compute_discount which takes a float as the cost and a Boolean value to indicate membership. If the customer is a member, give him/her a 10% discount. If the customer is not a member, she/he will not receive a discount. Give all customers a 5% discount, since it is Cyber Tuesday. Return the discounted cost. Do not prompt the user for input or print within the compute_discount function. Call the function from within main() and pass...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
Task #4 Calculating the Mean Now we need to add lines to allow us to read...
Task #4 Calculating the Mean Now we need to add lines to allow us to read from the input file and calculate the mean. Create a FileReader object passing it the filename. Create a BufferedReader object passing it the FileReader object. Write a priming read to read the first line of the file. Write a loop that continues until you are at the end of the file. The body of the loop will: convert the line into a double value...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT