What is the difference between a for and a while loop?

A for loop iterates over set commands within the loop (need to be indented), executing this block of code in order until prompted to stop (as specified). A while loop is used when a condition needs to be checked each iteration before the loop can run through the block of code.

Answered by Tutor143011 D. Python tutor

1058 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

What is the difference between DFS and BFS? Where can I apply each?


Write a function that takes an imput (call it usr_in), the user's age (usr_age) and the user's name (usr_nm) and outputs the following string: "Hi, My name is [usr_nm], I am [usr_age] years old, and my favorite number is [usr_in]"


Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


Why are negative indexes used?


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2024

Terms & Conditions|Privacy Policy