extinctsion / easyPythonpi

A python library for the beginners. The program includes simple calulations. Genuine PRs will be merged without delays
https://pypi.org/project/easyPythonpi/
14 stars 36 forks source link

added the function bin2hex #23

Closed IltisGraph closed 1 year ago

IltisGraph commented 1 year ago

this function converts a binary string into hexadecimal as mentioned in the issue #20

extinctsion commented 1 year ago

I'm very happy to see you contributing to this library. The main objective of this library was to help the python beginners to see how importing and the code is being written inside a library works. Just using inbuilt functions and returning it as output does not fulfill the cause - [return hex(int(binary, 2))]. 😂😂😂 Anyway you should try to contribute to write a method on ur own and then raise a PR. You can also ask me if u are struck somewhere. Happy to help. Happy coding.

IltisGraph commented 1 year ago

Hi! Actually I'm one of those beginners this repository aims for. So of course I remade the function and overall it was a very fun experience to understand how hex works. So thank for your advice!!!

extinctsion commented 1 year ago

you can rewrite the method without using in-built library methods so that I can merge it with the main branch.

IltisGraph commented 1 year ago

@extinctsion I don't quite understand. I have rewritten the function already, what do I have to change? (Am I not allowed to use python functions like enumerate?)

extinctsion commented 1 year ago

@IltisGraph yes, the way you have written it now is good but the code is giving wrong output. Moreover you can test ur input and output in this website: Radpid Tables

Screenshot (28)

IltisGraph commented 1 year ago

@extinctsion I've hopefully fixed it now. I've tested it with a text function and there weren't any misstakes.

extinctsion commented 1 year ago

Still there is error with the output. Take reference from the sites given - [Binary to hexdec](https://codescracker.com/python/program/python-program-convert-binary-to-hexadecimal.htm#:~:text=Binary%20to%20Hexadecimal%20using%20int()%20and%20hex(),-This%20program%20uses&text=And%20using%20int()%20method,into%20its%20equivalent%20hexadecimal%20value.)

Plus it is giving error if we give 2 as input ([10 bin] -> 2) Screenshot (37)

extinctsion commented 1 year ago

@extinctsion I've hopefully fixed it now. I've tested it with a text function and there weren't any misstakes.

You should be writing a code that is readable, var names should be realted to what u are writing, and ur code should work for all test cases. All means all. For ex - If a user is giving a string as input then it should handle that error as well.

IltisGraph commented 1 year ago

@extinctsion but why should we give 2 as an input, if there aren't such numbers in binary? Furthermore I checked the code and on my machine there is other output than in your screenshot...

Screenshot_20230119_172232
extinctsion commented 1 year ago

@Jugalcody or @PreyumKr pls look into this issue and explain why the input is clashing with the code.

extinctsion commented 1 year ago

@IltisGraph im sorry to say but could you pls take this latest branch and rewrite the changes acc to py 3.x documentation and re raise PR? ill close this PR as everything is jumbled up here. Waiting to see ur new PR soon. ~ from easyPythonpi team