[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]

Halp pls

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: 14
Thread images: 2

File: 2016-08-04.jpg (63KB, 720x720px) Image search: [Google]
2016-08-04.jpg
63KB, 720x720px
Can someone help me with my computer science ??? I have three things to do and I don't know how to do it. I will start posting the things I need but first I need a program using py that performs addition and subtraction of two numbers. I will help you with something you need in return
>>
File: 2016-08-04 (5).jpg (14KB, 249x249px) Image search: [Google]
2016-08-04 (5).jpg
14KB, 249x249px
please help asap, These are easy things to do. I just don't have how to do them.
>>
Addition and subtraction?

use a variable: number1 and number2 for example, using an input of a string to enter them, like this:

number1 = input("Input number one")
number2 = input("Now number two")

number3 = (number1) - (number2)

Exchange the - for + and you should be fine, i hope this is what you needed!
>>
The input worked but they didn't add or subtract, it says i need to use sum(). How do I do this
>>
Ah, instead of the number3 variable just do:

sum = (number1) + (number2)

same with the minus
>>
Ah my bad, the inputs need to be number1 = int(input("Input number one"))

int standing for integer as its a number, not a string!
>>
number1 = int(input("Input number one"))
number2 = int(input("Now number two"))

number3 = (number1) - (number2)

print(number3)

^ Example of working code
>>
>>224558
Okay so the addition is working but how to get subtraction too, like how to get a program in which people can choose "+" or "-" and input the 2 numbers
>>
number1 = int(input("Input number one"))
number2 = int(input("Now number two"))

addOrSubtract = input("Do you wish to add or subtract?")
if addOrSubtract == "add":
number3 = (number1) + (number2)
else:
number3 = (number1) - (number2)

print(number3)

If you want me to explain it, I can attach images with comments!
>>
Remember to press tab before number3 on both lines in the if statement to make an indent.
>>
>>224566
>>224569
It says else is invalid syntax also if u can find a way for it to be repeatable that'd be great. Thanks so much for the help. I have more I need to do after so if you really don't have anything else to do, maybe you can help again?
>>
I have work right now so sorry I can't right now, if you have the time then add my steam @Zer0Ctrl, level 28 or something - else isn't invalid, you must have not indented it properly, make sure it's in line with the if statement and the two lines beginning with number3 are 4 spaces away from that. Add me on steam and ill get back to you asap!
>>
>>224572
thank yoU!!!!
>>
Hey, same guy, you didnt add me?
Thread posts: 14
Thread images: 2


[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.