Question

Write a PYTHON program that does the following: (instructions in the picture) Please use a 3.5...

Write a PYTHON program that does the following: (instructions in the picture) Please use a 3.5 version; You can use this website to write the code and then share the link here; because if you write the code and post here, it will have a problem with the indentations

https://repl.it/languages/python3Write a PYTHON program that does the follow

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the code for you:

#!/usr/bin/python
def numberSpelling(number):
num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \
6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \
11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \
15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \
19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \
50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \
90: 'Ninety', 0: 'Zero'}
output = '';
if number >= 100:
return num2words[number / 100] + ' hundred ' + numberSpelling(number % 100)
elif number >= 20:
return num2words[number / 10 * 10] + ' ' + numberSpelling(number % 10)
elif number >= 1:
return num2words[number]
else:
return 'zero'
  
  
def charCount(number):
return len(numberSpelling(number)) - numberSpelling(number).count(' ')
number = input('Enter an integer between 0 - 1000: ')
if(number < 0 or number > 1000):
print 'Invalid range.'
else:
while(charCount(number) != 4):
print numberSpelling(number), ' is ', charCount(number), '.'
number = charCount(number)
print numberSpelling(number), ' is ', charCount(number), '.'
print 'four is magic.'
  

Add a comment
Know the answer?
Add Answer to:
Write a PYTHON program that does the following: (instructions in the picture) Please use a 3.5...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the PYTHON code that displays the following numbers: The program should have a header that...

    Write the PYTHON code that displays the following numbers: The program should have a header that displays "Number   Doubled Tripled" above the start of the numbers. If putting all numbers on the same line, then they will need to be separated so you can see he individual number.(https://www.programiz.com/python-programming/methods/built-in/print) The program should display Every whole number from 1 through 35. The program should display that number doubled. The program should also display that number tripled. Make a working version of this...

  • To be done in C++ BER PROGRAMMING CONTENT: Submission request: For each program below: supply a...

    To be done in C++ BER PROGRAMMING CONTENT: Submission request: For each program below: supply a copy of the source code provide a screenshot of the output W if you use an online compiler like onlinegdb.com, the link of your final code. 4) (10 points) Static Variables Go to the following link (https://onlinegdb.com/HJd49mBcm) and fork the code so that you can write your own version of the function discount ( to achieve the goal as described in the comments. As...

  • Write a python program that does the following. a. It asks the user to enter a...

    Write a python program that does the following. a. It asks the user to enter a 5-digit integer value, n. b. The program reads a value entered by the user. If the value is not in the right range, the program should terminate. c. The program calculates and stores the 5 individual digits of n. d. The program outputs a “bar code” made of 5 lines of stars that represent the digits of the number n. For example, the following...

  • Complete the following python code, which involves use of classifiers (Statistics), SVM, epochs etc. Here are...

    Complete the following python code, which involves use of classifiers (Statistics), SVM, epochs etc. Here are the links (since I cannot upload the files here), Link for the data, (Don't use the one in the image) https://d1b10bmlvqabco.cloudfront.net/attach/idphd26a9rn2qv/gxjojd6rfmg22j/igwmr3eloj57/wdbc.data Link for the .py file (used for part A and part B) https://d1b10bmlvqabco.cloudfront.net/attach/idphd26a9rn2qv/gxjojd6rfmg22j/ih0v1nmyhwmr/svm.py Link for the .py file (used in part C) https://d1b10bmlvqabco.cloudfront.net/attach/idphd26a9rn2qv/gxjojd6rfmg22j/igwmq2mvn8v/svm_test.py INSTRUCTIONS: There are a bunch of TODO's in the .py files above to complete. Most of the code is already...

  • Please help with this python turtle problem using the functions provided. Python Turtle Write a program...

    Please help with this python turtle problem using the functions provided. Python Turtle Write a program using the turtle module to draw the face of a clock that looks like the image below. You will need to use the turtle module for this exercise as well as the bgcolor), shape(), color), penup), right(), forward(), pendown(), and stamp() functions. The code below can be removed or changed as needed. import turtle t turtle.Turtle0 t.forward(75)

  • Write the code in PYTHON and please provide the full code, thank you! Write a program...

    Write the code in PYTHON and please provide the full code, thank you! Write a program that plots two functions: f(x) = x2 and g(x) = ax. Write it in such a way that the intersection points are marked with an X, for arbitrary a. • You may use your favorite ready-made function to find the intersection points, if not: • One possible way to tackle this problem is to put both function values in arrays and check using a...

  • 1. Please write the following in Python 3 code. Also, write code and not psedo code....

    1. Please write the following in Python 3 code. Also, write code and not psedo code. Also, show all outputs and share your code. Question: Create one conditional so that if “Friendly” is in w, then “Friendly is here!” should be assigned to the variable wrd. If it’s not, check if “Friend” is in w. If so, the string “Friend is here!” should be assigned to the variable wrd, otherwise “No variation of friend is in here.” should be assigned...

  • Consider python please for this problem: I did a python program to read the first 20 lines from a...

    Consider python please for this problem: I did a python program to read the first 20 lines from a file and here is the code holder = 20 lines = 3 file = "123456.pssm" _file = ".txt" while 1:         out_file = input("[OUTPUT] - Please enter the name of file: ") + _file         if (not _file):         print("Filename not specified - Please Try Again\n")         continue     break with open(_file, "a") as e:     with open(file, "r") as f:         for num, line in enumerate(f, 1):                        ...

  • write a c program that does not output anything, whose execution time is 1 second (use...

    write a c program that does not output anything, whose execution time is 1 second (use nested loops). Then convert the program to Python, and run it using the Python interpreter. How long does the Python version take?

  • Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/...

    Write a Python equivalent program for the Unix spell utility. You can use the dictionary at /usr/share/dict/words (if you machine does not have it, you can copy it from a Linux machine such as npu29). The minimum requirement is to check if each word in the file exists in the dictionary as is (case insensitive). Your spell checker should inlcude at least two features: 1. Check the simple plural forms (add s or es). 2. Check the simple verb past...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT