Coding Computing Coach
@CodingComputing
Making Python simple for you, by exploring the fundamentals. Tips and explanations to become code-literate in this AI age. Building @PythonResources
You might like
🚨 Python Testing Series 🚨 Employ testing to gamify your coding. Learn how to test code using pytest. Build a Cash Dispenser project in Test Driven style. Ongoing series of posts, see README at: github.com/CodingComputin…
Answer: A. 17 Solution: We have to evaluate 2 ** 3 + 3 ** 2 `**` is the exponential operator. It has higher precedence than `+`. Therefore, `**`s get evaluated first, like so (2**3) + (3**2) This is the sum of cube of 2 (=8) and square of 3 (=9) ie, 8 + 9 = 17 That's the ans.
🤔🚀 Comment your answers below! 👇
Being a developer is strange: you’re constantly learning, yet constantly feeling like you know nothing.
Switching between "I've no idea why this breaks" to "I figured it out!" is insane
Arithmetic operations on Bools?
Answer: B. False Solution: Let's go checking the if-condition, which is (3>2) > 1 Now remember that no matter what, attack the parenthesis first. So we solve (3>2), ie, True Expression simplifies to True > 1 It's a bit of a fix now. Because how to compare a bool with int? +
🤔🚀 Comment your answers below! 👇
Do list comprehensions make your head spin? Worry not, this thread has you covered.
Answer: C. [8, 12] Solution: a and b are lists. Then there is a list comprehension that gives c. Let's analyze the list comprehension. Here is the trick to analyze list comps: 🗝️ Look for 3 things: `for`, `in`, and `if` (`if` is optional, sometimes it may not be there) +
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python doesn't read your mind (or your strings)
Answer: B. 55 Solution: See the data types! a and b are both strings, with the value "5". So, python treats them as characters, not numbers. Now, for string operands, the `+` operator joins them. So, a+b joins the strings '5' and '5', to '55'. Hence, 55 is printed.
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Tuples are immutable, so some methods just don't make sense for tuples.
Answer: D. Error Solution: (5, 10, 20) is a tuple. Tuples have no `insert` method, hence it's an Error. More generally, tuples are immutable. For a tuple once formed, you cannot modify it. So, an insert method cannot exist for tuple anyway.
Comment below the output! 😃👇
Users are really innovative when it comes to breaking software.
Convert strings to integer
Answer: C Solution: x is an int, and y is a string. The call to `int(y)` obtains the integer value from y (string "5") ie the integer 5. Thus, int(y) is integer 5. x is also integer 5. The printed value is their sum, ie 10. int is a handy function for converting to integer.
Comment below the output! 😃👇
It says what you want to hear.
“oh you are absolutely right, I see the problem now” chatgpt you didn’t see sh!t 😭
Some python methods do their work but give None
Answer: A Solution: Essentially we are calling func and printing it's return value. So let's work out what func is doing. lst, lst2 = [7], [7] is a tuple assignement lst is assigned [7], and lst2 is assigned [7] lst3 = lst *2 repeats lst twice, ie, [7, 7], assigns to lst3 +
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
United States Trends
- 1. Jarry 7,040 posts
- 2. Skinner 7,960 posts
- 3. The Plasma 32.3K posts
- 4. #FanCashDropPromotion 1,811 posts
- 5. Edmonton 5,522 posts
- 6. Smear the Queer 3,541 posts
- 7. Oilers 6,872 posts
- 8. FINALLY DID IT 500K posts
- 9. Kulak 8,543 posts
- 10. #FursuitFriday 13.6K posts
- 11. Dubas N/A
- 12. Woody Allen 2,787 posts
- 13. #TSTheEndOfAnEra 4,608 posts
- 14. #NXXT_PPA N/A
- 15. The WET 90.6K posts
- 16. Good Friday 67.6K posts
- 17. #FridayVibes 5,500 posts
- 18. Tina Peters 113K posts
- 19. Our Lady of Guadalupe 18.7K posts
- 20. Murashov N/A
You might like
-
Tom Mitchell
@imtommitchell -
tom ッ
@tom_antok -
Benjamin Bennett Alexander
@RealBenjizo -
Python Coding
@clcoding -
Akshay 🚀
@akshay_pachaar -
IA Revolução
@IArevolucao -
Raul Junco
@RaulJuncoV -
Mike Driscoll
@driscollis -
Professor the Hunter
@bughuntar -
Afiz ⚡️
@itsafiz -
Data Science Tutorials
@DataSciencetut -
Python Developer
@Python_Dv -
Pau Labarta Bajo
@paulabartabajo_ -
Security Trybe
@SecurityTrybe -
Python Programming
@PythonPr
Something went wrong.
Something went wrong.