- 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
2K+ Views
You can "update" an existing string by (re)assigning a variable to another string. The new value can be related to its previous value or to a completely different string altogether. For example −Example Live Demo#!/usr/bin/python var1 = 'Hello World!' print "Updated String :- ", var1[:6] + 'Python'OutputWhen the above code is ... Read More
Mohd Mohtashim
1K+ Views
Python does not support a character type; these are treated as strings of length one, thus also considered a substring.ExampleTo access substrings, use the square brackets for slicing along with the index or indices to obtain your substring. For example − Live Demo#!/usr/bin/python var1 = 'Hello World!' var2 = "Python Programming" ... Read More
Mohd Mohtashim
432 Views
Random numbers are used for games, simulations, testing, security, and privacy applications. Python includes following functions that are commonly used.Sr.NoFunction & Description1choice(seq)A random item from a list, tuple, or string.2randrange ([start, ] stop [, step])A randomly selected element from range(start, stop, step)3random()A random float r, such that 0 is less ... Read More
Mohd Mohtashim
494 Views
Loop control statements change execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are destroyed.Python supports the following control statements. Click the following links to check their detail.Let us go through the loop control statements brieflySr.NoOperator & Description1break statementTerminates the ... Read More
Mohd Mohtashim
109 Views
Python’s membership operators test for membership in a sequence, such as strings, lists, or tuples. There are two membership operators as explained below −Sr.NoOperator & DescriptionExample1inEvaluates to true if it finds a variable in the specified sequence and false otherwise.x in y, here in results in a 1 if x ... Read More
Mohd Mohtashim
9K+ Views
Sometimes, you may need to perform conversions between the built-in types. To convert between types, you simply use the type name as a function.There are several built-in functions to perform conversion from one data type to another. These functions return a new object representing the converted value.Sr.No.Function & Description1int(x [, ... Read More
Mohd Mohtashim
13K+ Views
Python's dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type, but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.ExampleDictionaries are ... Read More
Mohd Mohtashim
767 Views
A tuple is another sequence data type that is similar to the list. A tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.ExampleThe main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their ... Read More
Mohd Mohtashim
4K+ Views
Lists are the most versatile of Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different ... Read More
Mohd Mohtashim
4K+ Views
Multiple Statements on a Single LineThe semicolon ( ; ) allows multiple statements on the single line given that neither statement starts a new code block. Here is a sample snip using the semicolon −import sys; x = 'foo'; sys.stdout.write(x + '')Multiple Statement Groups as SuitesA group of individual statements, ... Read More
To Continue Learning Please Login
Login with Google