0% found this document useful (0 votes)
13 views1 page

Python Loop Examples and Syntax

The document contains examples of basic programming loops in Python and Java. It includes a for loop to print numbers from 1 to 10, a while loop that prompts the user to type 'stop', and a do-while loop that prints 'welcome!' based on user input. Additionally, it provides an example of declaring and printing an array of names in Java.

Uploaded by

interndisney16
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Python Loop Examples and Syntax

The document contains examples of basic programming loops in Python and Java. It includes a for loop to print numbers from 1 to 10, a while loop that prompts the user to type 'stop', and a do-while loop that prints 'welcome!' based on user input. Additionally, it provides an example of declaring and printing an array of names in Java.

Uploaded by

interndisney16
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link] for a loop that prints that numbers from 1to10?

for i in range(1, 11)​ ​


​ ​ print(i​​ ​ ​ ​ ​ ​ ​ ​
[Link] a while loop that asks the user to type "stop". Keep asking until they do?

while user_input.lower() != "stop":


user_input = input("Type 'stop' to end: ")

[Link] a do-while loop that always prints "welcome!" Once,and repeats only if the user
types "yes".

print("Welcome!")
answer = input("Do you want to see this again? (yes/no): ").lower()
if answer != "yes":
break.

[Link] an array of names:


String[]names={"Anna","Ben","Clara");

String[] names={“Daniel “,”Joshua”,”Ken”);


(
[Link](name);
)

You might also like