Year 9

Programming in Python

# This program prints Hello, world!
print('Hello, world!')
# This program adds two numbers

num1 = 1.5
num2 = 6.3

# Add two numbers
sum = num1 + num2

# Display the sum
print('The sum of num1 and num2 is ',sum)

 

# Store input numbers
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')

# Add two numbers
sum = float(num1) + float(num2)

# Display the sum
print('The sum of num1 and num2 is ',sum)

 

a = float(input('Enter first side: '))
b = float(input('Enter second side: '))
c = float(input('Enter third side: '))

s = (a + b + c) / 2

area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is ' ,area)

 

x = input('Enter value of x: ')
y = input('Enter value of y: ')

print('The value of x before swapping: ',x)
print('The value of y before swapping: ',y)

temp = x
x = y
y = temp

print('The value of x after swapping: ',x)
print('The value of y after swapping: ',y)

 

print("Enter the Principle Amount: ")
p = int(input())
print("Enter Rate of Interest (%): ")
r = float(input())
print("Enter Time Period: ")
t = float(input())
si = (p*r*t)/100
print("Simple Interest Amount: ")
print(si)

 

pi = 3.14
diameter = int(input("enter the diameter of the circle"))
radius = diameter / 2
perimeter = 2 * pi * radius
print("perimeter of circle is ", perimeter)

 

num = int(input("enter the number : "))
if(num%2==0):
 print("It is Even number")
else:
 print("It is Odd number")

 

 

age = int(input("enter the age : "))
if(age>=18):
 print("You can vote")
else:
 print("You can't vote")

 

pi = 3.14
radius = int(input("enter the radius of the circle"))
area = pi * radius * radius
print("area of circle is ", area)

 

kilometers = float(input("Enter value in kilometers: ")) conv_fac = 0.621371 
miles = kilometers * conv_fac 
print("kilometers is equal to miles",miles))

 

b=float(input("Enter the base of triangle"))
h=float(input("Enter the height of triangle"))
Area=(1/2)*b*h
print("The area of triangle is : ", Area)

 

a = float(input("Enter the dividend : "))
b = float(input("Enter the divisor : "))
Q = a // b
R = a % b
print("The quotient is : ", Q)
print("The remainder is : ", R)

 

a=int(input('Enter the first integer:'))
b=int(input('Enter the second integer:'))
c=int(input('Enter the third integer:'))

if a>b and a>c:
 print(a, 'is the largest integer')
elif b>c:
 print(b, 'is the largest integer')
else:
 print(c, 'is the largest integer')