computer-science

Sum w/o Smallest Values w/o using sum() or min()

Sum w/o Smallest Values w/o using sum() or min() Question: I have the problem: Write a function def sum_without_smallest(values) that computes the sum of a list of values, except for the smallest one, in a single loop, without using the sum() function nor the min() function. I am struggling to understand how to do this. …

Total answers: 3

Remove Minimum number from a list without min() or pop()

Remove Minimum number from a list without min() or pop() Question: My problem is: Write a function def remove_minimum(values) that returns the list resulting from removing the minimum value from a given list without using the min() function nor the pop() function. Do not print the list. I have a code that sorts and reverses …

Total answers: 4

List Comprehension Format for Dictionaries

List Comprehension Format for Dictionaries Question: I have a dictionary that has three categories for my customers, and there are multiple customers under each category: ddd = {‘category 1:’: {‘A’: 50.5, ‘B’: 28.9, ‘C’: 46.3, ‘D’: 513.8}, ‘category 2:’: {‘E’: 20.5, ‘C’: 48.1}, ‘category 3:’: {‘D’: 28.2, ‘F’: 68.3}} The number in each sub-dictionary represents …

Total answers: 1

GPA Calculator troubles

GPA Calculator troubles Question: For some reason that is unknown to me, my GPA calculator only calculates the last input in the list, I only have 2 days left to complete this and hopefully i can in time. I tried to make it to where it calculates every input nd not just the last one, …

Total answers: 3

How do I create a magic square matrix using python

How do I create a magic square matrix using python Question: A basket is given to you in the shape of a matrix. If the size of the matrix is N x N then the range of number of eggs you can put in each slot of the basket is 1 to N2 . You …

Total answers: 2

Why does my Python binary search algorithm not work for certain items?

Why does my Python binary search algorithm not work for certain items? Question: My binary search algorithm manages to find some items but does not find others: myList = [1,3,4,7,12,13,14,16,19,20,28,29,40,45,48,50,67,89,91,94] item = 67 found = False lowerBound = 0 upperBound = len(myList) – 1 index = 0 while not found and lowerBound != upperBound: index …

Total answers: 2

How to get solution path from greedy algorithm?

How to get solution path from greedy algorithm? Question: I have greedy algoithm with job scheduling problem, but I want to return which one projects were chosen to get this max value, how can I do that? from dataclasses import dataclass from datetime import date @dataclass class InvestmentProject: profit: int begin_date: date end_date: date def …

Total answers: 1

How to print a string based on user input of height and width

How to print a string based on user input of height and width Question: I’m sure this is a simple question, but my professor is terrible at explaining things and since I’m new to computer science I need help!! The assignment is to make a function that prints/returns a string given by the user in …

Total answers: 3