Professional Documents
Culture Documents
PYTHON
PYTHON
Basic Knowledge
Indentation is necessary.
DataTypes
Number
Int
Long
Float
Complex
String
List
Tuple
Dictionary
Lists
list = [a, b, c, d, e]
Syntax for list is [], and the elements in lists can be of any data type such as integers, strings, float
etc.
The index number in lists starts from 0 such as from the above example ‘a’ has the index number 0
and b has the index number 1 and so on…..
Dictionary
As the name suggests the dictionary stores data and it is denoted by {}. The dictionary in Python
contains Keys and Values, here the values are the definition or value of the keys. Dictionary can
contain all Data types but hey have to be specified in “”/’’.
Functions
Too lazy to define.
Syntax:
def mean(Parameter):
calc = sum(parameter)/len(Parameter)
return calc
How to calculate mean using a function and the values are taken from a dictionary
def mean(Parameter):
calc = sum(parameter.value())/len(Parameter.value())
return calc
Value
example = [1 , 3, 5, 6]
print(type(example))
OUTPUT :
If and else
Syntax:
X=1
If x == 1:
print (“Yes”)
else:
print(“No”)