Homework 1
Survey, Personal Website, and Python Basics
Direction
Please submit your Jupyter Notebook for Part 3 in Homework 1 to Brightspace with the name below:
danl-210-hw1-LASTNAME-FIRSTNAME.ipynb
( e.g.,danl-210-hw1-choe-byeonghak.ipynb
)
The due is February 17, 2025, 10:30 A.M.
Please send Byeong-Hak an email (bchoe@geneseo.edu) if you have any questions.
Part 1. Survey
Please complete the following survey:
Part 2. Quarto Website
- Decorate your website:
- Replace
YOUR NAME
with your name in_quarto.yml
andindex.qmd
. - Describe yourself in
index.qmd
. - Add the picture file (e.g.,
png
) of your profile photo toimg
directory. Then correctimg/profile.png
inindex.qmd
accordingly. - Add the PDF file of your resumé to the website working directory in your laptop.
- Correct links for your resumé, LinkedIn, email, and optionally social media.
- Make sure that you do not have any broken links in your website.
- Add a menu of “Project” to the navigation bar using
danl_proj_nba.ipynb
.
danl_proj_nba.ipynb
file is available from Brightspace.
- Add a drop-down menu of “Python Data Analysis” to the navigation bar.
- Under the menu of “Python Data Analysis”, add links for the following webpage:
- Pandas Basics using
pandas_basic.ipynb
- Seaborn Basics using
seaborn_basic.ipynb
pandas_basic.ipynb
andseaborn_basic.ipynb
files are available from Brightspace.
- Pandas Basics using
- Add a “Python Basics” blog post to your blog using Jupyter Notebook.
- In your “Python Basics” blog post, briefly explain Python Basics we discussed in Lecture 4 and Lecture 5, and in Classwork 4
- Choose a proper image file for a thumbnail for a blog post.
- An YAML header template for a blog post can be found below, including an image option:
---
title: BLOG_TITLE
author: YOUR_NAME
date: 2025-02-14
categories: [tag_1, tag_2, tag_3] # tags for a blog post (e.g., python)
image: "image.png"
toc: true
---
- Use the 3-step git commands (
git add .
,git commit -m "MESSAGE"
, andgit push
) to update your online website.
Part 3. Python Basics
Question 0
Provide your GitHub username.
Question 1
Q1a
- Create a list of integers from 1 to 10.
- Append the number
11
to the list and remove the number5
.
Q1b
- Consider the following dictionary of three employees and their salaries:
= {'Alice': 50000, 'Bob': 60000, 'Charlie': 70000} dict_salaries
- Add a new employee
'Dana'
with a salary of65000
. - Update
'Alice'
’s salary to55000
. - Print all employee names and their salaries.
Question 2
Q2a
- Assign a variable
salary
to75000
. - Use an
if
-elif
-else
statement to print:'Low'
ifsalary
is less than50,000
'Medium'
ifsalary
is between50,000
and99,999
'High'
ifsalary
is100,000
or more
Q2b
Assign two variables,
role
andsalary
, to'Manager'
and85000
, respectively.Use nested
if
-else
statements to print:'Eligible for bonus'
if therole
is'Manager'
and thesalary
is greater than80,000
.'Eligible for raise'
if therole
is'Analyst'
and thesalary
is less than60,000
.'No action needed'
for all other cases.
Question 3
Q3a
- Consider the following list of salaries:
= [45000, 60000, 75000, 120000, 30000] list_salaries
- Calculate the average salary.
- Use a
for
loop to print whether each salary is'Above Average'
or'Below Average'
.
Q3b
- Start with a
salary
of50000
. - Use a
while
loop to increase the salary by5000
each year until it exceeds80000
. - Print the salary after each increment.
Q3c
- Consider the following dictionary of employee salaries:
= {'Alice': 50000, 'Bob': 60000, 'Charlie': 70000, 'Dana': 45000} salaries
- Use a
for
loop to print the names of employees who earn more than55000
.
Q3d
= [42, 3.14, 'Data Analytics', True, None, [1, 2, 3], {'key': 'value'}, (4, 5)] data_list
- Given the list above, print the data type of each element using the
type()
function in afor
loop. In the loop:- Convert the integer
42
to a string. - Convert the float
3.14
to a string, then back to a float. - Convert the boolean
True
to an integer.
- Convert the integer
Question 4
Q4a
Consider the variables a
and b
:
= 10
a = 0 b
- Use a
try
-except
block to print the result ofa / b
.- If there is an error, print
'Cannot divide by zero!'
.
- If there is an error, print
Q4b
- Consider the following dictionary of salaries with some missing (
None
) values:
= {'Alice': 50000, 'Bob': None, 'Charlie': 70000, 'Dana': None, 'Eve': 80000} salaries
- Use a
for
loop with atry
-except
block to calculate the total of non-missing salaries.
Question 5
- Import the
math
library and calculate the square root of81
using thesqrt()
function provided by themath
library.