Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let's trigger some PR checks #18

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions app/game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@






def approach_1(user_choice, computer_choice):
if user_choice == "rock":
if computer_choice == "rock":
winning_choice = None
elif computer_choice == "paper":
winning_choice = "paper"
elif computer_choice == "scissors":
winning_choice = "rock"
elif user_choice == "paper":
if computer_choice == "rock":
winning_choice = "paper"
elif computer_choice == "paper":
winning_choice = None
elif computer_choice == "scissors":
winning_choice = "rock"
elif user_choice == "scissors":
if computer_choice == "rock":
winning_choice = "rock"
elif computer_choice == "paper":
winning_choice = "scissors"
elif computer_choice == "scissors":
winning_choice = None
return winning_choice


def approach_2(user_choice, computer_choice):
if user_choice == computer_choice:
winning_choice = None # represents a tie
elif computer_choice == "rock" and user_choice == "scissors":
winning_choice = computer_choice
elif computer_choice == "scissors" and user_choice == "rock":
winning_choice = user_choice
elif computer_choice == "paper" and user_choice == "rock":
winning_choice = computer_choice
elif computer_choice == "rock" and user_choice == "paper":
winning_choice = user_choice
elif computer_choice == "scissors" and user_choice == "paper":
winning_choice = computer_choice
elif computer_choice == "paper" and user_choice == "scissors":
winning_choice = user_choice
return winning_choice


def approach_3(user_choice, computer_choice):
winners = {
"rock": {
"rock": None,
"paper": "paper",
"scissors": "rock",
},
"paper": {
"rock": "paper",
"paper": None,
"scissors": "scissors",
},
"scissors": {
"rock": "rock",
"paper": "scissors",
"scissors": None,
}
}
winning_choice = winners[user_choice][computer_choice]
return winning_choice





if __name__ == "__main__":
u = "rock"
c = "paper"

print("------------------")
print("USER CHOICE:", u)
print("COMPUTER CHOICE", c)
print("------------------")
print("WINNER: (APPROACH 1)", approach_1(u, c))
print("WINNER: (APPROACH 2)", approach_2(u, c))
print("WINNER: (APPROACH 3)", approach_3(u, c))
7 changes: 4 additions & 3 deletions app/weather_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def get_hourly_forecasts(country_code, zip_code):
"conditions": period["shortForecast"],
"image_url": period["icon"]
})
return {"city_name": city_name, "hourly_forecasts": hourly_forecasts}
#return {"city_name": city_name, "hourly_forecasts": hourly_forecasts}
return {"hourly_forecasts": hourly_forecasts}

def format_temp(temp, temp_unit="F"):
"""
Expand All @@ -93,8 +94,8 @@ def format_hour(dt_str):
See: https://github.com/prof-rossetti/intro-to-python/blob/master/notes/python/modules/datetime.md
"""
dt = parse_datetime(dt_str)
#return dt.strftime("%I %p") #> "01 PM"
return dt.strftime("%H:%M") #> "13:00"
return dt.strftime("%I %p") #> "01 PM"
#return dt.strftime("%H:%M") #> "13:00"


if __name__ == "__main__":
Expand Down