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

Python For Loop Coding Challenges

Uploaded by

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

Python For Loop Coding Challenges

Uploaded by

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

Python Loop Coding Questions

------------------------------------------
1. Print numbers from 1 to 10 using a for loop
2. Print sum of the elements of a list using a for loop
my_list = [1, 8, 2, 3, 4, 5]
res=23
3. Calculate the product of elements in a list using a for loop
my_list = [ 2, 3, 4, 5]
res=120
4. Print even numbers from 1 to 20 using a for loop
5. Print numbers in reverse from 10 to 1 using a for loop
6. Print characters of a string using a for loop
ex - S='HELLO'
output: H E L L O
7. Find the largest number in a list using a for loop
my_list = [1, 8, 2, 3, 4, 5]
res=8
8. Find the average of numbers in a list using a for loop
my_list = [4, 7, 9, 2, 5]
9. Count the number of vowels in a string using a for loop
my_string = "Hello World"
o/p - 3
10. Find the first occurrence of a number in a list
my_list = [3, 8, 2, 7, 4,9,7,5]
target = 7
output - 4
11. Find all prime numbers between 1 and 50
12. Print the Fibonacci sequence up to the 10th term
output : 0,1,1,2,3,5,8,13,21,34
13. Find the common elements in two lists using a for loop:
list1 = [1, 2, 3, 4, 5]
list2 = [3, 4, 5, 6, 7]
output = [3,4,5]
14. Find the factorial of a number.

You might also like