Write a python code that takes in an number 0-9 and prints out the word of the number. For example 1 would print out one. Below is the skeleton of the code that needs to be filled in.
| def num2string(num): | |
| """ | |
| Takes as input a number, num, and | |
| returns the corresponding name as a string. | |
| Examples: num2string(0) returns "zero", num2string(1)returns "one" | |
| Assumes that input is an integer ranging from 0 to 9 | |
| """ | |
| numString = "" | |
| ################################### | |
| ### FILL IN YOUR CODE HERE ### | |
| ### Other than your name above, ### | |
| ### this is the only section ### | |
| ### you change in this program. ### | |
| ################################### | |
| return(numString) | |
| def main(): | |
| nums = input('Enter a multi-digit number: ') | |
| newStr = "" | |
| for n in nums: | |
| word = num2string(int(n)) | |
| newStr = newStr + " " + word | |
| msg = 'In words, your number is:' + newStr + "." | |
| print(msg) | |
| #Allow script to be run directly: | |
| if __name__ == "__main__": | |
| main() |
def num2string(num):
"""
Takes as input a number, num, and
returns the corresponding name as a string.
Examples: num2string(0) returns "zero", num2string(1)returns "one"
Assumes that input is an integer ranging from 0 to 9
"""
numString = ""
numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
numString = numbers[num]
return numString
def main():
nums = input('Enter a multi-digit number: ')
newStr = ""
for n in nums:
word = num2string(int(n))
newStr = newStr + " " + word
msg = 'In words, your number is:' + newStr + "."
print(msg)
# Allow script to be run directly:
if __name__ == "__main__":
main()

Write a python code that takes in an number 0-9 and prints out the word of...
Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the program. The function should take number between 1 and 12 as a parameter and returns the corresponding month as a string. For example, if the parameter is 1, your function should return "January". If the parameter is 2, your function should return out "February", etc. def monthString(monthNum): """ Takes as input a number, monthNum, and returns the corresponding month name as a string. Example:...
In Python, revise this code. define convert(s): """ Takes a hex string as input. Returns decimal equivalent. """ total = 0 for c in s total = total * 16 ascii = ord(c if ord('0) <= ascii <= ord('9'): #It's a decimal number, and return it as decimal: total = total+ascii - ord('0') elif ord('A") <= ascii <= ord('F'): #It's a hex number between 10 and 15, convert and return: total = total + ascii - ord('A') + 10 else...
### Question in python code, write the code on the following program: def minmaxgrades(grades, names): """ Computes the minimum and maximujm grades from grades and creates a list of two student names: first name is the student with minimum grade and second name is the student with the maximum grade. grades: list of non-negative integers names: list of strings Returns: list of two strings """ def main(): """ Test cases for minmaxgrades() function """ input1 = [80, 75, 90, 85,...
Number 1) Which of the following statements imports a module into the default namespace? a. from temperature import * b. import temperature as t c. import temperature as temp d. import temperature Number 2) Which of the following statements imports a module into the global namespace? a.from temperature import * b. import temperature as temp c. import temperature as global d. import temperature Number 3) Code Example 4-2 def get_volume(width, height, length=2): volume = width * height * length...
How do I make my code print out the text in the ServiceNotifier class? Python Code: class ServiceNotifier: #Subject responsible for notifying registered observer objects Observer = [Email, SMS, Phone] def attach(self): #add new observer Observer.append(insertnewobserverhere) def dettach(self): #remove an observer Observer.pop(insertnewobserverhere) def servicenotifier(self): for observers in Observer: print("Due to the forecast for tomorrow, all university and campus operations will be closed.") ...
AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y): if x == True and y == True: return True else: return False def main(): x = bool(input("Please...
Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point. ////////////////////////////////////////////////////// from datetime import datetime class Famous_Person(object): def __init__(self, last, first, month,day, year): self.last = last self.first = first self.month = month...
This needs to be in python, however, I am having trouble with the code. Is there any way to use the code that I already have under the main method? If so, what would be the rest of the code to finish it? #Create main method def main(): #Create empty list list=[] #Display to screen print("Please enter a 3 x 4 array:") #Create loop for rows and have each entered number added to list for i in range(3): list.append([int(x) for...
write programs with detailed instructions on how to
execute.
code is java
What you need to turn in: You will need to include an electronic copy of your report (standalone) and source code (zipped) of your programs. All programming files (source code) must be put in a zipped folder named "labl-name," where "name" is your last name. Submit the zipped folder on the assignment page in Canvas; submit the report separately (not inside the zipped folder) as a Microsoft Word...
Write a program that does the following in Python Code: Write a new Class called Famous_Day_Born which is a subclass of Famous_Person. Add a method to calculate the day of the week the person was born and print out all of the corresponding information using the overridden print method. Use the following code below as a starting point. ////////////////////////////////////////////////////// from datetime import datetime class Famous_Person(object): def __init__(self, last, first, month,day, year): self.last = last self.first = first self.month = month...