Python Practice Day 3: Problem-Solving Exercises

🐍 Python Practice – Day 3 ( 14 out of 50 questions solved) Continuing my Python learning journey and focusing on strengthening problem-solving skills through small coding exercises. 📌 Problems solved today: 🔹 Count vowels in a string 🔹 Reverse a number 🔹 Print the multiplication table of a number 🔹 Find the factorial of a number 📌 List-based problems: 🔹 Find the largest element in a list 🔹 Find the second largest number in a list 🔹 Remove duplicates from a list Each exercise helps improve my understanding of loops, conditions, lists, and basic Python logic. Consistency is the key, and I’m enjoying the process of learning step by step. Looking forward to tackling more problems tomorrow! 🚀 #Python #PythonLearning #CodingPractice Day 2 Count vowels in a string. try:     word=str(input("enter a string")).lower()     vowel={'a','e','i','o','u'}     s=0     for i in word:             if i in vowel:                 s=s+1     print(s) except ValueError:     print("Invalid input. enter string") Reverse a number. try:     num1 =str(input("Enter a number: "))     num2=num1[::-1]     print(num2) except ValueError:     print("invalid input. enter a number") Print multiplication table of a number. try:     num=int(input("enter a number"))     s=1     mult=0     while s<=10:         mult=num*s         s=s+1         print(mult)     except ValueError:     print("invalid input") Find factorial of a number. try:     num=int(input("enter a number"))     fact=1     while num>0:         fact=fact*(num)         num=num-1     print(fact) except ValueError:     print("invalid input") Find the largest element in a list. try:     list1=[1,2,3,4,5,6,7,8,898]     print(max(list1)) except ValueError:     print("error occured. Please check the code") Find the second largest number in a list. try:     list1=[1,2,3,4]     largest=max(list1)     secondlargest=float('-inf')     for i in list1:         if i != largest and i >secondlargest:             secondlargest=i     print(secondlargest) except ValueError:     print("error occured. Please check the code") Remove duplicates from a list. try:     list1=[1,1,2,2,3,3,4,4,5,5,6,6,7,7,8]     set1=set(list1)     print(list(set1)) except ValueError:     print("invalid operation")

To view or add a comment, sign in

Explore content categories