Python utils.py() Examples
The following are 30
code examples of utils.py().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
utils
, or try the search function
.
Example #1
Source File: b07902021.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #2
Source File: B07902019.py From PythonHomework with MIT License | 5 votes |
def task_8( img_url: str = 'https://i.imgur.com/B75zq0x.jpg' ) -> object: ''' Task 8: Module Args: img_url: address of an image Returns: result_img: an PIL Image Hints: * Make sure you have installed the PIL package * Take a look at utils.py first * You could easily find answers with Google ''' from urllib import request result_img = None # TODO: download the image from img_url with the request module # and add your student ID on it with draw_text() in the utils module # under src/. # You are allowed to change the img_url to your own image URL. from PIL import Image import utils p = request.urlopen(img_url) result_img = Image.open(p) result_img = utils.draw_text(result_img, "B07902019") # Display the image: # result_img.show() # Note: please comment this line when hand in. # If you are running on a server, use # result.save('test.jpg') # and copy the file to local or use Jupyter Notebook to render. # End of TODO return result_img
Example #3
Source File: b07902063.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #4
Source File: b07902023.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #5
Source File: B07902029.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #6
Source File: b07902063.py From PythonHomework with MIT License | 5 votes |
def task_8( img_url: str = 'https://i.imgur.com/B75zq0x.jpg' ) -> object: ''' Task 8: Module Args: img_url: address of an image Returns: result_img: an PIL Image Hints: * Make sure you have installed the PIL package * Take a look at utils.py first * You could easily find answers with Google ''' from urllib import request result_img = None # TODO: download the image from img_url with the request module # and add your student ID on it with draw_text() in the utils module # under src/. import utils import io from PIL import Image with request.urlopen(img_url) as response: r = response.read() result_img = Image.open(io.BytesIO(r)) result_img = utils.draw_text(result_img,'StudentID b07902063') # You are allowed to change the img_url to your own image URL. # Display the image: # result_img.show() # Note: please comment this line when hand in. # If you are running on a server, use # result.save('test.jpg') # and copy the file to local or use Jupyter Notebook to render. # End of TODO return result_img
Example #7
Source File: b04209023.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #8
Source File: b07902103.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #9
Source File: b07902069.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #10
Source File: b07902055.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #11
Source File: B07902003.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print (sentence) # End of TODO (do not change the code below) return True
Example #12
Source File: test_reverse_mode.py From tangent with Apache License 2.0 | 5 votes |
def test_grad_image(func, motion, optimized, preserve_result, timage, tkernel, conv2dstrides): """Test gradients of image functions.""" # TODO: Upgrade utils.py to allow simultaneous testing of uneven args. tfe_utils.test_rev_tensor(func, motion, optimized, preserve_result, (0,), timage, tkernel, conv2dstrides) tfe_utils.test_rev_tensor(func, motion, optimized, preserve_result, (1,), timage, tkernel, conv2dstrides)
Example #13
Source File: phrase_vocabulary_optimization.py From lasertagger with Apache License 2.0 | 5 votes |
def _added_token_counts(data_iterator, try_swapping, max_input_examples=10000): """Computes how many times different phrases have to be added. Args: data_iterator: Iterator to yield source lists and targets. See function yield_sources_and_targets in utils.py for the available iterators. The strings in the source list will be concatenated, possibly after swapping their order if swapping is enabled. try_swapping: Whether to try if swapping sources results in less added text. max_input_examples: Maximum number of examples to be read from the iterator. Returns: Tuple (collections.Counter for phrases, added phrases for each example). """ phrase_counter = collections.Counter() num_examples = 0 all_added_phrases = [] for sources, target in data_iterator: if num_examples >= max_input_examples: break logging.log_every_n(logging.INFO, f'{num_examples} examples processed.', 1000) added_phrases = _get_added_phrases(' '.join(sources), target) if try_swapping and len(sources) == 2: added_phrases_swap = _get_added_phrases(' '.join(sources[::-1]), target) # If we can align more and have to add less after swapping, we assume that # the sources would be swapped during conversion. if len(''.join(added_phrases_swap)) < len(''.join(added_phrases)): added_phrases = added_phrases_swap for phrase in added_phrases: phrase_counter[phrase] += 1 all_added_phrases.append(added_phrases) num_examples += 1 logging.info(f'{num_examples} examples processed.\n') return phrase_counter, all_added_phrases
Example #14
Source File: b07902039.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #15
Source File: b07902089.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #16
Source File: b07902131.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_d <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #17
Source File: b04302308.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8(http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #18
Source File: b07902079.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #19
Source File: B07902073.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #20
Source File: b03204032.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student_id <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #21
Source File: B05201050.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #22
Source File: b07902135.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #23
Source File: B07902017.py From PythonHomework with MIT License | 5 votes |
def task_8( img_url: str = 'https://i.imgur.com/B75zq0x.jpg' ) -> object: ''' Task 8: Module Args: img_url: address of an image Returns: result_img: an PIL Image Hints: * Make sure you have installed the PIL package * Take a look at utils.py first * You could easily find answers with Google ''' from urllib import request result_img = None # TODO: download the image from img_url with the request module # and add your student ID on it with draw_name() in the utils module # under src/. # You are allowed to change the img_url to your own image URL. # Display the image: # result_img.show() # Note: please comment this line when hand in. # If you are running on a server, use # result.save('test.jpg') # and copy the file to local or use Jupyter Notebook to render. from PIL import Image import utils response = request.urlopen(img_url) result_img = Image.open(response) result_img = utils.draw_text(result_img, "B07902017") # End of TODO return result_img
Example #24
Source File: B07902017.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #25
Source File: b07902067.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence="Hello world" print (sentence) # End of TODO (do not change the code below) return True
Example #26
Source File: b07902059.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #27
Source File: b07902005.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #28
Source File: b07902011.py From PythonHomework with MIT License | 5 votes |
def task_8( img_url: str = 'https://i.imgur.com/B75zq0x.jpg' ) -> object: ''' Task 8: Module Args: img_url: address of an image Returns: result_img: an PIL Image Hints: * Make sure you have installed the PIL package * Take a look at utils.py first * You could easily find answers with Google ''' from urllib import request import utils import io store = request.urlopen(img_url) result_img = Image.open(io.BytesIO(store.read())) result_img = utils.draw_text(result_img, "B07902011") # TODO: download the image from img_url with the request module # and add your student ID on it with draw_text() in the utils module # under src/. # You are allowed to change the img_url to your own image URL. # Display the image: # result_img.show() # Note: please comment this line when hand in. # If you are running on a server, use # result.save('test.jpg') # and copy the file to local or use Jupyter Notebook to render. # End of TODO return result_img
Example #29
Source File: b07902011.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python autograder.py -task 1 -student_id <your student ID>` # under src/ to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True
Example #30
Source File: b07902049.py From PythonHomework with MIT License | 5 votes |
def task_1(dummy=None): ''' Task 1: Basic Syntax and Flake8 Checker Python uses indentations to separate blocks instead of backets. Unlike most programming language (like C++), indentations in Python are required. See https://www.python-course.eu/python3_blocks.php for some examples. Flake8 (http://flake8.pycqa.org/en/latest/) could help you check these syntax error. It also regular your coding style. For example, using two whitespaces as indentation is allowed in Python. However, Flake8 will tell you it is an error "E111: indentation is not a multiple of four". This is because when many people work on the same project, it would be confusing if people are using different identation style. Following the coding style in Flake8 is strongly suggested. ''' # Hint: # Run `python src/autograder.py -task 1 -student <your student ID>` # to see if you pass this task. # The correct output would be "Hello world" without any # error. Note that passing this task does NOT mean you pass the # Flake8 chcker. Please check your style with # `flake8 src/student/<your student ID>.py` # TODO: fix the syntax error for the following code if True: sentence = "Hello world" print(sentence) # End of TODO (do not change the code below) return True