+ 2

What is the output of this code? >>> spam = "7" >>> spam = spam + "0" >>> eggs = int(spam) + 3 >>> print(float(eggs))

What is the output of this code? >>> spam = "7" >>> spam = spam + "0" >>> eggs = int(spam) + 3 >>> print(float(eggs))

4th Sep 2017, 4:32 PM
haroon
haroon - avatar
11 odpowiedzi
+ 12
spam contains "7" concatenated with "0", which is "70". eggs contain "70" casted to integer and added with 3, which is 73. eggs is casted to float and printed. Outputs 73.0
4th Sep 2017, 4:39 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
It's a string, concatenated to another. Then converted to a number? ... hmm, 73.0 I'd wager.
4th Sep 2017, 4:38 PM
ghostwalker13
ghostwalker13 - avatar
+ 1
73.0
4th Sep 2017, 4:38 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
73.0
21st Aug 2020, 4:36 PM
thida soe
thida soe - avatar
0
73.0
4th Dec 2020, 5:23 AM
Sonu Kumar Yadav
Sonu Kumar Yadav - avatar
0
73.0
7th Nov 2022, 6:20 PM
Ajayi Olumide A
0
output is: 73.0
23rd Dec 2022, 5:21 PM
Engr.Ayesha Liaqat
Engr.Ayesha Liaqat - avatar
0
spam = "7" spam = spam + "0" eggs = int(spam) + 3 print(float(eggs))
31st Jan 2023, 10:09 PM
esmael yasin
esmael yasin - avatar
0
3 41 Comments What's the output of this code if the user enters '42' as input: age = int(input()) print(age+8)
31st Jan 2023, 10:11 PM
esmael yasin
esmael yasin - avatar
0
3 41 Comments What's the output of this code if the user enters '42' as input: age = int(input()) print(age+8)
31st Jan 2023, 10:12 PM
esmael yasin
esmael yasin - avatar
0
3 41 Comments What's the output of this code if the user enters '42' as input: age = int(input()) print(age+8)
31st Jan 2023, 10:13 PM
esmael yasin
esmael yasin - avatar