CSCI 150 - Foundations of Computer Science
Fall 2013
Project 2: Looping and I/O
For this project, you are to write two programs. Here are the requirements:
- Each program must contain at least one
for loop.
- Each program should accept user input using at least one
input statement.
- Each program should give the user a response using at least one
print statement. Alternatively, the program may employ turtle graphics for
its output.
- At least one of the programs must employ a list.
- At least one of the programs must contain at least one
if statement.
- Each program should fulfill a useful, contextualized purpose.
- If you would like to employ a Python concept that we have not yet covered
in class, you are welcome to do so.
- Submit each program as a separate
*.py file, via Moodle.
- The project is due on Wednesday, September 25, 2013 at 11:55 pm.
Here are some examples of project ideas. You are welcome to use any of these. Feel free to expand (or simplify) any of these suggestions; alternatively,
you are greatly encouraged to pursue your own project ideas. In any event,
make sure your submissions fulfill to the above requirements.
NOTE: A program need not be long to be useful. Aside from the turtle
program (23 lines), all of my solutions for the project ideas below were 10
lines or less.
- Write a program that is a math tutor. It could contain a list of math problems. It would then loop over this list, displaying each problem and requesting
an answer. It would tell the user whether or not each answer is correct, and
it would display the player's score when finished. Here's what this could look like:
3 * 2 = 6
Correct!
5 * 4 = 20
Correct!
1 + 3 = 2
Sorry, answer is: 4
4 - 2 = 2
Correct!
Total correct: 3
- Write a program that accepts a list of employee names and salaries. It
will print the name and salary of the highest-paid employee and the lowest-paid employee. Here's an example:
How many employees are there? 3
Enter name:Moe
Enter salary:50000
Enter name:Larry
Enter salary:30000
Enter name:Curly
Enter salary:20000
Highest paid is Moe with salary 50000
Lowest paid is Curly with salary 20000
- Write a program that accepts a mathematical equation from the user, as
well as starting and ending values. It will print the summation of every value
of that equation across that range. Here's an example:
Enter expression with free variable 'x':x**2
Enter starting x:1
Enter ending x:5
sum: 55
- Write a program that accepts instructions for a turtle. Instructions
alternate between forward distances and turns. It will then execute the
instructions. Here's an example:
Enter number of turtle commands:6
Enter distance:100
Enter right turn angle:120
Enter distance:100
Enter right turn angle:-120
Enter distance:50
Enter right turn angle:0
Done?y