0% found this document useful (0 votes)
47 views8 pages

The Laboratory Work 3

The document outlines 10 exercises to practice various Python programming concepts using loops. The exercises include printing numbers and patterns using while and for loops, accepting user input, iterating through lists, reversing lists, looping through ranges, checking for prime numbers, and calculating factorials. The results of each exercise are not shown.

Uploaded by

lloooos
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)
47 views8 pages

The Laboratory Work 3

The document outlines 10 exercises to practice various Python programming concepts using loops. The exercises include printing numbers and patterns using while and for loops, accepting user input, iterating through lists, reversing lists, looping through ranges, checking for prime numbers, and calculating factorials. The results of each exercise are not shown.

Uploaded by

lloooos
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
You are on page 1/ 8

The laboratory work 3

Exercise 1: Print First 10 natural numbers using while loop.

Result:

Exercise 2: Print the following pattern

Result:
Exercise 3: Accept number from user and calculate the sum of all number from 1 to a
given number
For example, if user entered 10 the output should be 55.
Result:

Exercise 4: Print multiplication table of a given number

For example, num = 2 so the output should be


Result:

Exercise 5: Given a list, iterate it, and display numbers divisible by five, and if you find a
number greater than 150, stop the loop iteration

Result:
Exercise 6: Reverse the following list using for loop

Result:
Exercise 7: Display numbers from -10 to -1 using for loop.

Result:

Exercise 8: Display a message “Done” after successful execution of for loop

For example, the following loop will execute without any error.
Result:

Exercise 9: Write a program to display all prime numbers within a range

Note: A Prime Number is a whole number that cannot be made by multiplying other


whole numbers

Examples:

 6 is not a Prime Number because it can be made by 2×3 = 6


 37 is a Prime Number because no other whole numbers multiply together to make it.
Result:

Exercise 10: Write a loop to find the factorial of any number

The factorial (symbol: !) means to multiply all whole numbers from the chosen number
down to 1.

For example: calculate the factorial of 5


Result:

You might also like