# Program to find the sum of two numbers
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
sum_result = num1 + num2
print("The sum is:", sum_result)
output o
Enter first number:5
Enter first number: 5
Enter second number:7
Enter second number: 7
The sum is:12.0
The sum is: 12.0
# Program to swap two numbers
x = int(input("Enter first number: "))
y = int(input("Enter second number: "))
print("Before swapping: x =", x, " y =", y)
x, y = y, x
print("After swapping: x =", x, " y =", y)
output
output
Enterfirst
Enter firstnumber:10
number: 10
Entersecond
Enter secondnumber:20
number: 20
Before
Beforeswapping:
swapping:x=10 y=20
x = 10 y = 20
After swapping: x=20 y=10
After swapping: x = 20 y = 10
# Program to find the area and perimeter of a
circle
import math
radius = float(input("Enter the radius of the circle: "))
area = math.pi * radius * radius
perimeter = 2 * math.pi * radius
# Displaying the results
print("Area of the circle:", area)
print("Perimeter (Circumference) of the circle:", perimeter)
output
output
Enter
Enter thethe radius
radius of the
of the circle:
circle: 5 5
Area of of
Area thethe
circle: 78.53981633974483
circle: 78.53981633974483
perimeter (circumference) of the circle:31.41592653589793
Perimeter (Circumference) of the circle: 31.41592653589793
# Program to check if a number is odd or even
num = int(input("Enter a number: "))
if num % 2 == 0:
print(num, "is Even")
else:
print(num, "is Odd")
output
output
Enteraanumber:
Enter number:7 7
77isisodd
Odd
Enter a number: 12
Enter a number: 12
12 is even
12 is Even
# Program for string concatenation
str1 = "Hello"
str2 = "World"
result = str1 + " " + str2
print("Concatenated String:", result)
output
Concatenatedstring:
Concatenated String:Hello
HelloWorld
World
# Grade Calculator Program
# Taking marks input from the user
marks = float(input("Enter your marks (out of 100): "))
# Checking grade using conditions
if marks >= 90:
grade = "A"
elif marks >= 80:
grade = "B"
elif marks >= 70:
grade = "C"
elif marks >= 60:
grade = "D"
elif marks >= 50:
grade = "E"
else:
grade = "F"
# Displaying result
print("Your Grade is:", grade)
output
output
Enter
Enter your marks (out
your marks (outofof100):
100):85
85
Your Grade
Your Grade is:
is: BB