0% found this document useful (0 votes)
2 views1 page

Python Programs

The document contains several simple Python code snippets for basic tasks such as inputting numbers and printing their sum, displaying age, inputting a name and favorite subject, printing a square pattern, performing addition and subtraction in a simple calculator, calculating the average of two numbers, and printing numbers from 1 to 5.

Uploaded by

real
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Python Programs

The document contains several simple Python code snippets for basic tasks such as inputting numbers and printing their sum, displaying age, inputting a name and favorite subject, printing a square pattern, performing addition and subtraction in a simple calculator, calculating the average of two numbers, and printing numbers from 1 to 5.

Uploaded by

real
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Input Two Numbers and Print Their Sum

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
print("Sum is:", a + b)

Input Age and Display It


age = input("Enter your age: ")
print("Your age is", age)

Input Name and Favourite Subject


name = input("Enter your name: ")
subject = input("Enter your favourite subject: ")
print("Name:", name)
print("Favourite Subject:", subject)

Print a Square Pattern


print("****")
print("****")
print("****")
print("****")

Simple Calculator (Addition & Subtraction)


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

print("Addition:", a + b)
print("Subtraction:", a - b)

Average of Two Numbers


a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

avg = (a + b) / 2
print("Average is:", avg)

Print Numbers from 1 to 5


print(1)
print(2)
print(3)
print(4)
print(5)

You might also like