[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

python help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 6
Thread images: 1

File: code.jpg (24KB, 646x139px) Image search: [Google]
code.jpg
24KB, 646x139px
I'm trying to learn python and am having trouble writing this program. I every time I try to run it I get a syntax error.

What am i doing wrong

pic related
>>
>>18007568
I don't know python, but where do you declare the 'cake' variable? Because you have 'cakes' and no 'cake'.
>>
>>18007568
Should be cake = int(... etc. not cakes
>>
>>18007576
>>18007611
this
>>
>>18007568
>learns python over a real language like c#
>expects us to not think you are a cuck
>>
You didn't defy "cake" as a variable, only "cakes". You're getting a syntax error because the interpreter doesn't know what "cake" is.
You're also writing the ranges wrong. You need to delete the "and" and replace it with your input variable ... if (number) (<, <= , > , =>) "cake" (<, <=, >, =>): then enter your print() message below

You have to start with "if", because you have three outcomes that can come from user input in your program. This would be the correct program.

cake= int(input("how many cakes do we have?" ))
if 15 <= cake <= 20:
print("whos there, that's way too many cakes!")
if 5 <= cake < 15:
print("Okay, that's probably enough cakes.")
if 0 <= cake < 5:
print("I think we're going to need to get some more cakes.")
Thread posts: 6
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.