Python Forum
Inconsistency in Python programming language?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inconsistency in Python programming language?
#27
(Oct-06-2019, 06:51 AM)Gribouillis Wrote: What about ++++45 or -+54 ? Here is a corrected version

Glad to inform that your revised function works nicely, giving correct results for all our test strings, even if carrying + sign. However, with negative signed string, it still gives AssertionError.

For "++++45" & " -+54", VBA's Val() function returns 0 in both cases.

It is seen that for pure number strings, even if signed, python's built-in eval() function provides results similar to those by VBA's Val() function. For example:

print(eval("45"))
#>>>45
print(eval("+4.5"))
#>>>4.5
print(eval("-4.5"))
#>>>-4.5
However, for mixed strings like "4.5ABC" or " 2 45 7 ", eval() throws error.
A.D.Tejpal
Reply


Messages In This Thread
RE: Inconsistency in Python programming language? - by adt - Oct-06-2019, 08:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Programming robots using Python OscarBoots 5 4,913 Oct-31-2021, 09:38 AM
Last Post: Larz60+
  logo language code into python aayushi98 2 85,075 Jan-26-2021, 09:02 PM
Last Post: Serafim
  Programming Difficult math in Python Huntern 6 7,046 Oct-17-2019, 06:32 AM
Last Post: Huntern
  Terms describing Python Programming language leodavinci1990 3 3,896 Aug-12-2019, 02:48 PM
Last Post: leodavinci1990
  Please help a newbie choose which programming language to learn. yeto 2 4,434 Feb-25-2019, 12:56 AM
Last Post: yeto
  Python Programming Projects for Beginners jack_sparrow007 3 4,440 Dec-26-2018, 07:52 PM
Last Post: micseydel
  How to get image from WolframAlpha by using Python language manhnt 1 3,369 Oct-27-2018, 02:07 PM
Last Post: Larz60+
  Programming Python as a MS Windows app? Brian123 8 6,108 Oct-17-2018, 10:26 PM
Last Post: Brian123
  Help with Python programming mediaos 5 5,040 Aug-08-2018, 01:02 PM
Last Post: Larz60+
  How to make the python default language be 3.6 instead of 2.7 sylas 4 8,057 Jul-06-2018, 06:11 AM
Last Post: sylas

Forum Jump:

User Panel Messages

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