-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Python program for product of two numbers and Linear search program in python #372
Open
NormalVad
wants to merge
9
commits into
CodeToExpress:master
Choose a base branch
from
NormalVad:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
47f8889
Python
NormalVad 5b9de8f
Linear Search
NormalVad e30ae0f
Delete LinearSearch.py
NormalVad 548e534
Update README.md
NormalVad 2f99bca
Create Product.py
NormalVad c204466
Update README.md
NormalVad 8425bb1
Update README.md
NormalVad c6a8532
Update .all-contributorsrc
NormalVad db5711b
Update CONTRIBUTORS.md
NormalVad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
@author: NormalVad | ||
@date: 25/10/2020 | ||
""" | ||
|
||
def product(a,b): | ||
if(a==0 or b==0): | ||
return 0 | ||
elif(b == 1): | ||
return a | ||
elif(a<0 and b<0): | ||
a = a*(-1) | ||
b = b*(-1) | ||
return a + product(a,b-1) | ||
elif(a>0 and b>0): | ||
return a+product(a,b-1) | ||
elif(a<0 and b>0): | ||
a = a*(-1) | ||
x = a+product(a,b-1) | ||
return x*(-1) | ||
else: | ||
b = b*(-1) | ||
x = a+product(a,b-1) | ||
return x*(-1) | ||
|
||
print("Enter two numbers to be multiplied seperated by a space") | ||
(a,b) = list(map(int, input().split())) | ||
print(product(a,b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
@author:NormalVad | ||
@date:25/10/2020 | ||
""" | ||
|
||
|
||
def LinearSearch(a,n): | ||
l = len(a) | ||
found = False | ||
i = 0 | ||
while(i<l): | ||
if(a[i]==n): | ||
found = True | ||
break | ||
else: | ||
i += 1 | ||
if(found): | ||
return i | ||
else: | ||
return "Undefined" | ||
|
||
print("Please input Elements of array in single line seperated by spaces") | ||
arr = list(map(int, input().split())) | ||
print("Input element to be found") | ||
n = int(input()) | ||
print(LinearSearch(arr,n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was another part to the question where you needed to calculate the sum of the digits of a number using recursion. Do include the solution to that in this Python script as well.