229k views
0 votes
Write a function, stringify_digit that takes a single digit (integer) and returns the corre-sponding digit as a string. For example, stringify_digit(9) returns "9" and stringify_digit(0)returns "0". You may assume that only the digits 0 to 9 will be passed in as argumentsto your function. You may not use the str() function for this function.

1 Answer

3 votes

Answer:

The function in Python is as follows:

def stringify_digit(digit):

dig = "%s" % digit

return dig

Step-by-step explanation:

This defines the function

def stringify_digit(digit):

This converts the input parameter to string

dig = "%s" % digit

This returns the string equivalent of the input parameter

return dig

User Oneman
by
4.1k points