Skip to content

cloud-lab-private/python-222

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PY-CL-WhileLoop

Overview

This project focuses on counting the total number of digits in a given number using a while loop in Python. The project consists of an implementation file for the counting function, a script to interactively demonstrate the function, and unit tests to verify its correctness.

Files

app.py

The app.py file serves as the main entry point for the project. It prompts the user to input a number and then calls the count_digits function from lab.py to count the total number of digits in that number. The result is then displayed to the user.

lab.py

The lab.py file contains the implementation of the count_digits function. This function takes a number as input and returns the total number of digits in that number using a while loop.

lab_test.py

The lab_test.py file contains unit tests for the count_digits function. It ensures that the function behaves as expected by testing it with various input cases, including positive numbers, negative numbers, zero, and large numbers.

Project Structure

  • src/
    • main/
      • app.py
      • lab.py
    • test/
      • lab_test.py

Getting Started

  • Open the src/main/app.py file.
  • Run the app.py file to interactively test the count_digits function.
  • Modify the lab.py file to handle negative numbers gracefully if needed.
  • Run the test cases in lab_test.py to verify the correctness of the count_digits function.
  • Explore additional test cases or edge cases to ensure robustness.

Conclusion

This project demonstrates how to count the total number of digits in a number using a while loop in Python. By completing the implementation and running the provided test cases, you can gain a better understanding of while loops and number manipulation in Python.

Happy Coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages