Question

Can someone help me with this Python code Summary In this lab, you work with the...

Can someone help me with this Python code

Summary

In this lab, you work with the same Python program you worked with in Labs 5-1 and 5-3. As in those earlier labs, the completed program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. However, in this lab you should accomplish this using a while loop with a break statement.

Instructions

  1. Make sure that the file NewestMultiply.py is selected and open.
  2. Write a while loop that uses the loop control variable to take on the values 0 through 10 and breaks when the loop control exceeds 10.
  3. In the body of the loop, multiply the value of the loop control variable by 2 and by 10 and output the result.
  4. Execute the program by clicking the Run button at the bottom of the screen and verify that the output is correct.

"""

NewestMultiply.py - This program prints the numbers 0 through 10 along with

                     these values multiplied by 2 and by 10.

Input:  None.

Output: Prints the numbers 0 through 10 along with their values multiplied by

        2 and by 10.

"""

head1 = "Number: "

head2 = "Multiplied by 2: "

head3 = "Multiplied by 10:  "

NUM_LOOPS = 10  # Constant used to control loop.

print("0 through 10 multiplied by 2 and by 10" + "\n")

# Write while loop

0 0
Add a comment Improve this question Transcribed image text
Answer #1
head1 = "Number: "
head2 = "Multiplied by 2: "
head3 = "Multiplied by 10: "
NUM_LOOPS = 10  # Constant used to control loop.

print("0 through 10 multiplied by 2 and by 10" + "\n")

# Write while loop
i = 0
while True:
    print(head1 + str(i))
    print(head2 + str(i * 2))
    print(head3 + str(i * 10))
    i += 1
    if i > NUM_LOOPS:
        break
Add a comment
Know the answer?
Add Answer to:
Can someone help me with this Python code Summary In this lab, you work with the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Summary In this lab the completed program should print the numbers 0 through 10, along with...

    Summary In this lab the completed program should print the numbers 0 through 10, along with their values multiplied by 2 and by 10. You should accomplish this using a for loop instead of a counter-controlled while loop. Instructions 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 and...

  • Newmultiply.Java // NewMultiply.java - This program prints the numbers 0 through 10 along // with these...

    Newmultiply.Java // NewMultiply.java - This program prints the numbers 0 through 10 along // with these values multiplied by 2 and by 10. // Input: None. // Output: Prints the numbers 0 through 10 along with their values multiplied by 2 and by 10. public class NewMultiply {    public static void main(String args[])    {               String head1 = "Number: ";        String head2 = "Multiplied by 2: ";        String head3 = "Multiplied...

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • unctions with No Parameters Summary In this lab, you complete a partially prewritten Python program that...

    unctions with No Parameters Summary In this lab, you complete a partially prewritten Python program that includes a function with no parameters. The program asks the user if they have preregistered for art show tickets. If the user has preregistered, the program should call a function named discount() that displays the message "You are preregistered and qualify for a 5% discount." If the user has not preregistered, the program should call a function named noDiscount() that displays the message "Sorry,...

  • 1. Questions Python Code: For each line of code, write the type of error (syntax, semantics,...

    1. Questions Python Code: For each line of code, write the type of error (syntax, semantics, runt-time), cause of the error, and your fix. (1) def fun(num letter) (2) num == 7 + num (3) return 'num' - letter (4) result = fun(5, x) 2. Question Python Code: Run the code below to check the outputs of the print() call on lines 12. And : A) Analyze the application of the accumulation pattern and answer the following questions: #1. a....

  • Python I'm creating two linked lists from two txt files, merging them, then printing any duplicates...

    Python I'm creating two linked lists from two txt files, merging them, then printing any duplicates found. My program right now only reads numbers one after another following a comma. For example 10,20,15,2. How do i change it so it reads numbers one below another. Like this,                  class Node(object):     value = -1     next = None        def __init__(self,item):         self.val = item         self.next = None def merge_lists(vivendi, activision):     head = tail = Node(0)    ...

  • Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to...

    Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write...

  • Summary In this lab, you add a loop and the statements that make up the loop...

    Summary In this lab, you add a loop and the statements that make up the loop body to a Java program that is provided. When completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. Your loop should execute until the user enters the character X instead of L for left-handed or R for right-handed. The inputs for this program are as follows: R, R, R, L, L, L,...

  • Using Python, Can someone please assist in the following: These are the hints: Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the...

    Using Python, Can someone please assist in the following: These are the hints: Summary This week's lab is to create a simple multiplication table using nested loops and if statements. Prompt the user for the size of the multiplication table (from 2x2 to 10x10). Use a validation loop to display a warning if the number is less than 2 or greater than 10 and prompt the user to enter the data again until they enter a valid number Put a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT