Today I visited Chennai Institute Of Technology to attend a workshop on Networking. They thought very basic concept in it like types of network and some other basics. They session was completed so soon, that they completed the workshop within 2 hours. The experience in CIT was too bad. The food in the canteen is not so good. Overall workshop is too bad.
Author: 1chandru1
Exception Handling in Python
Normally in Python, the exception is handled by the computer itself. But the exception which is thrown by the system compiler is not known by all. In order to throw some specific Error, we use exception handling. It has four main blocks which is explained as follows.
The first two main blocks are try and expect. The expect is followed by the Exception. The general syntax is,
try:
Statement_1
Statement-2
…..
expect exception_name:
Exception message
The try block is used to check the condition. If the condition fails, then expect block block is called with corresponding to the exception.
Example:-
a=4
b=0
try:
c=a/b
expect Exception:
print(“Division by zero Error”)
Output:-
Division by zero Error
The keyword Exception is commonly used exception in the python. The third block is else which is used when the try block is satisfied and further step has to be executed.
The fourth block is finally, which is called even when the try block does not throws an exception. Lets see an example which contains all these blocks.
Example:-
a=int(input(“Enter a”)
b=int(input(“Enter b”)
try:
c=a/b
expect Exception:
print(“Division by zero Error”)
else:
print(“The Divided Number is %d” % c)
finally:
print(“Finally block is called”)
Output 1 :-
Enter a 10
Enter b 5
The Divided Number is 2
Finally block is called
Output 2:-
Enter a 5
Enter b 0
Division by zero Error
Finally block is called
A Normal Weekend
Today, I attended a competition in Hacker Earth which was conducted by my college. The questions were really tough to answer. I attended only 2 question out of 5. The test conducted for 2 hours and rest of day I chilled myself with my friends. I also spent some time in searching, to get some ideas about mini project which has to submitted within this month.
Ssn Workshop
Today I went to Ssn college of engineering to attend a workshop on Data analytics. But they didn’t teach anything about it. This workshop is totally waste and didn’t worth a penny. But I enjoyed the college atmosphere. The one thing special in this college is canteen. They provide tasty and quality food at cheaper rate. From today’s workshop, we gained only a certificate instead of knowledge.
Workshop
Today I and my friends attended a workshop on Auto Chatbot in VIT, Chennai. From this workshop I come to know the basics of creating a chat bot. But apart from this, I enjoyed roaming around VIT because it’s infrastructure was top notch. The saddest part is, they didn’t provide a certificate for attending this workshop.
Today after the college, Some college club members conducted a code test to test our skills. It is must for all juniors and so I attended it. All college buses were went off and so I traveled in out bus. So I reached home late and I was very tired.
Exam
Finally I have completed my typewriting course today. Today I have written senior paper for which I have been working for 6 months. While typing, my hands were shivering and my heart beat rate were surely increased. But somehow I completed it.
As today was a teacher’s day, the college management announced that this day is going to be a half working day. So we decided to have a cricket match between us. But unfortunately the ground was occupied by the seniors. So we played basketball and returned to home.
Sending off
Today I spent time with my friend as he going to study in abroad. My friend visited his native country which is India for his semester Holidays. He arrived Chennai before a month and we together enjoyed this vacation. Today we send off him with our memories to his country.
Introduction to File Handling
File is collection of the data or information. In python we can access the file easily with the inbuilt function and is easy to manipulate in python. Generally in python, the files are divided into two, text file and binary file. Text file is normal one which consist of text and the binary is one which can be accessed by the computer alone.
There are Some Basic modes in which a file can be accessed,
“r” = It is used to open the file in the read form and so we cannot make any modification in the file. Initially if we open the file, it will be in read mode.
“w” = It is used to make some modification in the file.
“a” = It is used to append the data in the file.
Opening a file
To open a file in python, we use open() command. It has two arguement. First one is the name of the file in which we want to open and the second one is in which mode we want to open the file.
>>> a = open(” python.txt “)
>>> a
<_io.TextIOWrapper name=’python.txt’ mode=’r’ encoding=’UTF-8′>
Closing a file
To close a file in python, we use close() command.
a = open(” python.txt “)
>>> a
<_io.TextIOWrapper name=’love.txt’ mode=’r’ encoding=’UTF-8′>
>>> a.close()
Always make sure the you close the file explicitly after using the file. Do not open the file for no reason because it leads to corruption of data or even loss of memory.