Sunteți pe pagina 1din 5

Day1:

Python Introduction:

->
Day2:
Basic Operators:

• Comparison (Relational) Operators


• Assignment Operators
• Logical Operators
• Bitwise Operators
• Membership Operators
• Identity Operators

• Arithmetic Operators

Parameters:

There are 4 types of 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.

Ex: def add(price,item):


print('the item is',item)
print('the price is',price)
item='chocolate'
price=20
add(item=item,price=price)
o/p:the item is chocolate
the price is 20

literal: a literal is a constant value we can not modify.

3 types of literals:

1. String literal

2. integer literal

3. boolean literal

yield keyword: To do iterations we are using this.

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.

The following are 2 types of files in python.

1 . TEXT FILE : It is used to store data(alphabets, numbers & special characters)

What Is Open() ?

It is used to open new or existing file to perform operations on files.

How to open file ?

Variable=open("filename.etn",'mode

of

operation',bufferingsize)

The following are modes operations on files

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

a: It allows to append data at last of the existing file data.

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

curser will blinks at

end point of data.

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:

S-ar putea să vă placă și