Difference between revisions of "CSC111 Homework 5 2015b"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- <bluebox> This assignment should be done in pairs, and is due on 10/8/15, at 11:55 p.m. </bluebox> <br /> =Problem 1= <br /> This problem is super easy, but will ...")
 
(Problem 1)
Line 10: Line 10:
 
This problem is super easy, but will get you to see the structure of the type of programs you will have to write for this homework.  All the programs will have the same structure, and will be tested in a similar way.
 
This problem is super easy, but will get you to see the structure of the type of programs you will have to write for this homework.  All the programs will have the same structure, and will be tested in a similar way.
 
<br />
 
<br />
Write a program called '''hw5_1.py''' that has contains a function called '''happyBirthday1Line(...)''', that receives one parameter, which will contain the name of a person (say, "Elena"), and that will print the following message:
+
* Write a program called '''hw5_1.py''' that has contains a function called '''happyBirthday1Line(...)''', that receives one parameter, which will contain the name of a person (say, "Elena"), and that will print the following message:
 
<br />
 
<br />
 
:::<source lang="text">
 
:::<source lang="text">
Line 16: Line 16:
 
</source>
 
</source>
 
<br />
 
<br />
Note that the function only prints '''one line'''.  No extra blank lines.
+
:Note that the function only prints '''one line'''.  No extra blank lines.
 
<br />
 
<br />
Add a main function to your program that will call your happyBirthday1Line() function.  For example:
+
* Add a main function to your program that will call your happyBirthday1Line() function.  For example:
 
<br />
 
<br />
 
:::<source lang="python">
 
:::<source lang="python">
Line 29: Line 29:
 
</source>
 
</source>
 
<br />
 
<br />
When you run your program, the output should be:
+
* When you run your program, the output should be:
 
<br />
 
<br />
 
<br />
 
<br />
Line 38: Line 38:
 
</source>
 
</source>
 
<br />
 
<br />
 +
* Submit your program to the HW 5 PB 1 section on Moodle.
 +
<br />
 +
<tanbox>
 +
Note that Moodle will remove the main function from your program and replace it with another main() function, that will call your function with different names.  This will ensure that you write your function correctly, independently of your main function. 
 +
So, do not be surprised if you see the output of your program on Moodle not corresponding to your output.  It's normal!
 +
</tanbox>

Revision as of 08:40, 4 October 2015

--D. Thiebaut (talk) 09:37, 4 October 2015 (EDT)


This assignment should be done in pairs, and is due on 10/8/15, at 11:55 p.m.


Problem 1


This problem is super easy, but will get you to see the structure of the type of programs you will have to write for this homework. All the programs will have the same structure, and will be tested in a similar way.

  • Write a program called hw5_1.py that has contains a function called happyBirthday1Line(...), that receives one parameter, which will contain the name of a person (say, "Elena"), and that will print the following message:


Happy birthday to you, dear Elena


Note that the function only prints one line. No extra blank lines.


  • Add a main function to your program that will call your happyBirthday1Line() function. For example:


def main():
     happyBirthday1Line( "Elena" )
     happyBirthday1Line( "Maria" )
     happyBirthday1Line( "Rui" )

main()


  • When you run your program, the output should be:



Happy birthday to you, dear Elena 
Happy birthday to you, dear Maria 
Happy birthday to you, dear Rui


  • Submit your program to the HW 5 PB 1 section on Moodle.


Note that Moodle will remove the main function from your program and replace it with another main() function, that will call your function with different names. This will ensure that you write your function correctly, independently of your main function. So, do not be surprised if you see the output of your program on Moodle not corresponding to your output. It's normal!