Python for Babies
19:461) Hello World!
Python is a very simple language, and has a very straightforward syntax. It encourages programmers to program without boilerplate (prepared) code. The simplest directive in Python is the "print" directive - it simply prints out a line (and also includes a newline, unlike in C).Indentation
Python uses indentation for blocks, instead of curly braces. Both tabs and spaces are supported, but the standard indentation requires standard Python code to use four spaces. For example:
Use the "print" command to print the line "Hello, World!".
2) Variables and Types
Python is completely object oriented, and not "statically typed". You do not need to declare variables before using them, or declare their type. Every variable in Python is an object.
Numbers
Python supports two types of numbers - integers and floating point numbers.
Strings
Strings are defined either with a single quote or a double quotes.
1) Single Quotes
2) Double Quotes
3) List
Lists are very similar to arrays. They can contain any type of variable, and they can contain as many variables as you wish. Lists can also be iterated over in a very simple manner. Here is an example of how to build a list.
0 comments