Thursday, 18 June 2020

Files with Exception handling

#Ask the user to take two input integer values var a,b

try:

    a=int(input("enter any integer value:"))

    b=int(input("enter any integer value:"))

    f=open("knl.txt","w")

    c=a/b

    print(c)

    f.write("writing %d in knl file" %c)

    #creating a new file name:knl.txt

   

except ZeroDivisionError:

    print("Please give other than zero for b")

finally:

    f.close()


x

Wednesday, 17 June 2020

Syllabus

1.Python Introduction
        How to write and execute Python program
       Comment Lines in Python
       Escape Sequences
       Python Identifier
       Reserved word
2.Using Variables in Python
       Variable https://youtu.be/ghJ8t7oKwoU
       Literal
       Python Constants
       Data types https://youtu.be/ghJ8t7oKwoU
         Built-in Data types
         https://youtu.be/ghJ8t7oKwoU
            Python Numbers
            type casting
            Bool data type https://youtu.be/_LeexaIyV1c
            None data type
            Sequences :
               str data type  https://youtu.be/aSeMyoERwOU
               List  https://youtu.be/uwELcLsIeWs
               Tuple https://youtu.be/wwBiOIeGA7M
               Set data type  https://youtu.be/gOWtl3m-Big
               range data type  
               byte data type 
               bytearray
Python Constants
How to download Pycharm software

3. Operators :
    (1.) Arithmetic Operators https://youtu.be/6whfA-ARyMQ
    (2.) Relational Operator https://youtu.be/N-rWkVn9Fqs
    (3.) Logical Operators https://youtu.be/SQxypOkKWyM
    (4.) Assignment operators https://youtu.be/kyh9qQbf_uk
    (5.) Special Operators https://youtu.be/kyh9qQbf_uk
    (6.) Bitwise Operators https://youtu.be/xBNdZ2ytTiU
    Operator Precedence https://youtu.be/q8jc3s7Nmhk

4. Input and output statements https://youtu.be/523O_gX3a-Y
    eval() function https://youtu.be/-AJntqLTi94
    Mathematical Functions

5. Control statements
    1. Conditional Statements https://youtu.be/_cS3R_6SbRc
        if else statement https://youtu.be/VozU5n3ouHM
        if..elif..else statemnet
    2. Loops in Python  https://youtu.be/hFcv96-p4OE
          for loop
            while loop
    3. Unconditional statements https://youtu.be/OdnfITud_6I

      The else suite
Strings and Characters https://youtu.be/KfN8GsNZo1E
Functions https://youtu.be/Gdx870Q6FjM
  Calling a function https://youtu.be/kG5i25P03Z8
  Return statement https://youtu.be/SIwAaHwKctY
  Passing Parameters https://youtu.be/XhsMOvrcuOg
    Formal and actual parameters
      Introduction to *args and **kwargs in Python https://youtu.be/P5NYP1g7PbQ
  Global variables and Local variables https://youtu.be/UJxexYTKGhM
  Recursive Function https://youtu.be/VWgE2KbKF7I
       Tower Of Hanoi https://youtu.be/Pkhmy6eFM0Y
  Lambda function https://youtu.be/8TVWQwEkcFg
    Using Lambda with filter () function https://youtu.be/WgSk2cGcraQ
  Decorator function https://youtu.be/d-qTxNTiZPM
   Assert keyword https://youtu.be/UORaySj-M2w
   Example program on class and object
   https://youtu.be/GkPc0kCsv2o
   Example program on constructors
Files
 • Regular Expressions
Multi-Threading

6. Principles of Object-oriented Programming (OOP)
Overview of OOP
Declaring Class and Creating Object
Understanding Inheritance
Using Magic Methods

7. Database connectivity SQLite

 • Introduction to SQL
Creating an SQLite database
Accessing SQLite Database through Python

8. Developing a GUI with PyQT
GUI and Event driven programming
Qt Designer
Using Common Widgets
Geometry Management
Designing Menu Systems

Clck here to See related videos

Tuesday, 16 June 2020

Files in Python

Files :

 To store data in permanently:

1.    Files

2.    Database

 #example program on without using files:

a=input("enter any string ");

print(a)

 Above program only process the data, but it will not store the data permanently in the hard disk. Because it stores in RAM (Random Access memory).

To store data we have to go for the following options:

1.    Files

2.    Using data base

 

Files:

#creating a file with name rfile.txt

f=open("rfile.txt","w")

a=input("enter any string:")

f.write(a)

f.close()

 

File definition:

File is a collection of related information which stores in our hard disk permanently.

 

Advantages:

1.    When the data is stored in a file, it is stored in the memory permanently.

2.    Updating becomes easy. For example we add or delete new data to the existing file, we can delete unnecessary data from the file.

3.    This file can be sharable to other modules or other programs.

4.    Huge amount of data can be stored in a file.

 

Types of Files:              

1.    Text files

2.    Binary Files

Test file store the data in the form of characters.

Binary Files stores the data in the form of bytes.  i.e a group of 8 bits.

It can store text file, image file, audio and video.

 

We have to follow some steps to handling the files:

1.    Open a file

Example: f=open("rfile.txt","w")

2.    Read /Write files

f.write(a)

3.    Closing the file

Example: f.close()

 

Example: 2:

#Reading a file from already existing

#Reading a file from already existing

#step1

f=open("rfile.txt","r")

#step2:

a=f.read(9)

print(a)

print(type(a))

#Step 3:

f.close()

"""

Hello I'm

<class 'str'>

"""

Example 3: using readlin() function

#Ex3: Reading a file from already existing

#step1

f=open("rfile.txt","r")

#step2:

##a=f.read(9)

a=f.readline()

print(a)

print(type(a))

#Step 3:

f.close()

"""

Hello I'm rajendra

<class 'str'>

"""

 

File mode

Meaning

w

To write the data into file. If already exists the file, previous data is deleted with ‘w’ mode.

r

To read the data from the file. Actually fp (file pointer) points to the beginning of the file. Where fp is a variable identifier. It acts as a just like a pointer.

w+

To write and read the data from the file. Previous data is deleted.

a

Appending mode. Adding the new data to the existing file at the end of the existing file. Here f or fp points at the end of the file. If file does’nt exist, it creates a new file for writing the data

r+

To read and write the data into a file. Previous data is not deleted

a+

To append and read data of a file.

x

Exclusive mode. If already exits one file, it will not create the file.

 #Ex3: By using looping to read the data entire

#step1: open the file rifle.txt in read mode.

f=open("rfile.txt","r")

#step2:execute the loop to read entire txt file

#a=f.readline()

for i in f:

    print(i)

#Step 3:

f.close()

"""

Hello I'm rajendra

 

I'm from Vijayawada

 

 

 

Python...

"""

Closing a file: f.close()

Syntax: variable.close()

A file which opened should closed using close() method. If a file is opened but we forgot to close the file, that file may be corrupted or deleted.

 

Writing the file to the existing file:

##Example program on appending the file

f=open("rfile.txt","a")

 

#appending the data to the file

f.write("we are going to write and give viva for python")

 

#closing the opened file

f.close()

 

once you execute the above code, go to your directory check the file.

 

f=open("pyt.txt","x")

print(f)

if f:

    print("file created successfully ")

 

"""

It leads to error if already exists.

Otherwise creates new file

"""

Next: Files part 2

Previous: 

Exceptions:

https://youtu.be/TeVaBIo-WQo

 

 

 


Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...