Question: part b please in python [10] 4. (a) Write a Python or MATLAB function that when given a number between 0 and 9 outputs a
part b please in python
![part b please in python [10] 4. (a) Write a Python or](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4e35b14479_01866f4e35aa2deb.jpg)
[10] 4. (a) Write a Python or MATLAB function that when given a number between 0 and 9 outputs a character string for the word representation of that number. For example, an input of 1 should return the character string 'one', an input of 2 should return two' etc. Your function should check whether the number inputted is an integer between 0 and 9 and print a suitable error message if not. (b) Write a Python or MATLAB program that defines an integer variable x which is equal to your ID number and prints a string of words representing each digit of that number. For example, if your student ID number is 21012345 then your program should output [15] two, one, zero, one, two, three, four, five, Hint: you might find the following commands for converting between numbers and strings useful for answering part (b): Function Python MATLAB convert a number to a string str(x) string(x) convert a string to an integer int(string) str2num(string)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
