Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Malhar Lathkar
Page 2 of 3
How can import python module in IDE environment available in tutorialspoint?
The TutorialsPoint online Python IDE provides a convenient browser-based environment for running Python code. While it supports Python's built-in standard library modules, importing external third-party packages has limitations. Available Standard Library Modules The TutorialsPoint Python IDE comes with most standard library modules pre-installed. You can import these modules directly without any special setup ? import math import datetime import random print("Square root of 16:", math.sqrt(16)) print("Current date:", datetime.date.today()) print("Random number:", random.randint(1, 10)) Square root of 16: 4.0 Current date: 2024-01-15 Random number: 7 How to Import Modules in TutorialsPoint IDE ...
Read MoreHow to replace backward "" slash from a string
In Python it does give the desired result>>> var = "aaa\bbb\ccc and ddd\eee" >>> var.split('') ['aaa', 'bbb', 'ccc and ddd', 'eee']
Read MoreHow i can replace number with string using Python?
For this purpose let us use a dictionary object having digit as key and its word representation as value −dct={'0':'zero', '1':'one', '2':'two', '3':'three', '4':'four', '5':'five', '6':'six', '7':'seven', '8':'eight', '9':'nine'Initializa a new string object newstr=''Using a for loop traverse each character ch from input string at check if it is a digit with the help of isdigit() function. If it is digit, use it as key and find corresponding value from dictionary and append it to newstr. If not append the character ch itself to newstr. Complete code is as follows:string='I have 3 Networking books, 0 Database books, and 8 Programming ...
Read MoreWhat does colon ':' operator do in Python?
The : symbol is used for more than one purpose in PythonAs slice operator with sequence −The − operator slices a part from a sequence object such as list, tuple or string. It takes two arguments. First is the index of start of slice and second is index of end of slice. Both operands are optional. If first operand is omitted, it is 0 by default. If second is omitted, it is set to end of sequence.>>> a=[1, 2, 3, 4, 5] >>> a[1:3] [2, 3] >>> a[:3] [1, 2, 3] >>> a[2:] [3, 4, 5] >>> s='computer' >>> s[:3] ...
Read MoreHow to indent multiple if...else statements in Python?
Use of indented blocks is an important feature of Python. Indent level of the block is more than previous statements. Hence, if multiple if statements are present in a program in nested fashion, each subsequent indented block will have increasing level of indent.if expr1==True: if expr2==True: stmt1 else: if expr3==True: stmt2 else: if expr3==True: stmt3 else: stmt4
Read MoreCan we use break statement in a Python if clause?
Python's break keyword is used as decision control statement. It causes the remaining iterations to be abandoned and control of execution goes to next statement after the end of loop. Invariably it is executed conditionally and appears inside if block within a loop.while expr==True: stmt1 stmt2 if expr2==True: break stmt3 stmt4 However it can't be used in an if block if it is not a part of loop.
Read MoreCan we use continue statement in a Python if clause?
Python's continue statement is a loop control statement. It causes starting next iteration of loop after abandoning current iteration. Invariably is is executed conditionally i.e. in if blockwhile expr==True: stmt1 stmt2 if expr2==True: continue stmt3 stmt4However, it can't be used in an if block if it is not a part of loop. If used, interpreter will throw syntax error.
Read MoreWhat are the >> and << operators in Python?
The symbols > are defined as left and right shift operators respectively in Python. They are bitwise operators. First operand is a bitwise representation of numeric object and second is the number of positions by which bit formation is desired to be shifted to left or right.The >> a=60 >>> bin(a) '0b111100' >>> b=a> b 240 >>> bin(b) '0b11110000'You can see two bits on right set to 0On the other hand >> operator shifts pattern to right. Most significant bits are set to 0>>> a=60 >>> bin(a) '0b111100' >>> b=a>>2 >>> b 15 >>> bin(a) '0b111100'
Read MoreHow does == operator works in Python 3?
The == symbol is defined as equality operator. It returns true if expressions on either side are equal and false if they are not equal>>> (10+2) == 12 True >>> 5*5 == 5**2 True >>> (10/3)==3 False >>> 'computer'=="computer" True >>> 'COMPUTER'.lower()=='computer' True
Read MoreWhat does 'is not' operator do in Python?
In Python, is and is not operators are called identity operators. Each object in computer's memory is assigned a unique identification number (id) by Python interpreter. Identity operators check if id() of two objects is same. 'is not' operator returns true of id() values are different and false if they are same.>>> a=10 >>> b=a >>> id(a), id(b) (490067904, 490067904) >>> a is not b False >>> a=10 >>> b=20 >>> id(a), id(b) (490067904, 490068064) >>> a is not b True
Read More