Monday, August 15, 2022
Home PYTHON Conditional Statement Program

Conditional Statement Program

Python program to print whether a given character is an upper case or a...

ch=input("Enter a single character: ") if ch>='A'and ch<='Z': print("You entered an Upper case character.") elif ch>='a'and ch<='z': print("You entered a Lower case...

Python program to sort elements in ascending order

a=int(input("Enter first number: ")) b=int(input("Enter second number: ")) c=int(input("Enter third number: ")) min=mid=max=None if a<b and a<c:   if b<c:       min,mid,max=a,b,c   else:       min,mid,max=a,c,b elif b<a and...

Python program for performing an arithmetic operations

num1=float(input("Enter first number:" )) num2=float(input("Enter second number:")) op=input("Enter operator :") result=0 if op=='+':   result=num1+num2 elif op=='-':   result=num1-num2 elif op=='*':   result=num1*num2 elif op=='/':   result=num1/num2 elif...

Python program for updating the time by one second

h=int(input("Enter Hours: ")) m=int(input("Enter Minutes: ")) s=int(input("Enter Second: ")) if((h<0)or(m<0)or(s<0)): # hour or minute or seconds can not be -ve number print("invalid data n"); elif((h>12)or(m>59)or(s>59)): # the...

Python program for find the area of triangle when three sides are given

from math import sqrt a=float(input("Please enter the first side: ")) b=float(input("Please enter the second side: ")) c=float(input("Please enter the third side: ")) if((a<=0)or(b<=0)or(c<=0)): # a side...

Python program to find the roots of quadratic equation

from math import sqrt a=float(input("Please enter first number: ")) b=float(input("Please enter second number: ")) c=float(input("Please enter third number: ")) d=b*b-4*a*c; # finding determinant if(d==0): # when d is...

Python program to find largest of three numbers

num1=int(input("Please enter first number: ")) num2=int(input("Please enter second number: ")) num3=int(input("Please enter third number: ")) if((num1>num2)and(num2>num3)): # use of logical and, which gives true only when...

Python program to check a number is positive negative or zero

num=int(input("Please enter a number to check Positive Negative or Zero ")) if(num>0): print("Given number is a positive number"); elif(num<0): print("Given number is...

Python program to check given number is even or odd

num=int(input("Enter a number to check even or odd ")) if(num%2==0): # checks for remainder is zero or not for even number it should be 0 ...

Python program to find largest and equal of two numbers

num1=int(input("Please enter first number: ")) num2=int(input("Please enter second number: ")) if(num1>num2): #check for num1 is largest and gives true when num1 is largest otherwise false ...

Python program to find the GCD of two numbers using recursive

def gcd(x,y):     if(y==0):       return x     else:       return gcd(y,x%y) x=int(input("Please enter first number: ")) y=int(input("Please enter second...

Python program to check find the given year is a leap year or not

year=int(input("Please enter a year to be check leap year or not: ")) if(year%4==0 and year%100!=0 or year%400==0): print("This year is a leap...

Python program to find the LCM of two numbers using recursive

def lcm(a,b): lcm.multiple=lcm.multiple+b if((lcm.multiple % a == 0) and (lcm.multiple % b == 0)): ...