Uploaded by annaluvsdawgs

H01

advertisement
Homework 1: INFOST 350 Application Development – Summer 2022
Completing this homework assignment will require you to follow the instructions very carefully in order
to submit your answers. There are four questions on this homework assignment. The assignment will
count 20 points towards your final grade.
You may use any resources available to you via the web. You may discuss the problems with others
before you sit down and attempt to complete the problems. However, you are expected to complete
the questions on your own without direct help from other people while you are completing the
questions. (You may still use websites and other non-human resources for help while working on the
homework.)
Make sure you have PythonAnywhere account and enter in uwmparkms as your teacher after
selecting Teacher tab on the website before you start this homework.
GETTING STARTED:
To begin this homework,
Go to PythonAnywhere.com and log into your own account. Make directory homework under your
account either using the Bash console or the File tab. If you use the Bash console to create the directory,
the command is: mkdir hw
Once the directory is made, crate files as described in the following questions. The instructor and/or TA
will access to your PythonAnywhere account to retrieve and review the files.
WHEN YOU ARE DONE:
When you have completed the homework, save this world document and submit it to Canvas assignment links.
Do not copy and paste the given codes in questions into Pythonanywhere. It will cause errors due to
special characters like quotation marks.
Page 1 of 6
Homework 1: INFOST 350 Application Development – Summer 2022
Question 1 (5 points):
Within your account/hw directory, create a file called h01_01.py. And capture the screen of
PythonAnywhere console and paste the image below to show the output when the following code is
executed:
fname= “Anna”
lname = “red-haired”
age = 56
affiliation = “Univ of Wisconsin-Milwaukee”
has_insurance = True
print(age, lname, has_insurance, affiliation)



Identify and list all variables in this code (2pts): fname, lname, age, affiliation, has_insurance
Identify and list all values in this code below and identify their data type of individual values:
(e.g., j: text, 9: numeric, Blooean) (2pts): Anna (text), red haired(text), age(numberic)
affliation(text) has_insurance(boolean)
Paste the captured output screen here (1pt) :
Question 2 (5 points):
Within your account/hw directory, create a file called h01_02.py. And capture the screen of
PythonAnywhere console and paste the image below to show the output when the following code is
executed:
Page 2 of 6
Homework 1: INFOST 350 Application Development – Summer 2022
* When you run the code below, you will get an error. Please identify the error and fix it to make the
code properly work.
j= “It is summer 2022”
print(i)
for i in range(5):
print(“Hello Class 350-201!”)


Explain what caused the error (3pts)-The error was that i was not defined as anything.
Paste the captured screen here (both debugged code and output screen) (2pts):
Question 3 (5 points):
The incomplete program below is to print out a friendly message to users. To complete the program,
modify the program below using some combination of print and input to print out a hello message with
your own full name.
To complete the program:
1. Create a module named h01_03.py from the directory hw
Page 3 of 6
Homework 1: INFOST 350 Application Development – Summer 2022
2. Comment and record your name, class number, and date of creation.
3. Type the incomplete program below to complete it using print and input.
Tip: the exact form of the input statement depends on the type of data
Don’t forget to remove ---- to complete the program
And then, capture the screen of PythonAnywhere console and paste the image below to show the
output when the following code is executed:
# practice with operation
# created by -------- ---------, --------- (record your first and last name, and date (mm-dd-yyyy) in
order)
first_name = “--------“
# replace -------- with your first name
last_name = “-------” # replace -------- with your last name
full_name = first_name + --------last name
# replace -------- with the variable stored the value of your
message = “Hello, “ + full_name.title() + “!”
---------(message) # replace -------- with a function or command that prints out the value stored
to the variable ‘message’
Page 4 of 6
Homework 1: INFOST 350 Application Development – Summer 2022
Paste the captured screen here:
Question 4 (5 points): The
incomplete program below is to
determine the future value of an
investment ten years into the
future. To complete the program,
modify the program below using
some combination of print and
input to:
a. compute an account be worth
30 years from now
b. accept information from the
user about how much money he/she starts with
c. accept information from the user about how much interest the account earns.
To complete the program:
4. Create a module named h01_pension.py from the directory homework
5. Record your name, class number, and date of creation.
6. Type the incomplete program below and modify h01_futval.py to complete it using print and
input.
Tip: the exact form of the input statement depends on the type of data
Don’t forget to remove ---- to complete the program
# h01_futval.py
# A program to compute the value of an investment
# carried 30 years into the future
# created by -------- ---------, --------- (record your first and last name, and date (mm-dd-yyyy) in
order)
def main()
-------------------------------------------------------------------
Page 5 of 6
Homework 1: INFOST 350 Application Development – Summer 2022
principal = eval(------(“Enter the initial principal: ”))
apr = ---- (------(“Enter the annual interest rate: ”))
for i in range(30):
principal = principal * (1 + apr)
-------(“The value in 30 years is:”, ---------)
main()
When you have completed the program, run the program and capture and paste the output below:
Paste the captured screen here:
Page 6 of 6
Download