Difference between revisions of "CSC111 Homework 1 2018"
(→Programming) |
|||
(9 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 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. | + | 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 /> | ||
Line 93: | Line 93: | ||
++ 2018 ++ | ++ 2018 ++ | ||
Alex is 20 years old and was born in 1998 | Alex is 20 years old and was born in 1998 | ||
− | Alex will be | + | Alex will be 22 in 2020 |
</source> | </source> | ||
|} | |} | ||
Line 99: | Line 99: | ||
<br /> | <br /> | ||
You click on ''run'' to verify that your program works. Click on ''evaluate'' to see if it outputs the correct information. | 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 130: | Line 132: | ||
</source> | </source> | ||
|} | |} | ||
+ | <br /> | ||
+ | <br /> | ||
+ | '''Possible grades''': A, A- or B. | ||
<br /> | <br /> | ||
<br /> | <br /> | ||
Line 167: | Line 172: | ||
</source> | </source> | ||
|} | |} | ||
+ | <br /> | ||
+ | <br /> | ||
+ | '''Possible grades''': A, A- or B. | ||
<br /> | <br /> | ||
<br /> | <br /> | ||
Line 208: | 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 248: | Line 258: | ||
</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. | ||
Line 298: | Line 311: | ||
</source> | </source> | ||
|} | |} | ||
− | <br /><br /> | + | <br /> |
+ | <br /> | ||
+ | '''Possible grades''': A, A- or B. | ||
+ | <br /> | ||
+ | <br /> | ||
<!-- ---------------------------------------------------------------------------------------------------- --> | <!-- ---------------------------------------------------------------------------------------------------- --> | ||
− | |||
Line 322: | 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 332: | Line 348: | ||
college = "Smith College" | college = "Smith College" | ||
− | bar = " | + | bar = "+" * len( college ) |
name = "Fiona" | name = "Fiona" | ||
print( bar ) | print( bar ) | ||
Line 355: | 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 371: | Line 387: | ||
def greetLength( person ): | def greetLength( person ): | ||
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
noChars = len( person ) | noChars = len( person ) | ||
Line 389: | Line 405: | ||
def greetLength( person ): | def greetLength( person ): | ||
− | bar = " | + | bar = "+++++++++++++++++++++" |
print( bar ) | print( bar ) | ||
noChars = len( person ) | noChars = len( person ) | ||
Line 402: | Line 418: | ||
</source> | </source> | ||
</showafterdate> | </showafterdate> | ||
− | + | </onlydft> | |
<br /> | <br /> | ||
<br /> | <br /> |