Python Journey Day 1: Variables, Functions, and Modules

Day 1️⃣ of my Python Journey 100 Days, 100 Projects Day 1️⃣ Topic: Working with Variables, Input, String Formatting (f-strings), and the datetime module. Before I started the Day 1 task, the course included a Python crash course video to help refresh previously learned concepts. This section served as a quick revision of the fundamentals such as variables, loops, conditionals, and the basic structure of Python programs. Going through this video helped reinforce my understanding and prepared me for the projects to be made. During this revision, I also learned about functions, which was something I didn’t previously have much prior knowledge about💔. Functions allow you to create your own reusable commands so that instead of repeating the same block of code multiple times, you can organize it into a function and call it whenever needed. I also learned that variables inside functions are known as parameters, which allow the function to accept and work with different inputs. After learning about functions, I built a small mini-project (first picture in the collage): a number guessing game. In this project, I worked with Python’s random library, specifically the randint() function, which generates a random number within a given range. The program randomly selects a number between 1 and 10, and the user is given three attempts to guess the correct number. This project helped me understand how libraries can extend Python’s functionality and how randomness can be introduced into a program. It also allowed me to combine conditional statements, loops, and user input to create a simple interactive program. I then moved on to the Day 1 main project (second picture in the collage), which was to create a simple program that welcomes a user. The program was created in the thonny IDE, because of network issues using the Google Collab website. The program asks the user for their name and favorite color using the input() function. I used f-strings to dynamically format the output so the response would be more readable and personalized. I also used title case formatting to ensure that the user’s name appears properly formatted, there are other case formatting styles like upper and lower, but since it is a sentence, I added the title case for more grammatical accuracy. To add more functionality, I imported the datetime module, which allowed the program to display the exact date and time when the user entered their information. This showed how Python programs can interact with system data to provide more context. Even though today’s project was simple, it helped me combine several concepts: functions, parameters, libraries, randomness using randint(), user input, string formatting, and modules. Looking forward to learning more and building bigger projects as the challenge continues. #Python #DataScience #100Projects #100Days0fCode #TechJourney #StudentGrowth

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories