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

? For Loop Problems

The document outlines a series of programming exercises focused on for loops and list manipulation. It includes tasks such as printing numbers, calculating squares, counting vowels, and modifying lists. Users are encouraged to complete the problems on their own machines and share their results with a group or mentor.

Uploaded by

gocef34052
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)
17 views2 pages

? For Loop Problems

The document outlines a series of programming exercises focused on for loops and list manipulation. It includes tasks such as printing numbers, calculating squares, counting vowels, and modifying lists. Users are encouraged to complete the problems on their own machines and share their results with a group or mentor.

Uploaded by

gocef34052
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

For Loop Problems (5)

1. Print Numbers from 1 to 10

Write a program using a for loop that prints numbers from 1 to 10.

2. Print Squares of First 5 Natural Numbers


Use a for loop to print the squares of the first 5 natural numbers (1² to 5²).

3. Print Each Character in a String


Take a string as input and print each character on a new line using a for loop.
Example: "Python" → P, y, t, h, o, n

4. Print Even Numbers Between 2 to 200

5. Count Vowels in a Word


Take a word as input and count how many vowels it contains using a for loop.
Hint: vowels are a, e, i, o, u

Example:

In word ‘university’, the vowels are u, i, e, i.

List Problems (3)

6. Add and Remove Elements


Start with an empty list.

• Append "apple", "banana", and "cherry" to the list


• Then remove "banana"
• Print the final list
7. Sort a List of Numbers
Given a list of numbers [5, 3, 8, 1, 4],

• Sort the array and print the list-

1. In ascending order
2. In descending order

8. Reverse a List
Given a list ["a", "b", "c", "d"],

• Reverse the list and pop() the 2nd element


• Print the result

Do these problems, run in your own machine and then send in the group or any mentor’s id.

You might also like