CLAProject3, A and B

Comments

Transcription

CLAProject3, A and B
CLA Project 3, A and B – You will create two programs on Ranger first using IDLE. Then you will create a
script log for each one. And then finally, copy the code of each program into MyProgrammingLab for
grading!
Part A
1.
2.
3.
4.
5.
Log into Ranger
At the ranger$ prompt – type in idle3 &
In the idle shell window click on File to New File
This new window is the idle scripting window, this is where we will type the program.
Type in the following comments at the top of the program:
# Your Name
# csci 1170 – 00x
# CLAProject3A
# Find a magic date
6. Now save this file to your CLA directory and call it project3A.py
7. Create a program that solves the description below. Run your program several times as you
work so that you will discover any syntax errors right away. The output must match the sample
exactly.
Program Description:
The date June 10, 1960, is special because when it is written numerically,
the month times the day equals the year:
6/10/60 --> 6 * 10 = 60
Design a program that asks the user to enter a month (in numeric form), a day,
and a two-digit year in three separate inputs. The program should determine
whether the month times the day equals the year. If so, it should print,
"This date is magic!" Otherwise, it should print, "This date is not magic.
2 Sample Outputs of the Program – Test yours with the same data.
Enter month (numeric): 12
Enter day: 8
Enter two digit year: 96
This date is magic!
Enter month (numeric): 11
Enter day: 28
Enter two digit year: 94
This date is not magic.
8. Once your program is finished, we will create a script file for grading purposes. Go to the
ranger$ prompt and do each of these commands one at a time. You may need to make sure you
are in the CLA directory first (cd CLA). You need to be in the same directory as the project3A.py
file. Type in ls for list to know where the file is. Be sure the correct information does display on
the screen (we need to be able to see your code and that you ran the program two times!)
script claProject3A.log
cat –n project3A.py
python3 project3A.py
(Enter 12, 8, and 96 for a magic date!)
python3 project3A.py
(Enter 11, 28, and 94 for a non-magic date.)
exit
9. Now print your script log file by typing: lph claProject3A.log
10. Turn in your printout to your GTA
11. Assuming MyProgrammingLab is working, let’s copy your code into the solution area and click
submit to have your program graded instantly!
a. Log into MyProgrammingLab
b. LOAD our Python course
c. Locate and expand the Chapter 3 questions
d. At the bottom of the chapter list expand the Programming Projects
e. Click to select Question # 71402
f. Scroll down in the Workbench Work Area, copy your program from the IDLE scripting
window to the area shown in the picture below.
g. Now click SUBMIT, Did it grade correctly?, If not, let us help you fix it!
Paste your code here then click SUBMIT
Part B
1.
2.
3.
4.
5.
Log into Ranger
At the ranger$ prompt – type in idle3 &
In the idle shell window click on File to New File
This new window is the idle scripting window, this is where we will type the program.
Type in the following comments at the top of the program:
# Your Name
# csci 1170 – 00x
# CLAProject3B
# Color mixing program
6. Now save this file to your CLA directory and call it project3B.py
7. Create a program that solves the description below. Run your program several times as you
work so that you will discover any syntax errors right away. The output must match the sample
exactly.
Program Description:
The colors red, blue, and yellow are known as the primary colors because they
cannot be made by mixing other colors. When you mix two primary colors, you get
a secondary color:
When you mix red and blue, you get purple.
When you mix red and yellow, you get orange.
When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors,
one at a time. If the user enters anything other than "red," "blue," or
"yellow," the program should print "You didn't input two primary colors."
Otherwise, it should print something in the format:
"When you mix red and blue, you get purple."
(Assuming the user entered "red" and "blue”.)
You program will only check for the words in lower case.
4 Sample Outputs of the Program – Test yours with the same data.
Enter primary color: red
Enter primary color: blue
When you mix red and blue, you get purple.
Enter primary color: blue
Enter primary color: yellow
When you mix blue and yellow, you get green.
Enter primary color: yellow
Enter primary color: red
When you mix yellow and red, you get orange.
Enter primary color: green
Enter primary color: yellow
You didn't input two primary colors.
8. Once your program is finished, we will create a script file for grading purposes. Go to the
ranger$ prompt and do each of these commands one at a time. You may need to make sure you
are in the CLA directory first (cd CLA). You need to be in the same directory as the project3B.py
file. Type in ls for list to know where the file is. Be sure the correct information does display on
the screen (we need to be able to see your code and that you ran the program two times!)
script claProject3B.log
cat –n project3B.py
python3 project3B.py
(Enter red and blue)
python3 project3B.py
(Enter blue and yellow)
python3 project3B.py
(Enter yellow and red)
python3 project3B.py
(Enter green and yellow)
exit
9. Now print your script log file by typing: lph claProject3B.log
10. Turn in your printout to your GTA
11. Assuming MyProgrammingLab is working, let’s copy your code into the solution area and click
submit to have your program graded instantly!
a. Log into MyProgrammingLab
b. LOAD our Python course
c. Locate and expand the Chapter 3 questions
d. At the bottom of the chapter list expand the Programming Projects
e. Click to select Question # 71403
f. Scroll down in the Workbench Work Area, copy your program from the IDLE scripting
window to the area shown in the picture below.
g. Now click SUBMIT, Did it grade correctly?, If not, let us help you fix it!