Mohd Mohtashim has Published 202 Articles

Creating Instance Objects in Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 29-Aug-2023 03:34:56

38K+ Views

To create instances of a class, you call the class using class name and pass in whatever arguments its __init__ method accepts."This would create first object of Employee class" emp1 = Employee("Zara", 2000) "This would create second object of Employee class" emp2 = Employee("Manni", 5000)You access the object's attributes using the dot ... Read More

How to create an image to zoom with CSS and JavaScript?

Mohd Mohtashim

Mohd Mohtashim

Updated on 16-Feb-2021 06:41:53

1K+ Views

Following is the code to create an image zoom:Example Live Demo    * {box-sizing: border-box;}    .img{       display: inline-block;    }    .img-zoom-container {       position: relative;    }    .img-zoom-zoomLens {       position: absolute;       border: 1px ... Read More

Insert the string at the beginning of all items in a list in Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 16-May-2020 10:50:38

347 Views

In this post we need to enter the string at the beginning of all items in a list. For ex: We're given string = "Tutorials_Point" and List contains multiple element such as "1", "2" etc. So in this we need to add Tutorials_Point in front of "1", "2" and so on.ExampleAproach ... Read More

Python - Insert list in another list

Mohd Mohtashim

Mohd Mohtashim

Updated on 16-May-2020 10:39:54

372 Views

A list also the extend() method, which appends items from the list you pass as an argument. extend() − Python list method extend() appends the contents of seq to list. You can read more about it here "https://www.tutorialspoint.com/python/list_append.htm"Now let us see hands onExample Live Demo#append first_list = [1, 2, 3, 4, ... Read More

Python - Increasing alternate element pattern in list

Mohd Mohtashim

Mohd Mohtashim

Updated on 16-May-2020 10:37:27

191 Views

In this we are going to use List Comprehension with enumerate() Python provides compact syntax for deriving one list from another. These expressions are called list comprehensions.List comprehensions are one of the most powerful tools in Python. Python’s list comprehension is an example of the language’s support for functional programming ... Read More

Parsing XML with DOM APIs in Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 31-Jan-2020 10:32:17

2K+ Views

The Document Object Model ("DOM") is a cross-language API from the World Wide Web Consortium (W3C) for accessing and modifying XML documents.The DOM is extremely useful for random-access applications. SAX only allows you a view of one bit of the document at a time. If you are looking at one ... Read More

Multithreaded Priority Queue in Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 31-Jan-2020 10:24:30

1K+ Views

The Queue module allows you to create a new queue object that can hold a specific number of items. There are following methods to control the Queue −get() − The get() removes and returns an item from the queue.put() − The put adds item to a queue.qsize() − The qsize() returns the ... Read More

Sending an HTML e-mail using Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 31-Jan-2020 10:05:04

789 Views

When you send a text message using Python, then all the content are treated as simple text. Even if you include HTML tags in a text message, it is displayed as simple text and HTML tags will not be formatted according to HTML syntax. But Python provides option to send ... Read More

Disconnecting Database in Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 31-Jan-2020 10:02:53

6K+ Views

To disconnect Database connection, use close() method.db.close()If the connection to a database is closed by the user with the close() method, any outstanding transactions are rolled back by the DB. However, instead of depending on any of DB lower level implementation details, your application would be better off calling commit ... Read More

Commit & RollBack Operation in Python

Mohd Mohtashim

Mohd Mohtashim

Updated on 31-Jan-2020 10:02:15

714 Views

COMMITCommit is the operation, which gives a green signal to database to finalize the changes, and after this operation, no change can be reverted back.Here is a simple example to call commit method.db.commit()ROLLBACKIf you are not satisfied with one or more of the changes and you want to revert back ... Read More

1 2 3 4 5 ... 21 Next
Advertisements