hello friends! new(ish)!
Python: Difference between revisions
>Beer mNo edit summary |
>Beer mNo edit summary |
||
Line 30: | Line 30: | ||
As you can see, we used the variable in the print() function and ''concatinated'' it with the rest of the string "Wolrd!". | As you can see, we used the variable in the print() function and ''concatinated'' it with the rest of the string "Wolrd!". | ||
[[Category:Programming]] |
Revision as of 16:30, 30 January 2014
Python is a wicked cool interpreted scripting language that a lot of people start their programming journeys with. It has an easy to read, dynamically typed syntax that appeals to beginners and people who suffer from great sloth.
Basic Examples
The basics of Python are to start a file with the path of the interpreter. If you have written code in BASH, Perl or Ruby you will recognize the opening line.
#!/usr/bin/python
To run your python application, you have two methods. If you are using a UNIX based operating system you can use the `chmod` command to make the file executable, or pass it as an argument to the python interpreter.
$ chmod +x my_file.py && ./my_file.py
Alternatively:
$ python my_file.py
Printing
Printing to the screen is always the most basic introduction to a programming language.
#!/usr/bin/python print("Hello World!")
Variables
Variables are a way of representing data with human-readable names.
#!/usr/bin/python my_variable = "Hello " printf(my_variable + "World!")
As you can see, we used the variable in the print() function and concatinated it with the rest of the string "Wolrd!".