Hacking University: Junior Edition. Learn Python Computer Programming from Scratch: Become a Python Zero to Hero. The Ultimate Beginners Guide in Mastering ... Freedom and Data Driven series Book 3) by Cody Isaac D

Hacking University: Junior Edition. Learn Python Computer Programming from Scratch: Become a Python Zero to Hero. The Ultimate Beginners Guide in Mastering ... Freedom and Data Driven series Book 3) by Cody Isaac D

Author:Cody,Isaac D. [Cody,Isaac D.]
Language: eng
Format: epub
Publisher: United Computer Geeks
Published: 2016-09-17T18:30:00+00:00


answer = 0

while (answer != 2):

answer = int(input("What is 4 / 2? "))

print ("Correct!")

So long as the specified condition evaluates to true, the “while” code block will continuously run. We can see a perfect example of this through the program above. We create a new variable “answer” and repeatedly compare it to 2. While answer is not equal to 2, the program will ask the user for the correct answer. Inputting something other than 2 will just loop back around to the while statement, again prompting for the correct answer. If while finally does evaluate to true (because answer equals 2) the loop will break and the program will resume by printing “Correct”.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.