20 Beginner Python Projects

freeCodeCamp.org

20 Beginner Python Projects by freeCodeCamp.org

This video tutorial features 20 beginner Python projects with step-by-step instructions for building each program. The projects range from sending emails and building a calculator to performing binary searches and creating a Python quiz app. For example, to send an email, the user needs to import the necessary libraries and specify the sender, password, receiver, subject, and body. The user then creates an instance of the message library to populate these fields and use the SSL and SMTP libraries to log in and send the email. In addition, the program loops through a dictionary containing the quiz questions and answers, allowing the user to answer them and tallying their score for display at the end of the quiz.

00:00:00

In this section, Tommy shows the steps to send an email with Python. The recent security updates from Gmail require a few more steps to get through before sending an email with Python. Once going through the security process and coming into the app password center, the user selects 'other' and labels the app as 'Python.' After selecting 'generate,' the user copies the code and creates an instance of the message to specify the email account, password, sender, receiver, subject, and body. Finally, Tommy creates variables for the email sender and email password that he stores inside an app to file for security reasons.

00:05:00

In this section, the speaker explains how to send an email using Python. To start, the user needs to import the password they want to use for their email. They can then specify the email receiver, create a subject line, and write the email body. The speaker demonstrates how to create an instance of the email message library and use it to populate the fields such as the sender, receiver, subject, and body. The video shows how to create a context and use SSL and SMTP libraries to create an SMTP connection and log in to send the email. The final step is to use the previously created email message instance, convert it to a string, and pass it to the send mail function.

00:10:00

In this section, the presenter demonstrates how to send an email using Python's new method, which requires setting up two-factor authentication and generating an app password. They import the necessary libraries and define the sender, password, receiver, and subject. Once the email message is created, they use SSL and SMTP libraries to log in and send the email. The presenter also shows how to build a word replacement program using Python's replace method and a simple calculator program defining functions for addition, subtraction, multiplication, and division.

00:15:00

In this section, the video tutorial walks through building a simple calculator using Python. The program will prompt the user to input two numbers and then ask what operation the user wants to perform. The options given will be add, subtract, multiply, or divide. Depending on the user's choice, a function will be called to perform the operation. The video demonstrates how to define these functions using the example of addition, then subtraction, multiplication, and division. Each function takes two inputs, calculates the result, and then returns a string that shows the input values and the answer. The program will continue running until the user chooses to exit.

00:20:00

In this section, the speaker explains how to create a calculator using Python. They start by defining a function for each arithmetic operation with print statements for the options of the user to choose from. Once the user chooses an option, the program asks for two numbers and converts them to integers. The program then calls the correct function based on the user's choice and performs the chosen arithmetic operation with the given numbers. Finally, the result is printed. The program uses if-else statements for each arithmetic operation choice and collects input from the user accordingly.

00:25:00

In this section, we learn how to create a basic calculator using Python that allows the user to choose an operation and input two numbers to calculate. We define all the functions, show the options to the user, collect the values, and call the function. To keep looping the program until the user decides to exit, we use a while loop and add a break for spacing. Next, we move on to building an email slicer that takes a specific email and splits it into the username, domain, and extension using the "@" symbol as a delimiter. This program collects the email, splits it using "@" and saves the first part as the username, the second part as the domain, and the last part as the extension.

00:30:00

In this section, the video focuses on creating an email slicer application using Python. The email slicer application prompts the user to input their email address and splits it into a username, domain, and extension. The domain is then split into the domain name and extension. The program then prints out the username, domain name, and extension. A function called "main" is created to house the entire process of splitting an email address and printing out the username, domain name, and extension. The function utilizes "input" to receive the email address from the user and "split" to divide the email into its distinct parts. Finally, a while loop is added to allow for continuous use of the application by the user.

00:35:00

In this section, we are introduced to binary search in Python. Binary search is a searching algorithm that works by splitting a set of data in half repeatedly until the target value is found. For example, if the list is 123456789 and the target is 3, the program will split the list in half and compare 3 to the middle value. If it is less than the middle value, the program discards the second half of the list. If it is greater than the middle value, the program discards the first half. This process is repeated until the target value is found. The tutorial then goes into the coding part where we will create a function with multiple variables to perform the binary search operation using a while loop or recursion.

00:40:00

In this section, the speaker explains the process of writing a binary search function in Python. He starts by defining the variables such as the midpoint, start, and end of the list. He then goes on to create a while loop that will continue to loop through the code until the start variable is no longer less than or equal to the end variable. Inside the loop, he prints the remaining list and the number of steps taken to split it. He then updates the steps taken and calculates the midpoint of the list. Finally, he divides the list into two halves and discards one of them based on whether the target is less than, greater than, or equal to the midpoint.

