0% found this document useful (0 votes)
2 views2 pages

Programming Loop Examples in Python

The document provides programming examples using different types of loops: while, do-while, and for. It includes tasks such as displaying phrases multiple times, generating sequences of natural numbers in reverse, calculating powers, and creating tables and shapes with asterisks. Each example emphasizes user input and output in various formats.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Programming Loop Examples in Python

The document provides programming examples using different types of loops: while, do-while, and for. It includes tasks such as displaying phrases multiple times, generating sequences of natural numbers in reverse, calculating powers, and creating tables and shapes with asterisks. Each example emphasizes user input and output in various formats.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Example of While Loop:

Q1: Write a program to display a “Pakistan Zinda Bad” three times and “Pakistan Painda Bad” one time.

Q2: Write a program which can gets starting and ending point from the user and generate a sequence
of natural number from start point to end point in reverse order and their sum and product.

Example of do-while loop:

Q1:This program inputs two numbers from user and display the result as first number raise to the power
of second number using do-while loop

Example of For loop:

Q1:Write a program which can gets starting and ending point from the user and generates a table using
for loop.
Q1:Write a program using nesting loops to produce a shape with asterisks as below
@@@@@@@@@@

@@@@@@@@@

@@@@@@@@

@@@@@@@

@@@@@@

@@@@@

@@@@

@@@

@@

@@

@@@

@@@@

@@@@@

@@@@@@

@@@@@@@

@@@@@@@@

@@@@@@@@@

@@@@@@@@@@

@@@@@@@@@@@

You might also like