[Tutor] taking support of strings in solving numerical problems
dn
PyTutor at danceswithmice.info
Sun Oct 25 00:49:37 EDT 2020
Perhaps the question was not sufficiently precise: what are examples of
real-world, or practical use-cases for, "various scenarios, where using
strings in a numerical problem reduces the size of the program"?
Repeating previous requests. Please re-consider:
1 top-posting,
2 ReplyToList.
On 25/10/2020 16:30, Manprit Singh wrote:
> Dear Sir ,
> As you asked for examples, I am going to give you a simple example to
> illustrate the fact
> Consider a problem where i have to reverse a number :
> A function definition can be written like this :
>
> def rev_num(x):
> s = 0
> while x != 0:
> x, r = divmod(x, 10)
> s = s*10 + r
> return s
>
> While if i use strings, i can write the same function as :
>
> def rev1_num(x): return int(str(x)[::-1])
>
> Need your comments on such cases
>
> Regards
> Manprit Singh
>
> On Sun, Oct 25, 2020 at 2:16 AM dn via Tutor <tutor at python.org
> <mailto:tutor at python.org>> wrote:
>
> On 25/10/2020 08:22, Manprit Singh wrote:
> > I have seen in various scenarios, where using strings in a numerical
> > problem reduces the size of the program
> >
> > Using strings to solve numerical problems in such a way is a
> valid use case
> > ? should this practise be followed in production ?
>
> Really?
> Examples please...
> --
> Regards =dn
> _______________________________________________
> Tutor maillist - Tutor at python.org <mailto:Tutor at python.org>
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
--
Regards =dn
More information about the Tutor
mailing list