'introduction'
'keyword'
'to access the keywords in python'
'keywords are the identifier which particular
task'
'''
syntax:
help('keywords')
import keyword
keyword.kwlist
there are 35 keywords in python
'''
'1.'
# help('keywords')
'2.'
# import keyword
# print(keyword.kwlist)
'to access the library of keyword'
# help('keyword')
'to check proper keyword or not'
import keyword
# print(keyword.iskeyword('import'))
# print(keyword.iskeyword('Import'))
# print(keyword.iskeyword('False'))
':keywords are not modifiable'
# print(keyword.iskeyword('true'))
# print(keyword.iskeyword('if'))
'variable'
'the identifier used to storage the data'
'syn: varname = value / object / data'
# a = 10
# print(a)
'rules to define a variable'
'''
1. variable must be alphanumeric
2. variable name can have _ but no other
special character
'''
'1.'
# a1 = 10
# print(a1)
'exception'
# 1a = 34
# print(1a)
'2.'
# _a1, a_1, a1_ = 20, 30, 12
# print(_a1, a_1, a1_)
# _a1, a_1, a1_ = 20, 30, 12
# print(_a1)
# print(a_1)
# print(a1_)
'exception'
# @a = 34
# print(@a)
'keyword cannot be variable'
# True = 67
# print(True)
'to check whether the identifier follows the
above rules'
'isidentifier'
'syn : "varname".isidentifier()'
# print('a1'.isidentifier())
# print('1a'.isidentifier())
# print('_1a'.isidentifier())
# print('a_!'.isidentifier())
# print('#1a'.isidentifier())
# print('1a_'.isidentifier())
# print('_a1'.isidentifier())
# print('a_1'.isidentifier())
'convention for variable'
'all the letters are written in lowercase'
# mynameis = 'Ashwini'
# print(mynameis)
'pascal case'
# MyAgeIs = 20
# print(MyAgeIs)
'camel case'
# myFavourPlaceIs = 'canada'
# print(myFavourPlaceIs)
'snake case'
# my_job_is = 'teaching'
# print(my_job_is)
'convention for constant'
'defining the identifier in uppercase is
constant'
# pi = 3.14
# print(pi)
#
# PI = 3.14
# print(PI)
'memory allocation in python'
# a = 10
# print(a)
'case-1'
# a = 10
# b = 20
# print(a, b)
# print(id(a), id(b))
'case-2'
'if variable name is different and object is
same'
# a = 10
# b = 10
# print(a, b)
# print(id(a), id(b))
'case-3'
'if variable name is same and different object'
# a = 20
# a = 30
# print(a)
# print(id(a))
'''
-----------------
in-build function
------------------
print
id
input
type
round
divmod
abs
trunc
isinstance
'''
# print(10, 'a', 5.5)
# print('a1'.isidentifier())
# print('10'.isidentifier())
'1. print -> to get the output in the console'
'syn: print(var1, var2,..., [sep], [end])'
# a = 10
# b = 20
'by default separated by white space'
# print(a, b)
'sep parameter will separate the data which is
in same print statem'
# print(a, b, sep='-')
# print(a, b, sep=' 6 ')
# print(a, b, 56, sep='^')
# print(a, b, 45, sep='')
# print(a, b, 67, sep='i')
'by default separated by \n(next line)'
# print(a)
# print(b)
'end parameter will separate the data which is
in diff print statem'
# print(a, end=' ')
# print(b)
# print(a, end='*')
# print(b)
# print(a, end='E')
# print(b)
# a = 10
# b = 20
# print(a, end='*')
# print(b, end=' ')
# print(10)
# print(45, end='*')
# print(56)
# print(10)
# print(45, end='*')
# print(56, sep='-')
# print(10)
# print(45, sep='*')
# print(56, sep='-')
# print(10)
# print(45, sep='*')
# print(56, end='-')
# print(10)
# print(45, sep='*')
# print(56, end='-')
# print(45, 45, sep='*')
# print(56, sep='-')
# print(45, 45, end='*')
# print(56, sep='-')
# print('hai', end='@')
# print('bangalore')
'2. id'
'to get address of the value '
'syn : id(varname)'
# int_ = 56
# print(int_, id(int_))
'3. input'
'to get the input from user side'
'syn : input("statement")'
'the input given to this function the datatype
by default will be string'
# print('------instagram--------')
#
# user_name = input('enter the username : ')
# password = input('enter the password: ')
# print(user_name, "is valid", password, "is
valid")
# print('login successful')
# print('------ICICI ATM-------')
#
# amount = input('enter the amount : ')
# pin = input('enter the pin: ')
# print(amount, pin)
# print('withdrew successfully')
'4. type'
'to check the datatype of a datatype'
'syn : type(value)'
# i_ = 56
# print(i_, type(i_))
# i_ = 56.6
# print(i_, type(i_))
# i_1 = input('enter: ')
# print(i_1, type(i_1))
# i_1 = False
# print(i_1, type(i_1))
'5. isinstance'
'returns True if the data is matching the
datatype else returns False'
'syn : isinstance(data, datatype)'
# print(isinstance(56, int))
# print(isinstance(45, float))
# print(isinstance('a', int))
# print(isinstance('a', (int, str)))
# print(isinstance(45, (str, float)))
# print(isinstance(True, bool))
# print(isinstance('True', bool))
'exception'
# print(isinstance('a', int, str))
'6. abs --> absolute value'
'it coverts any value(+ve or -ve) into positive
value only '
'syn : abs(value)'
# print(abs(-34))
# print(abs(56))
# print(abs(4.5))
# print(abs(-34.1))
'7. divmod'
'to return quotient and reminder'
'divmod(value1, value2)'
'''
2 --> q
---
2|4
4
-----
0 ---> r
'''
# print(divmod(4, 2))
# print(divmod(56, 23))
# print(divmod(34.5, 2))
# print(divmod(100, 25))
'8. trunc'
'it is a method used to convert any float
value(decimal) into integer '
'''
import math
math.trunc(floating value)
'''
# import math
# print(math.trunc(3.4))
# print(math.trunc(3.5))
# print(math.trunc(5.6))
'9. round'
'to round off a floating number'
'syn : round(float value, [precision])'
# print(round(2.3))
'if the value is even will be taking the same
value'
# print(round(2.5))
# print(round(2.6))
'if the value is odd will be added by 1'
# print(round(3.5))
'less than 5'
# print(round(34.2))
# print(round(31.1))
'equal to 5'
# print(round(34.5))
# print(round(31.5))
# print(round(54.5))
# print(round(55.5))
'greater than 5'
# print(round(34.6))
# print(round(31.6))
'if more than 1 decimal point 1 will be added
irrespective of odd or even'
# print(round(10.34))
# print(round(11.345))
# print(round(35.6))
# print(round(34.6))
# print(round(35.544))
# print(round(34.55))
# print(round(37.52))
# print(round(35.54))
# print(round(36.54))
# print(round(34.55))
# print(round(37.55))
'using precision'
'if the next value is => 5 1 will be added'
# print(round(23.456))
# print(round(23.456, 1))
# print(round(23.446, 1))
# print(round(23.466, 1))
# print(round(12.523, 1))
# print(round(12.55, 1))
# print(round(12.5843, 1))
# print(round(12.523, 2))
# print(round(12.55, 2))
# print(round(12.5843, 2))
# print(round(12.529, 2))
# print(round(12.4512, 2))
# print(round(12.455, 2))
'datatypes'
'''
individual datatype
--> we can pass single value into variable at a
time
integer, float, complex, boolean
collection datatype
--> we can pass more than 1 data into the
variable in the same time
string, list, tuple, set, dictionary
'''
'integer'
'it is whole number can be +ve or -ve'
'representation -> int'
'constructor : int()'
'1. to get the default value --> 0'
'2. to convert one datatype into other is
called typecasting'
# int_1 = 23
# int_2 = -34
# print(int_1, int_2)
# print(type(int_1))
# int_1 = input('enter the num : ') # --> '-78'
# print(int_1, type(int_1))
'constructor'
# print(int(), int(3.4))
'integer input'
# int_1 = int(input('enter the num : ')) # -->
int('-78') --> -78
# print(int_1, type(int_1))
'exception '
'we can convert only float to int, str(if the
str has integer) into int'
# print(int('10'))
'# ValueError'
# print(int('10.4'))
# print(int('a'))
'operators in integer'
'+, -, *, /, //, %, **'