From 54b4f45d768841c34341a22696f1d94036dc5621 Mon Sep 17 00:00:00 2001 From: Bhawar Bansal Date: Tue, 19 Aug 2025 10:31:30 +0530 Subject: [PATCH 1/3] Added contribution note in README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 908b36ab..b0e57863 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,4 @@ This repository will contain basic python programming questions and their soluti - Please run the program and check if there are no errors before making the PR - Review other PR's as well - No Spamming allowed, make sure to include all programs in one PR. +- This is my first contribution on Github From a89a16e5fc8a7a7c908a902a11c12e27283da89b Mon Sep 17 00:00:00 2001 From: Bhawar Bansal Date: Wed, 20 Aug 2025 11:54:40 +0530 Subject: [PATCH 2/3] Added program to add 3 numbers with error handling --- adding_error_message.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 adding_error_message.py diff --git a/adding_error_message.py b/adding_error_message.py new file mode 100644 index 00000000..785aee67 --- /dev/null +++ b/adding_error_message.py @@ -0,0 +1,8 @@ +try: + num1 = int(input("Enter First Number: ")) + num2 = int(input("Enter Second Number: ")) + num3 = int(input("Enter Third Number: ")) + print("The sum of the three numbers is:", num1 + num2 + num3) +except ValueError: + print("Invalid input! Please enter valid integers only.") + exit() From 7c4a5e5ab2b12bc20ba9f2098fddd62393593f1c Mon Sep 17 00:00:00 2001 From: Bhawar Bansal Date: Sat, 23 Aug 2025 10:35:37 +0530 Subject: [PATCH 3/3] Add number to words program and update README with details --- README.md | 1 + number_to_word_convertor.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 number_to_word_convertor.py diff --git a/README.md b/README.md index b0e57863..7978e0bf 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,4 @@ This repository will contain basic python programming questions and their soluti - Review other PR's as well - No Spamming allowed, make sure to include all programs in one PR. - This is my first contribution on Github +- Add a new program which convert the integer number in words diff --git a/number_to_word_convertor.py b/number_to_word_convertor.py new file mode 100644 index 00000000..7bbecdf9 --- /dev/null +++ b/number_to_word_convertor.py @@ -0,0 +1,28 @@ + # In this program we will convert numbers to words + # For example: 123 -> One Two Three +def number_to_words(number): +# Define a mapping of digits to words + digit_to_word = { + '0': 'Zero', + '1': 'One', + '2': 'Two', + '3': 'Three', + '4': 'Four', + '5': 'Five', + '6': 'Six', + '7': 'Seven', + '8': 'Eight', + '9': 'Nine' + } + result=[] + # Convert the number to string to iterate over each digit + for digit in str(number): + if digit in digit_to_word: + result.append(digit_to_word[digit]) + else: + return "Invalid input! Please enter a valid non-negative integer." + return ' '.join(result) +# Example usage +if __name__ == "__main__": + number = int(input("Enter a non-negative integer: ")) + print("Number in words:", number_to_words(number)) \ No newline at end of file