for each hour worked over 50 hours, the employee earns 2.0 times his hourly wage The function calculates and returns the total pay for the person. For instance, for 54 hours worked at a wage of $8.25 per hour, the function would compute the total pay as $519.75. CSE 101 – Spring 2017 Midterm Exam 1 Practice Problems Page 7 of 9
19. Write a Python function multiples of 3(low, high) that returns a list containing all of the values from low through high (inclusive) that are evenly divisible by 3, and only those values. For example, if low is 5 and high is 21, the function returns the list [6, 9, 12, 15, 18, 21] . 20. Write a Python function shortest(names) that takes a list of strings containing all the first names of undergraduate students at Stony Brook and returns the shortest name in the list that is at least five characters long. If two or more names have the same shortest length, then the function may return any one of them. Assume that there is at least one name in the list that has at least five characters. Also assume that no name in the list has more than 20 characters in it. Your function should work for a list that could have hundreds or even thousands of names in it. For example, if the names argument were [’Fred’, ’Pauline’, ’Jennifer’, ’Tom’] , the func- tion would return ’Pauline’ because that is the shortest name that has at least five characters in it. CSE 101 – Spring 2017 Midterm Exam 1 Practice Problems Page 8 of 9
21. Write a Python function one copy(nums) that takes a list of integers as its argument and returns a list containing exactly one instance of each number appearing in the argument. In other words, the duplicated values are eliminated. For example, if the list nums were [8, 6, 7, 4, 2, 6, 9, 8, 7, 3, 4, 2] , the returned list would contain only the seven values 8, 6, 7, 4, 2, 9 and 3 (in any order) with no duplicated values. CSE 101 – Spring 2017 Midterm Exam 1 Practice Problems Page 9 of 9
You've reached the end of your free preview.
Want to read all 9 pages?
- Fall '14
- Wind chill