User Tools

Site Tools


python

Work in Progress
Current tuturial: https://docs.python.org/3/tutorial/introduction.html

Python

Python is a powerful coding tool. there are many ways to start python or write in python.

  • $python
  • This will start the python comand console
  • Ctl+D to exit (like ctl+C for bash)

Some basics

  • #is the comment operator

value types

  • int
  • float
  • (more on this another time)

assign variables

Can do simple variable subs with =

  • >widht = 20
  • >height = 20
  • >width * height
  • 400

Also you can create multple assingments with , in both sides of =

  • >a, b = 0, 1

Output text

There are a lot of rules about printing text. Here are some basics.

  • print is the most common command, and followed by ('…')
  • >print('how cool')
  • >how cool
  • Quotes "" or '' will output ticket. If you want quotes you have to do them in ''
  • >'“yes” he said'

Special Charactors

When you want to indicate spaces, or chars that normally are used as an interpreter, put a \ before. As in:

  • >'Isn\'t it great'

To not interpret \ as a line, put r before quotes

  • >pint
python.txt · Last modified: 2017-03-03 T 17:14 (external edit)