Order Online
You can learn to program using Python
- No experience necessary to begin learning to writing programs using python. -
Rapid Python Programming' will take you from from absolute beginner to being able to write basic Python in a very short time.
Basics
This tutorial will teach you the basics of Python in 10 minutes. Consider this a cheatsheet to get up to speed quickly with Python.
Obviously, if you really want to learn a language you need to program in that language for a while. My book will help you with that. Chances are python might already be installed if you run Linux or Apple. If you run windows you can download at python.org. After you have downloaded and installed python. You can acces the python via the "command prompt" or "terminal".
When you type 'python' in the terminal you will see the following 'greater than' symbols in the screen.
>>>
This is known as the 'interpreter', and you can begin writing python code.
To exit out of this scree type quit()
>>>quit()
Getting Help
>>>help(3)
Help on int object:
class int(object)
...
..
.
(etc)
If you want detail about how an object works. All you need to do is type 'help()'. You can get a list of all objects with 'dir()'.
Variable and String
>>>myvar=40
>>>myvar+=2
>>>myvar
42
>>>mystring="Hello"
>>>mystring += " world."
>>>print(mystring)
Hello world.
# This is a comment
"""multiline
comment"""
Data types
>>> mydata = [1, ["list1", "list2"], ("my", "tuple")]
>>> mylist = ["List item 1", 2, 9.99]
>>> mylist[0] = "New list" # change first field
>>> mylist
['New list',2,9.99]
>>> mylist[-1] = 10 # Here, we refer to the last item.
>>> mylist
['New list',2,10]
>>> mydict = {"Key": "Val", 1: 20, "pi": 3.14}
>>> mydict["pi"] = 3.15 # change dictionary
>>> mydict
{1: 20, 'pi': 3.15, 'Key': 'Val'}
>>> mytuple = (1, 2, 3)
>>> myfunction = len
>>> print(myfunction(mylist))
3
If you find this interesting. The first part of the book is free here online
To post a comment you need to login first.