Python Practice

print("Username: ")
x = input()

print(x)

print("Password: ")
y = input()

print(y)
Username: 
hi
Password: 
no u

Official Code is in this one cell below:

import math
import datetime
# Create date variable with a random value
date = 1
# Create dateCalc to display the current time
dateCalc = datetime.datetime.now()
# If statements to change the value of date so then it can be used in the API. The day of the weeks for the API is three letter abbreviations.
if dateCalc.strftime("%A") == "Monday":
	date = "Mon"
if dateCalc.strftime("%A") == "Tuesday":
	date = "Tue"
if dateCalc.strftime("%A") == "Wednesday":
	date = "Wed"
if dateCalc.strftime("%A") == "Thursday":
	date = "Thu"
if dateCalc.strftime("%A") == "Friday":
	date = "Fri"
if dateCalc.strftime("%A") == "Saturday":
	date = "Sat"
if dateCalc.strftime("%A") == "Sunday":
	date = "Sun"

# Set count to 1 so the data only runs once, then this will only display the current day of this week and not next week.
count = 1

# Access the API
import requests

url = "https://yahoo-weather5.p.rapidapi.com/weather"

location = input()

querystring = {"location": str(location),"format":"json","u":"f"}

headers = {
	"X-RapidAPI-Key": "hi",
	"X-RapidAPI-Host": "hi"
}

response = requests.request("GET", url, headers=headers, params=querystring)

# Uncomment this to access raw data
# print(response.text)

# Filter out the data to display only weather info today
print("Weather is in ◦F")
print("Forecast in", str(location), ":")
result = response.json().get('forecasts')
for re in result:
	if count == 1:
		datesec = re["date"]
		count = count +1
		print(datesec)
		dateday = divmod(datesec,86400)
		print(dateday)
	# if count == 1:
	# 	if re["day"] == date:
	# 		print(dateCalc.strftime("%A"))
	# 		print("Low:", re["low"])
	# 		print("High:", re["high"])
	# 		print("Weather:", re["text"])
	# 		count = count + 1
Weather is in ◦F
Forecast in san diego :
1667185200
(19296, 10800)

Testing with JSON date info

import datetime

date2 = datetime.datetime.now()
print(date2.strftime("%A"))
print(date2)

date = 1
dateCalc = datetime.datetime.now()
print(dateCalc.strftime("%A"))
if dateCalc.strftime("%A") == "Tuesday":
	date = 2

print(date)
Monday
2022-10-31 11:23:03.951042
Monday
1