[SOLVED]How to solve coach codes in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

[SOLVED]How to solve coach codes in python?

Why won't sololearn just accept 55.0 instead of 55? And if I change it to int it will outcome other results wrong

27th Jan 2021, 9:49 AM
Sadra Shakouri
Sadra Shakouri - avatar
22 Answers
+ 12
I believe this works print(round(1.1*(40 + 5 * int(input()))))
27th Jan 2021, 11:22 AM
David Ashton
David Ashton - avatar
+ 7
Abhay Rik Wittkopp heres my code: paintn = int(input()) cost = 40 + paintn*5 tax = cost /10 price = cost + tax if int(price) != price: print(price) else: print (int(price)) and the link https://sololearn.com/coach/22/?ref=app
27th Jan 2021, 10:19 AM
Sadra Shakouri
Sadra Shakouri - avatar
+ 7
Well done Abhay Struggling with internet connectivity here. Swift may I suggest you review import math math.ceil() Round() in Python can round up or round down, but the challenge specifies rounding up, so ceil() is what you will need. PS: There are other ways to do this also
27th Jan 2021, 10:34 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 7
Abhay I think that 7 is for experimental and testing the code. If no input is given, it will use 7 instead.
27th Jan 2021, 11:05 AM
noteve
noteve - avatar
+ 6
Swift looking now
27th Jan 2021, 10:20 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 5
Swift question mentions "rounded up" to the nearest whole number. import math paintn = int(input()) cost = 40 + paintn*5 tax = cost /10 price = cost + tax print(math.ceil(price))
27th Jan 2021, 10:24 AM
Abhay
Abhay - avatar
+ 5
Abhay thanks, wow!
27th Jan 2021, 10:25 AM
Sadra Shakouri
Sadra Shakouri - avatar
+ 4
Shreyash(S&O CODERS) don't post your question under others question , Follow the guidelines , https://www.sololearn.com/Discuss/1316935/?ref=app
27th Jan 2021, 10:10 AM
Abhay
Abhay - avatar
+ 4
Abhay do you know what to do?
27th Jan 2021, 10:10 AM
Sadra Shakouri
Sadra Shakouri - avatar
+ 4
Abhay paintn = int(input() or 7) cost = 40 + paintn*5 tax = cost /10 price = cost + tax print(price) # Avoiding math.ceil() if price %1 !=0: print(price//1 +1)
27th Jan 2021, 10:54 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
wait, if i change codes that have an n.0 end to int will it work? but how should i do that
27th Jan 2021, 9:53 AM
Sadra Shakouri
Sadra Shakouri - avatar
+ 3
Shreyash(S&O CODERS) i mean the numbers that have n.0 not the ones that have a decimal value
27th Jan 2021, 9:59 AM
Sadra Shakouri
Sadra Shakouri - avatar
+ 3
Swift Your question is not clear. Can you please describe your challenge and attach your attempt. Also please specify which language you are using. Apologies: You have already specified Python
27th Jan 2021, 10:13 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
Rik Wittkopp I have done this way only and if you don't mind can you show what other ways you are talking about ?
27th Jan 2021, 10:36 AM
Abhay
Abhay - avatar
+ 3
Rik Wittkopp thank you and why do we have number 7 in input() or 7 tho .
27th Jan 2021, 11:00 AM
Abhay
Abhay - avatar
+ 3
You don't even need if and math.ceil to solve this code coach. 😉 Here's is my code brush= int(input("")) costb=brush*5 total=costb+40 tax=total/10 costt=total+tax print(round(costt)) https://www.sololearn.com/coach/22?ref=app
27th Jan 2021, 2:44 PM
Ayush Kumar
Ayush Kumar - avatar
+ 3
Abhay as Cyan has stated, 7 is a default input used if no user input. I use it for testing and for setting an example
27th Jan 2021, 6:06 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Just use PHP
28th Jan 2021, 7:24 PM
Biron Omondi
Biron Omondi - avatar
+ 1
I have no idea to how to start python
29th Jan 2021, 3:39 AM
Suchit rajbanshi
Suchit rajbanshi - avatar
+ 1
Please give me idea
29th Jan 2021, 3:40 AM
Suchit rajbanshi
Suchit rajbanshi - avatar