Project Level 2: Intermediate
This project is designed for intermediate learners who know Python fundamentals and are practicing building complete programs.
Project Description
In a previous beginner project, we created a program that picks a random name out of a long list of names in a text file. Today, your task is to create a similar but more complex program.
(1) The program starts by showing the user a menu. (2) The user enters a number (e.g., 2 to add a new name to the text file) and then proceeds with the instructions (e.g., adding a name such as Wimbly). (3) The program adds that new name to the names.txt file and then shows the menu again. In addition to adding new names, the user can also display the total number of names, and select a random name from the text file.
Learning Benefits
his project provides a more comprehensive look at working with file handling in Python. By implementing a menu and multiple functionalities, students gain experience with designing user-friendly command-line interfaces, modifying files dynamically, and working with lists and loops.
Prerequisites
Required Libraries: random
No need to install any library since random is a standard library.
Required Files: Download the text file in this link.
IDE: You can use any IDE on your computer to code the project.
Danger Zone
Once you code the project, compare it with our solution below: