# Python – Basic Programs 50+

## 50+ Python Basic Programs

1. To say Hello and Welcome all.

``````#Program -1
#To say Hello
#Author - Anjeev Singh

print("Hello, Welcome to mycsturial.in")

``````

Output:

Hello, Welcome to mycsturial.in

2. To calculate sum of two numbers.

``````#Program - 2
#To compute sum of two numbers
#Author - Anjeev Singh

num1 = 20
num2 = 30

result = num1 + num2

print("Number 1 : ", num1)
print("Number 2 : ", num2)
print("Sum : ", result)``````

Output :

Number 1 : 20
Number 2 : 30
Sum : 50

3. To print quotient and remainder after dividing one number by another number. / Find remainder and quotient.

``````# Program - 3
# To print quotient and remainder after dividing one number by another number
# Author - Anjeev Singh

num1 = 46
num2 = 7

remainder = num1 % num2
quotient = num1 // num2

print("Number 1 : ", num1)
print("Number 2 : ", num2)
print("Quotient : ", quotient)
print("Remainder : ", remainder)``````

Output:

Number 1 : 46
Number 2 : 7
Quotient : 6
Remainder : 4

4. To print the quotient after dividing one number by another number.

``````# Program - 4
# To print quotient after dividing one number by another number
# Author - Anjeev Singh

num1 = 46
num2 = 7

result = num1 / num2     #division operator

print("Number 1 ", num1)
print("Number 2 ", num2)
print("Result (Quotient)  : ", result)``````

Output:

Number 1 : 46
Number 2 : 7
Result (Quotient) : 6.571428571428571

5. To print quotient after dividing one number by another number.

``````# Program - 5
# To calculate area of triangle.
# area = ( b*h) / 2
# Author - Anjeev Singh

base = 40
height = 10

area = ( base * height) / 2

print("Base : ", base)
print("Height : ", height)
print("Area of Triangle : ", area)``````

Output:

Area of Triangle : 200.0

### Using of input( ) and print( )

6. To say Hello message, after inputting the name of student.

``````# Program - 6
# To say Hello to your friends after inputting name
# Author - Anjeev Singh

name = input("Enter your name : ")

print("Hello Dear ", name)
print("Welcome to mycsturial.in")``````

Output:

Hello Dear Amrit
Welcome to mycsturial.in

7. Program to obtain (input) three numbers and print their sum

``````# Program - 7
# Program to obtain (input) three numbers and print their sum
# Author - Anjeev Singh

num1 = int(input("Enter Number 1 : "))
num2 = int(input("Enter Number 2 : "))
num3 = int(input("Enter Number 3 : "))

Sum = num1 + num2 + num3

print("Sum of three numbers ", num1, num2, "and", num3, "is", Sum)
``````

Output:

Sum of three numbers 3456 8765 and 1230 is 13451

8. Program to obtain (input) three numbers and print their Average.

``````# Program - 8
# Program to obtain (input) three numbers and print their average
# Author - Anjeev Singh

num1 = int(input("Enter Number 1 : "))
num2 = int(input("Enter Number 2 : "))
num3 = int(input("Enter Number 3 : "))

Sum = num1 + num2 + num3
Average = Sum / 3

print("Three numbers are ", num1, num2, "and", num3)
print("Average : ", Average)``````

Output:

Enter Number 1 : 25
Enter Number 2 : 65
Enter Number 3 : 18
Three numbers are 25 65 and 18
Average : 36.0

9. To calculate the Area of the rectangle by obtaining length and breadth from the user.

``````# Program - 9
# To calculate Area of Triangle by obtaining length and breadth from user.
# Formula : Area of Rectangle = length x breadth
# Author - Anjeev Singh

length = int(input("Enter Length : "))

print("Rectangles Details ")
print("Area of Rectangle : ", area)``````

Output:

Enter Length : 56