blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
0291f8953312c8c71a778cb5defd91ca5c24ef09
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/AdvancedPython_OOP_with_Real_Words_Programs/App-6-Project-Calorie-Webapp/src/calorie.py
564
4.125
4
____ temperature _____ Temperature c_ Calorie: """Represents optimal calorie amount a person needs to take today""" ___ - weight, height, age, temperature): weight weight height height age age temperature temperature ___ calculate _ result 10 * weight + 6...
242a80f51b4940791d36fd79320394742aaf4aa5
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/codeabbey/_Python_Problem_Solving-master/Double Dice rolling.py
262
3.671875
4
#accept the range ___ i __ r..(i..(i.. ))): #accept the random numbers to be converted to double dice value a,b l.. m..(i..,i.. ).s..())) #calculate the double dice value res (a % 6 + 1 ) + (b % 6 + 1) #print the result print(res,end=' ')
23c0c2ee5b6165c16168522bf61bc190696b3161
syurskyi/Python_Topics
/079_high_performance/examples/Writing High Performance Python/item_49.py
1,819
4.15625
4
import logging from pprint import pprint from sys import stdout as STDOUT # Example 1 def palindrome(word): """Return True if the given word is a palindrome.""" return word == word[::-1] assert palindrome('tacocat') assert not palindrome('banana') # Example 2 print(repr(palindrome.__doc__)) # Example 3 "...
22055e3af9f95eb89f34a2f28ba24c3fe1c6584c
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/Graph/133_CloneGraph.py
1,075
3.71875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Definition for a undirected graph node # class UndirectedGraphNode(object): # def __init__(self, x): # self.label = x # self.neighbors = [] c.. Solution o.. ___ cloneGraph node __ n.. node: r_ None copyed_node_pair...
7b534d6967a16e1c6752b6ecf484d6d8c1d25a9e
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/Math/335_SelfCrossing.py
1,428
3.96875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # @Author: xuezaigds@gmail.com # @Last Modified time: 2016-04-05 16:17:53 """ According to: https://leetcode.com/discuss/88153/another-python Draw a line of length a. Then draw further lines of lengths b, c, etc. How does the a-line get crossed? From the left by the d-li...
cc75cc8322dfc9ae9ef6a5ccb943a848537c9be8
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/lintcode/36_reverse_linked_list_ii.py
1,012
4.03125
4
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ c_ Solution: """ @param: head: ListNode head is the head of the linked list @param: m: An integer @param: n: An integer @return: The head of the reversed ...
2f0cd45309945619d5e95e75abf7be9718989ddf
syurskyi/Python_Topics
/120_design_patterns/009_decorator/_exercises/templates/decorator_003.py
1,334
4.1875
4
# """Decorator pattern # # Decorator is a structural design pattern. It is used to extend (decorate) the # functionality of a certain object at run-time, independently of other instances # of the same class. # The decorator pattern is an alternative to subclassing. Subclassing adds # behavior at compile time, and the c...
19a961e8b85c8e1ed1babc8cf85b01cf04441e95
syurskyi/Python_Topics
/080_tracing/_exercises/templates/traceback — Exceptions and Stack Traces/007_Low-level Exception APIs.py
1,170
3.640625
4
# print_exception() uses format_exception() to prepare the text. # traceback_format_exception.py import traceback import sys from pprint import pprint from traceback_example import produce_exception try: produce_exception() except Exception as err: print('format_exception():') exc_type, exc_value, exc_tb...
3e287897a85f9b2c948f37a3ffe3c6b265490943
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/Stack/ReverseAStackByRecursive.py
510
3.75
4
""" 只能用递归不能用其他数据结构来逆序一个栈。 可以用另一个新栈的话比较容易。 """ from GetMinStack import Stack def reverseStack(stacks): new_stack = Stack() def helper(stacks): if stacks.empty(): return new_stack.push(stacks.pop()) helper(stacks) helper(stacks) return new_stack # 测试用例。 a =...
3ce6a0530910c15c3b0f97ad0a7a4b9fddf627c3
syurskyi/Python_Topics
/045_functions/007_lambda/_exercises/exercises/007_lambda_template.py
3,654
4.25
4
# -*- coding: utf-8 -*- # An example of using anonymous functions # f1 = l_: 10 + 20 # Функция без параметров # f2 = l_ x_ y_ x + y # Функция с двумя параметрами # f3 = l_ x y z_ x + y + z # Функция с тремя параметрами # print(f1()) # Выведет: 30 # print(f2(5, ...
1e11e649770bc1016e7babd381ba315750367a03
syurskyi/Python_Topics
/045_functions/008_built_in_functions/map/examples/006_Python map() with string.py
2,072
4.375
4
def to_upper_case(s): return str(s).upper() def print_iterator(it): for x in it: print(x, end=' ') print('') # for new line # map() with string map_iterator = map(to_upper_case, 'abc') print(type(map_iterator)) print_iterator(map_iterator) # Output: # <class 'map'> # A B C # Python map() with t...
68185a6fd9ceb61e1933d9edb9d0f79a7efe2073
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/Array/MinimumIndexSumOfTwoLists.py
2,157
3.984375
4
""" Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You c...
ee5aada9b9038f1262e4b8d07a2ad5bdeb8a076c
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/advanced/42/guess.py
2,517
4.15625
4
# _______ r__ # MAX_GUESSES 5 # START, END 1, 20 # # # ___ get_random_number # """Get a random number between START and END, returns int""" # r.. r__.r.. ? # # # c_ Game # """Number guess class, make it callable to initiate game""" # # ___ - # """Init _guesses, _answer, _win to set(), get_random...
8025d7201eedf7d82b483310c569a1fbd7f599bd
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/78/common.py
644
3.84375
4
programmers = dict(bob=['JS', 'PHP', 'Python', 'Perl', 'Java'], tim=['Python', 'Haskell', 'C++', 'JS'], sara=['Perl', 'C', 'Java', 'Python', 'JS'], paul=['C++', 'JS', 'Python']) def common_languages(programmers): """Receive a dict of keys -> names and values -> a seq...
08beeeeeb4f848ab756f2c8a3fdd0f6189b58349
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/Recursion, Backtracking and Dynamic Programming in Python/Section 2 Recursion/TowersHanoi.py
436
3.65625
4
# # ___ hanoi disk, source, middle, destination # # # this is the base case -index 0 is always the smallest plate # # we manipulate the smallest plate in the base case # __ ? __ 0 # print('Disk @ from @ to @' ? ? ? # r_ # # ? ? - 1 ? ? ? # # this is not necessarily the largest plat...
0fec0dfce518432a333ceae9e8ab900dfa7f5340
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/beginner/37/countdown.py
251
3.703125
4
# ___ countdown_for start=10 # ___ i __ r.. r.. 1, ? + 1 # print ? # print('time is up') # # # ___ countdown_recursive start=10 # # __ ? __ 0 # print('time is up') # r.. # # # print ? # # ? ? -1 # # # # # #
72882dfdf8cdecafedab9859163028bb722a2ee9
syurskyi/Python_Topics
/090_logging/examples/Logging in Python/008_Other Configuration Methods_conf.py
1,179
3.53125
4
# You can configure logging as shown above using the module and class functions or by creating a config file or # a dictionary and loading it using fileConfig() or dictConfig() respectively. These are useful in case you want # to change your logging configuration in a running application. # # Here is an example file co...
b4ac71ff4822751cff631103d7e2f9e52c9caeb6
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/LinkedList/234_PalindromeLinkedList.py
1,096
4.0625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # @Author: xuezaigds@gmail.com # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def isPalindrome(self, head): slow, fast, new_head = head, he...
d1d21e09f523d5c36453086f6f8a0c5c8a141b27
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/290_newbie_bite/save1_nopass.py
204
3.78125
4
# # List of car brands for you to iterate through # car_brands = 'Mazda', 'McLaren', 'Opel', 'Toyota', 'Honda' # # # # Pass in the car_brands list and code the for loop. # ___ list_cars # print(cars)
236cfd3e2f62c7660216fb0a30c1c12c01fe791e
syurskyi/Python_Topics
/070_oop/001_classes/_exercises/exercises/Learning Python/039_003_Classes Are Instances of type.py
1,685
3.625
4
# print(ty..([])) # In 3.0 list is instance of list type # # <class 'list'> # print(ty..(ty..([]))) # Type of list is type class # # <class 'type'> # # print(ty..(li.. # Same, but with type names # # <class 'type'> # print(ty..(ty..)) # Type of type is...
5d2f7f98d7e2ab0ff8346c87ca49169d64c51faa
syurskyi/Python_Topics
/095_os_and_sys/examples/realpython/021_Copying Directories.py
741
3.515625
4
# While shutil.copy() only copies a single file, shutil.copytree() will copy an entire directory and everything # contained in it. shutil.copytree(src, dest) takes two arguments: a source directory and the destination directory # where files and folders will be copied to. # # Here’s an example of how to copy the conten...
0530bc18101b06050dfc0fe9b215b99276a45bcd
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/Practice_Python_by_Solving_100_Python_Problems/59.py
162
3.8125
4
# #Print out three lines saying for instance item 1 has index 0, and so on. # a = [1, 2, 3] # # ___ index, item __ e__ ? # print("Item __ has index __" _ ? ?
4c3aa79a386db44a2bb76cfbf551c8f2d1d0fb88
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/lintcode/900_closest_binary_search_tree_value.py
725
3.625
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ c_ Solution: ___ closestValue root, target """ :type root: TreeNode :type target: float :rtype: int """ __ n.. root: ...
386c91256cdd3ee4cca357d861887ab923830c6f
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/738 Monotone Increasing Digits.py
1,014
4.03125
4
#!/usr/bin/python3 """ Given a non-negative integer N, find the largest number that is less than or equal to N with monotone increasing digits. (Recall that an integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.) Example 1: Input: N = 10 Output: 9 Example 2: Inpu...
1be54b84d0949dc683432acfc41b13cde9f570c1
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/100_python_Best_practices_for_absolute_beginers/Project+99 How to calculate the Area and Perimeter of Right Angle Triangle.py
276
4.1875
4
_______ math x float(input("Insert length of x: ")) y float(input("Insert length of y: ")) z math.sqrt((pow(x,2)+pow(y,2))) Area (x*y)/2 Perimeter x+y+z print("Area of right angled triangle = %.2f" % Area) print("Perimeter of right angled triangle = %.2f" % Perimeter)
b7e17d3710c68df3ebf3b937d389f40cf4257d7e
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/959 Regions Cut By Slashes.py
2,876
4.1875
4
#!/usr/bin/python3 """ In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, \, or blank space. These characters divide the square into contiguous regions. (Note that backslash characters are escaped, so a \ is represented as "\\".) Return the number of regions. Example 1: Input: [ " /",...
12c9d4674dd76d33772547c20f2324989c6c0c0f
syurskyi/Python_Topics
/110_concurrency_parallelism/002_threads/_exercises/exercises/ITVDN_Python_Advanced/example3_local.py
1,557
3.609375
4
import threading print(threading.active_count()) current = threading.current_thread() print(current.getName()) print(current.is_alive()) # # что произойдет, если попробуем еще раз его запустить try: current.start() except RuntimeError as e: print('ERROR: {error}'.format(error=e)) current.setName('SuperThread')...
2901e2dbaab6f155dfd2d32feeed803ef2d07a5d
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/674 Longest Continuous Increasing Subsequence.py
978
4.15625
4
#!/usr/bin/python3 """ Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Input: [1,3,5,4,7] Output: 3 Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3. Even though [1,3,5,7] is also an increasing subsequence, i...
7e268f53812fe3b81eeda97a72fb4f36320cafe9
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/57_v2/calculator.py
1,811
3.578125
4
# _______ a__ # _______ f.. # # ___ calculator f numbers # """TODO 1: # Create a calculator that takes an operation and list of numbers. # Perform the operation returning the result rounded to 2 decimals""" # # # # r.. r.. f...r.. l.... x,y| ? ? ? ? 2 # # # # ___ create_parser # """TODO 2: # ...
e666a664cc341955d01a29a7ca86400c0596f039
syurskyi/Python_Topics
/018_dictionaries/_templates/sort_dictionary/004.py
1,328
3.796875
4
# # Sort Dictionary Using a for Loop # # dict1 = {1: 1, 2: 9, 3: 4} # sorted_values = s.. ?.v.. # Sort the values # sorted_dict # dict # # ___ i __ ? # ___ k __ ?.k.. # __ ? ? __ ? # ? ? = ? ? # b.. # # print ? # # # Sort Dictionary Using the sorted() Function # # dict1 {1: 1,...
d7aaee2fc6997e16c23a8fb52674cda37660967e
syurskyi/Python_Topics
/125_algorithms/_examples/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 74 - PermutationsII.py
833
3.859375
4
# Permutations II # Question: Given a collection of numbers that might contain duplicates, return all possible unique permutations. # For example: # [1,1,2] have the following unique permutations: # [ [1,1,2], [1,2,1], [2,1,1] ] # Solutions: class Solution: # @param num, a list of integer # @return a list of ...
7281ca5442e46a66c75d4a2d2a4e77e7f30298cc
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/leetcode/124_binary_tree_maximum_path_sum.py
1,239
3.90625
4
""" Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None """ c_ Solution: ___ maxPathSum root """ :type root: TreeNode :rtype: int """ __ n.. root: r.. 0 a...
69accf57e5d5b8c3921c910a0f19e3b4def863dc
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/topics/supplementary exercises/e0001-zip.py
857
4.53125
5
# zip(), lists, tuples # list is a sequence type # list can hold heterogenous elements # list is mutable - can expand, shrink, elements can be modified # list is iterable # tuple is a sequence type # tuple can hold heterogeneous data # tuple is immutable # tuple is iterable # Test case 1 - when iterables are of equa...
fb32447bdacb68f154c47ea7b0640257c71e104c
syurskyi/Python_Topics
/095_os_and_sys/_exercises/exercises/Python pathlib tutorial/013_list_dirs.py
358
3.796875
4
# The iterdir() yields path objects of the directory contents. # list_dirs.py #!/usr/bin/env python from pathlib import Path path = Path('C:/Users/Jano/Documents') dirs = [e for e in path.iterdir() if e.is_dir()] print(dirs) # The example prints the subdirectories of the specified directory. # We check if the pat...
240c7407c29123e8f2818d72b6ffe2b826671ab3
syurskyi/Python_Topics
/125_algorithms/_examples/Python_Hand-on_Solve_200_Problems/Section 17 Recursion/greatest_gcd_solution.py
352
3.75
4
# To add a new cell, type '# %%' # To add a new markdown cell, type '# %% [markdown]' # %% # Write a Python program to find the greatest common divisor (gcd) of two integers. def Recurgcd(a, b): low = min(a, b) high = max(a, b) if low == 0: return high elif low == 1: return 1 else: return Recurgcd(low, hig...
1a44eeb8a042f963e304b61740de0d81c59b234b
syurskyi/Python_Topics
/070_oop/001_classes/examples/ITDN Python RUS/002_Nasledovanie i Polimorfizm/08-isinstance.py
807
3.640625
4
# -*- coding: utf-8 -*- """ isinstance(obj, cls) проверяет, является ли obj экземпляром класса cls или класса, который является наследником класса cls """ print(isinstance(8, int)) # True print(isinstance('str', int)) # False print(isinstance(True, bool)) # True print(isinstance(True, int)) # True, так как bool -...
390f3dfa31af8cd69e4ba47d4e9af1a33788ff2f
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 86 - ReverseLLII.py
1,243
3.796875
4
# # Reverse Linked List II # # Question: Reverse a linked list from position m to n. Do it in-place and in one-pass. # # For example: # # Given 1->2->3->4->5->NULL, m = 2 and n = 4, # # Return 1->4->3->2->5->NULL. # # Note: Given m, n satisfy the following condition: # # 1 ≤ m ≤ n ≤ length of list. # # Solutions: # # #...
d2e70c091928cc0ab6f68873256037160b147bec
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/673 Number of Longest Increasing Subsequence.py
1,683
4.0625
4
#!/usr/bin/python3 """ Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Input: [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [1, 3, 5, 7]. Example 2: Input: [2,2,2,2,2] Output: 5 Explanation: The length of longest contin...
8c9a8c9553dc6c8bc38392d192baf0d77e08c6f3
syurskyi/Python_Topics
/030_control_flow/001_if/examples/ITVDN Python Starter 2016/09-truth-value-testing.py
336
4.0625
4
# -*- coding: utf-8 -*- string = input('Enter a string: ') # то же самое, что if string is not None and string != '' if string: print('The string is {}'.format(string)) number = int(input('Enter a number: ')) if number: print('Число не равно нулю') else: print('Число равно нулю')
558a0fcd7e7e7ea3511d06cda1d68132db9682dc
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/DP/InterleavingString.py
6,232
3.6875
4
""" Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac" Output: true Example 2: Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc" Output: false 经过s1和s2的不断削减组合,最终是否能形成s3. 在最初使用了搜索的递归方法后进行学习DP以及改良,最终beat 85%以上。 思路: 最开始的思路就...
eb259aa8ef480717e23897aa3f32812135533765
syurskyi/Python_Topics
/070_oop/001_classes/examples/Python_OOP_Object_Oriented_Programming/Section 14 Inheritance - Methods/Inheritance-Methods-Code/1 - Shape, Triangle, Circle.py
879
3.859375
4
class Shape: def __init__(self, color, is_polygon, description): self.color = color self.is_polygon = is_polygon self.description = description def display_data(self): print(f"\n=== {self.description.capitalize()} ===") print("Color:", self.color) print("Is the ...
5f6790b885f92ac670bab82149f7044e7ade4ca6
syurskyi/Python_Topics
/125_algorithms/_exercises/exercises/100_Interactive_Python_Exercises_to_Boost_Your_Python_Skill/Section 4 Data Structures and Algorithms/Coding Exercise 22 Number Info NUKE.py
220
3.6875
4
def foo(number): return dict(sign = "positive" if number > 0 else ("negative" if number < 0 else "zero"), parity = "odd" if number % 2 == 1 else ("even" if number % 2 == 0 else "non integer"))
e145836dcf4ea4126c17ec1ff0816d0aeaee2ddd
syurskyi/Python_Topics
/115_testing/examples/Github/_Level_1/Unittest_examples-master(2)/Unittest_examples-master/pyexample_2.py
738
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Пример модуля с классами """ import unittest class FirstTestClass(unittest.TestCase): def test_add(self): self.assertEqual(120, 100 + 20) class SecondTestClass(unittest.TestCase): def setUp(self): """ Данный метод выполняет...
20c81149bf6ebde49eeec890443a40a5e67c085c
syurskyi/Python_Topics
/065_serialization_and_deserialization/002_json/_exercises/_templates/55. Using JSONDecoder - Coding.py
14,559
3.953125
4
# # Using JSONDecoder # # Just like we can use a subclass of JSONEncoder to customize our json encodings, we can use a subclass of # # the default JSONDecoder class to customize decoding our json strings. # # It works quite differently from the JSONEncoder subclassing though. # # When we subclass JSONEncoder we overrid...
bb5ea1238c5f902ce796ef0ed8929eb33d954eae
syurskyi/Python_Topics
/050_iterations_comprehension_generations/002_list_comprehension/examples/The_Modern_Python_3_Bootcamp/Coding Exercise 20 List Comprehension Exercises.py
373
3.65625
4
# Using list comprehensions: answer = [person[0] for person in ["Elie", "Tim", "Matt"]] answer2 = [val for val in [1, 2, 3, 4, 5, 6] if val % 2 == 0] print(answer) # Using good old manual loops: answer = [] for person in ["Elie", "Tim", "Matt"]: answer.append(person[0]) answer2 = [] for num in [1, 2, 3, 4, 5, ...
da7fa62688eef77231aefdd7f7ee6d33d6ff222c
syurskyi/Python_Topics
/070_oop/008_metaprogramming/_exercises/templates/python_cookbook/9.17_enforcing_coding_conventions_in_classes/example1.py
4,314
3.65625
4
# A metaclass that disallows mixed case identifier names class NoMixedCaseMeta(type): def __new__(cls, clsname, bases, clsdict): for name in clsdict: if name.lower() != name: raise TypeError('Bad attribute name: ' + name) return super().__new__(cls, clsname, bases, clsdi...
438cb7633c606ebafa831e5a24a8ceb3ae2ba851
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/intermediate-bite-272-find-common-words.py
1,862
4.34375
4
""" Given two sentences that each contains words in case insensitive way, you have to check the common case insensitive words appearing in both sentences. If there are duplicate words in the results, just choose one. The results should be sorted by words length. The sentences are presented as list of words. Example: ...
bee3d292f0898daadf8cbb51ccc92ae93139b520
syurskyi/Python_Topics
/115_testing/examples/Github/_Level_1/Python_Unittest_Suite-master/Python_Unittest_Patch_Multiple.py
2,236
3.671875
4
# Python Unittest # unittest.mock � mock object library # unittest.mock is a library for testing in Python. # It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used. # unittest.mock provides a core Mock class removing the need to create a host of stu...
235fee728f7853aa65b05a101deeb1dfeb5ebf8f
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/DynamicProgramming/198_HouseRobber.py
469
3.609375
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): # Dynamic Programming def rob(self, nums): if not nums: return 0 pre_rob = 0 pre_not_rob = 0 for num in nums: cur_rob = pre_not_rob + num cur_not_rob = max(pre_rob, pre_no...
e5963c5c51190c7231e249ac9a9dc30f2a3e0296
syurskyi/Python_Topics
/090_logging/_exercises/exercises/Good logging practice in Python/005_Capture exceptions with the traceback.py
1,020
3.609375
4
# # Capture exceptions with the traceback # # While its a good practice to log a message when something goes wrong, but it wont be helpful if there is no # # traceback. You should capture exceptions and record them with traceback. Following is an example: # # t__ # o.. '/path/to/does/not/exist' __ # e___ S.. K.. #...
ae706f18b09e6de72457f1ac23cf5ed37a7ebab3
syurskyi/Python_Topics
/115_testing/_exercises/_templates/temp/Github/_Level_1/Python_Unittest_Suite-master/Python_Unittest_Test_Prefix.py
1,699
3.6875
4
# Python Unittest # unittest.mock � mock object library # unittest.mock is a library for testing in Python. # It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used. # unittest.mock provides a core Mock class removing the need to create a host of stu...
e862d9cb13ed41dcf00350945782f41db0205e5b
syurskyi/Python_Topics
/030_control_flow/example/Python-from-Zero-to-Hero/03-Коллеции, циклы, логика/13-ДЗ-Опреляем Flush_solution.py
635
3.625
4
table_cards = ["A_S", "J_H", "7_D", "8_D", "10_D"] hand_cards = ["J_D", "3_C"] # ниже ваша реализация: suites = 'CHSD' flush = False table_suites = [i[-1] for i in table_cards] hand_suites = [i[-1] for i in hand_cards] suites_in_game = table_suites + hand_suites # and either with a list comprehension: flush = any([s...
97142a394d8c9bf78c236b4f597a59d092108f01
syurskyi/Python_Topics
/045_functions/007_lambda/_exercises/exercises/001_Python lambda expressions who are they_!cool!.py
492
3.640625
4
# -*- coding: utf-8 -*- # Лямдба-выражения позволяют нам превратить следующий код: colors = ["Goldenrod", "Purple", "Salmon", "Turquoise", "Cyan"] def normalize_case(string): return string.casefold() normalized_colors = map(normalize_case, colors) # Вот в такой код: colors = ["Goldenrod", "Purple", "Salmon"...
fc42c1a94d6d942bc21ac8b03a1e7290ce6a8bbc
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/lintcode/87_remove_node_in_binary_search_tree.py
1,132
3.578125
4
""" Main Concept: https://discuss.leetcode.com/topic/65792/recursive-easy-to-understand-java-solution Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ c_ Solution: """ @param: root: The root of the binary search tree. ...
61a04b3aa15caa8791f7420325e8b2ab08af676a
syurskyi/Python_Topics
/125_algorithms/_examples/100_Python_Exercises_Evaluate_and_Improve_Your_Skills/Exercise 51 - EOF.py
220
3.703125
4
#The script is trying to print out the type of the last character of updated string. #A: One more bracket is needed to close the print function print(type("Hey".replace("ey","i")[-1])) print("Hey".replace("ey","i")[-1])
196c3043137ac8a37d8ea496793847367cdecc60
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/399 Evaluate Division.py
2,383
3.671875
4
""" Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0. Example: Given a / b = 2.0, b / c = 3.0. queries are: a / c = ?, b / a = ?, a / e = ?, ...
ab296e2bb06b26e229bf476a06432826585dbbb5
syurskyi/Python_Topics
/125_algorithms/_examples/Python_Hand-on_Solve_200_Problems/Section 4 Condition and Loop/2_dimensional_array_solution.py
1,011
4.375
4
# To add a new cell, type '# %%' # To add a new markdown cell, type '# %% [markdown]' # %% # --------------------------------------------------------------- # python best courses https://courses.tanpham.org/ # --------------------------------------------------------------- # Write a Python program which takes two digit...
12caeb8af4b04ae3cf6150a0d8847676f4a70fc2
syurskyi/Python_Topics
/115_testing/examples/ITVDN_Python_Advanced/007_Модульное тестирование/007_Samples/example0_custom.py
765
3.59375
4
def concat(x, y): return '{} {}'.format(x, y) def sum_3_elem(a, b, c): return a + b + c def multiply_3_elem(a, b, c): return a * b * c def test_concat(): assert concat(1, 2) == '1 2' assert concat(10, 20) == '10 20' def test_sum_3_elem(): assert sum_3_elem(0, 2, 3) == 5 assert sum_3_...
f41b074a2c82c8a2ef811bbea596c6a375ef557b
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/Recursion, Backtracking and Dynamic Programming in Python/Section 3 Search Algorithms/linear_search_recursive.py
389
3.734375
4
___ linear_search_recursive(container, item, index0 # base case for search miss (when item is not present in the container) __ index > le_(container r_ -1 # base case when we find the item __ container[index] __ item: r_ index r_ linear_search_recursive(container, item, index + 1) ...
153eb2c8ad7e84e5cad4123398b8aec710d3ffc1
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/451 Sort Characters By Frequency.py
833
4.03125
4
#!/usr/bin/python3 """ Given a string, sort it in decreasing order based on the frequency of characters. """ ____ c.. _______ d.. c_ Solution(o.. ___ frequencySort s """ Brute force: counter, sort O(n log n) There is a uppper limit of the counter, thus bucket sort possible :type ...
d6547e1f12d4fb2f6683397346a4a5e0fd4583d3
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/043 Wildcard Matching.py
3,172
3.5
4
""" Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, const char *p) ...
fd8c3565c4951a7497a53ff3c1eb3d172425bd8a
syurskyi/Python_Topics
/055_modules/001_modules/examples/Python 3 Most Nessesary/12.1.Listing 12.4. Attribute existence check.py
329
3.640625
4
import math def hasattr_math(attr): if hasattr(math, attr): return "Атрибут существует" else: return "Атрибут не существует" print(hasattr_math("pi")) # Атрибут существует print(hasattr_math("x")) # Атрибут не существует
650b2156b592b55355fcd441cdf6a29ba8760226
syurskyi/Python_Topics
/050_iterations_comprehension_generations/006_nested_comprehensions/examples/006_nested_comprehensions.py
1,954
4.75
5
# Nested Comprehensions # Just as with list comprehensions, we can nest generator expressions too: # A multiplication table: # Using a list comprehension approach first: # The equivalent generator expression would be: # We can iterate through mult_list: # But you'll notice that our rows are themselves generators! # o f...
9652c845bbb6af2b08cca30ed454e17570bcd220
syurskyi/Python_Topics
/090_logging/examples/github/_logging_examples-master(2)/logging_examples-master/logger_example_2.py
756
3.515625
4
import argparse import logging import sys logging.basicConfig(filename='ex2_log.log', level=logging.DEBUG) def simple_parser(): logging.info("Command Line inputs: " + ' '.join(sys.argv[1:])) parser = argparse.ArgumentParser() parser.add_argument('A', type=int) parser.add_argument('B', type=...
0e75f1f8b46a9230a3c40c7a337864925c591d29
syurskyi/Python_Topics
/045_functions/007_lambda/_exercises/templates/010_Filter.py
558
3.671875
4
# -*- coding: utf-8 -*- # even _ l_____ x ? % 2 __ 0 # print li.. f.. ? ra.. 11 # # [0, 2, 4, 6, 8, 10] # # # Обратите внимание, что filter() возвращает итератор, поэтому необходимо вызывать list, # # который создает список с заданным итератором. # # # # Реализация, использующая конструкцию генератора списка, дает сле...
f171b8efbcf102bd8a563c2367ccff88912e1dcb
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/DynamicProgramming/10_RegularExpressionMatching.py
1,932
3.765625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): def isMatch(self, s, p): """ Dynamic Programming dp[i][j] represents isMatch(p[0...i], s[0...j]), default is False; dp[i][-1] represents isMatch(p[0...i], "") dp[-1][j] represents isMatch("", s[0...
f0deed5e91dc4476292f10ac0e544bd0a8290bb1
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/746 Min Cost Climbing Stairs.py
1,291
4.125
4
#!/usr/bin/python3 """ On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with index 0, or the step with index 1. Exampl...
12037708f7862d5be05538280cac4e7fa580660c
syurskyi/Python_Topics
/010_strings/_exercises/Learning Python/017_String Formatting Expressions.py
366
3.578125
4
# -*- coding: utf-8 -*- print('That is %s %s bird!' % (1, 'dead')) # Format expression print('The knights who say %s!' % 'exclamation') # String substitution print('%d %s %g you' % (1, 'spam', 4.0)) # Type-specific substitutions | - эквивалентно f или е print('%s -- %s -- %s' % (42, 3.14159, [1, 2, 3])) # All t...
7051770e9ce69ac4044e38df4bad8e2ec92bc703
syurskyi/Python_Topics
/115_testing/examples/Github/_Level_1/Python_Unittest_Suite-master/Python_Unittest_Mocks_As_Attributes.py
2,996
3.609375
4
# Python Unittest # unittest.mock mock object library # unittest.mock is a library for testing in Python. # It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used. # unittest.mock provides a core Mock class removing the need to create a host of stub...
f2a195534b38ecc53de8f47c4f25be48b7dbd9fa
syurskyi/Python_Topics
/090_logging/_exercises/exercises/Python Logging – Simplest Guide with Full Code and Examples/006_7. How to create a new logger.py
1,508
3.609375
4
# # You can create a new logger using the logger.getLogger(name) method. If a logger with the same name exists, # # then that logger will be used. # # # # While you can give pretty much any name to the logger, the convention is to use the __name__ variable like this: # # # ______ l____ # logger _ l____.gL_ -n # ?.i.. '...
ccc30660ab3a95002188a82d1634e305f7e867bb
syurskyi/Python_Topics
/050_iterations_comprehension_generations/002_dictionary_comprehension/examples/002_dictionary_comprehension.py
1,330
4.09375
4
# Comprehension Syntax Summary # Dictionary comprehension print({x: x * x for x in range(10)}) # Comprehending Set and Dictionary Comprehensions # Comprehension # Generator and type name # Set comprehension equivalent # Dict comprehension equivalent print({x * x for x in range(10)}) set(x * x for x in range(10)) pr...
fa729e7509e45d58afe1c792d586072f89546cd6
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/124 Binary Tree Maximum Path Sum.py
1,717
3.5625
4
""" Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3 Return 6. """ __author__ 'Danyang' # Definition for a binary tree node c_ TreeNode: ___ - , x val x left N.. rig...
f18c667920fd2bd0879cf08aefccec88f5ab5424
syurskyi/Python_Topics
/021_module_collection/ordereddict/examples/ordereddict_001.py
3,195
4.5
4
# OrderedDict # # Prior to Python 3.7, dictionary key order was not guaranteed. This became part of the language in 3.7, # so the usefullness of this OrderedDict is diminished - but necessary if you want your dictionaries to maintain key # order and be compatible with Python versions earlier then 3.6 (technically dicts...
629afab9d1f2edc335686eb9ba3c22d711437bff
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/LinkedList/143_ReorderList.py
1,737
4.0625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reorderList(self, head): """ Firstly, use two pointer to find the mid node_keep,...
5fdfd19366e69ce4f6d38a4fe3aa289881847a5f
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/Algorithms in Python Live Coding & Design Techniques/002_backtracking/004_word-search-puzzle/Boggle.py
770
3.59375
4
my_dict {'RAY', 'APPLE', 'FAKE', 'BOOKS'} m 4 n 4 ___ find_words(boggle, visited, i, j, word visited[i][j] 1 word ''.j..([word, boggle[i][j]]) __ word __ my_dict: print(word) ___ row __ ra__(i-1, i+2 ___ col __ ra__(j-1, j+2 __ is_valid(row, col, visited ...
dfad7dd31f2f90a1aa05d52dae88ac20f145b5f6
syurskyi/Python_Topics
/065_serialization_and_deserialization/001_pickle/examples/45. Pickling - Coding_002.py
11,845
4.59375
5
# n this part of the course I am only going to discuss pickling basic data types such as numbers, strings, tuples, # lists, sets and dictionaries. # In general tuples, lists, sets and dictionaries are all picklable as long as their elements are themselves picklable. # Let's start by serializing some simple data types, ...
4bdc3e5c0b1cb56581808303ac989ea1c599c5d1
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/234_capitalize_sentences/save5_passed.py
332
3.875
4
import re def capitalize_sentences(text: str) -> str: '''Returns sentence with correct capitalisation.''' def upper_it(m): return m.group().upper() sentence = re.split(r'([!?.])\s', text) output = ' '.join([re.sub(r'^\w', upper_it, line) for line in sentence]) return re.sub(r'\s([?.!])', r'...
4aa523e8b89b526e154a27c9d0b45f5056a4be9c
syurskyi/Python_Topics
/065_serialization_and_deserialization/002_json/_exercises/_templates/53. Custom JSON Decoding - Coding.py
21,723
3.9375
4
# # Custom JSON Decoding # # So far we have looked at how to encode (serialize) Python objects to JSON, using the standard as well as custom # # object serializers. # # Now we need to turn our attention to teh reverse process - deserializing (decoding) JSON data. # # Once again, the standard simple types such as string...
914cb8894d8d1e56c11d8be861b274e3df13d1fa
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/BinarySearch/81_SearchInRotatedSortedArrayII.py
1,464
4.09375
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: bool """ nums_size = len(nums) start = 0 end = nums_size - 1 while start <= end: ...
2f3eadacf6838ceff698dd25a24084b7774dcfe5
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/820 Short Encoding of Words.py
1,347
4.09375
4
#!/usr/bin/python3 """ Given a list of words, we may encode it by writing a reference string S and a list of indexes A. For example, if the list of words is ["time", "me", "bell"], we can write it as S = "time#bell#" and indexes = [0, 2, 5]. Then for each index, we will recover the word by reading from the reference ...
69fb9eab9782d4b53bbd781db80061561795fe8e
syurskyi/Python_Topics
/045_functions/013_switch_simulation/003.py
922
4.125
4
def add(x, to=1): return x + to def divide(x, by=2): return x / by def square(x): return x ** 2 def invalid_op(x): raise Exception("Invalid operation") def perform_operation(x, chosen_operation, operation_args=None): # If operation_args wasn't provided (i.e. it is None), set it to be an empt...
3ea498eec2df07acc5a10ff3b8daaa0ef24ef0f6
syurskyi/Python_Topics
/070_oop/007_exceptions/_exercises/templates/The_Complete_Python_Course_l_Learn_Python_by_Doing/74. Solution raising an error.py
154
3.8125
4
def count_from_zero_to_n(n): if n < 0: raise ValueError('Input should be a non-negative integer') for x in range(0, n+1): print(x)
a04255385772dd5f31a54968965cd6fd354b0f77
syurskyi/Python_Topics
/012_lists/examples/ITVDN Python Starter 2016/12-append.py
291
3.78125
4
# -*- coding: utf-8 -*- # Создание пустого списка my_list = [] # Метод append добавляет значение в список my_list.append(3) my_list.append(5) my_list.append(my_list[0] + my_list[1]) # Вывод списка на экран print(my_list)
c0f57ca64556bc368879e4ac1eed4a88eb6997cc
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/033 Search in Rotated Sorted Array.py
2,174
3.875
4
""" Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. """ __author__ 'Danyang' c_ Solution: ...
0cbbda0d988063e9926a52ca93580e511a91c11b
syurskyi/Python_Topics
/045_functions/_examples/The_Modern_Python_3_Bootcamp/369. SOLUTIONS Part 2.py
910
3.6875
4
# SOLUTIONS # Part # 2 # Solutions # Part # 2 # # Titleize def titleize(string): return ' '.join(s[0].upper() + s[1:] for s in string.split(' ')) # find_factors def find_factors(num): factors = [] i = 1 while (i <= num): if (num % i == 0): factors.append(i) i += 1 r...
dac3d95d56aaa07793ef86204efb0194e6709b9a
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/String/FindAndReplacePattern.py
2,144
4.09375
4
""" You have a list of words and a pattern, and you want to know which words in words matches the pattern. A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word. (Recall that a permutation of letters is a bijectio...
be6d3b624bf38e6ed7cf8c93a26d4c6cb6cd7269
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/100_python_Best_practices_for_absolute_beginers/Project+12 How to check if a point belongs to Circle.py
286
4.3125
4
_______ math x float(input("Insert point x: ")) y float(input("Insert point y: ")) r float(input("Insert the radius: ")) hypotenuse math.sqrt(pow(x,2) + pow(y,2)) __ hypotenuse < r: print("The point belongs to circle.") ____: print("The point does not belong to circle.")
a122ea2b3ce98e94a4d01e71fec488efeb01c53d
syurskyi/Python_Topics
/045_functions/008_built_in_functions/zip/_exercises/templates/015_zip() in Python.py
564
3.84375
4
# # Python code to demonstrate the working of # # zip() # # # initializing lists # name _ "Manjeet" "Nikhil" "Shambhavi" "Astha" # list # roll_no _ 4 1 3 2 # list # marks _ 40 50 60 70 # list # # # using zip() to map values # mapped _ z_ ? ? ? # # # convert...
0f7c3a814f2b69aa6b40bee42ff5ce60d131aed0
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/308_calculate_median_from_dictionary/save4_nopass.py
879
3.75
4
from collections import OrderedDict def calc_median_from_dict(d: dict) -> float: """ :param d: dict of numbers and their occurrences :return: float: median Example: {1: 2, 3: 1, 4: 2} -> [1, 1, 3, 4, 4] --> 3 is median """ values_sorted = dict(OrderedDict(sorted(d.items(), key=lambda t: t[...
428f83dfc61311945f20d61ded25298f643ed0ef
syurskyi/Python_Topics
/080_tracing/_exercises/templates/traceback – Extract, format, and print exceptions and stack traces/005_.py
1,293
3.796875
4
# Working With the Stack # There are a similar set of functions for performing the same operations with the current call stack instead of # a traceback. # # print_stack() import traceback import sys from traceback_example import call_function def f(): traceback.print_stack(file=sys.stdout) print 'Calling f() di...
79d56b1c2ecb5089792f5bdeb2ee0a55fbbc81d6
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/123/friends.py
1,080
3.890625
4
from collections import defaultdict names = 'bob julian tim martin rod sara joyce nick beverly kevin'.split() ids = range(len(names)) users = dict(zip(ids, names)) # 0: bob, 1: julian, etc friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (5, 9), (6...
fd930311925951b334d9b3f209d6d6a319ec9db5
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/621 Task Scheduler.py
2,660
4
4
#!/usr/bin/python3 """ Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could be done in one interval. For each interval, CPU could finish one task or just be idle. However, ...
40eb42e068769236a6f86af3da263cae1f533a6c
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/topics/OOP/313/constructors.py
1,016
3.703125
4
import re class DomainException(Exception): """Raised when an invalid is created.""" class Domain: def __init__(self, name): # validate a current domain (r'.*\.[a-z]{2,3}$' is fine) # if not valid, raise a DomainException self.name = name if not re.match(r'.*\.[a-z]{2,3}$', ...
f9e455c84aafd33dd75558bfbb089e9b43f1fd4c
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/lintcode/553_bomb_enemy.py
2,959
3.546875
4
""" Cache sharing nodes Main Concept: 1. the number of enemies killed is same between the two walls in line y 0 1 2 3 4 x 0 W 1 k 0 k W l 2 n 3 W 4 m the number of enemies killed is `n + k` at (1, 1) 2. since the iteration order, we can optimize the space ...
9927cba2ecbde550aadadc9ca4f15a1b6faa5276
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/pybites/intermediate/286_newbie_bite/save1_passed.py
251
3.84375
4
# Enter your code within the following function def get_username(): while True: username = input("Please type in the name 'PyBites':") if username == "PyBites": break else: print("Invalid username.")
9b0c5d18598425fafb0e07bc6bce6707020665ca
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/LinkedList/02.AddTwoNumbers.py
1,152
3.71875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # Definition for singly-linked list. c.. ListNode o.. ___ __init__ x self.val = x self.next = None c.. Solution o.. ___ addTwoNumbers l1, l2 """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """...
007503cf68313ea40c7b4ba5c843ed9c8e0fb404
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/algorithm-master/leetcode/382_linked_list_random_node.py
791
3.65625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None ____ r__ _______ r.. c_ Solution: ___ - , head """ @param head The linked list's head. Note that the head is guaranteed to be not null, so it contains at l...
0aa08a662cb93ae1b78a565535806c5f649c40c2
syurskyi/Python_Topics
/125_algorithms/_examples/Python_Hand-on_Solve_200_Problems/Section 4 Condition and Loop/triangle_types_solution.py
645
4.125
4
# To add a new cell, type '# %%' # To add a new markdown cell, type '# %% [markdown]' # %% # Write a Python program to check a triangle is equilateral, isosceles or scalene. # Note : # An equilateral triangle is a triangle in which all three sides are equal. # A scalene triangle is a triangle that has three unequal sid...
0533fe5dc87e34a79264ebf2b8ea6853312df088
syurskyi/Python_Topics
/018_dictionaries/_templates/dictionary_009.py
3,751
3.59375
4
# # -*- coding: utf-8 -*- # # # Keyword Arguments # d _ di__ a_100 b_200 # d # d _ di__ | 'a' 100 'b' 200 | # d # d _ di__ | 'a' 100 |'b', 200| # d # d _ |'a' 100 'b' 200 'c' |'d' 1, 'e' 2}} # d # # # We can also create dictionaries using a dictionary comprehension. # keys _ |'a' 'b' 'c'| # values _ 1 2 3 # # # We ...
aa70609eea170cb390ca53f697c3ff76f170d6c5
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/104_Maximum_Depth_of_Binary_Tree.py
407
3.625
4
# Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None c_ Solution: ___ maxDepth root """ :type root: TreeNode :rtype: int """ __ root is N..: r_ 0 ...