Answered step by step
Verified Expert Solution
Question
1 Approved Answer
part a please [10] 4. (a) Write a Python or MATLAB function that when given a number between 0 and 9 outputs a character string
part a please
[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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started