Skip to content

j-mccloskey/introduction-to-coding

Repository files navigation

Introduction to Coding

This repo contains the solutions for the exercises during the introduction to programming session with Python. To learn more about Python a good starting point would be Codecademy

Exercise 1 - Variables

Create well named variables for each of the following:

  • First name
  • Surname
  • University attended
  • Age
  • Maximum heart rate (220-Age) Print each of the variables

Solution

Exercise 2 - Output and String manipulation

Print each variable you created in its own sentence

Solution

Exercise 3 - User Input

Use user input to get values for each of your variables. Prompt the user to enter a value for each one. Continue to print each one in its own sentence

Solution

Exercise 4 - Conditionals

Continue to build upon what you have done. Prompt the user for y/n input whether they can drive or not

Print suitable messages for the following conditions:

  • Can drive and are above legal age
  • Can drive but are below the legal age
  • Can’t drive and are below legal age
  • Can’t drive but are above the legal age

Solution

Exercise 5 - Loops

Prompt the user for a sentence Use a loop to remove any letters that are vowels Print the new sentence

Solution

Exercise 6 - Functions

Create a functions to:

  • Calculate max heart rate
  • Remove vowels from a given string

Use each function multiple times and print result

Solution

Fizz Buzz Challenge

Define a function called fizz_buzz that has one integer parameter. It should:

  • Return Fizz when the integer is a multiple of 3
  • Return Buzz when the integer is a multiple of 5
  • Return FizzBuzz when integer is a multiple of both 3 and 5
  • Return the integer without any modification in all other cases

Write a function called challenge that will call the fizz_buzz function for all integers from 1 to 100 and print the result of each time

Solution

Tests

Rock, Paper, Scissors Game

  • Write a program to play ’Rock, Paper, Scissors’ against the computer. It should
  • Print a welcome message
  • Make a random choice for the computer
  • Ask the user for their choice, repeat until it’s a valid one
  • Print the result (Win/Lose/Draw)

Solution

Rock, Paper, Scissors Game - Extra features

Ask the player if they want to play again. Print the score at the end of the game session (W/D/L record)

Solution

Lists of Lists

  • Write a program that displays the vending machine to a user
  • Prompt them for the co-ordinates of their selection
  • Print the name of the item they pick

Solution

Dictionaries

  • Write a program where users can input the name of a movie
  • Output the names of the main actors for that movie
  • Handle scenario where movie is not known

Solution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages