Monday, July 27, 2015

Intro to Programming with Python - Tutorial 6 - Exercise 1

This is the solution to the exercise for the Intro to Programming with Python 6th tutorial covering lists.

The tutorial can be found here
https://youtu.be/2hdob7gw7r8

Exercise Description:
The exercise is to build a program that will do the following:
1 - Prompt the user to enter his/her four course names
2 - Print the course list back to the user
3 - Ask the user if they wish to change one of the courses (Yes, No)
4 - If they answer 'Yes':
    4.1 - Ask user which course number they wish to change (1,2,3,4)
    4.2 - Prompt the user to enter the new course name
    4.3 - Print the new course list to the user
5 - If they answer 'No':
    5.1 - Tell the user their course list did not change

Here is a sample output when you run the program you will create:


Bonus:
- Accept Y, Yes, yes, No, no, N
- Check if user entered less than 1 or more than 4 and if they did tell them they should enter only numbers from 1 to 4

Here is a sample output when you run the bonus version of the program:


Here is the solution to the exercise:


And here is the solution including the bonus checks:

Monday, July 20, 2015

Intro to programming with Python - Tutorial 5, Exercise 1

This is the solution to the simple calculator exercise in the fifth tutorial in the introduction to programming with Python series.
The tutorial can be found here:
https://www.youtube.com/watch?v=-I1QcEA8a7A

For this exercise you have to write a python program that will prompt the user for an operation (add, subtract, multiply, divide) then prompt the user for two numbers and perform the operation on them and display the result to the user.

Here is a sample output when you run your calculator python program (call it calc.py):


The program itself should be simple enough. You can copy this code into a python file (calc.py) and execute it.
Please note that in python lines that start with the pound sign are comment lines.
Comment lines give information about the code but do not affect how it executes. Python will ignore them.