Lab 01
Lab 01: Python Fundamental
This lab covers the fundamentals of Python data, including topics such as numerics, strings, lists, and dictionaries.
There are four questions in total. Please provide your code answers directly below each question.
Make sure to run all cells so that the answers are stored. Once completed, export your .ipynb file as either HTML or PDF, ensuring that all answers are included. Submit the HTML or PDF file to Canvas by midnight (11:29 PM) on September 8.
This lab is worth a total of 50 points and contributes 5% toward the final grade.
Numeric¶
Write a Python program that converts a temperature given in Celsius to Fahrenheit. Use the formula: (5 points in total)
Fahrenheit = (Celsius * 9/5) + 32
- Set the Celsius temperature to 25 (2 points)
- Convert this temperature to Fahrenheit and display the result (3 points)
String¶
idea = 'Python programming is fun' (15 points in total)
- Count the number of words in the idea using
len()
(5 points) - Replace the word 'Python' with 'Coding' using
replace()
method and display the updated string (5 points) - Convert the first letter in each word upper case using
title()
method and display the updated string (5 points)
list¶
list_nums = [12,7,5,51,26,44,5,5] (15 points in total)
- Sort the list in ascending order using
sort()
and display the updated list (5 points) - Append the number '25' to the end of the list using
append()
and displayed the updated list (5 points) - Return the number of times the value '5' appear in the list using
count()
(5 points)
Dictionaries¶
Landmarks = {'Worcester Art Museum': {'location': '55 Salisbury Street', 'description': 'Features an extensive collection of art spanning 50 centuries.'}, 'Worcester Common': {'location': '455 Main Street', 'description': 'A large public park in the center of the city with green spaces and historical monuments.'}, 'Hanover Theatre': {'location': '2 Southbridge Street', 'description': 'Offers a range of performances from Broadway shows to local productions.'}}
- Display description of 'Worcester Common' (5 points)
- Remove 'Hanaver Theatre' from the dictionary using
pop()
method and display the updated dictionary (10 points)