00:45:00

In this section, we learn about binary search in Python, which is a simple and efficient algorithm used to search for an item in a sorted list. The implementation involves initializing a start and end point, calculating the middle element of the list, and then updating the start and end points based on whether the target value is greater than or less than the middle element. This process is repeated until the target element is found or the search has exhausted the list. The function is then tested with a sample list and target value, resulting in a successful search that only required two steps.

00:50:00

In this section, the speaker discusses how to perform a binary search in Python. They provide code examples and explain the difference between binary search and linear search in terms of time complexity. The speaker also introduces the topic of building a quiz program that will use a dictionary to store questions and answers that the user will be prompted to answer. The program will keep track of the user's score and provide a percentage at the end. The speaker outlines the steps involved in building the program, including looping through the dictionary and keeping track of the user's score.

00:55:00

In this section, the speaker explains the steps for creating a Python quiz app for beginners. The app uses a Python dictionary to store the questions and answers, with each question as a separate key and the value being a dictionary containing the question and its answer. The app then loops through this dictionary to display each question to the user, allowing them to answer and informing them if they are right or wrong. The app also tracks the user's score and displays it at the end of the quiz. Finally, the speaker demonstrates how to set up the dictionary and initialize the score variable.

01:00:00

In this section, the video tutorial is demonstrating a Python code that allows users to take a quiz with a dictionary. The initial score is set to zero, and the code loops through the dictionary using the key and the values. The value of each question is printed, and the user is prompted to input their answer and check if it’s correct using a dot lower function to convert the answer to lowercase. The user score is increased by one if the answer is correct, and the final score and percentage are displayed at the end. The video also shows how to add spacing to make the code more readable.

01:05:00

In this section, the video tutorial shows how to create a basic quiz program in Python. The program starts by asking seven questions and then shows the percentage of correct answers. The code converts the score into a percentage by dividing it by seven and multiplying it by 100, then adds the percent symbol. The tutorial also covers how to create a function that converts a text or link into a QR code using Python by installing the necessary libraries, creating a function to generate a QR code, and saving the QR code as an image. The tutorial provides step-by-step instructions for installing libraries and importing necessary modules.

01:10:00

In this section, the video tutorial demonstrates how to build a QR code generator with Python. The code generates a QR code and prompts the user to input a URL, which will be incorporated into the QR code. The tutorial also shows how to create a basic user interface by allowing users to input their own URLs to generate different QR codes. Furthermore, the tutorial explains how to save the generated QR code as a PNG image on the computer. The tutorial encourages users to think creatively about how they can use QR code generators to improve their websites or automate certain tasks for their users.

01:15:00

In this section, the instructor explains how to create a monthly payment loan calculator in Python. First, create a main function that prints out a message to indicate that the program is a monthly payment loan calculator. Following that, receive input from the user for the principal amount as a float, APR as a float, and the number of years as an integer. Then, calculate the monthly interest rate, amount of months, and monthly payment using mathematical formulas. Finally, display the monthly payment to the user as a concatenated string.

01:20:00

In this section, the video demonstrates how to create a basic interest rate calculator and a random password generator in Python. For the interest rate calculator, the code takes in user inputs for the loan amount, interest rate, and term, calculates the monthly payment using a formula, and prints the result to the user. The video also shows how to make the output more presentable by formatting it to two decimal points. For the random password generator, the code uses the string and random modules to generate a password from a list of characters that includes ASCII letters, digits, and symbols. The program prompts the user for the desired password length and then prints the result to the console.

01:25:00

In this section, the speaker demonstrates how to build a password generator using Python. The user inputs the desired length of the password, and the program generates a random password composed of shuffled characters. The program prompts the user to specify yes or no to generate the password, and if the user opts out, the program will end. If the user inputs an invalid response, the program will output an error message and exit.

01:30:00

In this section of the video, the creator demonstrates how to create a simple password generator using Python. The code prompts the user to input whether they want to generate a password and how long they want the password to be. If the user inputs "yes", the program generates a random password based on the user's desired length and prints it out. The creator also shows how this code can be integrated into a web application for user registration purposes. Additionally, the video goes on to explain how to create a dice rolling simulator program using Python, which prompts the user to roll a virtual dice and generates a simulated roll with accompanying dice drawings. Both projects utilize the "random" import in Python to generate randomized outcomes for the user.

01:35:00

