Added swap case program and removed unexpected expression part by mayur200 · Pull Request #3212 · TheAlgorithms/Python · GitHub
Skip to content

Added swap case program and removed unexpected expression part - #3212

Merged
cclauss merged 25 commits into
TheAlgorithms:masterfrom
mayur200:master
Oct 14, 2020
Merged

cclauss merged 25 commits into
TheAlgorithms:masterfrom
mayur200:master

Conversation

@mayur200

Copy link
Copy Markdown
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?
  • I have added an algorithm for swap case in string folder
  • This pull request is all my own work -- I have not plagiarized.
  • I have fixed unexpected expression part from 2 algorithm.
  • All functions and variable names follow Python naming conventions.

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@mayur200
mayur200 requested a review from cclauss as a code owner October 11, 2020 22:13
@TravisBuddy

Copy link
Copy Markdown

Comment thread sorts/cocktail_shaker_sort.py Outdated
user_input = input("Enter numbers separated by a comma:\n").strip()
unsorted = [int(item) for item in user_input.split(",")]
print(f"{cocktail_shaker_sort(unsorted) = }")
print(f"{cocktail_shaker_sort(unsorted) }")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why break this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was getting error in pycharm 'unexpected expression part' before running a program.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it again and I have commited changes. Sorry for the inconvenience

Comment thread strings/naive_string_search.py Outdated
if __name__ == "__main__":
assert naive_pattern_search("ABCDEFG", "DE") == [3]
print(f"{naive_pattern_search('ABAAABCDBBABCDDEBCABC', 'ABC') = }")
print(f"{naive_pattern_search('ABAAABCDBBABCDDEBCABC', 'ABC')}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why break this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was getting error in pycharm 'unexpected expression part' before running a program.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pycharm is not upgraded to Python 3.8 and 3.9 which support this functionality.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have fixed this

Comment thread strings/swap_case.py Outdated
"""
if len(sentence) < 1001:
newstring = ''
for word in sentence:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are not words. They are char.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok. I will fix it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it and commit the changes

Comment thread strings/swap_case.py Outdated
Comment on lines +40 to +41
else:
raise Exception("Charater length should be between 1 and 1000")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why?

@mayur200 mayur200 Oct 13, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have raise an exception and its readable. If its not relatable should I remove it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No. I mean why create a 1000 character limit? Just process the string no matter how long it is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have removed condition

Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
def swap_case(sentence):
"""
This function will convert all lowercase letters to uppercase letters and vice versa.
>>>swap_case('Algorithm.Python@89')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
>>>swap_case('Algorithm.Python@89')
>>> swap_case('Algorithm.Python@89')

Without the space, the test is never run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will fix it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added space. I have commited changes

Comment thread strings/swap_case.py Outdated
2)>>>Please input sentence: github.com/mayur200
GITHUB.COM/MAYUR200

Constraints: Length of string should between 1 and 1000

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its example for problem statement. If someone failed to understand the problem. This example is self explanatory

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No. I mean why create a 1000 character limit? Just process the string no matter how long it is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I will fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it and I have pushed changes

@cclauss

cclauss commented Oct 12, 2020

Copy link
Copy Markdown
Member

All tests are failing.

@mayur200
mayur200 requested a review from l3str4nge as a code owner October 14, 2020 20:02
@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 1e9101f0-0e59-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 7a45e010-0e59-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 790c3220-0e5a-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 0603d7a0-0e5b-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 4eda6340-0e5b-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: bff9e410-0e5b-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 9ed5bd80-0e5c-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 913ca430-0e5d-11eb-964d-5d54b4986782

Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 8be5a5d0-0e5e-11eb-964d-5d54b4986782

@mayur200

Copy link
Copy Markdown
Contributor Author

Why my test is failed again??
I am confused I don't know why its failed my program gives me perfect output

@cclauss

cclauss commented Oct 14, 2020

Copy link
Copy Markdown
Member

https://travis-ci.com/github/TheAlgorithms/Python/jobs/399797450#L775

@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: cc658370-0e66-11eb-964d-5d54b4986782

Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: df9cfd00-0e67-11eb-964d-5d54b4986782

Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py Outdated
Comment thread strings/swap_case.py
@TravisBuddy

Copy link
Copy Markdown

Travis tests have failed

Hey @mayur200,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 4faa06f0-0e69-11eb-964d-5d54b4986782

@TravisBuddy

Copy link
Copy Markdown

@cclauss
cclauss merged commit ed30749 into TheAlgorithms:master Oct 14, 2020
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
…gorithms#3212)

* Removed an extra '=' which was creating an error while running a program.

* Removed the unexpected expression part.

* Added program for swap cases in string folder

* removed if condition and exchange word with char

* added '=' sign which I removed before because of unknowing error from pycharm

* added space in test

* removed costraint from problem statement

* Update cocktail_shaker_sort.py

* Update naive_string_search.py

* Update swap_case.py

* psf/black " not '

* added new line at the end of the file

* Fix flake8 issues

* added new line at the end of the file

* added True and fixed comment

* python file end with \n

* Update swap_case.py

* Update strings/swap_case.py

* Update strings/swap_case.py

* Apply suggestions from code review

* Update strings/swap_case.py

* Update swap_case.py

* Update swap_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
…gorithms#3212)

* Removed an extra '=' which was creating an error while running a program.

* Removed the unexpected expression part.

* Added program for swap cases in string folder

* removed if condition and exchange word with char

* added '=' sign which I removed before because of unknowing error from pycharm

* added space in test

* removed costraint from problem statement

* Update cocktail_shaker_sort.py

* Update naive_string_search.py

* Update swap_case.py

* psf/black " not '

* added new line at the end of the file

* Fix flake8 issues

* added new line at the end of the file

* added True and fixed comment

* python file end with \n

* Update swap_case.py

* Update strings/swap_case.py

* Update strings/swap_case.py

* Apply suggestions from code review

* Update strings/swap_case.py

* Update swap_case.py

* Update swap_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>
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