0

Which is the correct way of performing basic arithmetic operation in python. X=4 Y=2 A. print('addition'+str(x+y)) B.print(x+y)

25th Dec 2020, 3:01 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
16 odpowiedzi
+ 1
Your post is incomplete, please edit it properly. Move the code and multiple choices to the Description, where you can type more freely.
25th Dec 2020, 3:05 PM
Ipang
+ 1
print( x + y ) # basic arithmetic result print( "addition " + str( x + y ) ) # string concatenation and number to string conversion
25th Dec 2020, 3:57 PM
Ipang
0
I mean.. From the two options given below, which is the correct way of performing basic arithmetic operation in python (a or b).why? a. Print('addition'+str(x+y)) b.print(x+y)
25th Dec 2020, 3:11 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
Apart from the uppercase letter 'P' in `print` for option A (syntax error) ... It depends, whether you were instructed to print the "addition" word or not. Both does the same calculation, so the question is, do you have to print the "addition" word. Is this in relation to the courses?
25th Dec 2020, 3:16 PM
Ipang
0
Uppercase 'P' is typing mistake...it's lowercase 'p'... Here the the question is which one is basic arithmetic operation? Yes sir...this is in relation to the courses...our tutor has given this question.
25th Dec 2020, 3:22 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
Well, in that case, I'm going for option B, because printing "addition" adds some point to the sense of "basic arithmetic". It involves string concatenation and number to string conversion.
25th Dec 2020, 3:37 PM
Ipang
0
Thank you very much 😊 Looking for more support here after
25th Dec 2020, 3:41 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
No problem 👌 As future reference, please follow the below guide for posting a question. This community is helpful if we do things as expected 👍 https://www.sololearn.com/Discuss/333866/?ref=app
25th Dec 2020, 3:44 PM
Ipang
0
You mean B is correct..
25th Dec 2020, 3:45 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
I *assume* B was the right choice ...
25th Dec 2020, 3:46 PM
Ipang
0
Will you help me with giving strong reason
25th Dec 2020, 3:54 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
👍
25th Dec 2020, 3:58 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
B is the correct one.....
26th Dec 2020, 10:10 AM
Juma Chaje
Juma Chaje - avatar
0
Variable name should start with lowercase... then options B will work fine.
27th Dec 2020, 7:02 AM
Gaurav Misra
Gaurav Misra - avatar
0
Can please help me identifying python keyword.
28th Dec 2020, 2:19 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar
0
What is python keyword
28th Dec 2020, 2:25 PM
Tşhérìnģ Phűnţshøk
Tşhérìnģ Phűnţshøk - avatar