In this section, the tutorial teaches how to build a site connectivity checker in Python. The checker takes a URL or link and checks if the site is up and running by giving a response of 200 if everything is in order, or other responses if there is an error. The tutorial imports the urllib library and defines a function that takes the URL, checks its response, and prints either "Site is up and running" or "Error". The function is then called with a test URL to demonstrate its functionality.

01:40:00

In this section, the video tutorial covers the steps to create a site connectivity program using Python. The tutorial makes use of the URL lib library and its request module to get the data from the input URL. To begin with, we need to write a function that takes a URL and returns a response. The function to be created is called main and it collects the URL from the input by prompting the user to enter the URL. The entered URL is then stored in the URL variable which is then printed. Once the URL is obtained, we open it using the URL 'open' function and store the response in a response variable. Finally, the response status code is displayed using the 'get code' function.

01:45:00

In this section, the speaker explains the concept of Python looking up, not down, when calling functions. This means that if a function is called below its definition, it will not be recognized by Python. To fix this, the function needs to be defined above where it is called. The speaker demonstrates this through a site connectivity checker program. They also introduce a currency converter program, where the main function collects the amount of US dollars to be converted, runs a lambda function that converts it to Great Britain's pounds, and displays the result to the user. The program is easy and straightforward, using the evaluate function and lambda functions to perform the currency conversion.

01:50:00

In this section, the video tutorial showcases how to create a basic currency converter using Python. The presenter creates a new function called 'convert to pounds' that takes a dollar amount as input and converts it to pounds with the current exchange rate of 0.82 pounds sterling per dollar. The tutorial also explains how to build a simple program to determine if a particular year is a leap year or not, which involves using a new function called 'is leap year' that checks if a given year is divisible by 4, 100, and 400. The program prints 'leap year' if the year meets those conditions and 'not leap year' otherwise.

01:55:00

In this section, the tutorial shows how to build a simple word dictionary using Python. This program uses a Python dictionary to store a key-value pair that represents a word and its definition. Users can input a word, and the program will check if it is in the dictionary and print its definition. The tutorial walks through how to collect input from the user, how to check if the word is in the dictionary, and how to print the word definition. The tutorial also includes a while loop to allow users to keep asking for a word until they want to exit the program.

02:00:00

In this section, the video tutorial teaches the viewer how to create a word dictionary using a Python library named pi dictionary. The instructor explains that rather than manually inputting all the words and their definitions into the program, users can install this library on their computer, which has vast amounts of text data, synonyms, and definitions for words ready for use. The instructor shows the viewer how to import the pi dictionary module and define an instance of it. The user can then input a word and receive its definition using the "print dictionary.meaning of word" command. The instructor also adds a while loop that continues to prompt users to input words until they input a blank line, at which point the program exits.

02:05:00

In this section, the video tutorial demonstrates how to build a simple word dictionary in Python using the PyDictionary library. The library allows users to input a word and receive its meanings in a dictionary format that can be easily utilized in code. The tutorial shows how to input multiple words and receive their respective meanings using the library. The video then moves on to building a simple game of rock-paper-scissors using Python and the random library. The tutorial demonstrates how to create a while loop that allows the user to play the game repeatedly until they enter "exit", which will end the game. Overall, this section covers basic Python concepts such as loops, libraries, and data structures.

02:10:00

In this section of the video, the instructor explains the basic logic behind building a rock-paper-scissors game in Python. They start by asking the user for an input and checking for different possibilities, such as if the user inputs rock and the computer also inputs rock, resulting in a tie. If the computer wins, the program adds one point to the computer's total score. The instructor then goes through the same process for paper and scissors inputs, checking for different possibilities and adjusting the scores accordingly. Finally, they emphasize the importance of increasing a player's score when they win and not increasing scores in the event of a tie.

02:15:00

In this section of the video, the presenter demonstrates how to build a simple Rock, Paper, Scissors game using Python. The program includes logic to determine the winner of each round, keep track of the user's score, and print the final score when the user chooses to exit the game. The presenter also shows how to handle input validation to ensure the user enters a valid choice and convert integer scores to strings for concatenation. Lastly, he introduces the concept of face detection and explains that the user needs to have OpenCV installed to build their own face detection program.

02:20:00

In this section, the YouTuber explains how to create a face detection program using OpenCV and Python. To start, the user needs to install OpenCV and download the OpenCV XML file for face detection. They also need an image to detect faces from; this image can be obtained from a website or the user's personal files. With these files, the user can open a blank Python file and begin coding. The first step is to import OpenCV and load the cascade. Once the cascade is loaded, the image can be imported and converted to grayscale. The next step is to detect faces using the face cascade. Finally, the program uses a for-loop to draw a rectangle around each detected face.

02:25:00

