How to run this script in a mac terminal

0 Ash Marz · June 20, 2015
Enter the number of seconds: 8679

>>> minutes = seconds // 60
>>> hours = minutes // 60
>>> print ( seconds, "seconds is", hours, "hours and", minutes )
8679 seconds is 2 hours and 144

Post a Reply

Replies

Oldest  Newest  Rating
+2 alex constantin · June 20, 2015
Make a .py file containing this code, and then in terminal, do 

python3 "FILEDIRECTORY"

Where it says <FILE DIRECTORY>, just drag in the python file into terminal and it will autocomplete the directory.

Or, just cd to the directory the file is in and do: python3 file.py
0 Ash Marz · June 21, 2015
/images/forum/upload/2015-06-21/9c81f3459071b4f0d5464b83fff0b1cc.png
0 Ash Marz · June 21, 2015
it gives me this error
0 Ash Marz · June 21, 2015
/images/forum/upload/2015-06-21/d0e51671c36d7a0a0828d712467e2472.png
0 Ash Marz · June 21, 2015
Why does the python 3 file save like this, it also saves the syntax errors and other unnecessary things. How to make it only save the source code
+1 alex constantin · June 21, 2015
seconds = int(input("Enter the number of seconds: "))
hours = seconds/3600
hours = round(hours, 1)

print(hours)

minutes = round(hours % 1 * 60, 2)
print("{s} seconds is {h} hours and {m} minutes".format(s=seconds, h=hours, m=minutes))


Go in IDLE, then click File > New File (or CMD+N) and copy/type the code there. Save it anywhere and then click F5 to run
  • 1

Python

107,358 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator