answersLogoWhite

0


Best Answer

A program can be looped in Python by wrapping the entire program in a for or while loop.

If you wish to loop the program a finite amount of times, it can be done like so (x = the amount of times you want it to loop, this can be a number or variable storing a number):

for i in range(0,x):

[code]

If you wish to loop the program infinitely, you can use a simple while loop:

while True:

[code]

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you loop a program in python 3?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you loop a program in python?

An infinite loop might look something like: while 1==1: print("Infinite loop") as 1 is ALWAYS equal to 1.


What is a Python loop?

A Python loop is something that will always happen or continue to happen until the condition isn't met. So for example:while 1==1:print("Infinite loop")would be an infinite loop, as 1 will ALWAYS be equal to 1.


Write a program using a loop to output all the letters of the alphabet in uppercase?

Here's the code for your program: # Loop through the uppercase alphabet letters for letter in range(ord('A'), ord('Z') + 1): print(chr(letter)) BTW you can use this code in Python and try it out for yourself.


How Do you loop this program in python?

this is the program I'm trying to loop #Speed Speed =input('Speed in MPH:') #Distance Time= input('Time in hours:') # floating point number Speed = float(Speed) # floating point number6 Time = float(Time) #Calc Distance=Speed*Time


How do you make a program in python using do while loop to display the multiplication table of number from one to ten?

a = 0while a < 10 :a += 1print (a)Write the above simple script in a text editor (I use nano). Save as loop.py in home folder. To run, open a terminal and at the prompt, write: python loop.pyResult:rodney@downstairs:~$ python loop.py12345678910


What has the author Wesley Chun written?

Wesley Chun has written: 'Python fundamentals' -- subject(s): Python (Computer program language) 'Core Python programming' -- subject(s): Python (Computer program language)


Do you need Python in your PC?

Python is just a programming software, you don't actually need it to run your computer. You can use Python if you'd like to program something, or learn how to program.


A program with a loop that never ends is called an?

Infinite loop.


How do you open a Python program with MS-DOS?

open MS-DOS in the directory you have the python file in. type "python [INSERTNAMEOFSCRIPT]"


What is odd loop in 'C' program?

odd loop means at least the loop execute once.


Where does the program python run?

Python is a runtime interpreter. It usually runs on the web server.


I ned a program to print sum of digits without using while loop?

In python 3 I would write the following (assuming the digits are input by a user): #!/usr/bin/python a = input("Type a number: ") sum = 0 for i in a: #the for next loop performs the function of a while loop with less lines of code. #(My formating keeps getting deleted when I publish this answer. There should always be a tab- strictly speaking four spaces before this line) sum = sum + int(i) sum = str(sum) print("Your number was", a + ". The sum of its digits is" , sum + ".") As you can see, the for next loop iterates through each value in the string "a", and sets its value to "i". For each iteration, the current value of i is added to the variable "sum" until the end of the number is reached. The program then prints the original number, and the sum of its digits.