In this section, the video introduces how to build a simple face detection program using Python. The program makes use of the OpenCV library, which is an open-source computer vision and machine learning software library, to detect faces in an image and draw a rectangle around them. The video then moves on to another project, which involves creating a Python program that sends good morning text messages to a given mobile number at a designated time every day. This project requires the use of two Python libraries, textbelt, and schedule, both of which are easily installable with pip. The textbelt library is used to send the text messages, while the schedule library is used to schedule the time at which the message should be sent.

02:30:00

In this section, the video tutorial demonstrates how to use Python and the Textbelt API to schedule automated messages to be sent to a specific phone number. The key credentials needed for Textbelt API to send messages, including the phone number, the message and the key are specified. The tutorial also shows how to import the necessary libraries, requests, schedule, and time, and create the function that defines sending messages. The tutorial then explains how to use the schedule library to set up the time, and the frequency of sending messages, in this case, every day at 6 am.

02:35:00

In this section, the YouTuber demonstrates how to schedule a task using Python's schedule library and the Textbelt API, which allows for sending SMS messages. They import the necessary libraries, write the function that sends the SMS message using the Textbelt API, and schedule the function to run every 10 seconds using the while loop and time.sleep(). They also note that there are other libraries, such as Twilio, that can be used instead of Textbelt. The next section of the video discusses web scraping with Python and how to extract data from a website using BeautifulSoup and requests libraries.

02:40:00

In this section of the video, the instructor demonstrates how to perform web scraping using Python libraries requests and Beautiful Soup. The first step is to send a request from the code to the desired URL and receive a response containing the data needed. Once the libraries are installed, requests is used to send the request while Beautiful Soup is used to extract the required data. The instructor then shows how to inspect the HTML code of the data needed to determine which HTML tag the data belongs to, and how to use Beautiful Soup's find() function to retrieve the data. Ultimately, the instructor shows how to extract only the text from the HTML code using the get_text() method.

02:45:00

In this section of the video, the presenter demonstrates how to extract text from HTML using Python. They explain that if multiple sections of text are within the same tag, using `.get_text` function will return all the text within that tag. To extract individual pieces of text, the presenter demonstrates using a for loop to iterate through each tag and only extract the specific text within it. The presenter also demonstrates how to use Python's Pillow library to resize an image by following a few simple steps, such as installing Pillow, importing the necessary functions, and specifying the desired size for the image. The resulting code is straightforward and easy to follow.

02:50:00

In this section, the instructor guides the viewer through a tutorial on how to resize an image using Python. The code is broken down step by step, with the viewer being shown how to open the image and print its current size before resizing it to a specified dimension. The viewer is then shown how to save the newly resized image with a new filename. Additionally, the instructor demonstrates how this code can be used to build a web application where users can upload images and choose the size they want, creating a link to the newly resized image. Finally, the instructor wraps up by showing the viewer how to put the code into a function with two parameters for pixel dimensions.

02:55:00

In this section, the tutorial demonstrates how to resize an image using Python, making the process interactive by prompting the user to input the desired dimensions. The program utilizes the Pillow library to access and adjust the image. Additionally, the tutorial provides an introduction to drawing charts or graphs using the matplotlib library. It demonstrates how to import the library, define coordinates for the x and y-axis, plot the points, and label the axes accordingly.

03:00:00

In this section, the instructor demonstrates how to create a graph using Python's Matplotlib library. By specifying the x and y coordinates, the graph can easily be plotted using the PLT.plot() function and displayed using PLT.show(). The instructor also shows how to add more points and customize the graph, including adding different colored lines with labels and using PLT.legend() to indicate what each line represents. The resulting graph can even be saved for later use. Overall, the process is simple and straightforward and can be used to create various graphs for different applications.

03:05:00

In this section, the instructor demonstrates how to customize a graph using Python's Matplotlib library and draw a bar chart. They remove unnecessary elements from the graph and add customizations such as line style, marker size, and color. Then, they show how to draw a bar chart by specifying the heights and left coordinates of the bars and adding labels using tick label. Finally, they plot the bar chart and customize it with a width of 0.8 and color scheme of blue and orange.

03:10:00

In this section, the speaker demonstrates how to create a basic bar chart using the Python library, Matplotlib. With easy-to-follow code, they illustrate how to input data, add labels to the x and y axes, and customize the chart title. The final result is a clean and visually appealing bar chart that can be generated automatically by inputting data into the code. The speaker notes that other types of charts such as scatter graphs and pie charts can also be created using this library, and encourages users to explore its full functionality.

More from
freeCodeCamp.org

No videos found.

Related Videos

No related videos found.

Trending
AI Music

No music found.