Skip to content

HMthyl/Short-Python-Exercises

Repository files navigation

Short-Python-Exercises

Quick and basic Python

These are Python exercises completed in class around July 2021 (except, admittedly, the Rock Paper and Scissors game and the temperature conversion program, which I updated more recently (September))

List of contents

  1. BullsAndCows

    • A traditional game where the computer selects a random 4 digit number (no repeats), and the player must try and guess this number. Guess a digit in the correct 'place' and that's a Bull. Guess a correct number, but in the wrong place, you've got yourself a cow. e.g. Com: 1234 | You: 1624 = 2 Bulls (1, 4), 1 Cow (2). Of course, in the real game, you're not told which numbers are cows and which are bulls ;)
  2. CaseCount

    • A program that counts the number of upper and lower case letters in a string the user has inputted
  3. ConvertTemperatures

    • Allows you to convert Celsius to Fahrenheit, and vice versa
  4. EveryDigitEven

    • Prints out every number within range 100-400 incl., where each digit of the number is even
  5. FizzBuzz

    • You know what FizzBuzz is
  6. GuessTheNumber

    • COM guesses a number between 1-9 randomly; player must guess the number within 5 tries
  7. IsItPrime

    • User inputs a number: computer tells user if it is in fact(!) a prime number. Writing this one kicked my ass hard at the time, I'm not sure why? Wild.
  8. MaxofThree

    • User inputs three separate numbers and Python picks out the biggest number!
  9. MeatCooker

    • User inputs the type of meat they wish to cook (from a choice of 4 meats), along with the meat's weight in kg. The program then tells you how long the meat should be cooked for!* (I just repeated the word "meat" so much, it doesn't mean anything anymore. Meat.)
  10. PasswordGenerator

    • Generate a random password as needed: set the number of letters, numbers and special characters you wish!
  11. RangeExercises

    • Exercises making use of Python's range() function; pretty basic!
  12. ReverseUserString

    • Takes a string from the user and reverses the word order of that string
  13. RockPaperScissors

    • You know what this is :-)
  14. TipCalculator

    • Calculate how much each person in your group should pay towards an evenly split bill; staff tip included.

--

*HMthyl cannot be held responsible for over or undercooked meats.