this file is derived from exercise 0
#1. Variables and data types
1.1 operator
Some relational operators:
Symbol | Task Performed |
---|---|
== | True, if both sides are equal |
!= | True, if both sides are not equal |
< | True, if the left side is smaller |
> | True, if the left side is greater |
<= | True, if the left side is smaller or equal to the right side |
>= | True, if the left side is greater or equal to the right side |
1.2 basic functions
- print()
x = "Hello"
y = "World"
print (x + y)
# "HelloWorld"
- type(variable)
- str(variable)
- len(variable)
2. Data Structures
2.1 List
List can contain datas with same or different types, List is mutable.
lol = [[1,2,3], ["a","b","c"], [1.2,2.3,4.5,6.7,8.9]]
- lol.append(value)
- x = lol.pop(), pop out the last element of lol
- lol.length()
2.2 Tuple
Tuples are just the same as lists, but are immutable.
t = (1,2,3)
t1 = ((1,2),(1,3),3)
2.3 Set
Sets are similar collections, but have no order and can contain each element only once.