Question

Don't understand why code isn't running properly

Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options Window Help #Declare a variab i e and initialize

В Python 3.7.0 Shell File Edit Shell Debug Options Window Help Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v



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

CODE:

def displayInstructions(langCode):
   # corrected code
   ENGLISH_PROMPT = "Please enter your weight in pounds >> "
   SPANISH_PROMPT = "Por favor entre en su peso en libras >> "
   if langCode == 1:   print(ENGLISH_PROMPT)
   elif langCode == 2: print(SPANISH_PROMPT)
   else:               print("Stop")

# changes made to the design of the code
print("1 - English or 2 - Espanol >> ")
code = int(input("Enter code for instuctions "))
displayInstructions(code)
weight = input()
MOON_FACTOR = 0.166
moonWeight = float(weight) * MOON_FACTOR

if code == 1:   print("Your weight on the moon would be %.2f" %moonWeight)
elif code == 2: print("Su peso en la lune seris %.2f" %moonWeight)
else:           print("Stop")

def display! nstructions (dangcode) : # corrected code ENGLISH PROMETPlease enter your weight in pounds > SPANISH PROMPT Po

OUTPUT:

c:IvenvlScripts python.exe C:/Users/Arka/Dropbox/python/test.py 1English or 2 Espanol Enter code for inst Please enter your w

Add a comment
Know the answer?
Add Answer to:
Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options...
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
  • What is wrong with my python code. I am receiving this error: Traceback (most recent call...

    What is wrong with my python code. I am receiving this error: Traceback (most recent call last): File "C:/Users/owner/Documents/numberfive.py", line 7, in if age > 18: TypeError: unorderable types: str() > int() My code is age= input("Enter your age:") if age > 18: print("You can vote.") else: print("You can't vote.") if age > 64: print ("You're a Senior Citizen...you deserve two votes") endofprogram = input("Please hit enter to exit from this program:")

  • CAN SOMEONE PLEASE EXPLAN FO ME WHATS WRONG WITH MY CODE WHEN EVEN I RUN IT...

    CAN SOMEONE PLEASE EXPLAN FO ME WHATS WRONG WITH MY CODE WHEN EVEN I RUN IT IT GIVE ME THIS MASSAGE IM USING python BTW Traceback (most recent call last):                                                                                                                                                 File "../resource/asnlib/public/RUN.py", line 20, in <module>                                                                                                                      exec(source_code, dict())                                                                                                                                                      File "<string>", line 60, in <module>                                                                                                                                          NameError: name 'total_rough_sod' is not defined ) from math import pi length = float(input('Enter Course Length:')) width = float(input('Enter Course Width:')) def calculate_smooth_sod(width): grean_area_raduis= (width/2)/2 total_smooth_sod=2*pi*(grean_area_raduis**2) return total_smooth_sod def calculate_sand_trap_area(width): sand_trap_radius=(width/3)/2 sand_trap_area=pi*(sand_trap_radius**2) return sand_trap_area def calculate_rough_sod(length,...

  • Hi, can someone offer input on how to address these 4 remain parts the zybook python...

    Hi, can someone offer input on how to address these 4 remain parts the zybook python questions?   4: Tests that get_num_items_in_cart() returns 6 (ShoppingCart) Your output ADD ITEM TO CART Enter the item name: Traceback (most recent call last): File "zyLabsUnitTestRunner.py", line 10, in <module> passed = test_passed(test_passed_output_file) File "/home/runner/local/submission/unit_test_student_code/zyLabsUnitTest.py", line 8, in test_passed cart.add_item(item1) File "/home/runner/local/submission/unit_test_student_code/main.py", line 30, in add_item item_name = str(input('Enter the item name:\n')) EOFError: EOF when reading a line 5: Test that get_cost_of_cart() returns 10 (ShoppingCart)...

  • I'm making a To-Do list in Python 2 and had the program running before remembering that...

    I'm making a To-Do list in Python 2 and had the program running before remembering that my professor wants me to put everything in procedures. I can't seem to get it to work the way I have it now and I can't figure it out. I commented out the lines that was originally in the working program and added procedures to the top. I've attached a screenshot of the error & pasted the code below. 1 todo_list = [] 2...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • For my computer class I have to create a program that deals with making and searching...

    For my computer class I have to create a program that deals with making and searching tweets. I am done with the program but keep getting the error below when I try the first option in the shell. Can someone please explain this error and show me how to fix it in my code below? Thanks! twitter.py - C:/Users/Owner/AppData/Local/Programs/Python/Python38/twitter.py (3.8.3) File Edit Format Run Options Window Help import pickle as pk from Tweet import Tweet import os def show menu():...

  • I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to...

    I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to guess its because I'm not using the swap function I built. Every time I run it though I get an error that says the following Traceback (most recent call last): File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 146, in <module> main() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 122, in main studentArray.gpaSort() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py",...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • Programming language: PYTHON Prompt: You will be creating a program to show final investment amounts from...

    Programming language: PYTHON Prompt: You will be creating a program to show final investment amounts from a principal using simple or compound interest. First, get a principal amount from the user. Next, ask the user if simple or compound interest should be used. If the user types in anything other than these options, ask again until a correct option is chosen. Ask the user to type in the interest rate as a percentage from 0 to 100%. Finally, ask the...

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