Professional Documents
Culture Documents
Lecture 1.2
1. Backslash n (\n) is the character that is used to create the new line.
2. You can comment in python using a single hash (#) symbol at the beginning.
Lecture 1.3
Lecture 1.4
Variables :-
Input Statement (Let’s interact with the end user) :-
Lecture 1.5
Variables and Input Statements :-
Lecture 1.6
In code 2,
' r ' and ' area ' are variables.
The value of pi that is always 3.14 is the Literal.
Lecture 1.7
The command —> type(variable)<— prints the data type of the value that is stored in
the variable.
Additional info :-
Computers start counting from the number zero!
Lecture 1.8
The variable 'a' printed the value as 4 and not 4.5 , This is because we asked the
variable to store only integer values in it. So, it ignored the decimal part and stored the
integer part.
Similarly you can convert integer and float to string, give it a try!
The variable f is false because when computers convert integers into boolean every integer
except 0 is considered as true, 0 is the only value which gives a boolean value as false.
Here, the variable k is true because the zero in variable k is neither integer nor float. It is
a string and string representation of boolean is always true except one condition: if the
string is empty the boolean representation of empty string will be false.
Lecture 1.9
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
Floor division operator will only give the integer part as the output and leave the decimal part.
Division operator gives the integer as well as the decimal part as the output.
Output of Relational operators will always be a boolean value.
Lecture 1.11
In command —>print(s[1:5]) <— It prints the letter from 1st to the 4th position, the output will be
offe , it goes from 1 to 5-1 which is 4. (String slicing)
In part 2 we stored string type value in variables k and p. Hence, variable n
concatenates both the strings and gives output as 38. Addition operator between strings
means concatenation!
Lecture 1.12
In —>print('abcdef' < 'abcde') <— Letter 'f' on the left side has no letter left on the right side to
be compared with. Therefore, 'f' can not be smaller than nothing. Hence, It is false.