Codecademy Forums » Python
1,246 FOLLOWERS
Welcome to the friendliest place for anyone learning to code, Codecademy Forums. Get help with anything related to Python, understand Python programming language, discuss syntax, strings, loops, functions, input-output, and more.
Codecademy Forums » Python
1M ago
Hi,
I’m doing the Basta Fazoolin project. Everything worked fine until task 16.
My code doesn’t return the correct list of the Menu objects that are available at a specific time.
I believe it has something to do with the way I defined the time_display method.
If someone can help me figure it out, I’d appreciate it.
Thanks
# Design software to handle operations for a chain of restaurants (basta_fazoolin.py)
# Define a class for the menus
class Menu:
def __init__(self, name, items, start_time, end_time):
self.name = name
self.items = items
self.start_time = start_time
self.en ..read more
Codecademy Forums » Python
1M ago
I am coding doing a lesson and when I enter this code the terminal is blank Instead of showing anything or printing anything:
weight = 1.5
if weight <= 2:
cost_ground = weight * 1.5 + 20
elif weight <= 6:
cost_ground = weight * 3 + 20
elif weight <= 10:
cost_ground = weight * 4 + 20
elif weight > 10:
cost_ground = weight * 4.75 + 20
print(“Ground Shipping”,
cost_ground)
cost_ground_premium = 125.00
print(“Ground Shipping Premium $”,
cost_ground_premium)
#Drone Shipping
if weight <= 2:
cost_drone = weight * 4.50
elif weight <= 6:
cost_drone = weight * 9
elif weight <= 10:
c ..read more
Codecademy Forums » Python
1M ago
Hi again,
Thanks for the help I have recieved here so far. I have another question today.
Reviewing the following code:
# Tasks doesn't ask for a random number, but I want to try to see it work. # import random # weight = random.randint(1.00, 50.00) # remove comment to update weight to fixed number weight = 0.5 # Ground Shipping flat_charge = 20 ground_premium_cost = 125.00 # Ground shipping price calculations: if weight <= 2: cost_ground = 1.50 * weight + flat_charge elif weight > 2 and weight <= 6: cost_ground = 3.00 * weight + flat_charge elif weight > 6 and weight <= 10: cos ..read more
Codecademy Forums » Python
1M ago
from stack import Stack
print("\nLet's play Towers of Hanoi!!")
#Create the Stacks
stacks = []
left_stack = Stack("Left")
middle_stack = Stack("Middle")
right_stack = Stack("Right")
stacks += [left_stack, middle_stack, right_stack]
num_disks = int(input("\nHow may disks do you want to play with?\n"))
while num_disks < 3:
num_disks = int(input("Enter a number greater than or equal to 3\n"))
for disk in range(num_disks, 0, -1):
left_stack.push(disk)
# left_stack.print_items()
num_optimal_moves = (2 ** num_disks) - 1
print("\nThe fastest you can solve this game is in {0} moves.".f ..read more
Codecademy Forums » Python
1M ago
I’ve been working on the Coded Correspondence Off-Platform Project and I am running into issues with the fifth challenge. I have coded the following solution to the Vigenere Decoder:
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encoded_message = 'txm srom vkda gl lzlgzr qpdb? fepb ejac! ubr imn tapludwy mhfbz cza ruxzal wg zztcgcexxch!'
decoded_message = ''
keyword = 'friends'
keyword_phrase = ''
keyword_index = 0
for character in encoded_message:
if keyword_index >= len(keyword):
keyword_index = 0
if character in alphabet:
keyword_phrase += keyword[keyword_index ..read more
Codecademy Forums » Python
1M ago
Hi,
I am new to coding and is currently working through Python.
Today I was doing the “Practice Control Flow”, and was assigned the following task:
"You are given a monthly budget and some expenses and need to check if the sum of the expenses goes over budget!
First, store the total of all expenses into a variable called total.
Next, check if the total is greater than the budget. If it is, store True into a variable called over_budget, otherwise store False in over_budget."
I answered with the following code, which seems to do the job, but i am not getting the assigment approved. Could anyon ..read more
Codecademy Forums » Python
1M ago
Hi all,
Currently working on the portfolio project of US Medical Insurance.
I’ve created a two-way table using the Pandas crosstab function:
average_cost_by_sex_and_region = pd.crosstab(index=pd_df["sex"],
columns=pd_df["region"])
average_cost_by_sex_and_region.index = ["male","female"]
average_cost_by_sex_and_region
At the moment, the values in this table are “count” values - the number of females in the Northwest, for example, and what it want it to be are the mean insurance cost for them. I’ve generated those figures here:
pd_df.groupby(["region", "sex"])["c ..read more
Codecademy Forums » Python
1M ago
I need help in coverting datatypes, when I coverting each column of the dataframe using;
salaries[‘BasePay’].astype(float)
am getting this;
ValueError: could not convert string to float: ‘Not Provided’
if i pass the the datatypes while importing the data like;
import pandas as pd
salaries=pd.read_csv(‘Salaries.csv’, dtype={‘BasePay’: float})
still getting;
ValueError: could not convert string to float: ‘Not Provided’
what should I do
3 posts - 2 participants
Read full topic ..read more
Codecademy Forums » Python
1M ago
If you have seemingly random numbers showing up on your x axis for your categorical data,
here’s how to remove those numbers.
Remove the numbers on the x axis.
ax.set(xticklabels=)
1 post - 1 participant
Read full topic ..read more
Codecademy Forums » Python
1M ago
If you want to turn off that pesky Scientific Notation on your plot / graph.
to prevent scientific notation.
plt.ticklabel_format(style=‘plain’)
1 post - 1 participant
Read full topic ..read more