Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint
Cover Image
Cover Image
Drag to reposition
Contributed Answers

How to generate prime numbers using Python?

How to generate prime numbers using Python?                                      
Answered on 15th Feb, 2018, 0 Views

A prime number is the one that is not divisible by any other number except 1 and itself. In Python % modulo operator is available to test if a number is divisible by other.  Assuming we have to find prime numbers between 1 to 100, each number (let us say x) in the range needs to be successively checked for divisibility by 2 to x-1. This is achieved by employing two nested loops. , Abov.....

What does the >> operator do in Python?

What does the >> operator do in Python?                                                  
Answered on 12th Feb, 2018, 0 Views

It is a bitwise right shift operator. The bit pattern is shifted towards right by number of places stipulated by operand on right. Bits on left are set to 0 For example a=60 (00111100 in binary), a>>2 will result in 15 (00001111 in binary) ,

What is function of ^ operator in Python

What is function of ^ operator in Python?                                       
Answered on 12th Feb, 2018, 0 Views

In Python, ^ is called EXOR operator. It is a bitwise operator which takes bits as operands. It returns 1 if one operand is 1 and other is 0. Assuming a=60 (00111100 in binary) and b=13 (00001101 in binary) bitwise XOR of a and b returns 49 (00110001 in binary) ,

Explain function of % operator in Python.

Explain function of % operator in Python.                                                 
Answered on 12th Feb, 2018, 0 Views

In Python % is an arithmetic operator that returns remainder of division operation. It is called modulo or remainder operator and operates upon numeric operands except complex numbers ,

What is behavior of ++ and -- operators in Python?

What is behaviour of ++ and -- operators in Python?                            
Answered on 12th Feb, 2018, 0 Views

In C/C++ and Java etc, ++ and -- operators are defined as increment and decrement operators. In Python they are not defined as operators. In Python objects are stored in memory. Variables are just the labels. Numeric objects are immutable. Hence they can't be incremented or decremented. However, prefix ++ or -- doesn't give error but doesn't perform either. , Postfix ++ or -- produce errors ,

What is operation of <> in Python?

What is operation of <> in Python? Explain with example.                        
Answered on 12th Feb, 2018, 0 Views

The <> operator is available in Python 2.x as not equal to operator. there is also != operator for the same operation. In Python 3.x, <> operator is deprecated. Python 2.7 , Python 3 ,

How do we define dictionary in Python?

How do we define dictionary in Python?                                                                             
Answered on 8th Feb, 2018, 0 Views

Dictionary object is an unordered collection of key-value pairs, separated by comma and enclosed in curly brackets. Association of value with key is marked by : symbol between them. , Key can appear in a dictionary object only once, whereas single value can be assigned to multiple keys. Key should be of immutable data type i.e. number, string or tuple. ,

How can I parse a numeric string to its corresponding float value?

How can I parse a numeric string to its corresponding float value?                                                      
Answered on 8th Feb, 2018, 0 Views

Python’s number conversion function float() converts an integer to float with fractional part as 0. It also parses a string with valid representation of float number to a float object. ,

How to convert an integer to a octal string in Python?

How to convert an integer to a octal string in Python?                                           
Answered on 8th Feb, 2018, 0 Views

We have use oct() function from Python’s library to convert any integer to its octal equivalent number. We get a string having octal representation ,

How to convert an integer to a hexadecimal string in Python?

How to convert an integer to a hexadecimal string in Python?                                                      
Answered on 8th Feb, 2018, 0 Views

We can use built in hex() function to convert any integer to its hexadecimal representation. ,

loader
Advertisements
Contribution

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.