Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

hello, I was trying to run this code, but I get an error and I can't find it

Two Trains Runnin'.py .
Two Trains Runnin'.py > ...
1 import math
2
3
4
5
6
7
8
9
10
11
12
13
14
def main():
X=int (input("Enter number of miles (X) before right turn: "))
Y=int (input("Enter number of miles (Y) after right turn: "))
distancefromstation = math.sqrt(X*X+Y*Y) # compute distance from station using Pythagorean theorem
print("The distance traveled by train (as a string) = ", str(distance fromstation))
if
print("The distance traveled by train (round nearest tenth) = ", round (distance fromstation, -1))
print("The distance traveled by train (floating point value upto 2 decimal place) = %.2f"%(distance fromstation))
print()
print("The distance one train is from the other = ",str(2*distance fromstation))
print("The distance one train is from the other (round nearest tenth) = ",round (2*distance fromstation, -1))
print("The distance one train is from the other (floating point value upto 2 decimal place) = %.2f"%(2*distance fromstation))
___name__ == "__main__":
main() # calling of main function |
PROBLEMS OUTPUT TERMINAL JUPYTER DEBUG CONSOLE
PS C:\Users\Justin\Desktop\computer prgraming fundamenal> & C:/Users/Justin/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Justin/Desktop/computer prgraming fundamenal/Two Trains Runnin'.py"
Enter number of miles (X) before right turn: & C:/Users/Justin/AppData/Local/Programs/Python/Python310/python.exe "C:/Users/Justin/Desktop/computer prgraming fundamenal/Two Trains Runnin'.py"
Traceback (most recent call last):
File "c:\Users\Justin\Desktop\computer prgraming fundamenal\Two Trains Runnin'.py", line 14, in <module>
main() # calling of main function
File "c:\Users\Justin\Desktop\computer prgraming fundamenal\Two Trains Runnin'.py", line 3, in main
X-int(input("Enter number of miles (X) before right turn: "))
ValueError: invalid literal for int() with base 10: '& C:/Users/Justin/AppData/Local/Programs/Python/Python310/python.exe "C:/Users/Justin/Desktop/computer prgraming fundamenal/Two Trains Runnin\'.py"'
PS C:\Users\Justin\Desktop\computer prgraming fundamenal>
expand button
Transcribed Image Text:Two Trains Runnin'.py . Two Trains Runnin'.py > ... 1 import math 2 3 4 5 6 7 8 9 10 11 12 13 14 def main(): X=int (input("Enter number of miles (X) before right turn: ")) Y=int (input("Enter number of miles (Y) after right turn: ")) distancefromstation = math.sqrt(X*X+Y*Y) # compute distance from station using Pythagorean theorem print("The distance traveled by train (as a string) = ", str(distance fromstation)) if print("The distance traveled by train (round nearest tenth) = ", round (distance fromstation, -1)) print("The distance traveled by train (floating point value upto 2 decimal place) = %.2f"%(distance fromstation)) print() print("The distance one train is from the other = ",str(2*distance fromstation)) print("The distance one train is from the other (round nearest tenth) = ",round (2*distance fromstation, -1)) print("The distance one train is from the other (floating point value upto 2 decimal place) = %.2f"%(2*distance fromstation)) ___name__ == "__main__": main() # calling of main function | PROBLEMS OUTPUT TERMINAL JUPYTER DEBUG CONSOLE PS C:\Users\Justin\Desktop\computer prgraming fundamenal> & C:/Users/Justin/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/Justin/Desktop/computer prgraming fundamenal/Two Trains Runnin'.py" Enter number of miles (X) before right turn: & C:/Users/Justin/AppData/Local/Programs/Python/Python310/python.exe "C:/Users/Justin/Desktop/computer prgraming fundamenal/Two Trains Runnin'.py" Traceback (most recent call last): File "c:\Users\Justin\Desktop\computer prgraming fundamenal\Two Trains Runnin'.py", line 14, in <module> main() # calling of main function File "c:\Users\Justin\Desktop\computer prgraming fundamenal\Two Trains Runnin'.py", line 3, in main X-int(input("Enter number of miles (X) before right turn: ")) ValueError: invalid literal for int() with base 10: '& C:/Users/Justin/AppData/Local/Programs/Python/Python310/python.exe "C:/Users/Justin/Desktop/computer prgraming fundamenal/Two Trains Runnin\'.py"' PS C:\Users\Justin\Desktop\computer prgraming fundamenal>
Write python code that will figure out the below scenario.
Two trains leave the station going in the opposite direction. At X miles from the station, each train makes a right turn and travels Y miles to the destination. How far are the destinations from each other?
Y Miles
X Miles
X Miles
⠀⠀
Y Miles
You will need to use the Pythagorean theorem to solve this problem.
Note that there are two right triangles in this diagram.
1. Calculate the distance that one is (dotted line) from the other.
2. Print the distance each train traveled and the distance one train is from the other.
3. Show the variables output in a string, an integer and a floating point decimal. Label each as such.
4. Round your answer to the nearest tenth.
expand button
Transcribed Image Text:Write python code that will figure out the below scenario. Two trains leave the station going in the opposite direction. At X miles from the station, each train makes a right turn and travels Y miles to the destination. How far are the destinations from each other? Y Miles X Miles X Miles ⠀⠀ Y Miles You will need to use the Pythagorean theorem to solve this problem. Note that there are two right triangles in this diagram. 1. Calculate the distance that one is (dotted line) from the other. 2. Print the distance each train traveled and the distance one train is from the other. 3. Show the variables output in a string, an integer and a floating point decimal. Label each as such. 4. Round your answer to the nearest tenth.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education