# SMC Wizard Documentation File
# Copyright: SageMathCloud Authors, 2015
# License:   Creative Commons: Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)

language: python
category: Language / Tutorial
---
title: Hello World
descr: The "Hello World" program
code: print "Hello World"
---
title: Variables
descr: >
    A variable is a name for an object.
    It is done via this syntax:

    ```
    variablename = object
    ```
code: |
    x = 1
    y = x + 1
    print x
    print y
---
title: Print Data
descr: The "Hello World" program printing some values.
code: |
    x = "Hello"
    y = 2.123456789
    print "%s World, y = %f" %(x, y)
    print "x={x}, y={y:.3f}".format(**locals())
---
title: Expressions
descr: Expressions are evaluated, they can consist of operators and function calls.
code: |
    print (5 + 6) * 11
    z = 3
    print (1 + z)**2
    from math import sqrt
    print sqrt(z)
---
title: Functions
descr: >
    A function call is one of the most basic levels of abstraction.
    A common subroutine of evaluations is run with varying initial arguments.
    The `return` statement is very important: data flows back to where the functions has been called.
code: |
    def function1(x, y):
        z = 10 * x + y
        return z

    print function1(4, 5)
    print function1(1,-1)
---
title: "Data Structure: List"
descr: >
    To organize the information in a program, data structures come to help.
    A very basic one is an ordered collection of arbitrary objects.
code: |
    x = [42, "Hello", [1,2,3]]
    print x
    x.append("World")
    print x
---
title: "Data Structure: Dict(ionary)"
descr: >
    A dictionary is an mapping of (immutable) objects to arbitrary objects.
    The immutable objects are called "keys" and are most commonly numbers, strings or tuples.
code: |
    d = dict()
    d[42] = "The Answer"
    d["what"] = ["this", "and", "that"]
    d[(4,2)] = 99
    print d[(4,2)]
    print d.keys()
    print 42 in d