
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 238 Articles

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
329 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
527 Views
Variables are names (identifiers) that map to objects. A namespace is a dictionary of variable names (keys) and their corresponding objects (values).A Python statement can access variables in a local namespace and in the global namespace. If a local and a global variable have the same name, the local variable shadows the global variable.Each function ... Read More

Mohd Mohtashim
6K+ Views
You may need to process a function for more arguments than you specified while defining the function. These arguments are called variable-length arguments and are not named in the function definition, unlike required and default arguments.SyntaxSyntax for a function with non-keyword variable arguments is this −def functionname([formal_args, ] *var_args_tuple ): "function_docstring" function_suite ... Read More

Mohd Mohtashim
8K+ Views
Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error as follows −Example Live Demo#!/usr/bin/python # ... Read More

Mohd Mohtashim
495 Views
Defining a function only gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code.Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following ... Read More

Mohd Mohtashim
583 Views
The calendar module supplies calendar-related functions, including functions to print a text calendar for a given month or year.By default, calendar takes Monday as the first day of the week and Sunday as the last one. To change this, call calendar.setfirstweekday() function.Here is a list of functions available with the calendar module ... Read More

Mohd Mohtashim
472 Views
There is a popular time module available in Python which provides functions for working with times and for converting between representations. Here is the list of all available methods −Sr.NoFunction with Description1time.altzoneThe offset of the local DST timezone, in seconds west of UTC, if one is defined. This is negative if the ... Read More

Mohd Mohtashim
483 Views
You can format any time as per your requirement, but simple method to get time in readable format is asctime() −Example Live Demo#!/usr/bin/python import time; localtime = time.asctime( time.localtime(time.time()) ) print "Local current time :", localtimeOutputThis would produce the following result −Local current time : Tue Jan 13 10:17:09 2009 Read More

Mohd Mohtashim
218 Views
To translate a time instant from a seconds since the epoch floating-point value into a time-tuple, pass the floating-point value to a function (e.g., localtime) that returns a time-tuple with all nine items valid.Example Live Demo#!/usr/bin/python import time; localtime = time.localtime(time.time()) print "Local current time :", localtimeOutputThis would produce the following result, which ... Read More