Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Question 1 : # Create a function, called student _ id _ numbers, that takes a list of student names # and generates an

# Question 1:
# Create a function, called student_id_numbers, that takes a list of student names
# and generates an automatic student id number. The function must be able to handle
# collisions using dictionaries. A collision will happen when students have the same
# last name. The function must return the dictionary or dictionaries containing the
# students and their student id numbers.
# Note: using defaultdict might be helpful but not required. Having some good music
# while you code this might be helpful but also not required.
# You will also need to write a second function, called retrieve student_number that
# will take a student's name and will return their student id number. This function
# will need to handle misspelled names.
#Question 2:
# In France there is a child's marching song called "Un Kilometre a Pied" which
# translates to One Kilometer On Foot. The lyrics are:
# One kilometer on foot wears out, wears out,
# One kilometer on foot wears out your shoes for good.
# Two kilometers on foot wears out, wears out,
# Two kilometers on foot wears out your shoes for good.
#...
# The lyrics repeat to infinity (or rather until the kids get tired of singing).
# Create a function, called un_kilometre_a_pied, which takes no parameters and prints
# the lyrics of the song to the console. The function must make use of a generator to
# write the lyrics of the song until the user decides to stop. The generator you use must
# be able to produce a value that increses to infinity. You must make sure that your code
# doesn't get caught in an infinite loop that is difficult to exit, I recommend having
# the necessary logic to allow the user to exit whenever they get tired of the song. #Question 3:
# Create a class, called Tent, that contains the following attributes (in the order given):
# num_occupants (int)
# material (str)
# setup_time (int, number of minutes)
# sqft (float)
# vestibule (bool, True if tent has a vestibule)
# weight (float)
# structure_poles (bool, True if tent has structural poles. Should have a default value of True)
# seasons (int,3 or 4. Should have a default value of 3)
#The class should also have the following methods:
# __str__
# __repr__
# __lt__(this should use the num_occupants and sqft attributes to determine if one tent is
# less than another tent)
# is_better (a tent is considered better if and only if its weight and setup_time is less than
# another tent whilst having equal or better season rating)
#Question 4:
# We wish to compare and store data on various types of shelters for when we go backpacking.
# Create a class, called Hammock, that contains the following attributes (in the order given):
# num_occupants (int)
# material (str)
# setup_time (int, number of minutes)
# weight (float)
# length (int, length of hammock in feet. Should have a default value of 11)
# seasons (int,3 or 4. Should have a default value of 3)
#The class should also have the following methods:
# __str__
# __repr__
# __lt__(this should use the weight and setup_time attributes to determine if one hammock is
# less than another hammock)
# is_better (a tent is considered better if and only if its weight and setup_time is less than
# another tent whilst having equal or better season rating)
#Question 5:
# Create a class, called Tarp, that contains the following attributes (in the order given):
# num_occupants (int)
# material (str)
# setup_time (int, number of minutes)
# sqft (float)
# weight (float)
# seasons (int,3 or 4. Should have a default value of 3)
#The class should also have the following methods:
# __str__
# __repr__
# __lt__(this should use the num_occupants and sqft attributes to determine if one tent is
# less than another tent) # is_better (a tent is considered better if and only if its weight and setup_time is less than
# another tent whilst having equal or better season rating)
#Question 6:
# There is lots of repeated code above, let's create a parent class for Tent, Hammock and Tarp
# called Shelter. The Shelter class should have a constructor that takes over all of the
# attributes that are common for Tent, Hammock and Tarp. The Shelter class should also include
# the is_better method. You will also need to create a new method called total_sleeping_spots
# which will add up the total number of sleeping spots available from a non-determined number
# of Shelters being passed into the method.
# Rewrite the Tent, Hammock and Tarp classes taking into account the changes brought on by using
# the Shelter parent class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions