mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
commit
537132d254
|
@ -62,6 +62,7 @@ So far, the following projects have been integrated to this repo:
|
|||
|[CLI Calculator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/cli_calculator)|[Willian GL](https://github.com/williangl) |
|
||||
|[Find PhoneNumber in String](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Find-PhoneNumber-in-String)|[Austin Zuniga](https://github.com/AustinZuniga)|
|
||||
|[IMDB TV Series Info Extractor](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/imdb_episode_ratings)|[Yash Raj Sarrof](https://github.com/yashYRS) |
|
||||
|[Yoda-speak Translator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/speak_like_yoda)|[sonniki](https://github.com/sonniki) |
|
||||
|
||||
## How to use :
|
||||
|
||||
|
|
10
speak_like_yoda/README.md
Normal file
10
speak_like_yoda/README.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Speak-Like-Yoda
|
||||
|
||||
## Description
|
||||
A python script that translates an input English sentence into Yoda-speak.
|
||||
|
||||
## Usage
|
||||
Run ```python speak_like_yoda.py```. Type in your sentence to get it translated into Yoda-speak.
|
||||
|
||||
## Requirements
|
||||
The script only uses Python's standard modules ```random``` and ```string```, so no additional installation is needed.
|
2
speak_like_yoda/requirements.txt
Normal file
2
speak_like_yoda/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
random
|
||||
string
|
24
speak_like_yoda/speak_like_yoda.py
Normal file
24
speak_like_yoda/speak_like_yoda.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import random
|
||||
import string
|
||||
|
||||
def speak_like_yoda(sentence):
|
||||
"""
|
||||
Translate the input sentence into Yoda-speak.
|
||||
|
||||
:param sentence: input string
|
||||
:return: translation to Yoda-speak
|
||||
"""
|
||||
sentence = sentence.lower()
|
||||
for p in string.punctuation.replace("'", ''):
|
||||
sentence = sentence.replace(p, '')
|
||||
words = sentence.split()
|
||||
random.shuffle(words)
|
||||
new_sent = ' '.join(words)
|
||||
print()
|
||||
print('Your Yodenglish sentence:')
|
||||
print(new_sent.capitalize())
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('Your English sentence:')
|
||||
sentence = str(input())
|
||||
speak_like_yoda(sentence)
|
Loading…
Reference in New Issue
Block a user