- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Mohd Mohtashim has Published 251 Articles
Mohd Mohtashim
3K+ Views
An exception can have an argument, which is a value that gives additional information about the problem. The contents of the argument vary by exception. You capture an exception's argument by supplying a variable in the except clause as follows −try: You do your operations here; ...................... except ExceptionType, ... Read More
Mohd Mohtashim
2K+ Views
You can use a finally: block along with a try: block. The finally block is a place to put any code that must execute, whether the try-block raised an exception or not. The syntax of the try-finally statement is this −try: You do your operations here; ...................... Due ... Read More
Mohd Mohtashim
295 Views
An assertion is a sanity-check that you can turn on or turn off when you are done with your testing of the program.The easiest way to think of an assertion is to liken it to a raise-if statement (or to be more accurate, a raise-if-not statement). An expression is tested, ... Read More
Mohd Mohtashim
877 Views
The tell() method tells you the current position within the file; in other words, the next read or write will occur at that many bytes from the beginning of the file.The seek(offset[, from]) method changes the current file position. The offset argument indicates the number of bytes to be moved. The from argument specifies the reference position from ... Read More
Mohd Mohtashim
13K+ Views
The file object provides a set of access methods to make our lives easier. We would see how to use read() and write() methods to read and write files.The write() MethodThe write() method writes any string to an open file. It is important to note that Python strings can have binary data and not just text.The write() method ... Read More
Mohd Mohtashim
9K+ Views
Until now, you have been reading and writing to the standard input and output. Now, we will see how to use actual data files.Python provides basic functions and methods necessary to manipulate files by default. You can do most of the file manipulation using a file object.The open FunctionBefore you can read ... Read More
Mohd Mohtashim
3K+ Views
You can use any Python source file as a module by executing an import statement in some other Python source file.SyntaxThe import has the following syntax −import module1[, module2[, ... moduleN]When the interpreter encounters an import statement, it imports the module if the module is present in the search path. A search ... Read More
Mohd Mohtashim
2K+ Views
Python provides two built-in functions to read a line of text from standard input, which by default comes from the keyboard. These functions are −raw_inputinputThe raw_input FunctionThe raw_input([prompt]) function reads one line from standard input and returns it as a string (removing the trailing newline).#!/usr/bin/python str = raw_input("Enter your input: ") print ... Read More
Mohd Mohtashim
368 Views
The simplest way to produce output is using the print statement where you can pass zero or more expressions separated by commas. This function converts the expressions you pass into a string and writes the result to standard output as follows −Example Live Demo#!/usr/bin/python print "Python is really a great language, ", "isn't ... Read More
Mohd Mohtashim
1K+ Views
The globals() and locals() functions can be used to return the names in the global and local namespaces depending on the location from where they are called.If locals() is called from within a function, it will return all the names that can be accessed locally from that function.If globals() is called from within a ... Read More
To Continue Learning Please Login
Login with Google