- Get link
- X
- Other Apps
Basic Input & Arithmetic Operations
Simple Interest Calculator
python
p = float(input("Enter Principal: "))
t = float(input("Enter Time (years): "))
r = float(input("Enter Rate: "))
si = (p * t * r) / 100
print("Simple Interest is:", si)
Area and Perimeter of a Rectanglepythonlength = float(input("Enter length: "))
breadth = float(input("Enter breadth: "))
area = length * breadth
perimeter = 2 * (length + breadth)
print("Area:", area)
print("Perimeter:", perimeter)
Temperature Converter (Celsius to Fahrenheit)pythoncelsius = float(input("Enter temperature in Celsius: "))
fahrenheit = (celsius * 9/5) + 32
print("Temperature in Fahrenheit:", fahrenheit)
Conditional Statements (if-else)Odd or Even Numberpythonnum = int(input("Enter a number: "))
if num % 2 == 0:
print("The number is Even.")
else:
print("The number is Odd.")
Pass or Fail Checkerpythonmarks = float(input("Enter your marks: "))
if marks >= 35:
print("Result: Pass")
else:
print("Result: Fail")
UGreatest of Three Numberspythona = int(input("Enter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a >= b and a >= c:
print("Greatest number is:", a)
elif b >= a and b >= c:
print("Greatest number is:", b)
else:
print("Greatest number is:", c)
Loops (for & while)Sum of First 10 Natural Numberspythontotal_sum = 0
for i in range(1, 11):
print(i)
total_sum = total_sum + i
print("Total Sum is:", total_sum)
Multiplication Tablepythonnum = int(input("Enter a number for the table: "))
for i in range(1, 11):
print(num, "x", i, "=", num * i)
Even Numbers Between 1 and 50pythonfor i in range(1, 51):
if i % 2 == 0:
print(i, end=" ")
- Get link
- X
- Other Apps
Comments
Post a Comment