Documente Academic
Documente Profesional
Documente Cultură
Python Introduction:
->
Day2:
Basic Operators:
• Arithmetic Operators
Parameters:
1.positional parameters:
If any mismatches occurs in the actual and formal parameters then it’s showing an
error.A positional argument is any argument that's not supplied as a key=value
pair.
Ex:
def add(l,k,p):
c=l+k
return c
n=10
k=23
j=add(n,k)
print(j)
output:
Traceback (most recent call last):
File "week23.py", line 9, in <module>
j=add(n,k)
TypeError: rotatelist() missing 1 required positional argument: 'p'
2.Default arguments:
Default values indicate that the function argument will take that value if no argument
value is passed during function call. The default value is assigned by using
assignment(=) operator of the form keywordname=value.
Ex: def address(a,b=’Telangana’):
print(a,b)
address(“suryapet”)
o/p: ('suryapet', 'ts')
3.Keyword arguments:
keyword arguments are related to the function calls.when you use keyword
arguments in a function call , the caller identifies the arguments by the
parameter name.this allows you to skip arguments or place them out of order.
3 types of literals:
1. String literal
2. integer literal
3. boolean literal
Ex:def add():
yield 'hello’
yield 'sravanireddy'
a=add()
next(a)
o/p: hello
FILES IN PYTHON :
File is memory location which is used to store the data, which can be readable
whenever required.
What Is Open() ?
Variable=open("filename.etn",'mode
of
operation',bufferingsize)
w: It allows to write data into file, if you are re executing same file it erases existing
file.
r: It allows to read data from file, the cursor will blinks at starting position of the text
w+: It allows to write data into file as well as read data from file. However the data will
be deleted
automatically.
r+: It allows append data to an existing file and it allows to read data from file. The
a+: It allows append data or read the data from a file.The curser will blinks at end point.
PACKAGES IN PYTHON :
What is package ?
Package is a collection of modules.
Package is namespaces, which contains sub-packages & classes them self.
Task1:
Retrieving all csv files from a directory that contain any type of files?
Ans: