Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code - Sum of digits of a number #1969

Merged
merged 1 commit into from
Aug 28, 2023
Merged

code - Sum of digits of a number #1969

merged 1 commit into from
Aug 28, 2023

Conversation

sarayusreeyadavpadala
Copy link
Contributor

@geekcomputers I have added the changes to my previous code.

return num
else:
print("enter integer only")
if (i-1)<=1: # if user entered wrong input, it displays a message and chances left.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use if and else.
You can use ternary operator.
Like this:

print(f"{i-1} {'chance' if i-1 == 1 else 'chances'} left")
This, does the trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NitkarshChourasia I have added this. review my code

sys.exit()
while num > 0: # Addition- adding the digits in the number.
digit = int(num % 10)
Sum += digit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use doc-string on the main function.
To explain it when.
print(function.__doc__ ) is used.

@sarayusreeyadavpadala
Copy link
Contributor Author

I have changed my code. Help me to improve this further. Needs your suggestion.....

@NitkarshChourasia
Copy link
Contributor

tomorrow morning I will review.
Hey, listen I have a project coming up.
Would you mind, become a code reviewer on it?
It will be based on python.
but what other languages do you know?
I will be doing...
c++, javascript, and c languages.
and in python...
machine learning, statistics, and what not.

Are you ready to take part in all of these?

@NitkarshChourasia
Copy link
Contributor

It will be basic programs, you just have to review them and provide feedback, to whatever extent you can.
If you have any colleague you can tell them to join, too.
@sarayusreeyadavpadala

@NitkarshChourasia
Copy link
Contributor

@sarayusreeyadavpadala Always tag me like this...
@NitkarshChourasia to let me know, that you are asking specifically to me only, and not somebody else.

@NitkarshChourasia
Copy link
Contributor

@sarayusreeyadavpadala
Copy link
Contributor Author

@sarayusreeyadavpadala
Copy link
Contributor Author

@sarayusreeyadavpadala Always tag me like this... @NitkarshChourasia to let me know, that you are asking specifically to me only, and not somebody else.

Yeah ok @NitkarshChourasia

@sarayusreeyadavpadala
Copy link
Contributor Author

tomorrow morning I will review. Hey, listen I have a project coming up. Would you mind, become a code reviewer on it? It will be based on python. but what other languages do you know? I will be doing... c++, javascript, and c languages. and in python... machine learning, statistics, and what not.

Are you ready to take part in all of these?

Thanks @NitkarshChourasia
Yeah definitely, I'll review your code.
I know C++, C, Python, a little javascript.
But I don't have in depth knowledge in it.

Yeah! I am ready to take a part in this.
@NitkarshChourasia

@sarayusreeyadavpadala
Copy link
Contributor Author

It will be basic programs, you just have to review them and provide feedback, to whatever extent you can. If you have any colleague you can tell them to join, too. @sarayusreeyadavpadala

Okay! I'll do that. @NitkarshChourasia

@NitkarshChourasia
Copy link
Contributor

tomorrow morning I will review. Hey, listen I have a project coming up. Would you mind, become a code reviewer on it? It will be based on python. but what other languages do you know? I will be doing... c++, javascript, and c languages. and in python... machine learning, statistics, and what not.
Are you ready to take part in all of these?

Thanks @NitkarshChourasia Yeah definitely, I'll review your code. I know C++, C, Python, a little javascript. But I don't have in depth knowledge in it.

Yeah! I am ready to take a part in this. @NitkarshChourasia

Yeah, it will be a learning experience, Indeed.
I am starting and trying myself from base printing function zero....to ....hero...suppose.

@NitkarshChourasia
Copy link
Contributor

@sarayusreeyadavpadala ASK ALL YOUR FRIENDS TO PARTICIPATE FOR IT.
I WILL BE NEEDING THEIR USERNAME TO ADD TO THE REPOSITORY AS A REVIEWER, I GUESS.

return num
else:
print("enter integer only")
print(f'{i-1} chances are left' if (i-1)>1 else f'{i-1} chance is left') # prints if user entered wrong input and chances left.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print(f"{i-1} {'chance' if i-1 == 1 else 'chances'} left")

This is better readability I think.
But, your is fine, too!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @NitkarshChourasia

@geekcomputers geekcomputers merged commit ccfcea1 into geekcomputers:master Aug 28, 2023
0 of 2 checks passed
@NitkarshChourasia
Copy link
Contributor

@sarayusreeyadavpadala Congratulations.

@sarayusreeyadavpadala
Copy link
Contributor Author

Thank you @NitkarshChourasia

@NitkarshChourasia
Copy link
Contributor

@sarayusreeyadavpadala Welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants