GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

A Dog is a dictionary with the following keys: ‘age’ which…

A Dog is a dictionary with the following keys: ‘age’ which is an integer representing the age of the dog ‘breed’ which is a string representing the breed of the dog (e.g., Corgi) ‘name’ which is a string representing the name of the dog Define a function compare_dog_lists that consumes three parameters (two lists of dogs and a string) and produces a string (eigher ‘first’, ‘second’ or ‘equal’. The first two parameters are the first list of dogs and the second list of dogs. The third parameter is a string representing a given breed of dog. The function should determine which of the two lists has the most dogs of the given breed. If the first list of dogs hasmore of the given breed than the second list, then produce the string ‘first’. If the second list has more, then produce the string ‘second’. Otherwise, produce the string ‘equal’. If you accidently erase the code, you can copy it from here. from cisc108 import assert_equal dogs1 = [    {‘age’:5, ‘breed’:’Great Dane’, ‘name’:’Astro’},    {‘age’:5, ‘breed’:’Siberian Husky’, ‘name’:’Balto’},    {‘age’:5, ‘breed’:’St. Bernard’, ‘name’:’Beethoven’} ]dogs2 = [    {‘age’:5, ‘breed’:’Great Dane’, ‘name’:’Scooby Doo’},    {‘age’:5, ‘breed’:’Great Dane’, ‘name’:’Marmaduke’},    {‘age’:5, ‘breed’:’St. Bernard’, ‘name’:’Barry’} ]dogs3 = [    {‘age’:5, ‘breed’:’Great Dane’, ‘name’:’Landru’} ]dogs4 = [] #put your code here assert_equal(compare_dog_lists(dogs1,dogs2,’Great Dane’),’second’)assert_equal(compare_dog_lists(dogs1,dogs3,’Siberian Husky’),’first’)assert_equal(compare_dog_lists(dogs1,dogs2,’St. Bernard’),’equal’)assert_equal(compare_dog_lists(dogs1,dogs4,’Great Dane’),’first’)

Read Details

A Table is a dictionary with the following keys: ‘width’ wh…

A Table is a dictionary with the following keys: ‘width’ which is an integer representing the width of the table. ‘height’ which is an integer representing the height of the table. ‘color’ which is a string representing the color of the table. (3 pts) Create 3 different lists. The first one is empty. The second one should contain at least 3 table dictionaries. The third one cannot be the same as the other two. (4 pts) Define a function get_areas that consumes a list of Tables and produces a list of integers representing the areas of each Table (width multiplied by height). (3 pts) Write the unit tests (assert_equal) for each of the lists you created above. If the given list is empty return None. If the given list contains 3 tables, the list that gets returned will contain 3 integers. If you accidently erase the code, you can copy it from here. from cisc108 import assert_equal # Create 3 lists here. One should be empty, one should contain more than 1 dictionary, and the other is up to you. # put your code here for get_areas # Write at least 3 assert_equal tests. Each one is given one of the lists created above.

Read Details

Consider how a dictionary could represent a gift/present wit…

Consider how a dictionary could represent a gift/present with the following keys:  ‘Weight’ which is a float representing the weight/size of the present  ‘For You?’ which is a boolean indicating whether or not the present is for you  ‘Giver’ which is a string representing the name of the person who gave you the present  ‘Color’ which is a string representing the color of the wrapping paper Define a function color_of_my_smallest_present that consumes a list of presents and produces a string representing the color of the lowest weight present that is for you. If no present is found, return the string value ‘nothing’ instead. The largest possible weight of a present is 10 lbs.  If you accidently erase the code, you can copy it from here. from cisc108 import assert_equal presents = [    {‘Weight’:1.3, ‘For You?’:True, ‘Giver’:’Jude’, ‘Color’:’Red’},    {‘Weight’:0.2, ‘For You?’:False, ‘Giver’:’Jesse’, ‘Color’:’Orange’},    {‘Weight’:0.3, ‘For You?’:True, ‘Giver’:’Jaron’, ‘Color’:’Blue’},    {‘Weight’:2.1, ‘For You?’:False, ‘Giver’:’Julian’, ‘Color’:’Yellow’},    {‘Weight’:1.5, ‘For You?’:True, ‘Giver’:’Jayden’, ‘Color’:’Purple’},    {‘Weight’:1.2, ‘For You?’:True, ‘Giver’:’Jade’, ‘Color’:’Green’}  ] mypresents = [    {‘Weight’:1.2, ‘For You?’:False, ‘Giver’:’Jordan’, ‘Color’:’Silver’}  ] #put your code here assert_equal(color_of_my_smallest_present(presents),’Blue’)assert_equal(color_of_my_smallest_present(mypresents),’nothing’)assert_equal(color_of_my_smallest_present([]),’nothing’)

Read Details

(CLO 2)  What propels food through the esophagus toward the…

(CLO 2)  What propels food through the esophagus toward the stomach?

Read Details

Define a function named tsp_to_tbs that consumes an integer…

Define a function named tsp_to_tbs that consumes an integer (representing the number of teaspoons) and produces a float representing the same volume amount in tablespoons by multiplying the teaspoons by 0.33.  If you accidently erase the unit tests, you can copy them from here. assert_equal(tsp_to_tbs(2), 0.66)assert_equal(tsp_to_tbs(5), 1.6500000000000001)assert_equal(tsp_to_tbs(6), 1.98)

Read Details

A Cat is a dictionary with the following keys: ‘age’ which…

A Cat is a dictionary with the following keys: ‘age’ which is an integer representing the age of the cat ‘breed’ which is a string representing the breed of the cat (e.g., Persian) ‘name’ which is a string representing the name of the cat Define a function compare_cat_lists that consumes three parameters (two lists of cats and a string) and produces a string (eigher ‘first’, ‘second’ or ‘equal’. The first two parameters are the first list of cats and the second list of cats. The third parameter is a string representing a given breed of cat. The function should determine which of the two lists has the most cats of the given breed. If the first list of cats hasmore of the given breed than the second list, then produce the string ‘first’. If the second list has more, then produce the string ‘second’. Otherwise, produce the string ‘equal’. If you accidently erase the code, you can copy it from here. from cisc108 import assert_equal cats1 = [    {‘age’:5, ‘breed’:’Siamese’, ‘name’:’Church’},    {‘age’:5, ‘breed’:’Ragdoll’, ‘name’:’Binx’},    {‘age’:5, ‘breed’:’Sphynx’, ‘name’:’Ruh’} ]cats2 = [    {‘age’:5, ‘breed’:’Siamese’, ‘name’:’Luna’},    {‘age’:5, ‘breed’:’Siamese’, ‘name’:’Jiji’},    {‘age’:5, ‘breed’:’Sphynx’, ‘name’:’Duchess’} ]cats3 = [    {‘age’:5, ‘breed’:’Siamese’, ‘name’:’Kitty’} ]cats4 = [] #put your code here assert_equal(compare_cat_lists(cats1,cats2,’Siamese’),’second’)assert_equal(compare_cat_lists(cats1,cats3,’Ragdoll’),’first’)assert_equal(compare_cat_lists(cats1,cats2,’Sphynx’),’equal’)assert_equal(compare_cat_lists(cats1,cats4,’Siamese’),’first’)

Read Details

Define a function named check_assignment that consumes a com…

Define a function named check_assignment that consumes a completion rate of an assignment (float) and whether or not the due date is past (boolean). Your function should produce the status of the assignment (string). If the completition rate is 0.0 or the due date is past, then return the string”failed”. If the completition rate is 1.0, then return the string “perfect”. Otherwise, return the string “partial”  If you accidently erase the unit tests, you can copy them from here. assert_equal(check_assignment(0.75,True), “failed”)assert_equal(check_assignment(0.75,False), “partial”)assert_equal(check_assignment(0.0,True), “failed”)assert_equal(check_assignment(0.0,False), “failed”)assert_equal(check_assignment(1.0,True), “failed”)assert_equal(check_assignment(1.0,False), “perfect”)

Read Details

Determine the missing values in the table below when given t…

Determine the missing values in the table below when given the equation . Do not put spaces when typing your ordered pairs.  x y  (x, y)  -1 (-1,  ) 2 (2,     ) 3 -3 ( ,  -3) 11 -5 Leave your answers as simplified fractions.   Be sure your work is shown in an organized fashion on your work upload. 

Read Details

The list method .index(pattern) consumes a pattern (an int)…

The list method .index(pattern) consumes a pattern (an int) and produces an integer indicating the position of the pattern in the list. Use the above method to implement a function called find_zipcode that consumes a list of integers representing zipcodes and the number to search for representing the zipcode. The function should return the position of the zipcode in the list. If the zipcode is not in the list, the function should return None. If you accidently erase the unit tests, you can copy them from here. assert_equal(find_zipcode([84095,84118,84043,84015,84404],84404),4)assert_equal(find_zipcode([],84409),None)

Read Details

Write a function called buy_ticket that consumes a number re…

Write a function called buy_ticket that consumes a number representing a person’s age. The function should return the price of the ticket according to the age of the person. “Free” for children 3 and younger. “5$” for children 12 and younger. “10$” for adults. “9$” for seniors (60 and older). If you accidently erase the unit tests, you can copy them from here. assert_equal(buy_ticket(3),”Free”)assert_equal(buy_ticket(4),”5$”)assert_equal(buy_ticket(12),”5$”)assert_equal(buy_ticket(13),”10$”)assert_equal(buy_ticket(59),”10$”)assert_equal(buy_ticket(60),”9$”)assert_equal(buy_ticket(61),”9$”)

Read Details

Posts pagination

Newer posts 1 … 15 16 17 18 19 … 94,155 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top