Sei sulla pagina 1di 4

# This program adds two numbers

num1 = 1.5
num2 = 6.3
sum =num1+num2
print('The sum is ' , sum)

# This program adds two numbers


num1=int(raw_input(“Enter First Number”))
num2=int(raw_input(“Enter Second Number”))
sum =num1+num2
print('The sum is ' , sum)

# This program prints Hello, world!


print('Hello, world!')

# This program prints Hello, world!


print(“Hello, world!”)

# This program prints Hello, world!


print('’’Hello, world!'’’)

# Python Program to find the area of triangle


h=5
b=6
area = 0.5 * b * h
print('The area of the triangle is ' , area)

# Python Program to find the area of triangle


b= float(raw_input('Enter Breadth: '))
h = float(raw_input('Enter Height: '))
area = 0.5 * b * h
print('The area of the triangle is ' , area)

# Python Program to convert temperature in celsius to


fahrenheit
cel = 37.5
fahren = (cel * 1.8) + 32
print('Answer is ',fahrenheit))

#Check if a number is Positive or Negative (elif)


num = float(raw_input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")

#Check if a number is Positive or Negative (nested if)


num = float(raw_input("Enter a number: "))
if num >= 0:
if num == 0:
print("Zero")
else:
print("Positive number")
else:
print("Negative number")

#Check if a number is Odd or Even (if, Modulus)

num = int(raw_input("Enter a number: "))


if (num % 2) == 0:
print("The given Number is Even")
else:
print("The given Number is Odd”)

# Python program to find the biggest number among two

num1 = 10
num2 = 14
if (num1 > num2) :
print(“num1 is big”)
elif (num2 > num1) :
print (“num2 is big”)
else:
print(“Both num1,num2 are equal”)

# Python program to find the biggest number among two

num1 = float(raw_input("Enter first number: "))


num2 = float(raw_input("Enter second number: "))
if (num1 > num2) :
print(“num1 is big”)
elif (num2 > num1) :
print (“num2 is big”)
else:
print(“Both num1,num2 are equal”)
# Python program to find the largest number among the
three numbers

num1 = 10
num2 = 14
num3 = 12
if (num1 >= num2) and (num1 >= num3):
print(“num1 is bigger”)
elif (num2 >= num1) and (num2 >= num3):
print(“num2 is bigger”)
else:
print(“num3 is bigger”)

# Python program to find the largest number among the


three numbers

num1 = float(raw_input("Enter first number: "))


num2 = float(raw_input("Enter second number: "))
num3 = float(raw_input("Enter third number: "))
if (num1 >= num2) and (num1 >= num3):
print(“num1 is bigger”)
elif (num2 >= num1) and (num2 >= num3):
print(“num2 is bigger”)
else:
print(“num3 is bigger”)

# Python program to check if the number is divisible by 6

n = 2000
if (n % 6= = 0):
print("The given number is divisible by 6 ")
else:
print("The given number is not divisible by 6 ")

# Python program to check if the number is divisible by 6

n = int(raw_input("Enter the Number: "))


if (n % 6= = 0):
print("The given number is divisible by 6 ")
else:
print("The given number is not divisible by 6 ")

# Python Program to find the area of square


b= float(raw_input('Enter Size: '))
area = b*b
print('The area of square is ' , area)

# Python Program to find the area of rectangle


l= float(raw_input('Enter Length: '))
b = float(raw_input('Enter Breadth: '))
area = l * b
print('The area of the rectangle is ' , area)

# Python Program to find the circumference of circle


r= float(raw_input('Enter Radius: '))
cf = 2*3.14*r
print('The circumference of the circle is ' , cf)

# Python Program to find the area of circle


r= float(raw_input('Enter Radius: '))
a=3.14*r*r
print('The area of the circle is ' , a)

# Python Program to find the perimeter of rectangle


l= float(raw_input('Enter Length: '))
b = float(raw_input('Enter Breadth: '))
p = 2 *( b + l)
print('The perimeter of the rectangle is ' , p)

# Python Program to find the perimeter of square


s= float(raw_input('Enter Size: '))
area = 0.5 * b * h
print('The area of the triangle is ' , area)

Potrebbero piacerti anche