Today took a first step towards learning Data Science.
In Python, we learned about few methods like print(),id() etc, and about Mutable & Immutable variable types.
Method Print() Syntax:
<>print(value)
value
Method id() Syntax:
<>id(variable_name)
1023432 #memory address
Variable always refers to the memory reference and not to the value.
Variable type like Integer, float and Boolean are of Immutable Type.
In Immutable variable type value cant be changed and only one instance of memory is created but shall be referred to with n number of variables.
eg: a = "20" , age = "20" , number = "20"
Variable types like Strings, Lists are Mutable, meaning could be changed.
Data structure type List:
Syntax:
<>Fruits = ["apple","mango","kiwi"]
As mentioned above in the list data structure a list of values could be stored in an order and could be referred to a particular value by indexing, index 0 refers to the first value in the List and progressively 1,2,3 etc refers to the next consecutive values.
Negative indexing also is there and index -1 refers to the last value in the List and -2, -3 refers to the consecutive values from the last.
<>Fruits[2]
kiwi
<>Fruits[-2]
mango
Data Structure type Dictionary:
key (immutable only):value(mutable/immutable)
Syntax
<> subjects = {}
Top comments (0)