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

Python Notes

The document outlines several Python programming problems, including counting vowels in a string, finding the largest digit in an integer, calculating the factorial of a number, checking for palindromes, and generating a nested loop pattern. Each problem is accompanied by a code snippet that illustrates the solution. The problems are designed to enhance programming skills and understanding of basic algorithms.
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)
9 views2 pages

Python Notes

The document outlines several Python programming problems, including counting vowels in a string, finding the largest digit in an integer, calculating the factorial of a number, checking for palindromes, and generating a nested loop pattern. Each problem is accompanied by a code snippet that illustrates the solution. The problems are designed to enhance programming skills and understanding of basic algorithms.
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

Problem 6: Counting Vowels in a String

Create a Python program that counts the number of vowels (a, e, i, o, u, case-insensitive)

text = input("Enter a string: ")


count = 0 vowels = "aeiouAEIOU"

for char in text: if char in


vowels: count += 1
print("Number of vowels:", count)

Problem 7: Finding the Largest Digit in an Integer


num = int(input("Enter a positive integer: "))
largest = 0

while num > 0:


digit = num % 10 if
digit > largest: largest
= digit num //= 10
print("Largest digit:", largest)

Problem 8: Factorial of a Given Number


num = int(input("Enter a number: "))
fact = 1

for i in range(1, num + 1): fact


*= i print("Factorial of", num, "is",
fact)

Problem 9: Palindrome Checker

text = input("Enter a string: ")


text = [Link]() reverse = ""

for char in text:


reverse = char + reverse

if text == reverse:
print("It is a palindrome!")
else: print("Not a
palindrome.")

Problem 10: Nested Loop Pattern

Example:
Output:
1
12
123
1234
12345
rows = int(input("Enter number of rows: "))
for i in range(1, rows + 1):
for j in range(1, i + 1):
print(j, end=" ") print()

You might also like