Created by Juan Manuel Torres / @onema
What is GitHub?
Computer programs are collections of instructions that tell a computer how to interact with the user, the computer hardware or process data [1]
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. [Used ] for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.
Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance.
Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed. [2]
http://redac.socialinput.fr/wp-content/uploads/2013/01/Albino_Burmese_Python.jpg
"Hello, World!"
The "Hello, World!" program is the simplest program you can write in any programming language. All it does is output "Hello, World!" [3]
"Hello, World!"
#!/usr/local/bin/python3.5
print('Hello, World!')
With our project there is a sample 01hello.py file
Function to "print" to the screen
Anything in the quotes is a "string"
Used before the script is run, ignored my python
A variable is a storage location associated with a name. Variables contain an unknown quantity or information called value [4]
# 01variables.py
variable = 'Juan'
print(variable)
print(type(variable))
print(id(variable))
variable = 1
print(type(variable))
print(id(variable))
variable = 1234.5678
print(type(variable))
Variables names must start with a letter or an underscore, such as:
The remainder of your variable name may consist of letters, numbers and underscores.
Names are case sensitive.
#!/usr/local/bin/python3.5
# 03variables.py
name = 'Juan'
numbers = 12345
hello = 'Hello, {0}! {1}'.format(name, str(numbers))
print(hello)
A Data Type Is classification identifying one of various types of data [6]
Python defines several data types [7]
#!/usr/local/bin/python3.5
# 04datatypes.py
print(type(True))
print(type(12345))
print(type(5678.90123))
print(type([1, 2, 3]))
print(type({'a': 1, 'b': 2, 'c': 'something'}))
An operator in a programming language is a symbol that tells the [computer] to perform specific mathematical, relational or logical operation and produce final result. [8]
An operator is something that takes one or more values (or expressions, in programming jargon) and yields another value. [9]
-a | Negation | Opposite of a. |
a + b | Addition | Sum of a and b. |
a - b | Subtraction | Difference of a and b. |
a * b | Multiplication | Product of a and b. |
a / b | Division | Quotient of a and b. |
a % b | Modulus | Remainder of a divided by b. |
a ** b | Exponentiation | Result of raising a to the b'th power. |
#!/usr/local/bin/python3.5
# 05operators.py
a = 1;
b = 2;
three = a + b;
print(three)
The assignment operator "=" is used to assign a value to a variable. It is not used to compare!
$a == $b | Equal | TRUE if $a is equal to $b |
$a === $b | Identical | TRUE if $a is equal to $b |
$a != $b | Not equal | TRUE if $a is not equal to $b |
$a !== $b | Not identical | TRUE if $a is not equal to $b |
$a < $b | Less than | TRUE if $a is strictly less than $b . |
$a > $b | Greater than | TRUE if $a is strictly greater than $b . |
$a <= $b | Less than or equal to | TRUE if $a is less than or equal to $b . |
$a >= $b | Greater than or equal to | TRUE if $a is greater than or equal to $b . |
#!/usr/local/bin/python3.5
# 06comparison_operators.py
print(1 == 2) # FALSE
print(1 < 2) # TRUE
print(1 <= 2) # TRUE
print(2 > 2) # FALSE
print(2 >= 2) # TRUE
print(1 == True) # TRUE
print(1 != True) # FALSE
The assignment operator "=" is used to assign a value to a variable. It is not used to compare!
Write a program that does the following:
Juan Manuel Torres | @onema