×
Home
Jobs
Tools
Coding Ground
Current Affairs
UPSC Notes
Online Tutors
Whiteboard
Net Meeting
Tutorix
Categories
Java
JSP
iOS
HTML
Android
Python
C Programming
C++ Programming
C#
PHP
CSS
Javascript
jQuery
SAP
SAP HANA
Data Structure
RDBMS
MySQL
Mathematics
8085 Microprocessor
Operating System
Digital Electronics
Analysis of Algorithms
Mobile Development
Front End
Web Development
Selenium
MongoDB
Computer Network
General Topics
Warning
: Use of undefined constant php - assumed 'php' (this will throw an Error in a future version of PHP) in
/var/www/tutorialspoint/mui-header.php
on line
161
Library
Videos
Q/A
eBooks
Library
Videos
eBooks
Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Selected Reading
UPSC IAS Exams Notes
Developer's Best Practices
Questions and Answers
Effective Resume Writing
HR Interview Questions
Computer Glossary
Who is Who
Jayashree
has Published
93
Answers
How to find the value closest to positive infinity in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 18:57:53
Although infinity doesn't have a concrete representation, the closest number to infinity is represented as return value of float() function with 'inf' as argument>>> a=float('inf') >>> a inf
How to find exponential value in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 18:53:25
Exponential value of a x is xth power of e, Euler's constant which is an irrational number called Euler's number and is equal to 2.718281.There are two ways to calculate it.Using ** operator>>> import math >>> math.e**2 #math.e is defined constant in math module 7.3890560989306495Using exp() function>>>import math >>> math.exp(2) ...
Read More
How to find the fractional and integer parts of x in a two-item tuple in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 18:41:45
The method modf() returns the fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float. First item in tuple is fractional part>>> import math >>> math.modf(100.73) (0.730000000000004, 100.0) >>> math.modf(-5.55) (-0.5499999999999998, -5.0)
Read More
How to Find the Power of a Number Using Recursion in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 16:21:18
Following program accepts a number and index from user. The recursive funcion rpower() uses these two as arguments. The function multiplies the number repeatedly and recursively to return power.Exampledef rpower(num, idx): if(idx==1): return(num) else: return(num*rpower(num, idx-1)) base=int(input("Enter number: ")) exp=int(input("Enter ...
Read More
How to find power of a number in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 15:38:55
Power of a number can be computed using two methods.using math.pow() function>>> math.pow(10,2) 100.0Using exponentiation operator>>> 10**2 100
How to round off a floating number using Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 15:29:38
The round() function in Python's library rounds the number to given position. Following are some Examples.>>> round(11.6912, 2) # upto second decimal place 11.69 >>> round(11.6912, 1) # upto first place after decimal point 11.7 >>> round(11.6912) # rounded to nearest integer 12 >>> round(11.6912, -1)#rounded to ten's place 10.0
Read More
How to round down to 2 decimals a float using Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 15:21:20
Python's round() function requires two arguments. First is the number to be rounded. Second argument decides the number of decimal places to which it is rounded. To round the number to 2 decimals, give second argument as 2. If third digit after decimal point is greater than 5, last digit ...
Read More
How do you round up a float number in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 15:11:19
Python has an in-built function round() for this purpose. The function takes two arguments, the number to be rounded and the places upto which it is to be rounded. If the number is to be rounded to nearest integer, the second argument is not given.>>> round(1.7456) 2 >>> round(1.4756) 1If ...
Read More
How to perform square root without using math module in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 14:55:05
Python has exponentiation operator (**) which can be used to calculate power of a number. x**y returns x raised to y i.e. y times multiplication of x. Since we need to calculate square root, y should be (1/2)>>> 10**(1/2) 3.1622776601683795 >>> 25**(1/2) 5.0
How to calculate square root of a number in Python?
Python
Server Side Programming
Programming
Jayashree
Published on 06-Mar-2018 14:50:05
using the sqrt() function defined in math module of Python library is the easiest way to calculate square root of a number>>> import math >>> math.sqrt(10) 3.1622776601683795 >>> math.sqrt(3) 1.7320508075688772
Previous
1
2
3
4
5
6
7
...
10
Next
Advertisements
Print
Add Notes
Bookmark this page
Report Error
Suggestions
Save
Close
Dashboard
Logout