cs50

My CS50AI Minesweeper code causes my PC to run out of resources

My CS50AI Minesweeper code causes my PC to run out of resources Question: import itertools import random class Minesweeper(): """ Minesweeper game representation """ def __init__(self, height=8, width=8, mines=8): # Set initial width, height, and number of mines self.height = height self.width = width self.mines = set() # Initialize an empty field with no mines …

Total answers: 1

Nutrition problem – I don't undestand why my dict does not work

Nutrition problem – I don't undestand why my dict does not work Question: I’m trying to solve de nutrition problem in CS50 python course and I defined my dictionary as follows: fruits = [{"Name": "Apple", "Calories": "130"}, {"Name": "Avocado", "Calories": "50"}, {"Name": "Banana", "Calories": "110"}, {"Name": "Cantaloupe", "Calories": "50"}, {"Name": "Grapefruit", "Calories": "60"}, {"Name": "Grapes", …

Total answers: 2

Debugging with the right number of command-line arguments

Debugging with the right number of command-line arguments Question: I want to debug my code that check for a certain number of command-line arguments; but when I hit step over it goes straight to another condition where the command line arguments are fewer. How do I debug my code when I have the right number …

Total answers: 1

pset1 meal time but check fails

pset1 meal time but check fails Question: The problem require to convert user’s input to time and print meal time (i.e lunch time, dinner time e.t.c) When I test my code with the time provided in the problem I get the expected output. Sadly, when I run check it fails. Here is my code def …

Total answers: 1

Why does my assignment for CS50 Problem Set 3 fail only on one parameter?

Why does my assignment for CS50 Problem Set 3 fail only on one parameter? Question: In CS50’s Python Problem Set 3, Fuel Gauge, my code passes all the tests except one. According to the feedback, "2/3" returns "66%n", which is incorrect. When I run the script, it returns "66%" without the "n" or a new …

Total answers: 1

CS50 taqueria task – input of eof halts program

CS50 taqueria task – input of eof halts program Question: I am trying to solve the taqueria task for the Harvard CS50 python course. It generally works, but check50 spits out the following: 🙁 input of EOF halts program Cause expected exit code 0, not 1 This is my code: menu = { "Baja Taco": …

Total answers: 2

CS50P Introduction to Programming. Problem Set 4 Problem "Little Professor"

CS50P Introduction to Programming. Problem Set 4 Problem "Little Professor" Question: I am trying to get my program to pass the automated test "Little Professor generates 10 problems before exiting" but I keep gettin the error "Cause: timed out while waiting for program to exit". I have checked that the program handles edge cases, non-integer …

Total answers: 1

Using try after except is not working on Python

Using try after except is not working on Python Question: I’m doing exercise 4 on CS50P "outdated" and after trying to make the code work with if/else statements I came across a solution that used try/except for dealing with cases instead of if/else. In the following code I don’t understand why the second except gets …

Total answers: 1

Can anyone help me understand how value is assigned to Dictionary in python?

How is the value assigned to Dictionary? Question: This is a very simple problem where it reads file from a CSV with first column header as "title" and then counts how many times the title appears in side the dictionary. But I am not understanding in which step it is assigning the "title" to "titles" …

Total answers: 2

Can not assign value to a variable

Can not assign value to a variable Question: def simulate_tournament(teams): """Simulate a tournament. Return name of winning team.""" # If only one team left if len(teams) == 1: # Assigns the only element of type dictionary of the list to a variable winner = teams[0] # Gets value of the firs key(name a team) i …

Total answers: 1