- Trending Categories
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
Pythonista has Published 40 Articles
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
315 Views
We can use zip() function to produce an iterable from two tuple objects, each corresponding to key and value items and then use dict() function to form dictionary object>>> T1=('a', 'b', 'c', 'd') >>> T2=(1, 2, 3, 4) >>> dict((x, y) for x, y in zip(t1, t2))Dictionary comprehension syntax can ... Read More
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
532 Views
Python’s standard library contains built-in function set() which converts an iterable to set. A set object doesn’t contain repeated items. So, if a string contains any character more than once, that character appears only once in the set object. Again, the characters may not appear in the same sequence as ... Read More
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
157 Views
Since Python 3.0, it is no longer possible to define unpacked tuple as a parameter in a function (PEP 3113). It means if you try to define a function as below −def fn(a, (b, c)): passPython interpreter displays syntax error at first bracket of tuple. Instead, define tuple objects ... Read More
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
212 Views
A complex number is a pair of real numbers a and b, most often written as a+bi, or a+ib, where i is called the imaginary unit and acts as a label for the second term. Mathematically, i2 = -1. Sometimes, j is used instead of i.Here’s how a complex number ... Read More
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
102 Views
Python has an in-built join() function that returns a string by joining elements in a sequence object by inserting separator between elements. If we need a string without any separator, we initialize it with null string>>> lst=['h','e','l','l','o'] >>> str='' >>> str.join(lst) 'hello'
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
1K+ Views
PostgreSql database is by default installed on port number 5432. Python interface to PostgreSql is provided by installing psycopg2 module. Assuming that test database and employee table with fname, sname, age, gender and salary fields is available.First establish connection and obtain cursor object by following statements in Python script.import psycopg2 ... Read More
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
2K+ Views
Assuming that MySQL database named as test is present on server and a table named employee is also created. The table has five fields fname, lname, age, gender, and salary.A tuple object containing data of a record is defined ast1=('Mac', 'Mohan', 20, 'M', 2000)To establish interface between MySQL and Python ... Read More
![Pythonista](https://www.tutorialspoint.com/assets/profiles/15003/profile/60_128639-1514576467.png)
Pythonista
8K+ Views
Unlike while loop, for loop in Python doesn't need a counting variable to keep count of number of iterations. Hence, to convert a for loop into equivalent while loop, this fact must be taken into consideration.Following is a simple for loop that traverses over a rangefor x in range(5): ... Read More