It is not. You’d get an error after the else
.
uwu = input('Come on lets go for uwu!! party! uwu!')
match uwu:
case 'uwu!':
print('OWO')
case 'UWU!':
print('Blush')
@Idkwhttph point, please.
Yesh yesh
i actually learnt how to use match and case from one of your replies
I’ll think of a challenge tomorrow, I’m going to sleep.
Oh, sorry, didn’t read the indentation.
How can I know if it’s my turn?
There is no turn.
When a player solves that puzzle, that player gets to make the nxt puzzle
each puzzle will get progressively harder
when the player makes the next puzzle and asks us to solve it
Anyone can solve it, first person to solve it gets a point. First one to 10 points wins
today = date.today()
from datetime import date
print("EVENT COUNTDOWN!\n")
event = input("Input the event: ")
year = int(input("Input the year: "))
month = int(input("Input the month (Numbers only): "))
eventDate = date(year, month, day)
day = int(input("Input the day (Numbers only): "))
print()
difference = difference.days
difference = eventDate - today
print(f"{difference} more days until {event}!")
if difference > 0:
elif difference < 0:
print(f"{event} is today!")
else:
print(f"{event} happened {abs(difference)} days ago.")
Expected output(s):
EVENT COUNTDOWN!
Input the event: birthday
Input the year: 2024
Input the month (Numbers only): 03
Input the day (Numbers only): 30305 more days until birthday!
EVENT COUNTDOWN!
Input the event: last birthday
Input the year: 2023
Input the month (Numbers only): 03
Input the day (Numbers only): 30last birthday happened 62 days ago.
No imports, remember.
Yea, standart libraries must be allowed, @bobastley.
Sorry for the confusion.
IIRC, I think I was refferring to installed modules/packages, like ones installed using pip
and npm
. Regardless, I do agree, because these are technically built-in modules they will be allowed for use.
Pretty sure this works:
from datetime import date
today = date.today()
print("EVENT COUNTDOWN!\n")
event = input("Input the event: ")
year = int(input("Input the year: "))
month = int(input("Input the month (Numbers only): "))
day = int(input("Input the day (Numbers only): "))
eventDate = date(year, month, day)
print()
difference = eventDate - today
difference = difference.days
if difference > 0:
print(f"{difference} more days until {event}!")
elif difference < 0:
print(f"{event} happened {abs(difference)} days ago.")
else:
print(f"{event} is today!")
I will think of one tomorrow, but I might forget, so ping me
You’re very close! But if I were to input a date before today, then it’d say the event is today. I guess this is a pretty big hint but yeah, that would be a logic error.
Ok, here is mine (in python):
loop = asyncio.get_running_loop()
import asyncio
def asyncStep() -> asyncio.Future:
fut.set_result(None)
return fut
async def aprint(s: str) -> str:
print(s)
fut = loop.create_future()
return s
await asyncStep()
async def main() -> None:
await aprint(s)
for s in res:
res = await asyncio.gather(*[aprint(f"Hello world #{s}!") for s in range(1, 21)])
asyncio.run(main())
Expected result:
Hello world #1!
Hello world #2!
Hello world #3!
Hello world #4!
Hello world #5!
Hello world #6!
Hello world #7!
Hello world #8!
Hello world #9!
Hello world #10!
Hello world #11!
Hello world #12!
Hello world #13!
Hello world #14!
Hello world #15!
Hello world #16!
Hello world #17!
Hello world #18!
Hello world #19!
Hello world #20!
Hello world #1!
Hello world #2!
Hello world #3!
Hello world #4!
Hello world #5!
Hello world #6!
Hello world #7!
Hello world #8!
Hello world #9!
Hello world #10!
Hello world #11!
Hello world #12!
Hello world #13!
Hello world #14!
Hello world #15!
Hello world #16!
Hello world #17!
Hello world #18!
Hello world #19!
Hello world #20!
Awesome, I don’t know the first thing about asyncio so this will be fun!
Wow that was a lot easier than I thought it would be:
import asyncio
def asyncStep() -> asyncio.Future:
loop = asyncio.get_running_loop()
fut = loop.create_future()
fut.set_result(None)
return fut
async def aprint(s: str) -> str:
await asyncStep()
print(s)
return s
async def main() -> None:
res = await asyncio.gather(*[aprint(f"Hello world #{s}!") for s in range(1, 21)])
for s in res:
await aprint(s)
asyncio.run(main())
@dragonhunter1 can you confirm?
yup! Only 1 line was different but it does not affect the output.
nice. I was thinking the same that asyncStep basically does nothing and aprint is just print with async
EDIT @dragonhunter1: true.
asyncStep basically does nothing and aprint is just print with async
asyncStep
increases the authenticity of concurrency and will be needed in some special cases. (It make the async handler move to the next task.)
Yes aprint
is just async print
Oh right, it’s my turn to come up with a challenge again… I’ll think of one in a bit.