study24x7
Python Technologies
  • Followers
  • Latest Feeds
  • About
  • Review
  • Gallery
  • Question
Interests
Python Technologies

File Access Modes in Python:

1. Read Only ('r') : Read mode which is used when the file is only being read.This is also the default mode in which file is opened.
2. Write Only ('w') : Erase and write to a file.
3. Read and Write ('r+') : Open the file for reading and writing, which is used to handle both actions when working with a file.
4. Write and Read ('w+') : Write and read a file, overwriting its contents.
5. Append Only ('a'): Appending mode, which is used to add new lines to the end of a file.
6. Append and Read ('a+') : Open the file for reading and writing. The data being written is in appending mode,which is used to add new lines to the end of a file.

study24x7
Write a comment

Exception Handling in Python:
The try block lets you test a block of code for errors.
The except block lets you handle the error.
The code in the finally block will be executed regardless of whether an exception occurs.

Basic Syntax :
try:
// Code
except:
// Code
finally:
// Code

study24x7
Write a comment

The if…elif…else statement is used in Python for decision making.
When you want to justify one condition while the other condition is false, then you use "if statement".
The "else condition" is usually used when one condition goes wrong or fails to meet the requirement.
By using "elif" condition, you are telling the program to print out the third condition or check for 4th,5th possibilities when the other condition goes wrong or incorrect.

Syntax:
if test expression:
Body of if
elif test expression:
Body of elif
else:
Body of else

study24x7
Write a comment

There are four collection data types in the Python programming language:

a)List is a collection which is ordered and changeable. It is created by placing all the items (elements) inside a square bracket [] separated by commas and allows duplicate members.
b)Tuple is a collection which is ordered and unchangeable and it allows duplicate members. And, one cannot change elements of a tuple once it is defined.
c)A set is an unordered collection of items where every element is unique (no duplicates). Sets are mutable. You can add, remove and delete elements of a set.
d)Dictionary is a collection which is unordered, changeable and indexed and has no duplicate members.While other compound data types have only value as an element, a dictionary has a key: value pair.

study24x7
Write a comment

Python is a widely used general-purpose, high level programming language. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability and its syntax allows programmers to express concepts in fewer lines of code.It has deep support for more advanced software reuse mechanisms, such as object-oriented programming (OOP).
It's great as a first language because it is concise and easy to read, and it is also a good language to have in any programmer's stack as it can be used for everything from web development to software development and scientific applications.

study24x7
Write a comment
  • Vinayak Harti
  • Hello Folks,
    I want to learn python scripting. for the same want to understand the logic from where we can start writing the script based on requir...

    see more

    Ratings
    5.0
    out of 5
    2 Ratings
    5 study24x7
     
    2.0
    4 study24x7
     
    0.0
    3 study24x7
     
    0.0
    2 study24x7
     
    0.0
    1 study24x7
     
    0.0