Can anybody help me with this python practice? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anybody help me with this python practice?

Here's the problem: Imagine you work for an e-commerce company, and you need to calculate the shipping cost for customer orders based on the weight of the packages they purchase. The cost per kilogram is $5. Task Complete the cost() function to take the weight as an argument, calculate the shipping cost based on the weight, and display it in the given format. The function call has already been provided. Input Expected output weight = 5 Shipping cost = 25 weight = 14 Shipping cost = 70 weight = 10 Shipping cost = 50 This is what I got so far: weight = int(input()) def shipping_cost(weight): print("Shipping cost:", weight*5) shipping_cost(5)

6th Jul 2023, 11:10 AM
Andrea Latteri
Andrea Latteri - avatar
13 Answers
+ 5
Sample Output expected is "Shipping cost = 25" But you getting "Shipping cost: 25" # got it?
6th Jul 2023, 11:37 AM
Jayakrishna 🇮🇳
+ 4
The correct answer should look like this: #taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): print("Shipping cost:", weight*5) #function call shipping_cost(weight)
23rd Jul 2023, 1:32 PM
Alina Yukhymenko
Alina Yukhymenko - avatar
+ 3
Oh... You are taking input into weight, that value you need to pass to the function, (not 5, you are passing 5 instead).. shipping_cost(weight)
6th Jul 2023, 1:57 PM
Jayakrishna 🇮🇳
+ 3
You need to add index😉 #taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): index= weight *5 print(index ) #function call shipping_cost(weight )
6th Oct 2023, 3:49 AM
Sharareh.H
Sharareh.H - avatar
+ 2
The code won't run anyway...
6th Jul 2023, 1:34 PM
Andrea Latteri
Andrea Latteri - avatar
+ 2
#taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): print(weight*5) #function call shipping_cost(weight)
30th Jul 2023, 3:26 PM
Janelyn Oliveros
+ 1
Thank u for your help
6th Jul 2023, 3:59 PM
Andrea Latteri
Andrea Latteri - avatar
+ 1
#taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): print(weight*5) #function call shipping_cost(weight) TRY THIS ONE AND GOODLUCK
12th Oct 2023, 3:08 PM
Sami Ait Ahmed
Sami Ait Ahmed - avatar
+ 1
This is the correct answer Try it #taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): index= weight *5 print(index ) #function call shipping_cost(weight)
22nd Nov 2023, 9:23 PM
Mohamed Fathy
0
Doesnt work
12th Jul 2023, 2:21 AM
ismael Feria
ismael Feria - avatar
0
weight = int(input()) def shipping_cost(weight): print( weight*5) shipping_cost(weight)
11th Jan 2024, 11:52 PM
Dennis Kalmykov
0
The code without errors be: #Taking the weight as input weight = int(input()) #complete the function def shipping_cost(weight): print( weight*5) #function call shipping_cost(weight)
13th Jan 2024, 1:03 AM
VIJAY BANGARU ABIRAM KOTANI
VIJAY BANGARU ABIRAM KOTANI - avatar
0
I FOUND IT !!!! #takes de input 5 14 etc etc etc weight = int(input()) # define the func and then add new called cost (or whatever) multiply by 5 ( as the project input asks) and then print it with the added one (cost) def shipping_cost(weight): cost = weight * 5 print(cost) #then call the function WEIGHT because te values was repleaced with the total values of the def shipping_cost() values added to WEIGHT shipping_cost(weight)
29th Feb 2024, 5:50 AM
G. Valmont
G. Valmont - avatar