5
Jul

Question:

Write a python program to generate passwords

Program:

Explanation:

Following are the criteria for creating a password:

1. At least 1 letter between [a-z]

2. At least 1 number between [0-9]

1. At least 1 letter between [A-Z]

3. At least 1 character from [\$#@]

4. Minimum length of transaction password: 6

5. Maximum length of transaction password: 12

Output:

4
Jul

### Area of Rectangle using classes

Question:

Calculate area of a rectangle using classes

Program:

Explanation:
A class rect is created with two breadth and length, and method area which tabulates the area of the rectangle.
An object obj of class rect is created and used

Output:

3
Jul

### Even numbers using list comprehension

Question:

Create a list of even numbers between 0 and 10 using list comprehension.

Program:

Explanation:

List comprehensions provide a concise way to create lists.

It consists of brackets containing an expression followed by a for clause, then
zero or more for or if clauses. The expressions can be anything, meaning you can
put in all kinds of objects in lists.

List comprehensions provide a concise way to create new list of elements that satisfy a given condition from an iterable. Here the iterable prints out even numbers.

Output:

2
Jul

### Prime Numbers within a range

Question :

Write a program to print prime numbers within a range

Program:

Explanation:

A prime number is a number that is divisible only by itself and 1 (e.g. 2, 3, 5, 7, 11).

Output:

1
Jul

### Difference between range() and xrange()

Question:

Write a program to show the difference between range() and xrange() function

Program:

Explanation:

The variable holding the range created using range() uses so much memory compared to
the variable created using xrange()

The reason is that range creates a list holding all the values
while xrange creates an object that can iterate over the numbers on demand.

Eventhough the xrange is memory efficient, the price we have to pay
for this efficieny is access time. The range variable created with range()
will have a faster access time compare to the variable created with xrange()
as it is entirely stored in the memory so it is readily available
whereas the variable created with xrange() have to load its contents
to memory ‘on demand’ only. So time efficiency is a drawback of xrange()

Output: