1. Home
  2. Docs
  3. Programming with Python
  4. Introduction to Python
  5. 10+ Basic Python Programs

10+ Basic Python Programs

1.) Write a python program to print Hello, World!

# Simple program to print Hello, World!
print("Hello, World!")

2.) Write a python program to Take a Name as Input and Display It.

name = input("Enter your name: ")
print("Hello, " + name)

3.) Write a python program to Add Two Numbers.

num1 = 10
num2 = 90
print("The sum is:", num1 + num2)

4.) Write a python program to Take two numbers as input and add them.

# Take two numbers as input
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

# Add the numbers
sum = num1 + num2

# Display the result
print("The sum of", num1, "and", num2, "is:", sum)

5.) Write a python program to Take two numbers as input and Find the remainder.

# Take two numbers as input
num1 = int(input("Enter the first number: "))
num2 = int(input("Enter the second number: "))

# Find the remainder
remainder = num1 % num2

# Display the result
print("The remainder when", num1, "is divided by", num2, "is:", remainder)

6.) Write a python program to Take two numbers as input and Multiply the numbers.

# Take two numbers as input
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

# Multiply the numbers
product = num1 * num2

# Display the result
print("The product of", num1, "and", num2, "is:", product)

7.) Write a python program to Take two numbers as input and Subtract the numbers.

# Take two numbers as input
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))

# Subtract the numbers
difference = num1 - num2

# Display the result
print("The difference between", num1, "and", num2, "is:", difference)

8.) Write a python program to Take the user’s name as input and Print a Personalized Greeting.

# Take the user's name as input
name = input("Enter your name: ")

# Print a personalized greeting
print("Hello, " + name + "! Welcome to Python programming.")

8.) Write a python program to Calculate the Area of a Circle (Using PI as a Constant).

# Define PI as a constant
PI = 3.14159

# Take the radius as input
radius = float(input("Enter the radius of the circle: "))

# Calculate the area
area = PI * radius ** 2

# Display the result
print("The area of the circle is:", area)

9.) Write a python program to Calculate the Perimeter of a Rectangle.

# Take the length and width as input
length = float(input("Enter the length of the rectangle: "))
width = float(input("Enter the width of the rectangle: "))

# Calculate the perimeter
perimeter = 2 * (length + width)

# Display the result
print("The perimeter of the rectangle is:", perimeter)

10.) Write a python program to Convert Celsius to Fahrenheit.

# Take temperature in Celsius as input
celsius = float(input("Enter temperature in Celsius: "))

# Convert to Fahrenheit
fahrenheit = (celsius * 9/5) + 32

# Display the result
print(celsius, "Celsius is equal to", fahrenheit, "Fahrenheit.")

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *