You are on page 1of 3

PYTHON

Basic Knowledge

Python was created by Guido Van Rossum on February 20,1991.

Python is popular because of its simplified syntax and ease of learning.

Python is case sensitive.

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.

In lists for every element/object there is an index number.

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

Dictionary = {“Mark” : 14, “John” : 17, “Mary” : 15}

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:

How to calculate mean using a function

def mean(Parameter):

calc = sum(parameter)/len(Parameter)

return calc

THE ABOVE IS ALSO USEFUL FOR LISTS

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 :

list (not exactly but it does tell the type of example)

If and else

Syntax:

X=1

If x == 1:

print (“Yes”)

else:

print(“No”)

You might also like