+ 3
help me out with this code
x=6 y=2 print("x+y") I want 8 to be displayed on screen instead of x+y https://code.sololearn.com/c9ESG2JPI9Ll/?ref=app
35 Respostas
+ 17
print(x + y)
double quote is for string
+ 7
Brother Bot When you print anything inside quotes it becomes string.That's why it is printing x+y instead of 8. If you want 8 to be printed just print x+y
+ 6
Brother Bot In Class = x +y
Class is considered as a variable with the value containing the value of x+y i.e. 8 so now printing variable name class is going to print it's value.So it's correct. Just don't use Quotes it will consider anything inside it as a string.
+ 5
thanks
what about this?
x=6
y=2
class="x+y"
print(class)
+ 5
Never and never use a keyword for naming a variable. Use other name like num or addition
+ 5
Brother Bot That's why I have written Class as C capitals as variable. you can't use buit-in function as variable names
+ 5
A͢J I checked it with an online checker and it answered that is was human text
+ 4
Brother Bot
or:
_class = x + y
+ 3
Brother Bot that is better, yeah
+ 3
Brother Bot "x+y" and x+y is not same, bro
+ 3
Dragon RB
Don't post CHAT GPT answer.
+ 3
Remove the quotation mark Because if yoU use quotaion mark(" ") it will read it as a string so make it like this:
x = 6
y = 2
print(x+y)
+ 2
Nope, now class is the string "x+y". Get rid of those quotes and it'll work though
+ 2
Dragon RB
That is good if it is your own answer but explanation looks like that.
+ 2
x=6
y=2
sum=(x+y)
print(sum)
#bro use "sum" function for addition
+ 2
RAJ SONI😈😈
Don't give wrong answer
in your answer sum is a variable
And a inbuilt method can't be a variable
+ 1
thanks a lot Ugulberto
how do I know the list of keywords which I have to avoid while naming a variable.
+ 1
thanks I got the list of 33 keywords
+ 1
i can write it as
x=6
y=2
Class=x+y
print(Class)
+ 1
Print(x+y) is correct