A for loop is used for iterating over a sequence (like the letters in a string or the items in a list).
Problem Statement
Write a Python program that uses nested for loops to print a right-angled triangle of stars (*) with a height specified by the user.
Expected Output:
Enter triangle height: 5
*
**
***
****
*****
Problem Statement
The factorial of a number is the product of all positive integers less than or equal to that number.
For example:
5! = 5 × 4 × 3 × 2 × 1 = 120
Write a Python program using a for loop and range() to calculate the factorial of a number entered by the user.
Expected Output:
Enter a positive integer: 5
The factorial of 5 is 120.
Problem Statement
Write a Python program that takes a word from the user, uses a for loop to inspect each character in the string, and counts how many vowels (a, e, i, o, u) are inside it.
Expected Output:
Enter a word to analyze: programming
The word 'programming' contains 3 vowels.
Write a Python program that:
Stores a list of floating-point item prices (e.g., [12.50, 45.00, 8.99, 99.99, 23.40]).
Uses a for loop to iterate through each price in the list.
Compares each price against a running tracker to find and store the highest value.
Prints out the final maximum price neatly.
Expected Output:
Scanning item prices: [12.5, 45.0, 8.99, 99.99, 23.4]
-> Most expensive item found: $99.99