Using Jupyter notebook, answer each of the following questions. This is an individual lab. You must submit your own work. You will do your work in Jupyter notebook and must show the code you used to get the answer if it is a code-based question. To complete the assignment you must download your Jupyter notebook with code and answers as an html file and upload the notebook in html format. All questions should be answered fully when a text answer is required and all code must be shown to indicate how you arrived at the result.
Your report submission should be formatted using Markdown and code in Jupyter notebook as follows:
The name of the assignment as an H1, your name as an H2, and the date as an H3 all in the first cell block. Add a horizontal line/rule after the cell. The questions should then be answered in individual cells indicated by Q1, Q2, Q3…etc. in H4 format and separated from other questions by horizontal lines/rulers.
- What are conventions/rules for naming Python variables?
- What are the two main numeric data types in Python?
- Why are data types important?
- How do you check an object’s data type?
- Create a string called “Washington D.C.” and assign it to a variable using a name that follows Python conventions.
- How can you remove the periods from the string you created in #5?
- What are two different ways to access the “W” in “Washington D.C.” with an index?
- Create a list of employee IDs from 100 to 110 incremented by 1
- Loop through the list of employee IDs and print “Sales” if the employee is less than 105 and print “Finance” otherwise.
- Convert the following scenario to a conditional statement: If a user clicks “buy” print “Thank you for your purchase!”
- Add to the above conditional statement by printing “Need more time?” if the user does not click buy. Ensure the function returns a value.
- Write a for loop that iterates over a list (that you create) of 10 stock prices. In the for loop, add conditions that check the price and print “High”, “Mid”, or “Low” depending on the value. You decide on the prices and values for each condition.
- Define a function that takes a list as an input and returns a new list that contains the first and last element of the input list.
- Define a function that calculates a business’ debt-to-equity (D/E) ratio given its total liabilities and total equity. Return the result. Ensure the function returns a value.
- Adjust the function you defined in #14 to return “Warning” if the result is greater than 2 and “OK” otherwise. Test your function to ensure it works.
- What is scope and why is it important?
- Define a function with a local variable called “base_amount” that takes the value of 50 and takes two inputs, computes the sum of base amount and the two inputs, and then multiples that sum by “base_amount.” Run the code with inputs to ensure it works.
- Try to print “base_amount” in your global environment. What happens? What does Python tell you?
- What are classes?
- Create a class called User with three attributes: id, lastname, balance. Create three instances of the User class called user1, user2, user3. Print the last name of user1 and the balance of user2, using an f-string.
- What is the command line? Explain what each of the following command line commands do: ls, pwd, cd, mkdir
- What is git (in your own words)? Explain what each of the following git command line commands do: git init, git status, git add, git commit, git push
- What is a virtual environment and why is it useful for deploying Python applications?
- What is the difference between git and GitHub? Is it possible to use git without using GitHub?
- What is a list comprehension? Write a for loop that returns a new list with the cube of 2, 3 and 4. Write a list comprehension that does the same thing.
Please submit the Jupyter Notebook as an HTML report (an HTML file).