Skip to content

Instantly share code, notes, and snippets.

@prodeveloper
Last active February 3, 2017 11:50
Show Gist options
  • Select an option

  • Save prodeveloper/22e6a0af3bfdaf0bcd11ba4e3065e066 to your computer and use it in GitHub Desktop.

Select an option

Save prodeveloper/22e6a0af3bfdaf0bcd11ba4e3065e066 to your computer and use it in GitHub Desktop.
Working with Python scripts in c9

Today we will be saving our python scripts so that we can access them later.

Python scripts are text files that contain python code. Their filenames are appended with ".py

To create a script select create a new file

 photo Screen Shot 2017-02-02 at 15.50.27_zps0cinsxdq.png

Select to save the file

 photo Screen Shot 2017-02-02 at 15.52.04_zpswlzb4tdd.png

Save the file as test.py

 photo Screen Shot 2017-02-02 at 15.52.53_zps2em7xlhq.png

Type into the file a python command such as
print ("My name is Lovelace")

 photo Screen Shot 2017-02-02 at 15.55.46_zpshbnpsruy.png

Then save the file using the shortcut "CNTRL + S".

This file can now be run using pythons interpreter.

You can then run it by typing into the terminal

python3 test.py

 photo Screen Shot 2017-02-02 at 15.57.35_zpsnrjoiym9.png

- Create a new script with your name eg "chencha.py" - Make the script print out your name

##How to name your files

  • modules (filenames) should have short, all-lowercase names, and they can contain underscores;
  • packages (directories) should have short, all-lowercase names, preferably without underscores;

##Assignment

Write a python script called "assignment.py" that when run outputs to the screen the following:

My name is Chencha
When you multiply 570 by 843 you get 480510
THIS STRING WAS SAVED IN LOWER CASE BUT NOW IS IN UPPER

##References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment