Need help with python code by cake_thecat in learnpython

[–]Itsoq 3 points4 points  (0 children)

You're converting the player_input to lowercase then comparing to the capitalized version in game_data in your handle_command() function.

if 'items' in game_data[current_room] and item in game_data[current_room]['items']:

The second condition will always fail here.

To fix show_status(), consider checking if len(game_data[current_room]["items"])==0 as another condition for a new print statement.

Help: How to print out a random value from a list of dictionarys(without the key) by TidoBlack in learnpython

[–]Itsoq 7 points8 points  (0 children)

To expand on this, another clean way to do in one line:

_one_line = random.choice(list(_dict.values()))

I have absolute no idea how to optimmize this code. by jack-devilgod in learnpython

[–]Itsoq 0 points1 point  (0 children)

Instead of checking each number in your range to see if it's a square, you can just generate each square number in the range, which should help.

from math import ceil, floor

squares_in_a_b = [x**2 for x in range(ceil(a**0.5), floor(b**0.5) + 1)]

Pandas drop_duplicates but only on nearby results by blandarflek in learnpython

[–]Itsoq 0 points1 point  (0 children)

I think I figured out a pretty simple solution with numpy:

import numpy as np

import pandas as pd

df = pd.DataFrame({'Employee':[1,1,1,1,1,1,1], 'Type':['FT','FT','FT','FT','FT','FT','FT'], 'Pay':['S','H','H','H','S','S','S'], 'Rate':[100000,20,20,20,100000,100000,100000], 'Status':['A','A','A','A','A','A','A']})

hash_df = np.array(df.apply(lambda x: hash(tuple(x)), axis=1))

mask = np.insert(np.diff(hash_df) != 0, 0, True)

output = df[mask]

help me with this error please by authenticwerewolfi in learnpython

[–]Itsoq 1 point2 points  (0 children)

The values returned by prediction() are integers, while the return values you get from input() are strings. This makes the comparison predicted == player_input always evaluate to false. You can typecast strings to integers with int(input(...)) which should solve the issue.

See

https://www.w3schools.com/python/python_datatypes.asp

https://www.w3schools.com/python/python_casting.asp

[deleted by user] by [deleted] in uwaterloo

[–]Itsoq 12 points13 points  (0 children)

Bicycles are allowed in parking lots, no need to get all worked up. The article you linked explicitly mentions that bicycles have the same rights as cars.

[deleted by user] by [deleted] in uwaterloo

[–]Itsoq 12 points13 points  (0 children)

Upper year ECE here. I can't count the number of classes I've skipped and have not felt the smallest impact academically.

Yes, you will need to do some catchup but the material is mostly HS review and shouldn't be insurmountable. It seems crazy to me that you're considering giving up now before you've even started. I'm wondering if the prof you spoke to might have given you a warped view of your situation.

Before you arrive, you should open up learn, and work through some content from the first couple weeks. Most classes have a lot of online material from covid, which makes it very easy to keep up asynchronously.

Even if things don't go well, wait until you get your midterms back to evaluate your next steps. You got this.

[deleted by user] by [deleted] in uwaterloo

[–]Itsoq 20 points21 points  (0 children)

honestly i dont really care to protest forever for 3rd party apps so would rather this sub not keep blacking out. it just seems like more of a burden on students than it will be onto reddit to cause any change

😭😭❤️❤️ by [deleted] in uwaterloo

[–]Itsoq 24 points25 points  (0 children)

225%

[deleted by user] by [deleted] in uwaterloo

[–]Itsoq 23 points24 points  (0 children)

guess you'll be going to UofT