Monday, May 25, 2020
Home PYTHON Conditional Statement Program

# Conditional Statement Program

### 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 largest 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 ...

#### Stay connected

19,697Fans
2,180Followers
14,700Subscribers

### Python program to display the fibonacci sequence using recursive

def recursive_fibo(num): if num <= 1: return num else: ...

### Python program to find the product of two numbers using recursive

def mult_product(x,y): if(x<y): return mult_product(y,x) elif(y!=0): ...

### Python program to convert octal to decimal using function

def octal_to_dec(n): # Function which is convert octal to decimal num = n; dec_value = 0; ...