Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
The output is 55. Since both variables are strings, the + operator performs concatenation, not arithmetic addition. In Python, "5" + "5" simply joins the two strings together, resulting in "55"
Stream, call, game, and work in even the most remote locations. Order online in minutes
The output of print(a+b) will be 55. This is because the variables a and b are defined as strings due to the quotes surrounding the numbers. When you use the + operator on two strings in Python, it performs string concatenation, which means
The answer is B. 55. Mathematical operation cannot be performed on string data type, therefore the plus operator would concatenate the stings. So that makes the answer 55
Additions of strings will lead to concatenation, so B.
guys you could be teaching some useful stuff here smh
Answer:-(B)55 a and b are two strings here so when you use + operator here then python performs string concatenation.
The answer is 55 😄 Because both a and b are strings, not numbers, so Python doesn’t add them , it just sticks them together. So writing "5" + "5" will print "55", same way "tea" + "cup" gives "teacup". So simple when you get it 😉
Enterprise grade phone system from 3CX. Cut licensing costs by 80% with no per user pricing. Easy set up, DIY admin, cut call costs and choose where to host. 3CX is the PBX of choice for 350,000 installs and counting.
concatenating strings? This is your gotcha?
United States 趨勢
- 1. GTA 6 51.2K posts
- 2. GTA VI 18.1K posts
- 3. Rockstar 47.4K posts
- 4. GTA 5 1,792 posts
- 5. Antonio Brown 4,519 posts
- 6. Nancy Pelosi 120K posts
- 7. #LOUDERTHANEVER 1,503 posts
- 8. Rockies 3,870 posts
- 9. Ozempic 16.8K posts
- 10. Paul DePodesta 1,930 posts
- 11. Justin Dean 1,307 posts
- 12. GTA 7 1,126 posts
- 13. Grand Theft Auto VI 39.9K posts
- 14. Luke Fickell N/A
- 15. Elon Musk 221K posts
- 16. Grisham 1,739 posts
- 17. $TSLA 54.4K posts
- 18. RFK Jr 28.4K posts
- 19. Oval Office 41.5K posts
- 20. Pete Fairbanks N/A
Something went wrong.
Something went wrong.