Skip to content

Python foundations repository of small console programs and turtle graphics; covers user input, functions, control flow, exceptions, randomness, menu-driven calculators, mini-programs, and simple beginner games.

Notifications You must be signed in to change notification settings

r-siddiq/Python-Foundations

Repository files navigation

Python Foundations

This repository contains a series of introductory Python programs, serving as a portfolio of my fundamental programming skills. The assignments were completed for an introductory computer science course and demonstrate an understanding of core concepts such as variables, data types, conditional logic, loops, functions, and user interaction.


Inputs, Conditionals, and Calculators

This set of programs focuses on taking user input, performing calculations, and using conditional statements (if, elif, else) to control the program's flow.

  • Problem 1: Driver's License Eligibility
    • Description: A program that checks a user's age to determine if they are eligible for a driver's license. It handles valid age ranges and outputs a specific message for each condition.
  • Problem 2: Number Comparison
    • Description: Compares two numbers entered by the user and identifies which one is greater, less than, or if they are equal.
  • Problem 3: Grade Calculator
    • Description: Calculates the average of five scores entered by the user and assigns a letter grade (A, B, C, D, or F) based on the average.
  • Problem 4: Time Converter
    • Description: Converts the number of days in a selected month into hours, minutes, and seconds. It also includes a special case for February to account for leap years.
  • Problem 5: Age in Seconds
    • Description: Calculates a person's age in seconds based on user input for years, days, and hours, with an option to account for leap years.

Turtle Graphics

These programs use Python's built-in turtle module to create graphical shapes. They demonstrate the use of loops to repeat drawing commands and create intricate patterns.

  • Problem 1 & 2: Basic Shapes
    • Description: Uses for loops to draw simple squares with two turtles moving in opposite directions.
  • Problem 3 & 4: Complex Patterns
    • Description: Uses nested loops to draw multiple squares and triangles, changing colors and positions to create more complex, visually interesting designs.

Basic Math Operations

This file is a collection of programs that perform fundamental arithmetic operations on two numbers provided by the user.

  • Description: This set of problems covers a range of basic operations, including:
    • Addition.
    • Subtraction.
    • Multiplication.
    • Division.
    • Exponentiation (**).
    • Remainder (%).
    • Integer division (//).

Menu-Based Calculator

This program combines basic math operations into a single, menu-driven application. It introduces the concept of functions to modularize the code.

  • Description: The program presents a menu of eight different operations, including addition, subtraction, multiplication, and average. It uses functions to perform each calculation, making the code more organized and reusable. It also includes error handling for division and modulus by zero, as well as for an invalid number of values for averaging.

Python Mini-Programs

This file contains several small programs that demonstrate the use of loops, user input, and formatted output.

  • Problem 1: Sum of Numbers
    • Description: Calculates the sum of all numbers up to a user-specified value, printing the numbers in a formatted list.
  • Problem 2: Star Square
    • Description: Prints a square of stars based on a user-provided number. It also displays the total number of stars printed.
  • Problem 3: Star Pyramid
    • Description: Creates an ascending and descending pyramid pattern of stars, with each row corresponding to a number.
  • Problem 4: Number Pyramid
    • Description: Creates a pyramid pattern using numbers instead of stars, with both an ascending and descending section.
  • Problem 5: Parking Fee Calculator
    • Description: Calculates the parking fee for multiple cars based on a flat rate for the first three hours and an additional charge for each subsequent hour, with a daily maximum. It uses a function to handle the fee calculation and a loop to process multiple customer inputs.

Python Basic Programs

This collection of programs further explores loops, user input validation, and simple game logic.

  • Problem 1 & 2 & 3: Star & Number Patterns with Validation
    • Description: Similar to the "Python Mini-Programs" file, but with added input validation using a while loop to ensure the user enters a positive integer.
  • Problem 4 & 5: Guessing Games
    • Description: Two simple games: a coin-flip game where the user guesses heads or tails, and a number-guessing game where the user tries to guess a randomly generated number between 1 and 10. These demonstrate the use of the random module and while loops for game logic.
  • Problem 6: Multiplication Table
    • Description: Generates a multiplication table for a number specified by the user, up to a maximum number also defined by the user.
  • Problem 7: String Sorter
    • Description: Takes a string from the user, splits it into words, sorts the words alphabetically, and writes them to a file named myfile.txt.
  • Problem 8: Palindrome Checker
    • Description: Checks if a string entered by the user is a palindrome (reads the same forwards and backward). It uses a function to perform the check.
  • Problem 9: Running Calculator
    • Description: A program that calculates either calories burned from a run or the distance needed to run to burn a certain number of calories. It greets the user with a title based on their gender.
  • Problem 10: Parking Fee Calculator
    • Description: This is a duplicate of the parking fee calculator from the "Python Mini-Programs" file.
  • Problem 11: Combined Menu
    • Description: This is a more comprehensive program that combines the basic calculator functions and the guessing games into a single, menu-driven application.

About

Python foundations repository of small console programs and turtle graphics; covers user input, functions, control flow, exceptions, randomness, menu-driven calculators, mini-programs, and simple beginner games.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages