blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
2edb868e7f02efbea1a31d254a8bf03f405258be
LingChenBill/python_first_introduce
/fluent_python/ch02/14_memoryview.py
499
3.578125
4
# Date:2020/5/20 # Author:Lingchen # Mark: 内存视图其实是泛化和去数学化的NumPy数组 # 它让你在不需要复制内容的前提下,在数据结构之间共享内存。 import array numbers = array.array('h', [-2, -1, 0, 1, 2]) print('numbers 1: ', numbers) memv = memoryview(numbers) print('len(memv): ', len(memv)) print('memv: ', memv) print('memv[0]: ', memv[0]) memv_oct = memv.c...
94977699b83bbd652cc305c34cdd31ca9204cbac
LingChenBill/python_first_introduce
/head_first_python/ch03/self_bif/lc_nester.py
743
3.5625
4
# Date:2020/5/8 # Author:Lingchen # Mark: 将列表输出到文件或者到屏幕 import sys def print_lol(the_list, indent=False, level=0, out=sys.stdout): for each_item in the_list: if isinstance(each_item, list): print_lol(each_item, indent, level + 1, out) else: if indent: for ta...
52ad04495ef0b8edaea24b5c7de7d16d0d9bbfe0
LingChenBill/python_first_introduce
/ffawp/ch03/5_pandas_value_in_set.py
643
3.5625
4
# Date:2020/5/24 # Author:Lingchen # Mark: 利用pandas筛选出Excel购买日期属于一个特定集合的行 # python 5_pandas_value_in_set.py data/sales_2013.xlsx data/output/5_output_pandas.xlsx import pandas as pd import sys input_file = sys.argv[1] output_file = sys.argv[2] data_frame = pd.read_excel(input_file, sheet_name='january_2013', in...
399613f8d834c37ea1d847713a8f32db5f646caf
LingChenBill/python_first_introduce
/ffawp/ch04/2_db_insert_row.py
1,260
4
4
# Date:2020/5/31 # Author:Lingchen # Mark: 创建一个数据表,向表中插入CSV文件中的数据,然后展示表中数据 # python 2_db_insert_row.py data/supplier_data.csv import csv import sqlite3 import sys # csv文件名 input_file = sys.argv[1] con = sqlite3.connect('data/Suppliers.db') # 光标对象 c = con.cursor() # 创建数据表Suppliers create_table = """ CREATE ...
a3f8003be92584bf19119fce6c0bcd35d46e4727
LingChenBill/python_first_introduce
/head_first_python/ch02/05_07_3_nester.py
471
3.53125
4
'''这是nester.py模块,提供了一个print_lol函数,这个函数的作用是打印列表,其中有可能包含,也有可以不包含嵌套列表。''' print("模块函数:") def print_lol(the_list): '''the_list可以是任意嵌套的列表,把所指定的列表输出到屏幕上, 各个数据项各占一项 ''' for item in the_list: if isinstance(item, list): print_lol(item) else: print(item)
2bf855bce42dcf61cee814e5f33825db0913a26b
LingChenBill/python_first_introduce
/head_first_python/ch01/05_07_1_list_solving.py
1,589
4.1875
4
fav_movies = ["The Holy Grail", "The life of Brian"] print(fav_movies) print(fav_movies[0]) print(fav_movies[1]) print("For 迭代列表:") for each_flick in fav_movies: print(each_flick) # 列表处理代码被称为“组” print("也可考虑用while循环迭代:") count = 0 while count < len(fav_movies): print(fav_movies[count]) count = count + 1 p...
a4d669a05f159f33bf285f2e1cb1fc04d537c02c
LingChenBill/python_first_introduce
/fluent_python/ch02/3_listcomp_tshirts.py
636
3.859375
4
# Date:2020/5/16 # Author:Lingchen # Mark: 列表里是3种不同尺寸的T恤衫,每个尺寸都有2个颜色 # 列表推导的作用只有一个:生成列表 colors = ['black', 'white'] sizes = ['S', 'M', 'L'] # 得到的结果是先以颜色排列,再以尺码排列 tshirts = [(color, size) for color in colors for size in sizes] print('tshirts color -> size: ', tshirts) print('tshirts for: ') for color in colors: ...
90755c8780706dd6cd8ede0af03978df8ddb8214
SerhiiDemydov/Cursor-HW-Advansed
/HW4-Test/UnitTest_Calc.py
2,755
3.765625
4
import unittest from Calculator import Calculator class TestCalculator(unittest.TestCase): def test_add(self): self.assertEqual(Calculator.add(3, 5), 8) self.assertEqual(Calculator.add(-2, 5), 3) self.assertEqual(Calculator.add(0, 5), 5) x = 5 self.assertEqual(Calculator.ad...
d8d65f9ba9813cceca5b9ae485222ae551fef13a
oaugusto256/foo.bar
/solution1.py
740
3.6875
4
def remove_values_from_list(the_list, val): return [value for value in the_list if value != val] def solution(data, n): # Your code here dictionary = {} if n == 0: return [] for value in data: if (dictionary.get(value) == None): dictionary[value] = 1 else: ...
28a7215ecb09d65b12c17e899437db6bd0dacfd8
shenxiaoxu/leetcode
/questions/1775. Equal Sum Arrays With Minimum Number of Operations/equal.py
1,151
4
4
''' You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive. In one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive. Return the minimum number of operations required to make ...
34d1d0dc8975f8566f4b11479a8b338012c3beea
shenxiaoxu/leetcode
/questions/1742. Maximum Number of Balls in a Box/maximum.py
893
3.859375
4
''' You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity. Your job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball...
b2a44dc07e4c060fd439125a409b581bd6ede7d1
shenxiaoxu/leetcode
/questions/1864. Minimum Number of Swaps to Make the Binary String Alternating/min.py
1,434
3.921875
4
''' Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible. The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, while the string "0100" is not. Any two characters may be sw...
036f405a15ba9f3da90a02ded35743a1c92a051f
shenxiaoxu/leetcode
/questions/1686. Stone Game VI/stone.py
1,649
3.953125
4
''' Alice and Bob take turns playing a game, with Alice starting first. There are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and Bob may value the stones differently. You are given two integer arrays of length n, aliceValues a...
efb0454f42df610d0e882058d7b01b05fc1d3ef1
shenxiaoxu/leetcode
/questions/1838. Frequency of the Most Frequent Element/freq.py
788
3.984375
4
''' The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1. Return the maximum possible frequency of an element after performing at most k operations....
e37cbe213edd0e30a98047db6833345219bbbf5f
shenxiaoxu/leetcode
/questions/1822. Sign of the Product of an Array/sign.py
480
3.96875
4
''' There is a function signFunc(x) that returns: 1 if x is positive. -1 if x is negative. 0 if x is equal to 0. You are given an integer array nums. Let product be the product of all values in the array nums. Return signFunc(product). ''' class Solution: def arraySign(self, nums: List[int]) -> int: sign ...
4a3d01f604f2965978c7ee8920314693da7b781f
shenxiaoxu/leetcode
/questions/654. Maximum Binary Tree/maximum.py
1,321
3.8125
4
''' You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the following algorithm: Create a root node whose value is the maximum value in nums. Recursively build the left subtree on the subarray prefix to the left of the maximum value. Recursively build ...
bc4d3a8f910cc1dbab2c410282431f0299a9b56a
shenxiaoxu/leetcode
/questions/1758. Minimum Changes To Make Alternating Binary String/minim.py
821
3.9375
4
''' You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa. The string is called alternating if no two adjacent characters are equal. For example, the string "010" is alternating, while the string "0100" is not. Return the minimum number o...
3c847b586eb83fd23e3c800567cd1f1eff2c5177
shenxiaoxu/leetcode
/questions/1697. Checking Existence of Edge Length Limited Paths/checking.py
1,494
3.625
4
''' An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. Note that there may be multiple edges between two nodes. Given an array queries, where queries[j] = [pj, qj, limitj], your task is to determine for each queries[j] ...
f01274bb331d78f5e7f7d5153be233a2a969a75f
shenxiaoxu/leetcode
/category practice/Recursion&BinarySearch/74. Search a 2D Matrix/search.py
789
3.9375
4
''' Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. ''' class Solution(object): def searchTarget(self, matrix, ta...
f6a91bc6a2ce4b26d3f8fb3580b944180daf7405
shenxiaoxu/leetcode
/questions/1943. Describe the Painting/describe.py
2,061
4.09375
4
''' There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti...
c06392de7e6bf2bc9b46977eae9c6417c64e3b5c
shenxiaoxu/leetcode
/questions/1879. Minimum XOR Sum of Two Arrays/mini.py
784
3.828125
4
''' You are given two integer arrays nums1 and nums2 of length n. The XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed). For example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = ...
b368f95fe983f786d4dcdd0391a722ce3a4e8bca
shenxiaoxu/leetcode
/questions/1837. Sum of Digits in Base K/sum.py
658
3.96875
4
''' Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k. After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10. ''' class Solution: def sumBase(self, n: int, k: int) -> int: res...
a8626188d5831240cc523718cf5cf2f14b578163
shenxiaoxu/leetcode
/questions/1759. Count Number of Homogenous Substrings/count.py
626
3.625
4
''' Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 109 + 7. A string is homogenous if all the characters of the string are the same. A substring is a contiguous sequence of characters within a string. ''' class Solution: def countHomogenous(s...
c46f03052193dc90c6bd2865ec132d83f8d3abb6
shenxiaoxu/leetcode
/category practice/Array&Sort Algorithm/Selection Sort/stack.py
471
3.734375
4
''' use two stack to simulate selection sort ''' class Solution(object): def selectionsort(self, nums): s1, s2, res = nums, [], [] while len(s1): g_min = float('inf') while len(s1): g_min = min(g_min, s1[-1]) s2.append(s1.pop()) while len(s2): if s2[-1] == g_min: s2.pop() else: ...
03db28e49674fc104470715a0e49a1e01977c602
shenxiaoxu/leetcode
/questions/1800. Maximum Ascending Subarray Sum/maximum.py
775
3.875
4
''' Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums. A subarray is defined as a contiguous sequence of numbers in an array. A subarray [numsl, numsl+1, ..., numsr-1, numsr] is ascending if for all i where l <= i < r, numsi < numsi+1. Note that a subarray of s...
d9775445461e8c16c0fe356849829f28b5298b1f
shenxiaoxu/leetcode
/questions/1930. Unique Length-3 Palindromic Subsequences/unique.py
797
4.09375
4
''' Given a string s, return the number of unique palindromes of length three that are a subsequence of s. Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once. A palindrome is a string that reads the same forwards and backwards. A subsequence of a string is a new s...
a6e716aa95a9e834266d591e5cbbb3d0716e14b3
shenxiaoxu/leetcode
/questions/1552. Magnetic Force Between Two Balls/magnetic.py
1,048
3.84375
4
''' In universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any tw...
2ccf110ec49a06d26670911123698c8e7bd262aa
shenxiaoxu/leetcode
/questions/1870. Minimum Speed to Arrive on Time /minimum.py
1,396
4.0625
4
''' You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the ith train ride. Each trai...
4f67561ea72c4f3b2ff76b00d81f5afefdb374d5
shenxiaoxu/leetcode
/questions/300. Longest Increasing Subsequence/longest.py
610
3.8125
4
''' Given an integer array nums, return the length of the longest strictly increasing subsequence. A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7]. ''...
8e09225dd550758eaf7f580d58e301c7b47d0d04
shenxiaoxu/leetcode
/questions/1763. Longest Nice Substring/longest.py
1,258
3.953125
4
''' A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, "abABB" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, "abA" is not because 'b' appears, but 'B' does not. Given a string s, return the longest substring of s that...
0de0211390d12a1925f30a632ee30a8154093c16
shenxiaoxu/leetcode
/questions/1925. Count Square Sum Triples/count.py
542
3.84375
4
''' A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2. Given an integer n, return the number of square triples such that 1 <= a, b, c <= n. ''' class Solution: def countTriples(self, n: int) -> int: c_s = set() res = 0 for i in range(1,n + 1): c...
8372dc1afe76290b6cd97c7d0e0ad6e3a8c3b769
shenxiaoxu/leetcode
/questions/1850. Minimum Adjacent Swaps to Reach the Kth Smallest Number/min.py
2,126
3.875
4
''' You are given a string num, representing a large integer, and an integer k. We call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones. For example, when num = "5489355142":...
412e761a0cfdd588548885d0c84f0b77bc454136
shenxiaoxu/leetcode
/questions/1668. Maximum Repeating Substring/maximum.py
1,039
3.890625
4
''' 1668. Maximum Repeating Substring For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value...
7ec99d4dac71b730e7a610afeb15b125ef8a49bc
shenxiaoxu/leetcode
/questions/1681. Minimum Incompatibility/min.py
1,839
3.953125
4
# coding: utf-8 ''' 1681. Minimum Incompatibility You are given an integer array nums​​​ and an integer k. You are asked to distribute this array into k subsets of equal size such that there are no two equal elements in the same subset. A subset's incompatibility is the difference between the maximum and minimum el...
52736e13eed34412485f62469c4cf04c60a8ac64
shenxiaoxu/leetcode
/questions/1916. Count Ways to Build Rooms in an Ant Colony/count.py
1,339
3.59375
4
''' You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom, where prevRoom[i] indicates that you must build room prevRoom[i] before building room i, and these two rooms must be connected directly. Room 0 is alre...
306246b9e68c7489347d96f7340978ed8782dbd2
shenxiaoxu/leetcode
/category practice/Recursion&BinarySearch/278. First Bad Version/first.py
800
3.671875
4
''' 278. First Bad Version You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n ...
29807122939846080e6edd0ddc72f3510c9f42df
shenxiaoxu/leetcode
/questions/1865. Finding Pairs With a Certain Sum/find.py
1,572
3.796875
4
''' You are given two integer arrays nums1 and nums2. You are tasked to implement a data structure that supports queries of two types: Add a positive integer to an element of a given index in the array nums2. Count the number of pairs (i, j) such that nums1[i] + nums2[j] equals a given value (0 <= i < nums1.length and...
ac218cb723c696c8727ac623a83772a3e73bc79b
shenxiaoxu/leetcode
/questions/76. Minimum Window Substring/minimum.py
1,192
3.8125
4
''' Given two strings s and t, return the minimum window in s which will contain all the characters in t. If there is no such window in s that covers all characters in t, return the empty string "". Note that If there is such a window, it is guaranteed that there will always be only one unique minimum window in s. '''...
a6cbfa9a159f99f2ac7d771d01f491c1b3d5686e
shenxiaoxu/leetcode
/questions/42. Trapping Rain Water/trapping.py
667
3.65625
4
''' Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. ''' class Solution: def trap(self, height: List[int]) -> int: stack, res = [], 0 for i in range(len(height)): while stack and height[i] >= h...
d6fb1774f0abf4a7dfacc3630206cc2e8fda883c
shenxiaoxu/leetcode
/questions/1807. Evaluate the Bracket Pairs of a String/evaluate.py
1,448
4.125
4
''' You are given a string s that contains some bracket pairs, with each pair containing a non-empty key. For example, in the string "(name)is(age)yearsold", there are two bracket pairs that contain the keys "name" and "age". You know the values of a wide range of keys. This is represented by a 2D string array knowled...
3c7fa49e6b389bfd3daf1e5b43971e7b07951899
shenxiaoxu/leetcode
/questions/1765. Map of Highest Peak/map.py
1,788
3.875
4
''' You are given an integer matrix isWater of size m x n that represents a map of land and water cells. If isWater[i][j] == 0, cell (i, j) is a land cell. If isWater[i][j] == 1, cell (i, j) is a water cell. You must assign each cell a height in a way that follows these rules: The height of each cell must be non-nega...
e46f38dc68bea6a74e30c2473fe91b91f8a5e794
shenxiaoxu/leetcode
/questions/1887. Reduction Operations to Make the Array Elements Equal/reduction.py
749
3.90625
4
''' Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps: Find the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i. Find the next largest val...
a1229a7f1c86ca19fe1b39b9496aa6d13cf520b8
shenxiaoxu/leetcode
/questions/1708. Largest Subarray Length K/array.py
1,548
3.8125
4
''' An array A is larger than some array B if for the first index i where A[i] != B[i], A[i] > B[i]. For example, consider 0-indexing: [1,3,2,4] > [1,2,2,4], since at index 1, 3 > 2. [1,4,4,4] < [2,1,1,1], since at index 0, 1 < 2. A subarray is a contiguous subsequence of the array. Given an integer array nums of di...
7902a7ed39635064d0e3e93aa1a0a24e1ac4a625
nikonst/Python
/OOP/oop1.py
1,247
4.125
4
# OOP Basic Concepts class Person: species = "Human" # Class field def __init__(self, name, gender): self.name = name self.gender = gender def introduceYourself(self): print("Hi! My name is ", self.name) def myFavouriteMovie(self): print("Terminator I") ...
1ec02d0f4606d7c8891724e2b78aabf69533430d
nikonst/Python
/Visualization/areaHistogramBarPlots/areaPlots.py
2,559
3.59375
4
import pandas as pd import matplotlib.pyplot as plt df_can = pd.read_excel('../Canada.xlsx', sheet_name='Canada by Citizenship', skiprows=range(20), skipfooter=2) print('Data downloaded and read into a dataframe!') #Print the dimensions of the dataf...
bfe9ecfe1e7c5e04be74a9ad86e0deed0535063e
nikonst/Python
/Core/lists/big_diff.py
691
4.125
4
''' Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in min(v1, v2) and max(v1, v2) functions return the smaller or larger of two values. big_diff([10, 3, 5, 6]) - 7 big_diff([7, 2, 10, 9]) - 8 big_diff([2, 10, 7, 2]) - 8 ''' i...
29dc483eabdfada41277bd0879d4d30db4c5e9e1
nikonst/Python
/Core/lists/centered_average.py
859
4.21875
4
''' Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, ignore just one copy, and likewise for the largest value. Use int division to produce the final a...
e924c76da60630526344873dfd5523c3bf9bec7d
nikonst/Python
/Core/lists/max_end3.py
792
4.40625
4
''' Given an array of ints length 3, figure out which is larger, the first or last element in the array, and set all the other elements to be that value. Return the changed array. max_end3([1, 2, 3]) - [3, 3, 3] max_end3([11, 5, 9]) - [11, 11, 11] max_end3([2, 11, 3]) - [3, 3, 3] ''' def maxEnd3(nums): ...
2a0e2276363ee4da8086654dd45f0acfcd621716
nikonst/Python
/Visualization/areaHistogramBarPlots/histogramPlots.py
4,958
3.546875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt df_can = pd.read_excel('../Canada.xlsx', sheet_name='Canada by Citizenship', skiprows=range(20), skipfooter=2) print('Data downloaded and read into a dataframe!') #Print the dime...
1b250401ab2bb07c17979979088b165c095461f8
Vaishnavi-cyber-blip/LEarnPython
/req.py
342
3.5
4
import requests # r = requests.get("url name") # Pre-requisite: internet connection # get function gets the code content of a entered url # Usage of post request url = "http://creativethinkers.ezyro.com/" data = { "p1": 7, "p2": 9 } r2 = requests.post(url=url, data=data) # Task : Search for free API , Send...
2dde45ecac9827dc9804a3d4277054bb07e5be02
Vaishnavi-cyber-blip/LEarnPython
/Online library management system.py
1,658
4.1875
4
class Library: def __init__(self, list_of_books, library_name): self.library_name = library_name self.list_of_books = list_of_books def display_books(self): print(f"Library name is {self.library_name}") print(f"Here is the list of books we provide:{self.list_of_books}") def...
22685b80e601c73f188734b3d511d5de29f51708
VesaKelani/python-exercises
/palindrome.py
253
4.21875
4
wrd = input("Enter a word: ") wrd = str(wrd) rvs = wrd[::-1] while rvs != wrd: print("This word is not a palindrome") wrd = input("Enter a word: ") wrd = str(wrd) rvs = wrd[::-1] if rvs == wrd: print("This word is a palindrome")
f9c5cd3e2dd12bf53a50c284e653cd35a8d055c9
as-xjc/xls_to_language_code
/prototype.py
1,399
3.53125
4
# -*- coding: UTF-8 -*- class Prototype: def __init__(self): self.args = {} self.types = {} self.data = {} def getArg(self, arg): return self.args[arg] def setArg(self, key, arg): self.args[key] = arg def printArgs(self): print('-- args ---') ...
ac00febe6fd077ad3b11e33b9e229e805cb9401d
IgorKreknin/2019-2-Atom-Backend-I-Kreknin
/Homework #2/game.py
3,741
3.671875
4
"""Game.py""" import re import os class Game(object): """Game class""" def __init__(self): self.players = ['', '', 'friendship'] self.vocabulary = ['X', 'O'] self.drow = True self.field = [[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]] self.current_player = False ...
0d70416d7d6d50d3f69d38ab8bb6878b3e673667
MarkVarga/python_to_do_list_app
/to_do_list_app.py
1,819
4.21875
4
data = [] def show_menu(): print('Menu:') print('1. Add an item') print('2. Mark as done') print('3. View items') print('4. Exit') def add_items(): item = input('What do you need to do? ') data.append(item) print('You have added: ', item) add_more_items() def add_more_items()...
b9b4c1d787db448d56fa849fadb9039b243cc5a9
shubhangisiddhapure/DSA-programme
/subset.py
845
3.9375
4
def Subset(arr1,arr2,arr1_size,arr2_size) : count=0 dir={} for i in range(arr1_size): if arr1[i] not in dir: dir[arr1[i]] = 0 dir[arr1[i]] += 1 for i in range(arr2_size): if arr2[i] not in dir: count += 1 break else : ...
5d88aca1f2b2f909acdba8d02c1f6d40f1907700
kundanjha1076/pythonbasics
/in_not_in.py
351
3.96875
4
# parrot = "Norwegian Blue" # letter = input("Enter a character ") # if letter in parrot: # print("{} is in {}".format(letter,parrot)) # else: # print("I don't need the letter") activity = input("What would you like to do today? ") if "cinema" not in activity: print("But I want to go to cinema") a = "AC...
4cb9c43593923526bc8483f2d3d323cb204a1cd8
rongqingpin/RSI_python
/Lecture6_6_parseTree.py
4,949
3.828125
4
# define parse tree using stack and binary tree # note: the current version requires putting parentheses wherever possible (input) import operator class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.a...
876ee3a679787d6fa10d306e31a9067245e71d71
rongqingpin/RSI_python
/Lecture3_5_stack.py
485
3.90625
4
class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items)-1] def size(s...
68188e833df911198bc8fc3c208f908b3cee778e
652412716/GetSvnLog
/two_number_sum.py
651
3.734375
4
# coding=utf-8 """ 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 难度:easy 题目链接:https://leetcode-cn.com/problems/two-sum/ 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] """ # 测试用例 test_nums = [2, 7, 11, 15] test_target = ...
fdf65da1b4283612c37241a1f789ff7fa5aed2ac
wachira90/python-all
/argument/test-argv1.py
253
3.6875
4
#!python import sys add = 0.0 # Getting the length of command # line arguments n = len(sys.argv) for i in range(1, n): add += float(sys.argv[i]) print ("the sum is :", add) ''' python test-argv1.py 3.14 2.89 4.44 the sum is : 10.47 '''
07692f7a1591e6f00b930925188af74218c4a9f5
aasergienko/Repozitoriy_Python
/homework12/pass_folder.py
453
3.71875
4
import os import re def count_folders(string): file_list = os.listdir(string) file_list = set(file_list) array = list() file_list = list(file_list) for c in file_list: if os.path.isdir(string + "/" + c): a = re.findall("[А-я]", c) b = re.findall("[A-z]", c) ...
fb0b1609d0affe23770a0f7182bdd004312bda72
avegso28/my_first_turtle
/user_draw.py
2,573
3.546875
4
import turtle as trtl bob = trtl.Turtle() r = input("What radius do you want to use for your circle? ") r = int(r) outC = input("What Color do you want for your outline? ") fillC = input("What color do you want to fill your circle with? ") bob.penup() bob.goto(-150,-150) bob.pendown() bob.color("green") bob.begin_fi...
66db9e4f15d4dfd9100812b10064529edb791cf2
blevgoblue/si206_hw3
/madlibhw3.py
2,095
3.9375
4
# Using text2 from the nltk book corpa, create your own version of the # MadLib program. # Requirements: # 1) Only use the first 150 tokens # 2) Pick 5 parts of speech to prompt for, including nouns # 3) Replace nouns 15% of the time, everything else 10% # Deliverables: # 1) Print the orginal text (150 tokens) # 1)...
a74c1aa289a51734a1378058f93bcc5b05951f73
j-hmd/daily-python
/Object-Oriented-Python/composition_intro.py
1,157
3.984375
4
# We can use composition to represent a "has a" relationship thta # breaks down a monolithic class, into smaller ones, with the appropriate # distribution of functionality class Book: def __init__(self, name, author=None): self.name = name self.author = author # Book has chapters chap...
ff3ccbf45d3be6f6933f03ec3be4ec8c03c15be1
j-hmd/daily-python
/Object-Oriented-Python/dataclasses_intro.py
600
4.1875
4
# Data classes make the class definition more concise since python 3.7 # it automates the creation of __init__ with the attributes passed to the # creation of the object. from dataclasses import dataclass @dataclass class Book: title: str author: str pages: int price: float b1 = Book("A Mao e a Luva",...
673f4b8a83013d62a8769bdcf928ba1b986df2fc
jlmcdonough/Kattis-Problems
/lastfactorialdigit.py
341
3.6875
4
def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) ans = [] inp = int(input()) for i in range(inp): x = int(input()) fact = (factorial(x)) if(fact>10): temp = str(fact) ans.append(temp[-1]) else: ans.append(fact) for y ...
d891c680c693cb42e567b8224d9c885946bf94c8
jlmcdonough/Kattis-Problems
/r2.py
147
3.765625
4
userInput = input() val1,val2 = userInput.split(" ",1) val1 = int(val1) val2 = int(val2) difference = val2-val1 ans = difference + val2 print(ans)
a4c66a8658f9b1045a6233448574bd97165c00ae
Isweet/euler
/python/09.py
374
3.5625
4
from itertools import count # Generator for all pythagorean triples s.t. r < bound def pyth_triples(bound): iterable = range(2, bound) if bound else count(2) for r in iterable: for s in range(1, r): yield [r*r - s*s, 2*r*s, r*r + s*s] for a, b, c in pyth_triples(None): if (a + b +...
cfb7b0c12dc6ca194aa3713b3c9ab44dd45a660f
pbsugg/DataStructuresP2
/graph/test_graph.py
1,779
3.5
4
import unittest from graph import Graph from node_graph import NodeGraph class GraphTestCase(unittest.TestCase): #6 nodes, see connections on McDowell, p. 107 def setUp(self): node0 = NodeGraph(0) node1 = NodeGraph(1) node2 = NodeGraph(2) node3 = NodeGraph(3) node4 =...
62f34f57d5ce31a08fc10c3ffe824f6eae0a5075
claudia1402/exercicio-3-fcc
/contagem regressiva.py
150
3.84375
4
'''Escreva a contagem regressiva de um foguete. ''' num = 10 while num >=0: print("Número: ", num) num = num - 1 print("FOGO!!")
1b0630e9ed6506481832ddcd5f7704350c27ced8
Mstrange8/Linked_Structures
/course.py
1,271
3.609375
4
""" Name: Matthew Strange Class: CS2420 Date: 02/06/2021 Description: Contains class for Course objects """ class Course: """Creates class object containing course information""" def __init__(self, _number=0, _name="", _credit=0.0, _grade=0.0): if not isinstance(_number, int) or _number ...
1ad481bbc989296f8ee7650e97d0a3f4c14d2311
rebeldroid12/glowing-octo-spice
/RICEU/interactivePython2013/memory.py
4,300
3.515625
4
# implementation of card game - Memory import simplegui import random deck = range(8)*2 exposed = [] state = 0 card1 = 0 card2 = 0 counter = 0 # helper function to initialize globals def new_game(): global deck, exposed, counter state = 0 counter = 0 random.shuffle(deck) exposed = [False] * 16 ...
982b0a210e30c742dfe6959d2e8fca0540519db4
AkashKV-1998/Warehouse-Management-System
/Python Code/Wh_manage-master/Wh_manage-master/wh_manage/productDetails/templates/productDetails/spclass.py
3,825
4.25
4
import math def Dijkstra(graph,source,target): # These are all the nodes which have not been visited yet unvisited_nodes=graph # It will store the shortest distance from one node to another shortest_distance={} # This will store the Shortest path between source and target node route=[] ...
d05200e052c3aedabeda49df3ac9da25595bdafd
4hmedher0/python-learn-code
/ssss.py
1,641
4.0625
4
class myclass : def __init__(self): print("Y R Welcom") def pr (self): print() def student (self,name): self.marks=[] #self.marks.append(Mark) self.name=name print("welcome %s in School"%(name)) color="red" def add_mark(self,mark): s...
975f43786306ca83189c8a7f310bec5b38c1ac84
Pawan459/infytq-pf-day9
/medium/Problem_40.py
1,587
4.28125
4
# University of Washington CSE140 Final 2015 # Given a list of lists of integers, write a python function, index_of_max_unique, # which returns the index of the sub-list which has the most unique values. # For example: # index_of_max_unique([[1, 3, 3], [12, 4, 12, 7, 4, 4], [41, 2, 4, 7, 1, 12]]) # would return 2 si...
da41ccc4fe2c768a710013a5e25f4450907baa93
Pawan459/infytq-pf-day9
/easy/Problem_26.py
684
3.875
4
# Given a string, write a python function to # return True if the strings "mat" and "jet" # appear the same number of times in the given string, else return False. # Note: Perform case insensitive string comparison wherever necessary. # Sample Input Expected Output # Jet on the Mat but mat is too long False # mat je...
8f550ef35946e2062b3a4fee6eceea9c2685734e
Pawan459/infytq-pf-day9
/easy/Problem_48.py
678
4.03125
4
# This problem is a practice for Debugging covered on Day 3 # The code is supposed to replace each value in a list with twice the preceding value # (and the first value with 0) # What's wrong with the code: # An input of [1,2,3] should give [0,2,4] # Debug the code to get the expected output. # Note: Problem ...
9105402ce5b6bde25f2f0bc82d8ec5f523b63f17
matckolck1/cosas
/anida.py
316
4.125
4
for i in range(3): print ("a") for j in range(3): print ("b") for i in range(2): print("te quiero") for m in range(3): print("mucho") for i in range(2): print("te quiero") for m in range(3): print("mucho") for t in range(1): print("naranja")
ca8642e04442fa7df4528a4d858029159ac4d982
ShivaniMaliwal/practice
/serverssp.py
729
3.515625
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 28 19:40:53 2020 @author: SHIVANI MALIWAL """ import socket def server_program(): target_ip = "192.168.43.127" target_port = 2623 server_socket = socket.socket() server_socket.bind((target_ip, target_port)) server_socket....
fd86b2ae3b647afb8b1f7a0bcc081a8d7bf380e5
buribae/is-additive-python
/is_additive.py
1,143
4.15625
4
import sys import time def secret(n): return n+n def primes_of(n): """Uses sieve of Eratosthenes to list prime numbers below input n Args: n: Maximum integer representing Returns: An array containing all prime numbers below n Alternative: Pyprimesieve https://github.com/jaredks/pyprimesieve """ if n < 2...
a18b9f086360672df0d2f96123f2f7986eae2231
thapakorn613/comarchMultiplication
/function.py
1,684
3.515625
4
import toFile as toFile def numToBinary(n,rangeOffbit): result = '' for x in range(rangeOffbit): r = n % 2 n = n // 2 result += str(r) result = result[::-1] return result def binToDecimal(str): n = 0 temp = 0 sum = 0 str_exe = list (str) for x in reversed(str...
0dfef4490db48fa6240d454c36aef2123e7cfb56
montioo/ticketbot
/tests/stats_database/stats_database.py
1,205
3.5625
4
import sqlite3 # db_name = "tix_stats.db" db_name = "../../splashTicketBot/tix_stats.db" version = "db_test" def create_db(): conn = sqlite3.connect(db_name) c = conn.cursor() c.execute("CREATE TABLE tickets (name text, price real, added integer, removed integer, version text)") conn.commit() co...
9d5d6b983be19cebcb5b3ff61c229eef19d59815
basharSaid/Python
/Random und Range.py
524
3.625
4
import random random.seed() # Werte un Berechnug a = random.randint(1, 10) b = random.randint(1, 10) c = a + b print ("Die Aufgabe:", a, "+", b) # Schleifr mit Range for versuch in range(1, 10): #Eingabe print("Bitte eine Zahl eingeben:") z = input() zahl = int(z) # Verzweigung if zahl == c: ...
cf436e734278683cefd80af9cd87bf485b22c4f1
Dervun/Python-at-Stepik
/1/11.3/11.3.py
1,753
3.546875
4
''' Напишите простой калькулятор, который считывает с пользовательского ввода три строки: первое число, второе число и операцию, после чего применяет операцию к введённым числам ("первое число" "операция" "второе число") и выводит результат на экран. Поддерживаемые операции: +, -, /, *, mod, pow, div, где mod — это вз...
fa2bb3897975551b93f517e134139139cf29d417
Dervun/Python-at-Stepik
/2/6.10/6.10.py
1,416
4.3125
4
""" Напишите программу, на вход которой подаётся прямоугольная матрица в виде последовательности строк, заканчивающихся строкой, содержащей только строку "end" (без кавычек). Программа должна вывести матрицу того же размера, у которой каждый элемент в позиции i, j равен сумме элементов первой матрицы на позициях (i-1, ...
ef4b1f9b167c368dbd47e7bd9c270db6326bc7af
Dervun/Python-at-Stepik
/1/11.5/11.5.py
754
4.3125
4
''' Напишите программу, которая получает на вход три целых числа, по одному числу в строке, и выводит на консоль в три строки сначала максимальное, потом минимальное, после чего оставшееся число. На ввод могут подаваться и повторяющиеся числа. ''' arr = sorted([int(input()) for i in range(3)]) print(arr[2], arr[0], ar...
b47ed870bcb81fde3e680cd534af554b3512ce19
Leadashtray/UniPY
/UniPy.py
3,625
3.546875
4
import requests import json import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) class Unifier(): ''' Caller to a unifi controller. The caller has a variety of functions, the most useful of which is likely make_request. simply add your endpoint as an argument, for ex...
58b5cdb93ea5ffbfc176ff880352778b0eae8848
ncorran/projeuler
/q9.py
694
3.65625
4
squares = [] n = 1000 # Set up a list of squares to check against for i in range(1, n): squares.append(i*i) # Check all a^2 + b^2 = c^2 for sum a+b+c = n # Then find a*b*c for a in range(1, n): # a < b < c, so start b from a+1 for b in range(a+1, n): csq = a*a + b*b # only check the cases ...
30f3900703453ccf006b78fba18b58bf42fae731
Huihuimu/shiyanlou-code
/calculator2.py
1,681
3.5
4
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ import sys def calculator(salary_orig): """计算税后薪资的函数,参数为原始收入""" start_point = 5000 # 应纳税所得额为收入减5000 social_security_rate = 0.08 + 0.02 + 0.005 + 0.06 shouldPay = salary_orig (1 - social_security_rate ) - start_p...
d568f47bf8b1412d11cdcd3172459f9fef4c9bbc
wSedlacek/Lambda-Hash-Tables
/src/hashtable.py
4,468
3.9375
4
from typing import List class LinkedPair: ''' Linked List hash table key/value pair ''' def __init__(self, key, value): self.key = key self.value = value self.next = None class HashTable: ''' A hash table that with `capacity` buckets that accepts string keys ...
5275618f52190d4abd3aa9a7eb65066f162bff26
JohnOiko/python-learning-projects
/tic_tac_toe/tic_tac_toe.py
8,814
4.1875
4
from random import seed, randrange, choice from datetime import datetime seed(datetime.now()) row_count = 3 column_count = 3 board = [[' ' for column in range(column_count)] for row in range(row_count)] # print the current state of the board def print_board(): i = 0 row_separator = f"{('-' * 5 + '+') * (colu...
66224869d973f4473690aa5b11e6ad9b41e7e4f3
rcalfredson/omaha
/lib/breakout.py
9,476
3.71875
4
"""Analyzes stock data for price breakouts, used as entry and exit signals. """ from random import randint import datetime import json from .alphavantage import backward_from from .maths import exp_moving_average def detected(numbers, mode): """ Returns a Boolean result indicating whether the last member in a ...
1de9906fe354e66728cb5f3c1266b0ea9cd449db
wym2010/learn_jenkins
/LICENSE.md/fib.py
149
3.65625
4
def fib(): x,y=0,1 while 1: yield x x,y=y,x+y for i in range(0,10): print (fib().__next__())
02d4805c2b4e613d55f89b73db19494d24637b05
manuellara/dataStructuresPython
/linkedList.py
1,445
3.859375
4
#Linked List class node: def __init__( self , data = None ): self.data = data self.next = None class linkedList: def __init__( self ): self.head = node() def append( self , data ): newNode = node( data ) cur = self.head while cur.next != None: ...
2ff9ef2057d8f8b647a5c6d3b109280e4bb2046c
kvantos/intro_to_python_class
/classwork/lesson_types.py
650
3.8125
4
import numpy as np import math # calculus of rectangle square h = 10 w = 20 s = h * w print("площадь прямоугольника с высотой %i и шириной %i будет: %i" % (h,w,s)) # calculate circle square radius = 5 circle_square = np.pi * radius**2 print("Площадь круга с радиусом %d будет: %.2f" % (radius, np.round(ci...
230237333f97d28111414c6e181c22cc496112af
kvantos/intro_to_python_class
/A5.py
2,121
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random import A4 # Каждому символу в таблице символов Unicode соответствует число. # Написать функцию, которая рассчитывает сумму чисел, которые # соответствуют символам, стоящим между двумя заданными включительно. # Например, в функцию передаются символы ‘x’ и ‘z...
37cd4739c746a8f6db689dddc8f91472976e6116
kvantos/intro_to_python_class
/A6.py
4,641
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math import random # 21. Вывести все числа от 0 до 1000, которые содержат в # себе цифры 1 и 7. Т.е. числа: 17, 71, 107, 117, 127, 137, … def find_numbers(): """ Input: nothing, it have everything it need. Output: numbers which contains...
ce17c91ee89fa0f460b8c07b742bd26b655ba961
kimbomejune/Coding_Test
/WeeklyContest221/Where_Will_the_Ball_Fall.py
4,645
3.53125
4
# WhereWilltheBallFall # You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides. # m x n 사이즈의 2차원 그리드 박스와 공이있다. 그 박스는 위아래가 뚫려있는 형태이다. # Each cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right o...
26a812952cf8362f48262c68c670857b2a4f28ca
Chestermozhao/Notes
/algorithms_practice/26.py
566
3.640625
4
"""Leetcode 26 Easy Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. """ class Solution: def removeDuplicates(...