Complete Task 2: odd_or_even()
1) Complete the odd_or_even() function.
Mark Breakdown
2) 2 additional doctests are created
a) Doctest output is accurate (0.5 marks x 2 = 1 mark)
b) Doctest passes (0.5 marks x 2 = 1 mark)
3) Does function pass all assignment doctests provided? (0.4
marks x 5 = 2 marks)
Edef odd_or_even(data): 27 28 29 II III 30 31 32 33 This function determines either a) if the numerical value is odd or even b) if the number of characters of a string is odd or even c) if the number of elements in a list or tuple is add or even d) If any other data type, there is no return :param data: either a number, string, list or tuple (all four data types must be acceptable) :return: either the text "odd" or "even" or no return 34 35 36 37 38 39 40 41 >>> odd_or_even("hello world") 'odd' >>> odd_or_even(1234) 'even' >>> odd_or_even (12.34) 'even'. >>> odd_or_even(list(range(2, 11))) 'odd' >>> odd_or_even(tuple("cool")) 'even' 42 43 44 45 46 47 Add 2 more Doctests 48 49 E 50 51 A pass # code goes here. Replace 'pass' with your own python code
Complete Task 2: odd_or_even() 1) Complete the odd_or_even() function. Mark Breakdown 2) 2 additional doctests are creat
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am