Term 1
Term 2
Programming in Python
Python Program to Print Hello world!
# This program prints Hello, world! print('Hello, world!')
Python Program to Add Two Numbers
# 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)
Add Two Numbers With User Input
# 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)
Python Program to Calculate the Area of a Triangle
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)
Python Program to Swap the values of Two Variables
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)
Python Program for simple interest
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)
Python Program to find perimeter of a circle using Diameter
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)
Python program to check whether a number is Even or Odd
num = int(input("enter the number : ")) if(num%2==0): print("It is Even number") else: print("It is Odd number")
Python program to check whether a person is eligible to vote or not
age = int(input("enter the age : ")) if(age>=18): print("You can vote") else: print("You can't vote")
Python program to find the area of a Circle using Radius
pi = 3.14 radius = int(input("enter the radius of the circle")) area = pi * radius * radius print("area of circle is ", area)
Python program to convert distance from Kilometer to Miles
kilometers = float(input("Enter value in kilometers: ")) conv_fac = 0.621371 miles = kilometers * conv_fac print("kilometers is equal to miles",miles))
Write a program that accepts base and height and calculate the area of triangle.
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)
Write a program to read two numbers and prints their quotient and reminder
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)
Write a program to find largest among three integers
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')