Python Forum
Mathematical Operators in String
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mathematical Operators in String
#1
Hey this is a very simple question, how do I use mathematical numbers in text such as 1,000.00 and 9,000.00.
For example:
x=float(1,000.00)
y=float(19,000.00)
print(x*y)
Error:
Traceback (most recent call last): File "C:\Users\aabha\OneDrive\Desktop\py4e\rough.py", line 1, in <module> x=float(1,000.00) TypeError: float expected at most 1 arguments, got 2
Reply
#2
Starting with python 3.6, one can use underscores in numeric literals. Commas are not supported.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Magic Method Arithmetic Operators ClownPrinceOfCrime 3 120 Jan-10-2021, 03:24 PM
Last Post: ndc85430
  About mathematical equations seyidcemkarakas 3 261 Oct-04-2020, 01:21 PM
Last Post: Gribouillis
  Recognising mathematical expressions from word and pdf file Preeti15 0 288 Aug-19-2020, 09:06 AM
Last Post: Preeti15
  Mathematical Conversion Scripts for Weather Station Mickey53usa 11 1,049 Jun-24-2020, 03:14 AM
Last Post: buran
  Class and Operators in Python rsherry8 1 432 May-27-2020, 07:09 PM
Last Post: buran
  Trying Comparison Operators PythonGainz 3 641 Mar-28-2020, 10:46 AM
Last Post: PythonGainz
  A doubt with 'in' and 'not in' operators with strings newbieAuggie2019 7 805 Oct-23-2019, 03:11 PM
Last Post: perfringo
  Mathematical function input Tiiill 2 609 Sep-10-2019, 09:25 PM
Last Post: nilamo
  understanding exponential and bitwise operators srm 1 696 Jun-15-2019, 11:14 AM
Last Post: ThomasL
  please help with this question about using operators to multiply a string? GilesTwigg 3 1,458 Feb-27-2019, 04:13 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020