Join 25,000+ aspiring Data Scientists and receive Python & Data Science tips every Tuesday!
Hi Reader,
This is a "special edition" of Tuesday Tips! π
Instead of the usual format, I'm going to pose a coding question and ask YOU to write the solution!
You can send me your solution, and I'll showcase the best solutions in next week's newsletter! π
There's a classic probability puzzle based on the TV game show "Let's Make a Deal" and named after its host, Monty Hall. Here's the puzzle:
You are a contestant on a game show. In front of you are three closed doors. Behind one of the doors is a car, and behind the other two doors are goats. Your goal is to pick the door with the car.
The host asks you to choose a door. You tell the host your choice. Instead of telling you whether your choice was correct, the host (who knows which door contains the car) opens one of the two doors you didn't choose and reveals a goat.
You now have the opportunity to keep your original choice or switch your choice to the door that is still closed. Which should you choose?
For example, let's pretend that you started by choosing door #1. The host opens door #3 to reveal that it contains a goat. Should you keep your original choice of door #1 or switch your choice to door #2?
One of the "superpowers" of being able to write code is that you can use simulations in order to solve problems like these! In this challenge, I want you to write Python code to simulate this problem.
Specifically, I want you to simulate that you are a contestant on this show 1000 times. Each time, you pick a random door as your first choice, let the host open a door that reveals a goat, and then switch your choice to the door that the host didn't open. With that strategy (known as the "always switch" strategy), how often do you win the car?
Here are a couple of details that I want to be clear about:
If you have questions about any other details, please let me know!
The goal of this challenge is to practice writing Python code to solve a problem. In other words, I don't just want to know the "answer" to this puzzle, rather I want to see the code you wrote to solve the problem!
There are two ways you can submit your code to me:
Please don't copy and paste your code into an email, send me a screenshot of your code, or send me your code as a file attachment. π
In next week's newsletter, I'll showcase the best solutions! I'm looking for code that is concise, easy-to-read, and represents the data in an elegant way.
If you used an AI tool to help you write the code, please let me know. I'm guessing that the most elegant solutions will come from humans, not AI! π€
If you enjoyed this weekβs newsletter, please forward it to a friend!Β Takes only a few seconds, and it really helps me out! π
See you next Tuesday!
- Kevin
P.S. Data structure humorβ
Did someone awesome forward you this email?Β Sign up here to receive data science tips every week!β
Kevin Markham
Join 25,000+ aspiring Data Scientists and receive Python & Data Science tips every Tuesday!
Hi Reader, I'm so excited to share this week's tip with you! It has been in my head for months, but I finally put it in writing βοΈ It's longer than usual, so if you prefer, you can read it as a blog post instead: Jupyter & IPython terminology explained π Link of the week Python Problem-Solving Bootcamp (April 1-21) Want to improve your Python skills quickly? There's no better way than solving problems, reviewing alternative solutions, and exchanging ideas with others. That's the idea behind...
Hi Reader, I just published a new blog post, Get started with conda environments. If youβre new to virtual environments in Python, give it a read! Once you start using virtual environments, youβll wonder how you ever got along without them! π Link of the week Yann LeCun on the future of AI (Lex Fridman interview) Yann LeCun is one of the βgodfathers of Deep Learningβ, the Chief AI Scientist at Meta, and (in my opinion) one of the clearest and most convincing thinkers on the future of AI. Itβs...
Hi Reader, In case you missed it, I launched a free, 7-hour pandas course! 800+ students have enrolled, and a few have already earned their certificate of completion π©π π Link of the week Data Internships Looking for an internship in Data Science or Analytics? This site curates the latest internship postings and emails them to you each week! π Tip #40: Build a DataFrame from multiple files Letβs say that your dataset is spread across multiple files, but you want to read the dataset into a...