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
  plotting based on the results of mathematical formulas Timur 1 335 Feb-08-2024, 07:22 PM
Last Post: Gribouillis
  Use of if - and operators Pedro_Castillo 1 488 Oct-24-2023, 08:33 AM
Last Post: deanhystad
  Taking Mathematical Expressions from Strings quest 2 700 Jul-02-2023, 01:38 PM
Last Post: Pedroski55
  Mixing Boolean and comparison operators Mark17 3 1,405 Jul-11-2022, 02:20 AM
Last Post: perfringo
  Magic Method Arithmetic Operators ClownPrinceOfCrime 3 2,315 Jan-10-2021, 03:24 PM
Last Post: ndc85430
  About mathematical equations seyidcemkarakas 3 2,024 Oct-04-2020, 01:21 PM
Last Post: Gribouillis
  Recognising mathematical expressions from word and pdf file Preeti15 0 1,783 Aug-19-2020, 09:06 AM
Last Post: Preeti15
  Mathematical Conversion Scripts for Weather Station Mickey53usa 11 4,586 Jun-24-2020, 03:14 AM
Last Post: buran
  Class and Operators in Python rsherry8 1 1,987 May-27-2020, 07:09 PM
Last Post: buran
  Trying Comparison Operators PythonGainz 3 2,703 Mar-28-2020, 10:46 AM
Last Post: PythonGainz

Forum Jump:

User Panel Messages

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