Python-Module-4 Assignment
This repository contains my solutions for the Module 3 programming assignments. This module focuses on the use of while loops, conditional statements, and mathematical simulations.
-
Divisible by Three: A program that prints all numbers divisible by three in the range of 1-1000 using a
whileloop. - Inches to Centimeters: A converter that continues to transform inches to centimeters until the user enters a negative value.
- Smallest and Largest Number: Collects numbers from the user until an empty string is entered, then identifies the minimum and maximum values.
- Number Guessing Game: A game where the computer selects a random number between 1-10, and the user guesses until they find it, receiving "Too high" or "Too low" feedback.
- Login Simulation: A secure login system that allows up to five attempts for a specific username and password.
-
Pi Approximation (Monte Carlo Method): An algorithm that estimates the value of
$\pi$ by generating random points inside a square and checking if they fall within a unit circle using awhileloop.
- Infinite Loops & Break Statements: Used in the conversion and login programs to handle user-driven exits.
-
Randomness: Utilizing the
randomlibrary for both the guessing game and the$\pi$ estimation. - Input Validation: Handling empty strings and specific credentials.
-
Mathematical Approximations: Implementing the geometric probability formula:
$$\pi \approx 4 \times \frac{n}{N}$$ where$n$ is points inside the circle and$N$ is total points.