DEV Community

Guru prasanna
Guru prasanna

Posted on • Edited on

Python - Level : 1 Tasks

Level 1 Tasks

1) Fahrenheit to Celcius Conversion

f=int(input("Enter the no. "))

c=5/9*(f-32)

print("Fahrenheit to celsius",round(c))
Enter fullscreen mode Exit fullscreen mode

Output:

Enter the no. 108
Fahrenheit to celsius 42

Enter fullscreen mode Exit fullscreen mode

2) Celcius to Fahrenheit Conversion

c=int(input("Enter the no. "))
f=c*(9/5)+32

print("celsius to fahrenheit",round(f))
Enter fullscreen mode Exit fullscreen mode

Output:

Enter the no. 42
celsius to fahrenheit 108

Enter fullscreen mode Exit fullscreen mode

3) Ft to Meter Conversion

#1 Feet = 0.3048 meters

feet=float(input("Enter the no. "))

meter=feet*0.3048

print("feet to meters",round(meter,1))
Enter fullscreen mode Exit fullscreen mode

Output:

Enter the no. 15
feet to meters 4.6

Enter fullscreen mode Exit fullscreen mode

4) Input-Side,Output-Area of A Square

side=float(input("Enter the no. "))

area=side**2

print("Area of a square is ",area)
Enter fullscreen mode Exit fullscreen mode

Output:

Enter the no. 5
Area of a square is  25.0

Enter fullscreen mode Exit fullscreen mode

5) Input-Length, Breadth;Output- Area of a Rectangle

#Area of a Rectangle=length*breadth

length=float(input("Enter length of the rectangle. "))
breadth=float(input("Enter breadth of the rectangle. "))

area=length*breadth

print("Area of a rectangle is ",area)
Enter fullscreen mode Exit fullscreen mode

Output:

Enter length of the rectangle. 5
Enter breadth of the rectangle. 10
Area of a rectangle is  50.0

Enter fullscreen mode Exit fullscreen mode

6) Radius - Area of a circle

#Area of circle = πr2

r=int(input("Enter the radius of circle: "))

area=3.14*(r**2)

print("Area of the circle is ",area)
Enter fullscreen mode Exit fullscreen mode

Output:

Enter the radius of circle: 5
Area of the circle is  78.5

Enter fullscreen mode Exit fullscreen mode

7) USD to INR Conversion

#usd=Rs. 84.56

dollar=float(input("Enter currency in dollars: "))
usd=dollar*84.56

print("Currency in rupees is =",usd)
Enter fullscreen mode Exit fullscreen mode

Output:

Enter currency in dollars: 500
Currency in rupees is = 42280.0

Enter fullscreen mode Exit fullscreen mode

8) Singapore time to india time

singapore time is ahead by 2.30 hours comparing to indian time.

from datetime import datetime, timedelta

singapore_time_str = input("Enter Singapore Time (HH:MM:SS): ")
singapore_time = datetime.strptime(singapore_time_str, "%H:%M:%S")

time_difference = timedelta(hours=2, minutes=30)

indian_time = singapore_time - time_difference
print("Indian Time:", indian_time.strftime("%H:%M:%S"))

Enter fullscreen mode Exit fullscreen mode

Output:

Enter Singapore Time (HH:MM:SS): 12:30:00
Indian Time: 10:00:00

Enter fullscreen mode Exit fullscreen mode

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay