Difference between revisions of "CSC111 Homework 1 2018"
(→Programming) |
|||
(25 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 15:01, 17 January 2018 (EST) | [[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 15:01, 17 January 2018 (EST) | ||
---- | ---- | ||
− | + | <onlydft> | |
<bluebox> | <bluebox> | ||
− | This homework is due | + | This homework is due on Thursday '''Feb 8th, at 11:55 p.m.''' The quiz part of the assignment should be done individually. For the programming part of the assignment, '''you should find a partner and work in pair, and use the pair-programming approach. You may want to work with your lab partner, if the two of you have a good schedule. ''' |
</bluebox> | </bluebox> | ||
<br /> | <br /> | ||
=Quiz= | =Quiz= | ||
<br /> | <br /> | ||
− | Please go to the CSC111 page on Moodle and answer the questions in the "Quiz | + | Please go to the CSC111 page on Moodle and answer the questions in the "Quiz" section for Week 1. The questions refer to Chapter 1 in the Zelle textbook, and to the [http://cs.smith.edu/~jfrankli/111s08/pairProgramming2000.pdf article] on ''pair programming.'' |
=Programming= | =Programming= | ||
Line 20: | Line 20: | ||
<br /> | <br /> | ||
+ | =Grading= | ||
<br /> | <br /> | ||
+ | Moodle uses numbers to grade programs. These numbers are translated into letters using the following scale: | ||
+ | * 100.00 - 93.00: A | ||
+ | * 92.99 - 90.00: A- | ||
+ | * 89.99 - 87.00: B+ | ||
+ | * 86.99 - 83.00: B | ||
+ | * 82.99 - 80.00: B- | ||
+ | * 79.99 - 77.00: C+ | ||
+ | * 76.99 - 73.00: C | ||
+ | * 72.99 - 70.00: C- | ||
+ | * 69.99 - 67.00: D+ | ||
+ | * 66.99 - 60.00: D | ||
+ | * 59.99 - 0.00: F | ||
+ | <br /> | ||
+ | <!-- | ||
=Quiz= | =Quiz= | ||
<br /> | <br /> | ||
Line 49: | Line 64: | ||
:The article suggests that it is acceptable for programmers involved in pair programming to sometimes work alone. But the time spent alone should be less than half of the total time spent on the project. True or false? | :The article suggests that it is acceptable for programmers involved in pair programming to sometimes work alone. But the time spent alone should be less than half of the total time spent on the project. True or false? | ||
<br /> | <br /> | ||
+ | --> | ||
=Problem #1= | =Problem #1= | ||
Line 65: | Line 81: | ||
# Name of pair partner #2 | # Name of pair partner #2 | ||
− | age = 1 | + | age = 1 # you may want to change this number |
name = "Alex" | name = "Alex" | ||
− | year = | + | year = 2018 |
− | print( " | + | print( "++", year ) |
print( name, "is", "and was born in" ) | print( name, "is", "and was born in" ) | ||
Line 75: | Line 91: | ||
| | | | ||
<source lang="text"> | <source lang="text"> | ||
− | + | ++ 2018 ++ | |
− | Alex is 20 years old and was born in | + | Alex is 20 years old and was born in 1998 |
− | Alex will be | + | Alex will be 22 in 2020 |
</source> | </source> | ||
|} | |} | ||
<br /> | <br /> | ||
− | + | You click on ''run'' to verify that your program works. Click on ''evaluate'' to see if it outputs the correct information. | |
+ | <br /> | ||
+ | '''Possible grades''': A, A- or B. | ||
<br /> | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------------------------- --> | ||
Line 101: | Line 119: | ||
college = "Smith College" | college = "Smith College" | ||
− | bar = " | + | bar = "+" * len( college ) |
name = "Fiona" | name = "Fiona" | ||
print( bar ) | print( bar ) | ||
Line 108: | Line 126: | ||
| | | | ||
<source lang="text"> | <source lang="text"> | ||
− | + | +++++++++++++ | |
Smith College | Smith College | ||
Fiona | Fiona | ||
− | + | +++++++++++++ | |
</source> | </source> | ||
|} | |} | ||
<br /> | <br /> | ||
− | + | <br /> | |
+ | '''Possible grades''': A, A- or B. | ||
+ | <br /> | ||
<br /> | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------------------------- --> | ||
+ | |||
=Problem #3= | =Problem #3= | ||
<br /> | <br /> | ||
Line 152: | Line 173: | ||
|} | |} | ||
<br /> | <br /> | ||
− | + | <br /> | |
+ | '''Possible grades''': A, A- or B. | ||
+ | <br /> | ||
<br /> | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------------------------- --> | ||
Line 170: | Line 193: | ||
# Name of pair partner #2 | # Name of pair partner #2 | ||
− | def greetBar( person ): | + | def greetBar( person ): |
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
print( person ) | print( person ) | ||
Line 181: | Line 204: | ||
| | | | ||
<source lang="text"> | <source lang="text"> | ||
− | + | +++++++++++++++++++++ | |
Hello John | Hello John | ||
How are you? | How are you? | ||
− | + | +++++++++++++++++++++ | |
Hello Emily | Hello Emily | ||
How are you? | How are you? | ||
− | + | +++++++++++++++++++++ | |
Hello Lujun | Hello Lujun | ||
How are you? | How are you? | ||
Line 193: | Line 216: | ||
|} | |} | ||
<br /> | <br /> | ||
− | + | <br /> | |
+ | '''Possible grades''': A, A- or B. | ||
+ | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------------------------- --> | ||
− | + | =Problem #5= | |
− | =Problem 5= | ||
<br /> | <br /> | ||
Open IDLE on your computer and type in the incomplete program shown below. Save it as '''hw1_5.py'''. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 5 section. Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect! | Open IDLE on your computer and type in the incomplete program shown below. Save it as '''hw1_5.py'''. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 5 section. Be careful, as the Moodle testing program counts extra spaces or extra blank lines in your output as incorrect! | ||
Line 216: | Line 240: | ||
def greetLength( person ): | def greetLength( person ): | ||
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
print( "Hello", person ) | print( "Hello", person ) | ||
Line 226: | Line 250: | ||
| | | | ||
<source lang="text"> | <source lang="text"> | ||
− | + | +++++++++++++++++++++ | |
Hello John how are you? | Hello John how are you? | ||
− | + | +++++++++++++++++++++ | |
Hello Emily how are you? | Hello Emily how are you? | ||
− | + | +++++++++++++++++++++ | |
Hello Jo how are you? | Hello Jo how are you? | ||
</source> | </source> | ||
|} | |} | ||
+ | <br /> | ||
+ | <br /> | ||
+ | '''Possible grades''': A, A- or B. | ||
<br /> | <br /> | ||
<br /> | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------- --> | ||
− | =Problem 6= | + | =Problem #6= |
<br /> | <br /> | ||
Open IDLE on your computer and type in the incomplete program shown below. Save it as '''hw1_6.py'''. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 6 section. | Open IDLE on your computer and type in the incomplete program shown below. Save it as '''hw1_6.py'''. Modify it until you get it to show the output shown in the second column, below. When you are satisfied your program runs correctly, submit it to Moodle, in the HW 1 P 6 section. | ||
− | Be careful, as the Moodle testing program | + | Be careful, as the Moodle testing program may count extra spaces or extra blank lines in your output as incorrect! |
− | |||
− | |||
<br /> | <br /> | ||
Line 263: | Line 288: | ||
def greetLength( person ): | def greetLength( person ): | ||
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
noChars = len( person ) | noChars = len( person ) | ||
Line 275: | Line 300: | ||
| | | | ||
<source lang="text"> | <source lang="text"> | ||
− | + | +++++++++++++++++++++ | |
==> Maria Callas <== | ==> Maria Callas <== | ||
Your name contains 12 characters | Your name contains 12 characters | ||
− | + | +++++++++++++++++++++ | |
==> Sir Elton John <== | ==> Sir Elton John <== | ||
Your name contains 14 characters | Your name contains 14 characters | ||
− | + | +++++++++++++++++++++ | |
==> Lady Gaga <== | ==> Lady Gaga <== | ||
Your name contains 9 characters | Your name contains 9 characters | ||
</source> | </source> | ||
|} | |} | ||
− | <br /><br /> | + | <br /> |
+ | <br /> | ||
+ | '''Possible grades''': A, A- or B. | ||
+ | <br /> | ||
+ | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------- --> | ||
− | |||
Line 310: | Line 338: | ||
year = 2015 | year = 2015 | ||
− | print( " | + | print( "++", year, "++" ) |
print( name, "is", age, "years old and was born in", year-age ) | print( name, "is", age, "years old and was born in", year-age ) | ||
print( name, "will be", 2020-2015 + age, "in 2020" ) | print( name, "will be", 2020-2015 + age, "in 2020" ) | ||
Line 320: | Line 348: | ||
college = "Smith College" | college = "Smith College" | ||
− | bar = " | + | bar = "+" * len( college ) |
name = "Fiona" | name = "Fiona" | ||
print( bar ) | print( bar ) | ||
Line 343: | Line 371: | ||
# Homework 1, Problem 4 (read Section 1.6 in Zelle) | # Homework 1, Problem 4 (read Section 1.6 in Zelle) | ||
− | def greetBar( person ): | + | def greetBar( person ): |
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
print( "Hello", person ) | print( "Hello", person ) | ||
Line 359: | Line 387: | ||
def greetLength( person ): | def greetLength( person ): | ||
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
noChars = len( person ) | noChars = len( person ) | ||
Line 377: | Line 405: | ||
def greetLength( person ): | def greetLength( person ): | ||
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
noChars = len( person ) | noChars = len( person ) | ||
Line 390: | Line 418: | ||
</source> | </source> | ||
</showafterdate> | </showafterdate> | ||
− | + | </onlydft> | |
<br /> | <br /> | ||
<br /> | <br /> |