blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
58645efc9f8154f9c87baec0a415c338f08f1e66
Crazy-Ginger/Python
/University/Software1/TurtleExample.py
243
3.65625
4
#!/usr/bin/env python3 import turtle from math import cos window = turtle.Screen() window = turtle.Screen() alex = turtle.Turtle() alex.speed(10) alex.pensize(1) step = 5 for i in range (10,200000,2): alex.forward(50) alex.right(i)
c1ab6cd737155bae1e9571f8f360b9982b54df98
BoyceLee/Pottery_Templates
/draw_a_polygon_spiral.py
830
3.96875
4
from save_to_svg import saveImg import turtle window = turtle.Screen() window.bgcolor("white") def spiral(new_turtle, number_of_sides, angle, set_length): new_turtle.pendown() new_turtle.left(angle) for item in range(0,(set_length)/7): new_turtle.forward(set_length) new_turtle.left(angle) set_length = set_le...
5161ba6c6bb12f7d0e97cb012973fb7c3e5d6576
dpm76/Microvacbot
/embedded/uvacbot/engine/driver.py
6,817
3.765625
4
class Driver(object): ''' Controls a motor set ''' #Driver modes MODE_DRIVE = 0 MODE_ROTATE = 1 #Thresholds for throttle ranges. For each range a different turning method will be used. THROTTLE_RANGE_THRESHOLD_1 = 25.0 THROTTLE_RANGE_THRESHOLD_2 = 75.0 THROTTLE_RANGE_THR...
4bc9e00f8f06cb43c4232a029814de6dd0a3afd9
jamix10/1102
/13/hw2_task2.py
332
3.9375
4
num_1 = int(input('Ввести число 1> ')) num_2 = int(input('Ввести число 2> ')) num_3 = int(input('Ввести число 3> ')) if num_1 == num_2 or num_1 == num_3 or num_2 == num_3: msg = num_1 + 5 + num_2 + 5 + num_3 + 5 print(msg) else: print('Нет равных чисел')
34011f8ac0d7ad2cf820466bdf6db15d1567168e
Steph-harris/py_exercises
/ex50/bin/dates.py
244
3.65625
4
from datetime import date from datetime import time from datetime import datetime def main(): today = date.today() dtNw = datetime.now() print(dtNw)#today.day, today.month, today.year if __name__ == "__main__": main()
96a30a242acc6256ab1295df82372f37eebbe243
chutianwen/LeetCodes
/LeetCodes/Amazon/MathPow.py
836
3.84375
4
def math_pow(x, y): ''' O(N) 2^(log2_N) :param x: :param y: :return: ''' if y == 0: return 1 else: if y % 2 == 0: return math_pow(x, y//2) * math_pow(x, y//2) else: return x * math_pow(x, y//2) * math_pow(x, y//2) res = math_pow(2, 5) # pr...
1af725bd08ff96f8809ef30c3dead1959eee2e3f
luckyharryji/Artificial-Intelligence-Practice
/Python_Initial/Assignment1/xjq158-pa1.py
10,563
3.53125
4
''' Name: Xiangyu Ji NetID: XJQ158 ''' """Homework 1 of EECS 348: Intro to AI. This file/module contains my personal solution for the 4 problem set of assignment. Each problem aresolved with one function/Class. """ def binarySearch(L, v): """Search a value in a list with binary search. Search to decide if ...
f75bc0731ff2f1a73281fa4c5d64f6fdea146b19
Lingrui/Learn-Python
/Beginner/binary_number.py
361
4.28125
4
#!/usr/bin/python #print out a few binary numbers #the second parameter 2, tells python we have a number based on 2 elements(0 and 1), to convert a byte to decimal print int('00',2) print int('01',2) print int('10',2) print int('11',2) print int('00000010',2) print int('00000011',2) print int('00010001',2) print i...
6a07bfb124013107932f9611def1073ecaedfe8e
crerwin/advent
/advent/advent2022/day3.py
2,026
4.1875
4
from advent.day import Day class Day3(Day): year = 2022 day = 3 def _part1(self): return get_priorities_sum(self.input().splitlines()) def _part2(self): return part2_priorities_sum(self.input().splitlines()) def split_line(line: str) -> tuple[str, str]: if len(line) % 2 != 0: ...
b07ad2fc7c8150c6563c1f74cc0a47860c04fb6a
fatjan/code-practices
/python/cvalleys.py
292
3.53125
4
def countingValleys(n, s): pos = 0 valCount = 0 for i in s: if i == 'U': if pos + 1 == 0: valCount += 1 pos += 1 else: pos -= 1 return valCount print(countingValleys(8,'UDDDUDUU'))
ba5b0cb3aa6abd98d16630ce9af029cadde70093
utkarsh192000/PythonBasic
/84Concatenation.py
78
3.515625
4
print("Geeky"+"Shows") str1="Expert" print("Hello "+str1) print("Hello",str1)
24f99bece4ea5897701cace171421892d184fc33
keyinggo/keyinggo.github.io
/COVID-19.py
3,109
3.890625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt pd.set_option('display.max_column', None) # Q1-1 Store the COVID19.csv data into a DataFrame covid covid = pd.read_csv('COVID19.CSV') # Q1-2 Print the dimensions of the covid (number of rows and columns). print(covid.shape) # Q1-3 Print a summary...
8c154adf32e098e354cb23db2039d8f6458c7de8
kevinhur99/PythonGames
/Game_5c.py
6,945
3.53125
4
import random import pygame import sys from pygame.locals import * # Board: (List (List Color)) # A Board is a 2-D list of colors # A Color is a [List Int, Int, Int] # - Where each position represents the RGB GRAY = (100, 100, 100) NAVY_BLUE = (60, 60, 100) WHITE = (255, 255, 255) RED = (255, 0, 0) ...
82ae91727b2dc31156971d1e69b05ce749b2f7fe
medifle/python_6.00.1x
/Pset1_3_1.py
446
3.890625
4
# alphabetical substrings s = 'abcfzbcd' l = len(s) - 1 i = 0 start = 0 end = 0 ifContinue = 0 result = '' while l > 0: if ifContinue == 0: start = i if s[i] <= s[i + 1]: ifContinue = 1 else: ifContinue = 0 end = i if len(s[start:end + 1]) > len(result...
3ceb23b9da7125f28624d13d844f02b9956b7f33
calgagi/leetcode
/0728/answer.py
492
3.546875
4
class Solution(object): def selfDividingNumbers(self, left, right): """ :type left: int :type right: int :rtype: List[int] """ returnList = [] for i in range(left, right+1): sdn = True for j in str(i): if j == "0" or i %...
5d498fe781f3eda015083f6876fa223ced4a4977
zhangyebai/LeetCode
/Python/remove_duplicates_from_sorted_array.py
1,035
3.921875
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ class Solution(object): # 直接pop出重复的元素,耗时较长。。 def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ length = len(nums) if length <= 0: return length curr = nums[0] inde...
b0a35cf8f22efcc33a73db6edefb5a24d1b92e1d
hiimmuc/Algo-Ds
/data_structure_Python/Queue.py
1,815
3.671875
4
# FIFO rules class Queue: def __init__(self, capacity: int): self.front = self.size = 0 self.rear = capacity-1 self.Q = [None] * capacity self.capacity = capacity def EnQueue(self, data): if self.isFull(): print('Full!!') self.DeQueue() ...
54d47ce9938972d5f30312154faf63bdad95fd8f
yukclam9/yukclam9
/LearningPython/learnpythonthehardway/ex10.py
809
3.90625
4
# \t does the tab function in python tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." # \ would not cause anything, and \\ would # escape the later \ backslash_cat = "I'm \\ a \\ cat." # tab appears at any place # would skip a line if the string starts at another line # after """ # = """ #stringst...
331fad6f0508a973dabf40bfe3bfde6fb591e719
sarathrajkottamthodiyil/python
/Practise/stringslice.py
255
3.9375
4
astring = "HELLO WORLD" print(astring[3:7]) ######### astring = "hello world" print(astring[3:7]) print(astring[3:7:1]) print(astring[::-1]) ######lower & upper######## astring = "Hello world" print(astring.upper()) print(astring.lower())
d4fa88731db0d13ebe67582819296bcd9c23d9c1
dikoko/practice
/5 Lists/5-14_add_num_in_list.py
1,649
3.9375
4
class Node(object): def __init__(self, val): self.val = val self.next = None def append_val(head, val): if not head: return None node = head while node.next: node = node.next node.next = Node(val) def print_list(head): node = head while node: pri...
05789d1a7e8bc3c0f03f2f3eade849df5b3ea034
kirankumarm97/python-practices
/pgms/mostcommen.py
290
3.546875
4
from collections import Counter,OrderedDict if __name__ == "__main__": s = input().strip() b=[] a=Counter(s) for i in a.keys(): if(a[i]>1): b.append([i,a[i]]) b=sorted(b,key=lambda x:x[1]) b.reverse() for i in b print(*i)
7828ce5d7898575bd778be48f08990d5c2fce73c
arpit0891/Project-Euler
/p179.py
406
3.5
4
import sys if sys.version_info.major == 2: range = xrange def compute(): divisors = [2] * (10**7 + 1) # Invalid for indexes 0 and 1 for i in range(2, (len(divisors) + 1) // 2): for j in range(i * 2, len(divisors), i): divisors[j] += 1 ans = sum((1 if divisors[i] == divisors[i + 1] else 0) for i in range(2...
c35b1b144f24e07a65e44600e03007ac6bc6f675
nanihari/regular-expressions
/strings in text.py
393
4.3125
4
##program to search some literals strings in a string. import re patterns=["An", "aim", "fortune", "hari"] text="An aim in the life is the only fortune worth finding" for pattern in patterns: print('Searching for "%s" in "%s" ->' % (pattern, text),) if re.search(pattern, text): print(...
7c86027b709636153916523ed5f3e5afc7c0ebec
JoeCare/Courses-and-exercises
/Cryptography/my_decrypter.py
2,086
4.25
4
#!/usr/bin/env python3 # thanks to Al Sweigart for this and many other Python exercises and projects ideas def main(): user_msg = input('Please type or paste string You want to decrypt.') key1 = int(input('Please input first encryption key value for Your message.')) key2 = int(input('Please input second ...
5db18fbb18655ab731866be1bb25a2289a419a5b
DrakeAlia/Graphs
/projects/ancestor/ancestor.py
4,231
4.03125
4
# Suppose we have some input data describing a graph of relationships between parents and children over multiple generations. # The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique integer identifier. # Write a function that, given the dataset and the ID of an individua...
e02f1d8754194a53234b3551c68711492bca6a8a
DanielGB-Dev/RepositorioTC1001S.101-Eq4
/HCRfinal.py
2,347
3.875
4
import random Lado_A = ['Granjero', 'Zorro', 'Ganzo', 'Maiz'] Lado_B = [] Path = [] def seleccion(L): """Select a random element from a list. Args: L (list): Lado_A Returns: str: element from L """ op = random.randint(0, len(L)-1) return (L[op]) def Viaje(F, D): """Si...
17750ecb01632f2bf91a61c2d794f41b972e4a51
J-RAG/DTEC501-Python-Files
/Lab 2-1-1qs4.py
567
4.125
4
# Lab 2-1-1 question 4 # By Julan Ray Avila Gutierrez, jra0108@arastudent.ac.nz user_name = input("Please enter your first name: ") exchange_rate = float(input(f"Hi {user_name}. Please enter the NZ/AU exchange rate: ")) nzd_money = float(input("Please enter the amount of NZ $'s you want to exchange: ")) aus_mo...
85c4b1ac4fdd87309c99730ecd71abbbb5b3ef71
coingraham/codefights
/python/isLucky/isLucky.py
385
3.765625
4
def isLucky(n): n_string = str(n) n_list = [] is_zero = 0 for digit in n_string: n_list.append(int(digit)) half = len(n_list)/2 for item in range(0, len(n_list)): if item < half: is_zero += n_list[item] else: is_zero -= n_list[item] return...
e06c47aa161dec0c5a016a8bba3cef5f3f3ab01d
mydearlutein/python-practice
/problems/valid_palindrome.py
718
4.125
4
import argparse import re def is_palindrome(self, s: str) -> bool: s = s.lower() # 특수문자 및 공백 제거 s = re.sub(r'[^a-z0-9]','', s) # # 뒤집힌 char 집합 생성 # chars = list(s) # chars.reverse() # # # 뒤집힌 문자열 생성 # s_reverse = "".join([char for char in chars]) # # return s == s_revers...
91f5154668d8fe2dc470492dae673f99bd0cc18d
liuspencersjtu/MyLeetCode
/71-Simplify-Path.py
420
3.578125
4
class Solution: def simplifyPath(self, path: str) -> str: path = path.split('/') path = list(map(lambda x:x.replace('/', ''), path)) path =list(filter(lambda x: (x!='' and x!='.'), path)) res = [] for p in path: if p == '..': if res: ...
4e07437038af92672268b7ef9aec4bac90dcae45
Binodsubedi/Lab_1
/Area_of_triangle.py
193
4.15625
4
Base = int(input("Enter the base length of the triangle:")) Height = int(input("Enter the height of the triangle:")) Area = 1/2* Base * Height print("Area of your prefered triangle is ", Area)
b9fbc2b322870bc6e26652c88ced2436f8629d0e
InsideZhou/inside-utils
/python/leetcode/permutations.py
1,520
4
4
#!/usr/bin/env python # https://leetcode.cn/problems/permutations/ import unittest from typing import List # 借助不含重复数字的特性,利用分治的思路实现。 def permute(nums: List[int]) -> List[List[int]]: nums_length = len(nums) if 2 == nums_length: return [nums, nums[::-1]] elif 1 == nums_length: return [nums] ...
eace34348a6a63ced4bee321e33da085f890542a
RyanPilon/exercism
/python/phone-number/phone_number.py
610
3.625
4
import re class PhoneNumber: def __init__(self, phone_number): exp = '([+]1)*\D*([2-9]\d\d)\D*([2-9]\d\d)\D*(\d\d\d\d)(\d*)' result = re.search(exp, phone_number) if (result is None) or (len(result.group(5)) > 0): raise ValueError('.+') self.area_code = result....
3f84471c79bf6dc9998ffc20dd0bb552966e1ba2
Buzz-D/project-euler
/problem_10.py
574
3.875
4
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. import time from util.prime import is_prime def main(): max_range = 2000000 sum_of_primes = 2 # Already added the 2 so that only every second number can be checked for being a prime for i in range...
ebd31180fe0535f19872dbbabdc3e78cfd0735b9
enrique-ayala/untitled
/last2.py
571
4.125
4
__author__ = 'enrique' ''' Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring). last2('hixxhi') → 1 last2('xaxxaxaxx') → 1 last2('axxxaaxx') → 2 ''' def last2(str):...
d8e98db5997cf50dc5cb98cefc3705914e00c85d
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_41/71.py
3,698
3.71875
4
#!/usr/bin/env python ################################################################################ import sys import os import logging #if (os.environ.get("DEBUG") != None): #logging.basicConfig(level=logging.DEBUG) def main(): input = sys.stdin # T specifies the number of test cases T = int(in...
6b42735b6a040c8de89a7ae11b9a910f1a4cea2c
SimeonTsvetanov/Coding-Lessons
/SoftUni Lessons/Python Development/Python Fundamentals September 2019/Problems And Files/05 EX. B. SYNTAX, CONDITIONAL STATE. AND LOOPS - Дата 20-ти септември, 1430 - 1730/More Exercises/03. Wolf In Sheep's Clothing.py
1,683
3.96875
4
""" Basic Syntax, Conditional Statements and Loops - Exercise Check your code: https://judge.softuni.bg/Contests/Practice/Index/1720#2 Video: https://www.youtube.com/watch?time_continue=4&v=7sHE4HEUqi8 SUPyF2 Basic Exercise More - 03. Wolf In Sheep's Clothing Problem: Wolves have been reintroduced to Great Br...
196c5910f86d629ba145e0ec7fb208a8426d86ba
Hari-krishna-tech/Leetcode-questions-and-Answer-in-python
/a11-leetcode_question.py
1,594
3.9375
4
""" Reversing A LinkedList """ ''' simple Linked list implementation ''' class Node: def __init__(self,data,next = None): self.data = data self.next = next class LinkedList: def __init__(self): self.head = None self.length = 0 def get_head(self): return self.head def add(self,data): ...
5354ac524b6f7ed4560ec942f9604e39a4f2531e
modolee/algorithm-practice
/baekjoon/permutation/STL.py
282
3.734375
4
import itertools input_str = 'ABC' per = list(itertools.permutations(input_str)) print(per) per2 = list(itertools.permutations(input_str, 2)) print(per2) com = list(itertools.combinations(input_str, 3)) print(com) com2 = list(itertools.combinations(input_str, 2)) print(com2)
9da005af5b92f319af7e198f16f6cdf9d7b9b1e1
milanmenezes/python-tutorials
/solutions/unit6/calci.py
410
3.765625
4
class calc(): # def __init__(self): # self.x=0 # self.y=0 def __init__(self,x,y): self.x=x self.y=y def add(self): return self.x+self.y def sub(self): return self.x-self.y def mul(self): return self.x*self.y def div(self): if self.y!=0: return self.x/self.y else: return ...
8be5539bff8c4852124082e5f53475b03f42021a
heitorchang/learn-code
/checkio/elementary/correct_sentence.py
290
3.890625
4
def correct_sentence(text: str) -> str: """ returns a corrected sentence which starts with a capital letter and ends with a dot. """ # your code here result = text[0].upper() + text[1:] if result[-1] != ".": result += "." return result
55f628b5c4d95fa67f1f2947a4bd3d45df97fead
lozaeric/icpc_undav
/RPC/2018/12/palindrome.py
320
3.75
4
def is_palindrome(w): m = len(w)//2 for i in range(0,m): if w[i] != w[i+m]: return False return True w = input() n = len(w) c = 0 for i in range(n): for j in range(i,n): if is_palindrome(w[i:j+1]): c += 1 if c%2 == 1: print("Odd.") else: print("Or not.")
d8b74bc39d4988754b599afc8421e18c3e7d3d4b
xiaoxiamin/py-script
/games.py
682
3.6875
4
#!/usr/bin/env python #coding: utf8 import random import sys allList = ['石头', '剪刀', '布'] gDict = {'石头':0, '剪刀':1, '布':2} prompt = """(0)石头 (1)剪刀 (2)布 请选择对应的数字: """ chnum = raw_input(prompt) if chnum not in '012': print 'Invalid choice' sys.exit(1) uchoice = allList[int(chnum)] cchoice = random.choice(allList) #...
484be29e8e68924418832d64ce04d75c285da1b4
an1ruddha/practice-python
/leetcode-longest-consecutive-sequence/main.py
1,334
3.6875
4
from typing import List class Solution: def longestConsecutive(self, nums: List[int]) -> int: if not nums: return 0 if len(nums) == 1: return 1 nums.sort() max_consecutive = 1 counter = 1 for i in range(1, len(nums)): if nums[i] - ...
f0b344a89ce5320af8d4cc56aab1f299733b2746
LunarEclipz/OOPP-Slazz
/Book.py
2,158
3.515625
4
import datetime as dt now = dt.datetime.now() class Book: renewCount = 0 def __init__(self): self.title = '' self.synopsis = '' self.genre = '' self.date_borrowed = 0 self.due_date = 0 self.reminder = 0 def get_title(self): retu...
7c696e77181e10d827325f6440fff20fc630af6b
asma123-ctr/Newcodes
/CALCUL.py
671
4.375
4
print("python calculator") first_number = int(input("enter first number:")) second_number = int(input("enter second number:")) print("operation type") print("+ for Addition") print("- for subtraction") print("* for multiplication") print("/ for division") operator = input("please select any one of above options...
7673fbc8abec16241e7c030cfdaaaf6cec25b4cb
ayr0/numerical_computing
/Labs/GaussianQuadrature/solutions.py
2,899
3.875
4
import numpy as np from matplotlib import pyplot as plt from math import sqrt, exp from scipy.linalg import eig from scipy.integrate import quad # function shifting problem def shift_function(f, a, b): """ 'f' is a callable funciton, 'a' and 'b' are the limits of the interval you want to consider.""" retur...
1ac1b3dcb7bfba4868085622e2b7ae7ca9c5b3de
WSOCcodingclub/django_docker
/Python_intro.py
170
3.8125
4
def hi(name): print('Hi ' + name + '!') girls = ['Rachel', 'Monica', 'Phoebe', 'Ola', 'You'] for name in girls: hi(name) print('Next girl') sortednames = []
a9f0de9662a3d03f4d0c48896e5b9450337a936b
felipechiarotti/development
/python/python_learning/m-to-mm.py
104
3.734375
4
meter = float(input("Digite um valor (m): ")) print("%.1fm corresponde a %.1fmm" % (meter, meter*1000))
3635f33e30b59b7d9d533254ecb8bd48fa446e28
SteffyDevassy/PythonLuminar
/Python_Collections/Dictionary_Pgms/dict_first.py
312
4.15625
4
#values stored in key-value pairs student={"rollno":100,"name":"ajay","course":"mca"} #access values using keys print(student["rollno"]) #duplicate keys are not allowed,but duplicate values are allowed #updation student["name"]="vijay" print(student) #adding new ele student["gender"]="male" print(student)
8c92d2934c952d60598b2adc790df8ae1160a331
Codechef-SRM-NCR-Chapter/30-DaysOfCode-March-2021
/answers/Tanmay Jaiswal/Day16/question2.py
439
3.65625
4
import numpy as py print("Input: ",end="") arr = py.array(input().split()).astype(int) def count(arr, low, high): while high >= low: mid = (high + low)//2 if (arr[mid] == 1 and (mid == 0 or arr[mid - 1] == 0)): return mid if arr[mid]==1: high...
93221fc68970af9eab98628776b94b76933e5af2
varun2020-tech/LABS
/varun1.py
161
3.953125
4
name=raw_input('what is your name?') print 'hi %s.' % name age=input('how old are you') print ' you will be hundred if you get the age' centuary=input(100-age)
db4c22e5b932491627e22034d7c9751012acd6ee
arthurlockman/RBE3002-Homework-3
/diesim.py
2,107
4
4
from random import SystemRandom class DieSim: """ This class allows for simulating a "fair" die by using a random number generator. """ def __init__(self, minimum, maximum, die=1): """ Initialize the die sim. :param minimum: Minimum die value. :param maximum: Maxim...
32ae1f3670ec5390f3f7b8d31ce3f912fd6a4b7d
vsutaria/CSP_Sudoku
/sudoku.py
2,936
3.828125
4
#from graphics import * from utilities import read_input_file, set_neighbors, is_solved, create_2d_list_from_sudoku, is_solution_valid from AC3_new import ac3, backtracking_search from sys import setrecursionlimit n = 9 inside_n=3 def display_solution(solved_sudoku): win = GraphWin('Face', 361, 361) # give title an...
8094d0b717b89795c40bfe75805830620b1453cc
yiming1012/MyLeetCode
/LeetCode/贪心算法/5760. 构成交替字符串需要的最小交换次数.py
1,928
3.953125
4
""" 5760. 构成交替字符串需要的最小交换次数 给你一个二进制字符串 s ,现需要将其转化为一个 交替字符串 。请你计算并返回转化所需的 最小 字符交换次数,如果无法完成转化,返回 -1 。 交替字符串 是指:相邻字符之间不存在相等情况的字符串。例如,字符串 "010" 和 "1010" 属于交替字符串,但 "0100" 不是。 任意两个字符都可以进行交换,不必相邻 。   示例 1: 输入:s = "111000" 输出:1 解释:交换位置 1 和 4:"111000" -> "101010" ,字符串变为交替字符串。 示例 2: 输入:s = "010" 输出:0 解释:字符串已经是交替字符串了,不需要交换。 ...
976d5365a8afb0f4521dd0dfa4b26398c1befa3f
dictator-x/practise_as
/algorithm/leetCode/0863_all_nodes_distance_k_in_binary_tree.py
1,149
3.578125
4
""" 863. All Nodes Distance K in Binary Tree """ from collections import defaultdict class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def distanceK(self, root: TreeNode, target: TreeNode, K: int) -> List[int]: graph = defau...
2399e217e3616fa3a7283fbe5e64be637cfb83f0
sahusaurabh65/-100daysofML
/Day_1 python oops concepts/property decorators .py
888
3.828125
4
#getter,setter,deleter class Employee: raise_amt =1.05 def __init__(self,first,last): self.first=first self.last= last @property def email(self): return '{}.{}@email.com'.format(self.first,self.last) @property def fullnam...
c6671a52a72fd18f44875532f871829a61de0196
Heroku-elasa/heroku-buildpack-python-ieee-new
/all_functions/configs/proxy_scraper/google_scrapy.py
738
3.5625
4
''' Example of Scrapy spider used for scraping the google url. Not actual running code. ''' import re import os import sys import json from scrapy.spider import Spider from scrapy.selector import Selector class GoogleSearch(Spider): #set the search result here name = 'Google search' allowed_domains = ['www.google...
18434f66b63d72303e29e957c4796e03d776e8c6
hanliang38/Codeit-BasicPython
/topic3/Palindrome/main.py
940
3.75
4
# 실습과제 # "토마토"나 "기러기"처럼 거꾸로 읽어도 똑같은 단어를 '팰린드롬(palindrome)'이라고 부릅니다. # 팰린드롬 여부를 확인하는 함수 is_palindrome을 작성하려고 하는데요. is_palindrome은 파라미터 word가 팰린드롬이면 True를 리턴하고 팰린드롬이 아니면 False를 리턴합니다. # 예를 들어서 "racecar"과 "토마토"는 거꾸로 읽어도 똑같기 때문에 True가 출력되어야 합니다. 그리고 "hello"는 거꾸로 읽으면 "olleh"가 되기 때문에 False가 나와야 하는 거죠. # 실행 결과 # True # Fal...
a7b368c50ecd1b8a456222c6208da0cc3e40fb5c
syedsrepo/machinelearning
/udemy_Machine_Learning_A-Z/polynomial_regression.py
2,035
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jan 25 22:17:54 2019 @author: syedsalahuddin """ # data preprocessing # importing the libraries #mathematical calculations import numpy as np import matplotlib.pyplot as plt import pandas as pd import os os.chdir('/Applications/work/machinelearning'...
3ad35af7a20b31b140b32cb4be5fc462d2eaf027
kaydee0502/Data-Structure-and-Algorithms-using-Python
/DSA/Stack/maxarInBinMat.py
3,063
3.59375
4
''' Max rectangle Medium Accuracy: 47.59% Submissions: 23830 Points: 4 Given a binary matrix. Find the maximum area of a rectangle formed only of 1s in the given matrix. Example 1: Input: n = 4, m = 4 M[][] = {{0 1 1 0}, {1 1 1 1}, {1 1 1 1}, {1 1 0 0}} Output: 8 Explanation: For the abov...
27fe9785ae5cd87d9a9bf3af246255da0c4d4873
westgate458/LeetCode
/P0413.py
920
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 14 16:10:45 2020 @author: Tianqi Guo """ class Solution(object): def numberOfArithmeticSlices(self, A): """ :type A: List[int] :rtype: int """ # length of the list l = len(A) # dp: number of all arithmeti...
03b164330a07ad1ea3826e0a72668d54e428a221
Safra-Man/FATEC
/Python/Laços de Repetição (1)/13.py
216
3.953125
4
#-*- coding:utf-8 -*- print('****Número de Letras, prima ! para sair**** \n') letra="a" n=-1 while letra!="!": letra=str(input('Letra: ')) n=n+1 print("\n A quantidade de letras é de: ",n) input()
bd9eb6c4f895261b250782188bc05015d889264e
pabb2002/Computer-Science-Labs
/CS1/Python/Discount_Abbaraju.py
178
3.71875
4
# Pranav Abbaraju # Discount def discount(amount): if amount >= 2000: amount = amount - .1*amount return amount print discount(int(raw_input("Enter the sales amount:: ")))
5700f93438c7f592243cfdc9ab1699f7ccab990c
mbrosowicz/PythonUdemy
/Condition_elIF.py
370
4.3125
4
Degree = input("enter your degree:") if (int(Degree) >= 90): print("your Score is A") elif (int(Degree) >= 80 and int(Degree) < 90): print(" your score is B") elif (int(Degree) >= 70 and int(Degree) < 80): print(" your score is C") elif (int(Degree) >= 60 and int(Degree) < 70): print(" your score is D")...
32438d12f742952debb89c5b864778a3c9609365
dwklatt/crypto
/hw3/isprime.py
1,472
3.6875
4
import random import math def special_pow(a,b,m): if b== 0: return 1 elif b%2 == 0: y = special_pow(a,b/2,m) z = pow(a,b/2,m) if z == 1 and y!=1 and y!=m-1: return 0 else: return z else: y = special_pow(a,b-1,m) z = pow(a*y, 1, ...
0b5dd2fbca33164f4b014fc7490e5a9cdd0018ee
Saurav9jal/Code
/findLongestCon.py
515
3.578125
4
##### Longest Consecutive Subsequence def findLongestC(list): if(len(list) == 0): return max_num =-10000 current_num = 0 dict ={} for num in list: dict[num] = 0 for num in list: temp_num = num current_num = 0 while(temp_num in dict.keys()): ...
ccd31472f5aca988b92c9918c081deaf29e087aa
KetanMehlawat/python-programs
/Stack.py
1,645
3.984375
4
########## STACK IMPLEMENTATION ############## """ Stack: implemented as a list top: integer having position of topmost element is Stack """ def isEmpty(stk): if stk==[]: return True else: return False def Push(stk,item): stk.append(item) top=len(stk)-1 def Pop(stk): ...
6ab8bbfeb231ea077e6f0448453d3661425847ec
gravvy23/Python
/matrix/test_matrix.py
2,826
3.734375
4
import unittest from matrix import Matrix #https://github.com/ppaula/kol1_gr1 class test_matrix(unittest.TestCase): def test_dimention_return_correct_result(self): m = Matrix(1,1,1,1,1,1,1,1,1) self.assertEqual(3,m.dimention) def test_add_method_return_correct_result(self): m = Matri...
1d5fca3c8dc7aca3d55eb3b0620011aca64c3fff
npandey15/CatenationPython_Assignments
/Task3_Python/Q7.py
63
3.671875
4
Num1=[1,3,5,7,9,10] Num2=[2,4,6,8] Num1[-1:] = Num2 print(Num1)
a8ede089a73d2f34b780e4ecfb7cfd3a8ce3c0b0
jqn/udacity-data-structures-n-algos
/project_unscramble_computer_science_problems/Task2.py
1,145
4.125
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent th...
516923bc2baae390c7be5e07c0821a5a4559b2e7
ShinCheung/LeetCode
/14.最长公共前缀.py
707
3.796875
4
# 编写一个函数来查找字符串数组中的最长公共前缀 # 如果不存在公共前缀,返回空字符串 "" # 示例 1: # 输入: ["flower","flow","flight"] # 输出: "fl" # 示例 2: # 输入: ["dog","racecar","car"] # 输出: "" # 解释: 输入不存在公共前缀。 # 说明: # 所有输入只包含小写字母 a-z class Solution: def longestCommonPrefix(self, strs): if not strs: return '' pre = strs[0] for...
4bbe70bf3504a1bf81d30cf414784e01d72662cc
mariaSerrabona/practica-III
/ej04.py
1,170
4.1875
4
#algoritmo para obtener la clasificación en la liga #PSEUDOCÓDIGO ''' en este caso, se nos pide la puntuación de un cierto equipo en la liga. Para ello, es necesario que que usuario nos pase por consola el número de partidos ganados, perdidos y empatados. COmo siempre, se trnasforma la cadena de texto introducida po...
80133f850d9ef32af98d09a01bf2a03e515dff72
shlomialon/Magshimim-networking-python
/assignment_1/password.py
1,892
4.21875
4
SCORES_NUM = 3 def get_input(): '''Recieves input from the user and returns it''' return input("Please enter a password: ") def get_length_score(password): '''Calculates password score based on password length''' if len(password) <= 4: # Short password return 0 elif 5 <= len(password) <= 7...
e364a4e6e1c4e0fd6805515a1149adaf92e9c8fb
goddl717/thisiscote
/연습문제/8.py
214
3.609375
4
n = input() n = list(n) n.sort() alph = [] num = [] for i in range(n) : if i.isalpha() : alpa.append(i) else : num.append(i) result.append(str(alpa)) result.append(str(num)) print(n)
313951c1e5120ce21da83e4c21d6eba487cf1f76
VeisaGit/python-practice
/Chekio/Elementary/6_End Zeros.py
953
4.21875
4
""" Try to find out how many zeros a given number has at the end. Input: A positive Int Output: An Int. Example: end_zeros(0) == 1 end_zeros(1) == 0 end_zeros(10) == 1 end_zeros(101) == 0 """ import re #First example def end_zeros(num: int) -> int: # your code here sep_list = [] amount_of_zeros = [] ...
0bcc02d9e56580d387d67dc53730ea0d34df9e25
vishalmnemonic/Python
/Python IBM/Python 101.py
5,109
4.15625
4
print("Hello World") # Comment type(11) Represents different types of data: int, float, str type(11.2) type("Hi") int(1.2):1 float(1):1.0 int(True):1 bool(1):True 25/5:5.0 26//5:5 my_variable = 1 my_variable x = 1 + 2 + 3 y = x + 5 y = y + 6 my = "Vishal" my[0]:V my[-1]:l my[0:2]:Vi my...
5c3a8cbad3bb0fd0d3d3af44ea8752781f330d3d
Iverance/leetcode
/392.is-subsequence.py
1,902
3.921875
4
# # [392] Is Subsequence # # https://leetcode.com/problems/is-subsequence # # algorithms # Medium (44.62%) # Total Accepted: 43.4K # Total Submissions: 97.4K # Testcase Example: '"abc"\n"ahbgdc"' # # # Given a string s and a string t, check if s is subsequence of t. # # # # You may assume that there is only low...
b6615c9c9b74e823342c4771f17d94d96d573134
virtool/virtool
/virtool/api/custom_json.py
2,231
3.875
4
""" Code for working with JSON. :class:`CustomEncoder` is a custom JSON encoder that encodes :class:`datetime.datetime` objects into ISO formatted strings. It is used mostly for encoding JSON API responses. The :func:`dumps` and :func:`pretty_dumps` functions stringify Python data structures into JSON. The pretty dum...
e196a78247b162b689a52a69251cbd1cec870aff
Vasallius/Python-Journey
/Data Structs and Algos/Chapter 1/Projects/P1.30.py
421
4.25
4
''' Write a Python program that can take a positive integer greater than 2 as input and write out the number of times one must repeatedly divide this number by 2 before getting a value less than 2. ''' def function(number): number = int(number) counter = 0 while number > 2: number /= 2 cou...
30e3776b52c01a976ab8f9b9a4f735c217d455ba
Icecarry/learn
/lianxi/类.py
234
3.515625
4
class Cat: def talk(self): self.age = 18 # print('age %s' % self.age = 18) print('talk %s' % self.name) tom = Cat() tom.name = 'xiaobao' tom.talk() print(tom.age) jac = Cat() print(jac.age) # jac.talk()
9605d115f452727f3754c12d02ac6d145a47462f
davmillar/coffeeadventure
/v004.txt
32,455
3.734375
4
#! /usr/bin/env python # Created by David Millar # Created August 4, 2007 # Last Modified August 18, 2007 # Version .004 import random import os import pickle # Scene Class - A scene is usually a room but can also be an event. class Scene: # Initiation Function def __init__(self, num, opts, desc, action, spe...
ee2a2112bc3cf4bac5bcf158cce6d74b767f1a12
bmorale1/Program-Repository
/Python/Morales_I_Assignment#6.py
3,308
3.796875
4
#Author: Isaac Morales #File Name: Morales_I_Assignment#6.py #purpose: create a TV remote simulator #Date: October 28, 2015 #initialize variables tvPower= 0 tvChannel=1 tvVolume=0 mute = 0 userChoice = 0 #printing Tv state def TvState(): if tvPower == 1: if mute ==1: ...
82ab23491ddbb7b82cd401139820f4d2748bf4dc
ParkinWu/leetcode
/python/offer/11.py
1,240
4.03125
4
# 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。例如,数组 [3,4,5,1,2] 为 [1,2,3,4,5] 的一个旋转,该数组的最小值为1。   # # 示例 1: # # 输入:[3,4,5,1,2] # 输出:1 # 示例 2: # # 输入:[2,2,2,0,1] # 输出:0 # 注意:本题与主站 154 题相同:https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array-ii/ # # 来源:力扣(LeetCode) # 链接:https://leetcode-...
9d5e7d21f733f49955dae0d7c68b13ad37bc71e3
Xamla/xamla_motion_examples
/example_07/example_07_2_rotate_joint.py
2,609
3.828125
4
""" In this example, the jogging interface is used to rotate the robot around its torso joint. This illustrates how velocities are applied to a joint and adjusted. """ import time from xamla_motion.data_types import JointValues, JointSet import example_utils from xamla_motion.jogging_client import JoggingClie...
110c6b72f6a166bc1907ad00e924201feef4bb02
jhilmilrsingh/Music-Database
/Lab08_Singh_Jhilmil.py
2,172
3.9375
4
import sqlite3 db_name = 'Music.db' def select_all(db_cursor): sql_statement = 'SELECT * from music' result_set = db_cursor.execute(sql_statement) print("\nTable now has the following rows:") for row in result_set: print(row) print() def db_steps(): db_conn = sqlite3.connect(db_na...
7435ffdcbfea0a4ed2e9865397dfbd64c8e584d2
hieast/PlayGround
/MOOC/Rice/Algorithm thinking/alg_project1/Imports physics citation graph .py
5,103
3.5625
4
""" Provided code for Application portion of Module 1 Imports physics citation graph """ # general imports import urllib2 import pylab # Set timeout for CodeSkulptor if necessary #import codeskulptor #codeskulptor.set_timeout(20) # Code for loading citation graph CITATION_URL = "http://storage.googleapis.com/cod...
2611d2fea6b10b30aec395770db5b64a239d3e35
AnastasiaSulyagina/NLP
/chunks.py
781
3.625
4
# сейчас пока кусками читать особого смысла нет, т.к оказалось, что большую # часть времени ест pymorphy, поэтому пока читаю все сразу, если надо будет, # адаптировать достаточно легко под необработанные данные и задать размер # кусков, которые он будет выдавать def read_chunk(f, delimiter): buf = "" while Tru...
3b622dafaa780cf658b691ed9490b97c2ef2b5e3
amanverma15/programing
/Aman/OldWork/calculate.py
248
3.796875
4
import a x = int(input('Enter a number:')) y = int(input('Enter a number:')) print("The answer is " + str(a.add(x,y))) print("The answer is " + str(a.sub(x,y))) print("The answer is " + str(a.mult(x,y))) print("The answer is " + str(a.div(x,y)))
207dea4e1eaf6607d9336c05bfe9abdbf1f224e7
ywhitecat/4hoursfreecodecampyoutubeEN
/TryExcept.py
201
3.953125
4
try: value =10/0 number= int(input("Enter a number ")) print(number) except ZeroDivisionError: print("You can't divide by 0") except ValueError: print("invalid input")
406f92482d49e05fb7c73b195a4bb8453006b5e4
vksmgr/ISTP3
/src/regression/linear.py
1,638
4.375
4
################################## ## this module explain the simpe linear regression model ## This is the Single variable regression Y = b0 + b1X ####################### import matplotlib.pyplot as plt import pandas as pd from sklearn import linear_model from sklearn.model_selection import train_test_split from sklear...
2f431f18df38e7e1edd37a21483ae7bdf2e136ee
GDG-Buea/learn-python
/chpt7/Linear_equations.py
1,811
4.25
4
# This program depicts a 2 by 2 system of linear equations # It prompts the user to enter the values a , b , c , d , e , and f for the linear equations:f # x = ed - bf / ad - bc and y = af - ec / ad - bc # # and and displays the result. If ad - bc is 0 , it prints the message “The equation has no solution. c...
203b0208e80e0b31a112a34d41d9f85cd5f87f37
abezukor/SSL-Urban-Magnetometer
/DataGathered/makeCSV.py
1,757
3.6875
4
import sys import csv import os #Function return true if all elements of values are can be floats, otherwise it returns false def isfloats(values): for value in values: try: float(value) except ValueError: return False return True try: data = "" fileDirPath...
ab80f65206e00656ebdddc354610085f2609c4bf
giginet/MachiMatch
/src/pywaz/device/__init__.py
808
3.78125
4
class Device(object): """Base class of any inputdevices. This is the base class of Mouse, Key, Joypad. It provides users to unified api. This class is abstract. Device class instance can't create. """ Mouse = 0 Key = 1 JoyPad = 2 numbuttons = 0 _type = None def __ini...
3f7fdaedffbf5d53344f2734b910b33649598a72
Itamar-Farias/TST_P1_UFCG
/unidade4/nova_palavra/nova_palavra.py
365
3.515625
4
# coding: utf-8 # Itamar da Silva Farias 115210021 # Programção I import string nome = raw_input() palavra = raw_input() numero = raw_input() lista_numero = [] nova_palavra = [] for i in range(len(numero)-1, -1, -1): lista_numero.append(int(numero[i])+1) for i in range(len(palavra)): nova_palavra.append(palavra[...
d9fa7eb84cdea6bf312664c0e9a5f554b5aeeb5e
eshagen/HW08
/HW08_ex11_04.py
2,178
4.09375
4
#!/usr/bin/env python # Exercise 4 # (1) Modify reverse_lookup_old so that it builds and returns a list of all # keys that map to v, or an empty list if there are none. # (2) Paste in your completed functions from HW08_ex_11_02.py # (3) Do not edit what is in main(). It should print what is returned, a list # of th...
b49597cc4b655ee96b9ee95950117424078ec2b3
Liujiubo/woniu
/mystr.py
465
3.625
4
''' week="星期一星期二星期三星期四星期五星期六星期日" i =int( input("请输入一个1~7之间的数字")) s=(i-1)*3 if 0<i<8: s1=week[s:s+3] print(s1) else: print("输入的数字有误") print(week[s:s+3]) ''' s = input("请输入一个字符串") s1= "" l = len(s) i = 0 while i < l: m = ord(s[i]) if 65<= m <=90: m += 32 s1+=chr(m) elif 97 <= m <= 122: m -= 32 s1 += c...
18efb75af78f20247bc5eb47a538b8226cc50e7e
athina-rm/dateTime-vningar
/dateTimeÖvningar/module2.py
229
3.84375
4
#Write a Python program to display the Day properties (year, month, day, hour, minute,second, millisecond etc.). #Expected Output : #year = 2016 #month = 8 #day = 16 #hour = 3 #minute = 57 #second = 32 #millisecond = 11
58c32fc196e9f91aa60edd4bda5a735417886f31
liangming168/leetcode
/DFSandBacktracking/Q694_distinctIsland.py
2,570
4.125
4
# -*- coding: utf-8 -*- """ Q694 number of distinct island Created on Sun Sep 23 21:29:03 2018 Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. Cou...
789557b18465e33b53b914fa42cb63f5808e30c4
Danarvelini/Codewars
/Python/Answers/Format_string_of_names.py
1,323
3.765625
4
#https://www.codewars.com/kata/53368a47e38700bd8300030d/train/python # Given: an array containing hashes of names # Return: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand. # Example: # namelist([ {'name': 'Bart'}, {'name': 'Lisa'}, {'...