Python Practice Progress: 6/50 Questions Solved

🚀 Day 3 – Python Practice Progress( 6 of 50 questions solved) Problems I practiced today: ✔ Check if a number is even or odd ✔ Find the largest of three numbers ✔ Print numbers from 1 to N ✔ Find the sum of numbers from 1 to N ✔ Check if a number is prime ✔ Check if a string is a palindrome While solving these, I practiced using: • Conditional statements • Loops (while / for) • Input validation using try–except • String slicing (for palindrome checking) 💡 One interesting concept I explored today was Python slicing: s = "python" print(s[::-1]) This reverses the string because the step -1 makes Python traverse the sequence backwards. Small problems like these are helping me build stronger problem-solving skills in Python. Looking forward to practicing more tomorrow. #Python #DataScience #Programming 1 Check if a number is even or odd. try:     num1=int(input("Enter a Number : "))     if num1%2==0:             print("number is even")     else:             print("number is odd") except ValueError:        print("invalid input. Please enter a number") 2. Find the largest of three numbers. try:     num1=int(input("Enter first Number: "))     num2=int(input("Enter second Number: "))     num3=int(input("Enter third Number: "))     if num1>num2 and num2>num3:         print("Larget Number is :", num1)     elif num2>num3 and num2>num1:         print("Largest Number is :", num2)     else:         print("Largest Number is :", num3) except ValueError:     print("invalid Input. Please enter a number") 3 Print numbers from 1 to N try:     num1=int(input("Enter a Number: "))     if num1>0:         s=0         while s<=num1:             print(s)             s=s+1;     else:         p=0         while p>=num1:             print(p)             p=p-1; except ValueError:     print("invalid input, please enter a number") 4 Find the sum of numbers from 1 to N. try:     num=int(input("Enter a number : "))     if num>0:         s=0         i=0         while i<=num:             s=s+i;             i=i+1;         print(s)     else:         p=0         q=0         while q >=num:             p=p+q;             q=q-1;         print(p) except ValueError:     print("invalid input. Enter correct Number") Check if a number is prime. try:     num=int(input("Enter a number : "))     if num>1:         is_prime=True         i=2         while i <num:             if num%i==0:                    is_prime=False                    break             i=i+1         if is_prime:             print("Number is prime")         else:             print("Number is not prime")     else:         print("Enter a number greater than 1") except ValueError:     print("Invalid Input. enter valid number") 6. Check if a string is a palindrome. try:     num=str(input("Enter a sring:"))     if num==num[::-1]:         print("Palindrome")     else:         print("not a palindrome") except ValueError:     print("invalid input. Enter a string")

To view or add a comment, sign in

Explore content categories