Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Unable to understand the meaning of the line of code.
Post: Unable to understand the meaning of the line of co...

Am unable to understand the meaning of the code on the r.h.s. of the below line of code, as given here. lambda A: sum(2*(A[a]==a)-(A[A[a]]==a) for a in A)The array 'A' here is: [0, 1, 2, 3], with 'a'...
jahuja73 General Coding Help 0 303 Jan-23-2024, 05:09 AM
    Thread: Why getting ValueError : Math domain error in trig. function, math.asin() ?
Post: RE: Why getting ValueError : Math domain error in ...

(Feb-24-2021, 12:01 PM)Serafim Wrote: 2 is outside the interval for which asin is defined. Pythons math.asin is an implemetation of arc sine and thus it is defined for values between -1.0 and 1.0 Ag...
jahuja73 General Coding Help 3 3,764 Feb-24-2021, 01:43 PM
    Thread: Finding square roots using long division.
Post: RE: Finding square roots using long division.

(Feb-24-2021, 12:09 PM)Serafim Wrote: Sorry, I am off to my next project. Try implementing it yourself. It is not that big an effort. Use my hint in previous message and the round() function. That w...
jahuja73 Homework 10 5,419 Feb-24-2021, 01:25 PM
    Thread: Why getting ValueError : Math domain error in trig. function, math.asin() ?
Post: Why getting ValueError : Math domain error in trig...

Unable to see why error in output. Tried on repl.it, as well as ideone.com; and get the same error. #your code goes here import math # number a = 2 print("asin(",a,") is = ", math.asin(a))Output: ...
jahuja73 General Coding Help 3 3,764 Feb-24-2021, 11:57 AM
    Thread: Finding square roots using long division.
Post: RE: Finding square roots using long division.

(Feb-24-2021, 11:01 AM)Serafim Wrote: I didn't answer your last question (3): I think normalize is the place. Add one digit to the decimals and then shorten the result. It's a messy business as the ...
jahuja73 Homework 10 5,419 Feb-24-2021, 11:37 AM
    Thread: Finding square roots using long division.
Post: RE: Finding square roots using long division.

(Feb-24-2021, 09:52 AM)Serafim Wrote: I have made an implementation that needs some explanation. I convert the input to a string as I want to simply move the decimal point out of the way. Stepwise f...
jahuja73 Homework 10 5,419 Feb-24-2021, 10:47 AM
    Thread: Finding square roots using long division.
Post: RE: Finding square roots using long division.

(Feb-22-2021, 09:54 AM)Serafim Wrote: If you want to continue beyond this you must add new groups of zeroes to "a", one group for the number of decimals you want Eg. the square root of 3: With your...
jahuja73 Homework 10 5,419 Feb-22-2021, 02:54 PM
    Thread: Finding square roots using long division.
Post: Finding square roots using long division.

Below is code for long division based finding square root. But, it fails for decimals, as well as non-square integers. I mean it gives the same result for 1225, and 1235, i.e. 35. INFINITY_ = 9999999 ...
jahuja73 Homework 10 5,419 Feb-22-2021, 05:39 AM
    Thread: Unable to execute input().
Post: RE: Unable to execute input().

(Feb-17-2021, 08:51 AM)bowlofred Wrote: You'll get that EOFError: EOF when reading a line error if input() gets an "end-of-file" condition. Perhaps by being redirected to an empty/unreadable file, ...
jahuja73 General Coding Help 5 4,441 Feb-18-2021, 06:51 AM
    Thread: Unable to execute input().
Post: RE: Unable to execute input().

(Feb-17-2021, 07:53 AM)Serafim Wrote: I don't get any errors when running that code. Neither when running it as is or when changing it to use the function "get_input()". Not perfect, but it runs wit...
jahuja73 General Coding Help 5 4,441 Feb-17-2021, 08:32 AM
    Thread: Unable to execute input().
Post: Unable to execute input().

Unable to run the below code. # your code goes here def get_input(): my_var = str(input('Enter "a" or "b": ')) if my_var == "a" or my_var == "b": print('got input:', my_var) r...
jahuja73 General Coding Help 5 4,441 Feb-17-2021, 07:01 AM
    Thread: Why not getting return on line #16?
Post: RE: Why not getting return on line #16?

(Feb-11-2021, 03:48 PM)deanhystad Wrote: Yes. That is the purpose of my code. To demonstrate why your convert function returns None when called with a non-zero value for n. Is the reason clear now...
jahuja73 General Coding Help 12 4,394 Feb-12-2021, 04:24 AM
    Thread: Why not getting return on line #16?
Post: RE: Why not getting return on line #16?

(Feb-11-2021, 05:00 AM)deanhystad Wrote: Is it now clear why convert() is returning None? convert6() does not have a return statement, and when you call convert(6), it doesn't have a return stateme...
jahuja73 General Coding Help 12 4,394 Feb-11-2021, 08:57 AM
    Thread: Why not getting return on line #16?
Post: RE: Why not getting return on line #16?

(Feb-10-2021, 09:37 PM)BashBedlam Wrote: The return statement in the convert function is indented too far. Align it with the if/else and it will work as expected. Thanks, but request some sort of pr...
jahuja73 General Coding Help 12 4,394 Feb-11-2021, 03:47 AM
    Thread: Why not getting return on line #16?
Post: RE: Why not getting return on line #16?

(Feb-10-2021, 10:34 PM)deanhystad Wrote: I don't know if there is an error in you logic or your code. As written, the code only returns a value if n == 0. This occurs only one time and is followed...
jahuja73 General Coding Help 12 4,394 Feb-11-2021, 03:38 AM
    Thread: Why not getting return on line #16?
Post: RE: Why not getting return on line #16?

(Feb-10-2021, 03:45 PM)deanhystad Wrote: Without following the link my guess is you have a code branch inside your function that doesn't end in a return. Do you have any if statements? No, rechecke...
jahuja73 General Coding Help 12 4,394 Feb-10-2021, 09:21 PM
    Thread: Why not getting return on line #16?
Post: Why not getting return on line #16?

I have a small python code (https://ideone.com/fc2MNb), but it on one line (line #16) returns None. While on another line (line #27) returns value.
jahuja73 General Coding Help 12 4,394 Feb-10-2021, 03:18 PM
    Thread: Unable to understand how given code takes a fixed input value, without inputting.
Post: RE: Unable to understand how given code takes a fi...

(Jan-28-2021, 03:22 PM)jahuja73 Wrote: Gribouillis: sorry that just changed text while you answered. To provide link to the Cpp code, it is at : https://ideone.com/OR4VZ. I concur with your answe...
jahuja73 General Coding Help 4 2,694 Jan-28-2021, 03:47 PM
    Thread: Unable to understand how given code takes a fixed input value, without inputting.
Post: RE: Unable to understand how given code takes a fi...

Gribouillis: sorry that just changed text while you answered.
jahuja73 General Coding Help 4 2,694 Jan-28-2021, 03:22 PM
    Thread: Unable to understand how given code takes a fixed input value, without inputting.
Post: Unable to understand how given code takes a fixed ...

I got code via link in a post at stackoverflow, but unable to understand how in the code there is a fixed value taken as input, while the code asks none. Code is at: https://ideone.com/nj4CF as given...
jahuja73 General Coding Help 4 2,694 Jan-28-2021, 11:35 AM

User Panel Messages

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