All codes for python
[Link] rectangle
# Define the length and width of the
rectangle
length = float(input("Enter the length
of the rectangle: "))
width = float(input("Enter the width of
the rectangle: "))
# Calculate the area
area = length * width
# Print the result
print("The area of the rectangle is:",
area)
[Link] circle
import math
# Ask the user for the radius of the
circle
radius = float(input("Enter the radius
of the circle: "))
# Calculate the area using the formula
area = [Link] * radius ** 2
# Print the result
print("The area of the circle is:", area)
[Link] convert kilometers to meters
# Ask the user for the number of
kilometers
kilometers = float(input("Enter the
distance in kilometers: "))
# Convert kilometers to meters
meters = kilometers * 1000
# Print the result
print(f"{kilometers} kilometers is equal
to {meters} meters.")
[Link] convert meters to kilometers
# Ask the user for the number of
meters
meters = float(input("Enter the
distance in meters: "))
# Convert meters to kilometers
kilometers = meters / 1000
# Print the result
print(f"{meters} meters is equal to
{kilometers} kilometers.")
[Link] convert fahraneit to celsius
# Ask the user for the temperature in
Fahrenheit
fahrenheit = float(input("Enter the
temperature in Fahrenheit: "))
# Convert Fahrenheit to Celsius
celsius = (fahrenheit - 32) / 1.8
# Print the result
print(f"{fahrenheit} Fahrenheit is equal
to {celsius} Celsius.")
[Link] convert Celsius to Fahrenheit
# Ask the user for the temperature in
Celsius
celsius = float(input("Enter the
temperature in Celsius: "))
# Convert Celsius to Fahrenheit
fahrenheit = (celsius * 1.8) + 32
# Print the result
print(f"{celsius} Celsius is equal to
{fahrenheit} Fahrenheit.")
[Link] to use print function
print (“expression”)
Ex- print (“7i world school”)
[Link] to add ,subtract ,multiply ,divide
x = 10
y=5
# Addition
result = x + y
print("Addition:", result)
x = 10
y=5
# Subtraction
result = x - y
print("Subtraction:", result) # Output:
5
x = 10
y=5
# Multiplication
result = x * y
print("Multiplication:", result) #
Output: 50
x = 10
y=5
# Division
result = x / y
print("Division:", result)
x = 10
y=5
z=2
# Combined operations
result = (x + y) * z / (x - z)
print("Combined Result:", result)
[Link] to use arthimetic operation
a = input (“Enter a number :”)
b= input (“Enter another number:”)
print (“The answer is:” , int(a) + int(b))
note- just change the sign to do
different operation
[Link] swap two variables using third
variable
a= int (input(“Enter value for a =”))
b= int (input(“Enter value for b =”))
t= a
a=b
b=t
print (“After swapped A =” , a)
print (“B =” , b)
11. .to swap two variables without
using third variable
a = a+b
b = a-b
a = a-b
print (“After swapped A =” , a)
print (“ B =” , b)