$34.99
This homework has the following goals:
• Introduce you to basic Python programming
• Demonstrate the differences between using the interactive shell to carry commands out immediately and writing a function that allows you to do the same tasks
• Get you started using and evaluating internet resources for learning Python
Assignment Problems:
1. (5 points) Research on Internet for one helpful Python resource. Post your link to Python Resources Thread on our class discussion board, along with a brief discussion of why you chose this resource.
2. (12 points) Try doing a task (printing stars like this *****) using three different ways:
a. Use an interactive Python session (shell/IDLE) to print out a line of 11 stars 7 times (so there will be 7 lines of output with each line containing 11 stars). Spoiler Alert, here is a hint, use only if needed: https://repl.it/@RG19/WholeHandyVolcano#main.py
b. Write a function that does the same thing as above, having each line printed individually. Do this also in Shell/IDLE. Spoiler Alert, here is a hint, use only if needed: https://repl.it/@RG19/BlushingSelfreliantScript#main.py
c. Write a function that uses a loop to do the same thing. Do this also in Shell/IDLE.
Spoiler Alert, here is a hint, use only if needed: https://repl.it/@RG19/SuperbStrictCareware#main.py
d. List one advantage for each of the above three different ways of doing the same thing, as you have demonstrated above.
3. (8 points) From Chapter 2 materials, you have learned how to obtain user input, store this in a variable, and evaluate it, in addition to learning about simple definite loops. Using these write a simple interactive Python Calculator program (see Chapter 2 Programming Exercises #12 on page 55 from the 3rd Ed. of our class textbook).
Here is the problem description:
Write an interactive Python calculator program. The program should allow the user to type a mathematical expression, and then print the value of the expression. Include a loop so that the user can perform many calculations (say, up to 100). Note: To quit early, the user can make the program crash by typing a bad expression or simply closing the window that the calculator program is running in. You will learn better ways of terminating interactive programs in late chapters.
Page 1 of 2
CSC 110: Introduction to Computer Programming Assignment 1
Here is a sample run (Italics is the prompt by the program; bold is the user input; underlined is the output result):
Enter a math expression: 1 + 2
1 + 2 = 3
Enter a math expression: 1 - 2
1 - 2 = -1
Enter a math expression: 1/2
1/2 = 0.5
Hint#1: make use of built-in function: range; notice that when you use the construction: for calculation in range (10), calculation will go through all the integers from 0 to 9, or a total of 10 times to process up to 10 calculations to evaluate 10 expressions entered by the user
Submission Instructions:
Gather all your solutions into a text (*.txt) document as show below.
It is a good idea to start adding comments to your Python code. A title comment at the top of Python Module, for example would look like:
# Mary Smith
# CSC 110 Programming Assignment#1
#
# Solution for part 2A
# <Copy/Paste your codehere>
#
# Solution for part 2B
# <Copy/Paste your codehere>
#
# Solution for part 2C
# <Copy/Paste your codehere>
#
# Your answer for: List one advantage of each of the above three different ways
#
# Solution for part3
# <Copy/Paste your codehere>
#
Turn In:
1. Post your Python resource link (for part 1) on the discussion topic on our Canvas class site
2. And submit your responses to parts 2 and 3 by attaching a text document formatted as show above. If you need help with attaching a file when submitting an assignment, see this link.
In coming weeks, you will learn how to code your programs in and submit your code using .py files (also referred as Python modules)
Page 2 of 2