python conditional statements exercises - Python

python conditional statements exercises

python conditional statements exercises

(Conditional Statements)

Conditional statements are a fundamental building block in programming, allowing us to make decisions and control the flow of our code. Whether you’re a beginner looking to solidify your understanding of python conditional statements exercises or an experienced programmer seeking to sharpen your skills, practicing with exercises is a fantastic way to reinforce your knowledge. In this article, we’ll explore a variety of python conditional statements exercises that cover a range of scenarios and difficulty levels. These exercises will help you become more proficient in using if statements, elif statements, and else statements, allowing you to write more robust and flexible code. Let’s dive in and enhance our understanding of Python’s conditional statements through hands-on practice.

Hello Students if you are searching about the  python conditional statements exercises then you are on right place.Here you will learn about python conditional statements exercises with  examples so must read the full article.

1) WAP to check enter number is greater than 20.

num=int(input(“Enter number”))
if num>10:
print(num,” is greater than 10″)

2) WAP to check whether enter number is positive or negative or zero.

num=int(input(“Enter any number”))
if num>0:
print(“Positive”)
if num<0:
print(“Negative”)
if num==0:
print(“Zero”)

3) Find Biggest Value of given 2 number from the command line by using if else statement.

a=int(input(“Enter first number”))
b=int(input(“Enter second number”))
if a>b:
print(a,” is greater than “,b)
else:
print(b,” is greater than “,a)

4) WAP to enter RUN scored by a cricket player check whether it is Triple Century, Double century, Century and Half.

run=int(input(“enter runs scored by cricket players”))
if run>=300:
print(“Triple Century”)
elif run>=200:
print(“Double Century”)
elif run>=100:
print(“Century”)
elif run>=50:
print(“Half Century”)
else:
print(“Under Half Century”)

5) WAP to check greater between 3 numbers using and operator.

a=int(input(“Enter first number”))
b=int(input(“Enter second number”))
c=int(input(“Enter third number”))
if a>b and a>c:
print(“a is greater”)
if b>c and b>a:
print(“b is greater”)
if c>b and c>a:
print(“c is greater”)

6) WAP to check greater between 3 numbers using Nested if.

a=int(input(“Enter first number”))#30
b=int(input(“Enter second number”))#200
c=int(input(“Enter third number”))#1000
if a>b:
if a>c:
print(“a is greater”)
else:
print(“c is greater”)
else:
if b>c:
print(“b is greater”)
else:
print(“c is greater”)

7) WAP to check whether enter character is vowel or consonant

ch=input(“Enter any character”)
if ch==’a’ or ch==’A’ or ch==’e’ or ch==’i’ or ch==’o’ or ch==’u’:
print(“VOWEL”)
else:
print(“Consonant”)

8) Write a Program to find your grade according to the following condition

Above 90- A+,Above-80-grade A, Above 70- Grade-B,Above 60-Grade C, Otherwise fail.

grade=int(input(“Enter your marks”))
if grade>=90:
print(“A+”)
elif grade>=80:
print(“A”)
elif grade>=70:
print(“B”)
elif grade>=60:
print(“C”)
else:
print(“Fail”)

9) WAP to check enter number is even or odd

num=int(input(“Enter any number”))
if num%2==0:
print(“Even”)
else:
print(“Odd”)

10) WAP to input percentage of a student and check whether the student is pass or fail. Passing Percentage is 40 and each subject marks are out of 50.

m1=int(input(“Enter marks1”))
m2=int(input(“Enter marks2”))
m3=int(input(“Enter marks3”))
total=m1+m2+m3
p=total*100/150
print(“Total=”,total)
print(“Percentage=”,p)
if p>=40:
print(“Pass”)
else:
print(“Fail”)

Thanks For Reading the Article python conditional statements exercises.

Also Check Our Latest Uploads

Olevel M3R5 Practical Exam

Olevel M3R5 Practical Exam Questions

For Live class Visit on our youtube channel

https://healthyworld111.com/

Leave a Comment