Lesson 22: Working with dates and converter between Fahrenheit and Celsius

posted Apr 11, 2018, 10:09 PM by Attila Lengyel   [ updated Apr 12, 2018, 8:00 AM ]
from datetime import datetime

now = datetime.now()
print(now)

mm = str(now.month)
print(mm)

dd = str(now.day)
print(mm + "/" + dd)

yyyy = str(now.year)
print(mm + "/" + dd + "/" + yyyy)

hour = str(now.hour)
print(mm + "/" + dd + "/" + yyyy + " " + hour)

mi = str(now.minute)
print(mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi)

ss = str(now.second)
print(mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss)

import geocoder
g = geocoder.ip('me')
print(g.latlng)

Celsius = float(input("Celsius:"))
Fahrenheit = 9/5 * Celsius + 32
print(Fahrenheit, "Fahrenheit")

Fahrenheit = float(input("Fahrenheit:"))
Celsius = (Fahrenheit - 32)*5/9
print(Celsius, "C")











Comments