This project focuses on handling user input and output operations in Python. It includes functions to interactively collect user input as strings, integers, and floats. Additionally, it demonstrates how to mock user input for testing purposes. The project consists of three main files: app.py, lab.py, and lab_test.py.
The app.py file serves as the main script for the project. It allows users to input their name as a string, age as an integer, and height as a float. The inputs are validated to ensure they are of the correct data type, and appropriate error messages are displayed if invalid input is provided.
The lab.py file contains the implementation of functions for collecting user input. It includes functions to collect input as strings, integers, and floats, with validation to handle incorrect input types.
The lab_test.py file contains unit tests for the functions defined in lab.py. It uses mocking to simulate user input and verifies that the functions correctly handle different input scenarios.
- src/
- main/
- app.py
- lab.py
- test/
- lab_test.py
- main/
- Open the
app.pyfile in thesrc/maindirectory. - Run the
app.pyfile to interactively collect user input. - Follow the prompts to input your name, age, and height, ensuring you provide inputs of the correct data types.
- Review the implementation of functions in
lab.pyto understand how user input is collected and validated.
- Open the
lab_test.pyfile in thesrc/test directory. - Run the
lab_test.pyfile to execute the unit tests. - Ensure that all tests pass, indicating that the implemented functions handle user input correctly.
This project provides practical examples of handling user input and output in Python. By exploring the functions in lab.py and running the tests in lab_test.py, users can learn how to collect and validate user input effectively, improving their Python programming skills.
Happy Coding!