blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
8c70ad656e92145347e8cc436ae7290bda797216
whoiscc/find-unique
/generator.py
1,874
3.640625
4
# from config import * from numpy.random import choice, randint import sys alphabet = [chr(x) for x in range(ord('a'), ord('z') + 1)] def random_word(len_list, len_index, char_list, char_index): word_len = len_list[0, len_index] word = char_list[0, char_index:char_index + word_len] # print(word) re...
8f80dba2dd5b812e76d71a33fd76641db75f54ca
chancebeyer1/CSC110
/functions2.py
1,186
3.78125
4
def Growth(P, R, N): for yr in range(N): increase = P * R/100 P = P + increase return P # compute x^n for any integer n, including negative and zero n def pow(x, n): if n >= 0: result = 1 for i in range(n): result = result * x return result else...
fe6c6413b1e05aa39720163e2cab5edf21b91654
huozhenlin/note
/python基础/优先队列.py
1,535
4.3125
4
""" python 优先队列实现有三种方式 第一种:list,写入tunple,然后sort,时间复杂度为O(n) 第二种:heapq, 底层实现也是list,不过可以实现nlogn的时间复杂度 第三章:使用queue中的PriorityQueue,内部实现是使用了heapq,区别是,heapq非线程安全, PriorityQueue为线程安全,提供锁机制 0 1 2 3 4 5 ...
7ad1daf531a144efb32af31573c3408d77c119a7
cobeam/DevNetRepo
/intro-python/part1/hands_on_exercise.py
1,120
4.40625
4
"""Intro to Python - Part 1 - Hands-On Exercise.""" import math import random # TODO: Write a print statement that displays both the type and value of `pi` pi = math.pi print ("Pi =", pi) print ("The type is", type(pi)) # TODO: Write a conditional to print out if `i` is less than or greater than 50 i = random.ran...
36f187a7af14ea4696dcfca7ca43719a67752f0b
tapaswenipathak/Competitive-Programming
/SPOJ/ADDREV.py
232
3.8125
4
def reverse_int(n) : return int(str(n)[::-1]) N = int(raw_input()) for i in range(N) : n1, n2 = raw_input().split() n1r = reverse_int(n1) n2r = reverse_int(n2) result = n1r + n2r print(reverse_int(result))
655ad3de3af44cb67ea96470271492d842d28ca7
adnansamad769/Lab-task-and-Class-Work
/Lab10/Program 3.py
407
3.5625
4
import tkinter window = tkinter.Tk() window.title("Playing with GUI") tkinter.Label(window, text = "Sufficent Width",fg = "white", bg = "purple").pack() tkinter.Label(window,text = "Taking All available width of X",fg = "white", bg = "green").pack(fill = "x") tkinter.Label(window,text = "Taking All available Hei...
13f74b7b97b49bcdad071c7f0797823c73018d0a
samantabueno/python
/CursoEmVideo/CursoEmVideo_ex082.py
678
4.09375
4
# Program that receives many numbers an then # returns a list with even numbers and other list with odd numbers. numbers = [] even_numbers = [] odd_numbers = [] while True: numbers.append(int(input('Type a number: '))) while True: cont = str(input('Do you whish continue? [Y/N]: ')).upper() if ...
7a4672e080967ec143ddf541987ea3ac1622f360
wpy-111/python
/month02/day06/sum_prime.py
778
3.671875
4
""" 计算质数的和 """ import time from multiprocessing import Process def print_time(sum_prime): def wrapper(*args,**kwargs): start_time=time.time() re = sum_prime(*args,**kwargs) stop_time=time.time() print(stop_time-start_time) return re return wrapper @print_time def sum_p...
cfd97b7cd9cac69d8ffcf801eefacf0e4393f7d6
GottixX/Week3
/Resolve-With-Functions/sum_divisors.py
415
3.875
4
def divisors(n): pot_divisors = range(1, n -1) divisors = [] for divisor in pot_divisors: if n % divisor == 0: divisors = divisors + [divisor] return divisors def sum_ints(numbers): sum_ints = 0 for number in numbers: sum_ints += number return...
222dab5c839206bac224803e46b6d6a5febfad7b
Martin-Ascouet/tp11_2nd_annee
/Exercice3.py
1,179
3.59375
4
class Rational: def __init__(self, num, den): self.__num = num self.__den = den def pgcd(self, F): a = self.__num * F.__den + self.__den * F.__num b = self.__den * F.__den r = a % b while r != 0 and b != 0: a = b b = r r = a % ...
7c0c7067c995157718517be73842539e2a451a78
srikanthpragada/PYTHON_06_APR_2020
/demo/ex/char_freq.py
175
3.921875
4
# Print how many times each letter is present st = "This is awesome. That is also great".upper() for n in range(65, 91): ch = chr(n) print(f"{ch} - {st.count(ch)}")
af744aa13f20169597273f4a8a859d5d413cf1bb
rojinebrahimi/key-logger
/keylogger.py
755
3.953125
4
from pynput.keyboard import Listener, Key # -- Used when the key is pressed, prints out the pressed key ---------------------- def pressed(key): print(f"{key} key was pressed.") # -- Used to call the function to write pressed keys to a log file ----------------- def released(key): if key == Key.esc: ...
8d93df546164e4cadbf2719a1356f1a8a520dbe9
shabnam12/spy_chat_app
/shabnam.py
272
3.5625
4
print"hello" print"let\`s get started" spy_wel=raw_input("welcome to spy chat") spy_name=raw_input("what is your name") print spy_name if len(spy_name) > 0: print spy_name spy_salutation=raw_input("mr or miss") spy_name = spy_salutation + " " + spy_name print spy_name
81e89138b6d6a6e8f999fbc605969ca03fd89785
Satyam-Bhalla/Python-Scripts
/Python Course/Tkinter/fifth.py
288
3.9375
4
from tkinter import * root = Tk() def printName(event): print("Satyam is my creator") # button_1 = Button(root,text="Who is your creator",command=printName) button_1 = Button(root,text="Who is your creator") button_1.bind("<Button-1>",printName) button_1.pack() root.mainloop()
937e5f7f7f9e740b4eecbb9abd8174f3445a152f
adarrah/CS-101
/program 8/Program 8.py
5,864
4.0625
4
######################################################################## ## ## CS 101 ## Program #8 ## Aaron Darrah ## add522@mail.umkc.edu ## ## PROBLEM : Wumpus are running amok in a maze that has a large fortune in it and we have to create a simulation for ## the user to determine the best possible path th...
afa06a60999359b10664b07160a6fb6558b3c724
ClaudioRizzo/coding_excercise
/google_interview.py
2,973
4.21875
4
import operator import functools import pprint import json def product_array(numbers, division=True): ''' Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our ...
24b594307bf496c728e3f7927009aa8860813098
HawkinYap/Leetcode
/leetcode893.py
468
3.59375
4
class Solution(object): def numSpecialEquivGroups(self, A): """ :type A: List[str] :rtype: int """ res = set() for sub in A: print(sub[::2], sub[1::2]) sub = ''.join(sorted(sub[::2]) + sorted(sub[1::2])) res.add(sub) return ...
550346d605ea387236075b00a6924b211c260360
luishpmendes/Maratona
/uri/1039/fireFlowers.py
371
3.5
4
import sys for line in sys.stdin : line = line.split(' ') r1 = int(line[0]) x1 = int(line[1]) y1 = int(line[2]) r2 = int(line[3]) x2 = int(line[4]) y2 = int(line[5]) dx = x2 - x1 dy = y2 - y1 distance = (dx * dx) + (dy * dy) if r1 > r2 and distance <= (r1-r2)*(r1-r2) : ...
4efc73d8898517fbac83959a331c738e5e88bec3
endarli/SummerImmersionProjects
/Python/test.py
1,852
4.25
4
# This is a comment # Python doesn't read # what goes here. # go to the directory and do # python [name of doc] # to run this code #7/15/2019 # task 1 #print("Hello, World!") #print("Woah") #task 2 #answerr = input("What is your name?") #print("Hello", answerr, "!") #answer = input("Who inspires yo...
db79db62761acb5441932312c91ddd536a51be01
fyreii/Python-3-Scripts
/math_module.py
313
4.09375
4
import math # part 1 - pythagorean theorem side1 = 3 side2 = 4 hypotenuse = math.hypot(side1,side2) print(hypotenuse) # part2 - pi and approx pi pi = 2 * (math.asin(math.sqrt(1 - 1**2)) + abs(math.asin(1))) print("The approximate pi is: " + str(pi)) print("The module pi is: " + str(math.pi))
b57cd237c944b9118fb4bd6b656cb22dbbffb363
xzpjerry/learning
/python/sb_dfs.py
5,969
4.15625
4
#!/usr/bin/env python3 ''' DFS of a dictionary tree assignment, CIS 210 Author: Zhipeng Xie Credits: 'python.org' official document Implement of DFS on a dictionary tree ''' tree1 = {0: [1, 2], 1: [5, 6], 2: [3, 4, 7], 3: [], 4: [], 5: [7], 6: [7], 7:...
694709fca21c4cddffb0da30d00bd04f68856a7e
Fei-WL/Leetcode
/290 单词规律.py
607
3.5
4
class Solution: def wordPattern(self, pattern: str, s: str) -> bool: inputs = s.split(" ") keys = list(pattern) if len(inputs) != len(keys): return False pattern_dict = {} for idx in range(len(keys)): key = keys[idx] value = inputs[idx] ...
aa4a88365825f03e649ff2ebdee511eaf36fd451
the-hobbes/algorithms_datastructures
/problems/chapter_2/merge_sort.py
3,852
4.21875
4
''' Merge sort, a divide and conquer algorithm using recursion for sorting - o(n) time Idea: You have two piles of cards face up on the table. These piles are sorted, with the smallest cards on top. We want to merge the two piles into a single sorted ouput file, face down (biggest on the top). Choose th...
330ea9addfae3b6dacb607e4efe797e2a4f989dc
just-for-spider/lawn
/python/class_setattr.py
418
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ######################################################################## # # Copyright (c) 2017 Qianbao.com, Inc. All Rights Reserved # ######################################################################## """ File: class_setattr.py Author: wangqj(wangqj@qianbao.com)...
faa7d2afa06ceb4a0f629c104d8a227f801b9854
LihaoYu94/Artificial-Intelligence-Project
/homework3/MDP/MDP.py
5,021
3.734375
4
import random import math class MDP: def __init__(self, ball_x=None, ball_y=None, velocity_x=None, velocity_y=None, paddle_y=None, ): ''' Setup MDP with the initial values provided. '...
0f2c318df28408c07d3cf5f9433436799eb07941
MikhailMinsk/Python_projects
/First_steps/oop/exerc1.py
1,572
3.765625
4
class cars(object): in_stock = 0 all_cars = 0 def __init__(self): self.on_the_run = False self.crash = False self.from_Germany = False self.from_Russia = False self.in_st() def print_info(self): print(type(self).__name__ + ':') print('On the run ...
20846fb908d12c35edcd843af26b1672dcc81ee9
qtuancr261/PyProjects
/tqtPrivateLib.py
424
3.78125
4
def check_prime(numberPara: int = 2) -> bool: """With argument""" if numberPara < 2: return False for checkValue in range(2, int(numberPara / 2) + 1, 1): if numberPara % checkValue == 0: return False return True def searchLetters(phrase: str, letters: str = 'aeiou') -> set:...
d2b27c466f289a6374fece0f0028fefadf69b20e
qsyPython/ArithmeticNice
/qsy/arithmetic/18_ywm_pascal_triangle.py
1,255
3.765625
4
''' 显示杨辉三角 输入数字,如4 显示对应杨辉三角: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 ''' # 获取某具体的某一行的list数据:每一行是上一行中倒3角中2个数字之和 # 思路:每一组数据都是list,要用list,该list要动态变化,以及赋值给自己,要用到到while,while内部加yield可提前走出, # 如何记录上一组数据?list 操作后再次赋值给list就ok # 如何执行一次操作后中断进行别的操作?while内部加yield L可提前走出 def triangles(n): L,index=[1],0 while in...
57921f2c4ff488cadb1fae2584ef70bc289835e7
xueer/homework
/2014-1-19-homewor-01.py
150
3.859375
4
#画出一个三角形 m=4 for i in range(0,5): for j in range(0,5): if j<m: print ' ', else: print '*', j +=1 m -=1 i +=1 print "\n"
b6f2f82a9e2c4a186d5c88ad09698e46fa5514fe
fjaschneider/Course_Python
/Exercise/ex029.py
358
3.90625
4
v = float(input('Qual a velocidade do carro? ')) if v <= 80: print('Parabéns, você está respeitando as leis de trânsito!') else: print('Você foi multado em R$ {:.2f}, por estar dirrigindo a {} km/h. \n' '{} km/h a mais do permitido!' .format((v - 80)*7, v, v-80)) print('Dirrija com cuidado, ...
a0ddca6221e22883cf97206a67ef31286aae942d
masoodaqaim/mini-projects
/rounding.py
691
4.125
4
''' Define the following constants: const int FLOOR_ROUND = 1; const int CEILING_ROUND = 2; const int ROUND = 3; Write a program that asks the user to enter a Real number, then it asks the user to enter the method by which they want to round that number (floor, ceiling or to the nearest integer). The program wil...
c915f4b25bcbbcb586b4d7ed15955c9b18b77774
acc-cosc-1336/cosc-1336-spring-2018-EricScotty
/tests/homework/test_homework4.py
2,771
3.9375
4
import unittest #write the import statements to bring in homework 4 functions #valid_letter_grade, get_credit_points, get_grade_points, and get_grade_point_average from src.homework.homework4 import sample_function from src.homework.homework4 import valid_letter_grade from src.homework.homework4 import get_credi...
6573ea8ed0d12e7eabe055b0feae726ab67a47e0
mohitraj/mohitcs
/Learntek_code/25_Sep_18/except5.py
187
3.84375
4
try: num1 = int(input("Enter the number ")) result = 10/num1 print (result) except (ValueError,ZeroDivisionError): print ("Int or 0 error") except : print ("Unknow error")
5a838bb9debb20df467c4c024cf59f0142f02822
carward25/average.py
/average.py
503
4.34375
4
# The following program finds the average of five numbers for the user # these are inputs print("Please enter five numbers") num1 = int(input("Enter the first number: ")) num2 = int(input("Enter the second number: ")) num3 = int(input("Enter the third number: ")) num4 = int(input("Enter the fourth number: ")) num5 = i...
634de5437494e9eafd44794fc57ccefb1a4cbef7
O5-2/leetcode
/Valid_Palindrome.py
441
3.515625
4
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ if len(s) <= 1: return True s = s.lower() to_remove = [" ",":",";",".",",","~","`","!","@","#","$","%","^","&","*","(",")","_","-","+","=","<",">","{","[","}","]",...
dc1b1bb117c69129c62759e947bf448d5b68e739
yanxurui/keepcoding
/python/algorithm/剑指offer/1.py
1,549
3.78125
4
# -*- coding:utf-8 -*- class Solution: # array 二维列表 def Find(self, target, array): # write code here return self.binary_search(target, array, 0,0, len(array)-1,len(array[0])-1) def binary_search(self, target, array, i1,j1, i2,j2): if i1 > i2 or j1 > j2: return False ...
97b0c11950b5d562ab2901bfd3b1291a9d31447b
gowthamanniit/python
/identity.py
91
3.625
4
a=10 b=20 c=10 if a is c: print("similar") else: print("not similar")
413f01399655bd057ebb4f4994410dfb1005c2d5
r4space/Fynbos
/Test_Generators/Thirtysix/full_hydra/scripts/fixed-point/works/floatconversion.py
3,887
3.921875
4
#!/usr/bin/python2.6 #File containing the function version of float1.py to convert input to float data word #File to convert decimal values into custom fixed point binary format #Takes in 2 arguements; 1: Integer portion of value, 2: Decimal portion of value. from test_parameters import * import sys from math import po...
db09c181c31e8c6f564db7184db6a6678c2bfc56
asheed/tryhelloworld
/excercise/ex031.py
319
3.515625
4
#!/usr/bin/env python # -*- coding: utf8 -* # 031 문자열 자르기 # # 사용자로부터 파일명을 입력 받은 후 확장자만 출력하는 프로그램을 작성하라. # # 실행 예: # filename: report.docx # docx filename = input("filename: ") new_filename = filename.split('.') print(new_filename[-1])
d6ac36f664f1f345a019a19acf17ad4f314a8a8b
m7dev/python_learning
/simple/while.py
497
3.671875
4
number = 23 running = True while running: # Поки running = True виконувати цикл guess = int(input('Введіть число:')) if guess == number: print ('Вітаю, ви вгадали') running = False # Завершення циклу elif guess < number: print ('Ні, число більше') else: print ...
254d1d5a511ed7ada427e567f117e3ab97e8073c
harshjohar/unacademy_a
/class/problem_solving/farmers_and_cows.py
1,190
3.8125
4
''' Farmers has a long barn with N stalls. The stalls are located along a straight line 0<=x<= 1e9 his C cows dont like this barn layout, and become aggressive towards each other once put into stall. To prevent the cows from hurting each other, Farmer wants to assign the cows to the stalls, such that min distance be...
091dc6d83e19d33eae9fc05048da4f2d287dd709
uvshrivass/Python
/list_comprehension.py
683
4
4
###Program to find the cubes of N numbers using list comprehensions. cube = [i**3 for i in range(10)]; print(cube) #Result: [0, 1, 8, 27, 64, 125, 216, 343, 512, 729] ###Program to convert temp from Fahrenheit to Celsius. f = [0,23.4,134.233,254.54,112.1] k = [((i + 459.67)* 5/9) for i in f] print(k) #Result: [255....
d705a57db41248b1a3291bd174a739d30f290be4
gautamits/hackerrank
/algorithms/implementation/acm-icpc-team.py
385
3.609375
4
import itertools n,m = map(int,input().split()) arr=[] for i in range(n): arr.append(int(input(),2)) ma = -float('inf') teams=0 for p1,p2 in itertools.combinations(range(n),2): combined_topics = bin(arr[p1]|arr[p2]).count('1') if (combined_topics==ma): teams+=1 elif (combined_topics>ma): ...
ce35f7731e40fbccefedf87fb98649176164a0a5
soham-shah/coding_practice
/CTCI/chapter_1/1_8.py
1,217
3.5
4
import unittest def zero_matrix(matrix): rows = len(matrix) cols = len(matrix[0]) zeroRows = set() zeroCols = set() for i in range (rows): for j in range(cols): if matrix[i][j] == 0: zeroRows.add(i) zeroCols.add(j) for i in zeroRows: ...
13127928e70104599d13977279aba7d6df1091ec
JulienRioux/CodeFignts
/FileNaming.py
1,175
4.09375
4
# You are given an array of desired filenames in the order of their creation. Since two files cannot have equal names, the one which comes later will have an addition to its name in a form of (k), where k is the smallest positive integer such that the obtained name is not used yet. # Return an array of names that wil...
4be4b49c65355782cc6cb5d5b055fbba49afb591
shelly2904/DSA-Practice
/LINKED_LIST/linkedlist.py
7,461
4.09375
4
#Reverse linked list by k nodes. class Node: def __init__(self, data_name): self.data = data_name self.next = None class LinkedList(object): def __init__(self, head = None): self.head = head def insert_at_front(self, node): #add at the fron...
3038bab26fceec7b776803e9cff8565b065c66d8
cjmonson17/Quest-of-the-Ancients
/MapInv.py
34,648
3.546875
4
#################################MINIMAPS################################### #mini1=Horastead #mini2=Ancient Ruin #mini3=Rebel House #mini4=TRoll cave #mini5=Dragon cave #mini6=Morceris castle #mini7=Morc Town 1 #mini8=Morc Town 2 #mini9=Morc town 3 #mini10= Goblin cave? dont really need #mini11= Ice Dra...
2944f0ba8d11bc4e3b9507db9b933749ea4616fb
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_135/2167.py
925
3.5
4
#!/usr/bin/env python import sys import os ERR = ['Bad magician!', 'Volunteer cheated!'] def solve(t): n = int(sys.stdin.readline()) r1 = [] for i in range(1, 5): if i is n: r1 = map(int, sys.stdin.readline().split()) else: sys.stdin.readline() n = int(sys.st...
ed55e69ac315d0022c58bba40da2f36d56a2ef4b
SohomRik/SohomRik-MY_CAPTAIN-PYTHON-SOHOM_GHORAI
/Circle Area.py
190
4.28125
4
from math import pi print ("Calculate Area of a Cirle ") r = float(input("Enter the radius of the Circle : ")) area = pi*(r*r) print ("The Area of the circle with raius ",r," is : ", area)
053a2fe4bf0c8ca62fc090e0ef5849490780dc18
OverlordYuan/Data_structrue
/LenkedList_11/detectCycle.py
1,291
3.609375
4
from ListNode import ListNode ''' 142. 环形链表 II 给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 null。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。 说明:不允许修改给定的链表。 示例 1: 输入:head = [3,2,0,-4], pos = 1 输出:tail connects to node index 1 解释:链表中有一个环,其尾部连接到第二个节点。 示例 2: 输入:head = [1,2], pos = 0 输出:tail connects to ...
a907dfc6b92e5201d37ca67f93864fc860ce2187
TonnyL/MyPythonLearnProject
/string_encoding.py
2,050
3.640625
4
# -*- coding: UTF-8 -*- # 上面的这一行注释就是指明了编码的方式,这样就可以避免不同语言的文字冲突导致的乱码问题 # Unicode把所有的语言统一到一套字符编码里 # UTF-8即'可变长编码'的Unicode编码,这样可以防止Unicode编码大量英文时造成的空间浪费问题 # 由于python的诞生时间要早于Unicode标准的发布时间,所以最早的python只支持ASCII编码 # 普通的'python_learn'在python内部是ASCII编码的 # python提供了ord()和chr()函数,可以把字母和对应的数字进行相互的转换 tmp = chr(66) print tmp tmp = o...
b79477aeb8fb66d45f322a9a898b13e549e2278e
MineSelf2016/PythonInEconomicManagement
/Part 1/exercise/exercise1.py
337
3.53125
4
""" 题目:有1、2、3、4, 4 个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? """ num = 0 for i in range(1, 5): for j in range(1, 5): for k in range(1, 5): if (i != j) and (i != k) and (j != k): num += 1 print(i, j, k) print(num)
0dd36cecc317f1fa7bc01d8f386f8fd5696b16eb
johnnytommy/GWU_classes
/DATS_6103_DataMining/Class03_classes/InClass03_recursive.py
7,462
4.15625
4
# To add a new cell, type '#%%' # To add a new markdown cell, type '#%% [markdown]' #%% # recursive functions # essential skill for building tree type constructs # watch out for stackoverflow and infinite loops import math #%% # You can just as easily write this following function with loops def triangleSum(n): "...
f58d148af0209f674629f90b59ced716de8045ae
CleitonSilvaT/URI_Python
/1-Iniciante/1114.py
387
3.90625
4
# -*- coding: utf-8 -* if __name__ == '__main__': # Atribuindo senha correta senha_correta = 2002 while(True): # Entrada senha = int(input()) # Condicao de parada do programa if (senha == senha_correta): print("Acesso Permitido") break # I...
4b296b06196e578ea52f1ea33cf597bc6ff3ae19
vipinsachan/Python_Learning
/session2/string_assignment/prg_8.py
122
4.40625
4
#Capitalize each word of the string. string=input("Enter the string that you want to capitalize: ") print(string.title())
776eb903b6a5fe488373763cc2cea3e17020275c
stanish28/hackathon_backend
/test.py
671
3.859375
4
from random import * print() print("Welcome to IncNumber Game") print() print("LET'S START") j = "Yes" i = 0 a = 0 while a <= 0: if j == "Yes" or j == "y" or j == "yes": while i <= 5: print("Game is on") p1 = int(input("Enter your number - ")) print() comp = str(p1+(randint(0,100...
1550b739dceba8f9fa608b0351264afb99954444
NikolasHofmann/pcc
/24-07-2021/9-5.py
1,745
3.78125
4
class User(): def __init__(self, first_name, last_name, email, age, phone_number): self.first_name = first_name self.last_name = last_name self.email = email self.age = age self.phone_number = phone_number self.login_attemps = 0 def describe_user(self): p...
7b3dce9551aa9acce445a765ca847dc956d1f375
rymo90/100DaysOfCodeChallenge
/numberfun.py
506
3.75
4
n= int(input()) svar="" for i in range(n): c= input() c= c.split() product= int(c[len(c)-1]) c = c[0:len(c)-1] c.sort(reverse = True, key= int) # print(c) if (int(c[0]) + int(c[1])) == product: svar="Possible" elif (int(c[0]) / int(c[1])) == product: svar="Possible" e...
2ce53052753c3fbbaa5b11bfb9be0e2163c9d90a
Xorgon/Connect4
/src/main/python/connect4.py
3,503
3.859375
4
# -*- coding: utf-8 -*- import numpy class VirtualBoard(): board = numpy.zeros((7, 6)) def __init__(self): self.reset_board() def reset_board(self): """Resets the board.""" for x in range(0, 7): for y in range(0, 6): self.board[x][y] = 0 def place...
7024ce01da84d25b453eb94f5b02b9b77b84dd73
tukangremot/py-req-test
/cart.py
737
3.921875
4
class Cart: product = {} def addProduct(self, name, num): if name not in self.product: self.product[name] = 0 self.product[name] += num def removeProduct(self, name, num = 1): if name in self.product: self.product[name] -= num else: prin...
5d6249338c9200c8dc90c597456582291c995854
alehpineda/bitesofpy
/99/sequence_generator.py
329
3.671875
4
from string import ascii_uppercase from itertools import cycle, chain def sequence_generator(): return cycle( chain.from_iterable( zip(range(1, len(ascii_uppercase) + 1), ascii_uppercase) ) ) def sequence_generator_2(): return chain.from_iterable(cycle(enumerate(ascii_upperca...
2e19a96d4043b74cc38e733979b38246bf155973
lucasoliveiraprofissional/Cursos-Python
/Ignorancia Zero/aula030_ex2.py
947
3.875
4
'''Peça uma lista de numeros inteiros para o usuário e imprima a lista sem repetições''' n= int(input('Digite o numero de elementos da lista: ')) lista= [] aux= [] for i in range(n): elemento= int(input('Digite o elemento {} de {}: '.format(i + 1, n))) lista.append(elemento) aux.append(elemento) #a l...
c8bcc5c812c84a0ae3ace8943cd79f9291a02cc4
subreena10/conversion
/cq2.py
137
3.703125
4
var_a=input("Enter the first number") var_b=input("Enter the second numebr") var_a=int(var_a) var_b=int(var_b) sum=var_a+var_b print(sum)
922d98700c63d904b94140a2b82c331d55e001a0
Ricardo16X/EDD_2S2019_P1_201700524
/SNAKE/EnlazadaDoble.py
3,778
3.625
4
import os class nodoDE(): def __init__(self, coordY, coordX): self.cX = coordX self.cY = coordY self.siguiente = None self.anterior = None self.char = '#' class listaDE(): def __init__(self): self.ancla = nodoDE(None,None) self.ultimo = None self....
20b3491b4d8eb38ad09346181c3d74f5a9f752ee
tanweer123/Python
/sets.py
274
3.90625
4
#Basic implementation of sets s = set() print(type(s)) l = [1,2,3,4] s_from_set = set(l) print(s_from_set) s.add(7) s.add(9) s.add(9) #it will only add the unique values/element s.add(12) print(s) s.remove(9) print(s) s1 = {4, 15} print(type(s)) print(s.isdisjoint(s1))
b5ce4f78ef55ca71174e4f4841bbd71c37701722
charlesseverson/CS275
/bigraph.py
2,180
3.78125
4
import random import disjointSet import matplotlib.pyplot as plt class BiGraph: '''An undirected binomial random graph''' def __init__(self): '''Graph constructor''' self.graph={} def Binomial(self, n, p): '''Generate and return an instance of a binomial random graph''' L=[] for i in range(n): fo...
0a542f482a24a2c530bd753d441f3d9f5c5f78a5
sheddy007/leetcode-summary
/SlidingWindow/MonotonicQueue/239.sliding-window-maximum.py
1,034
3.59375
4
# # @lc app=leetcode id=239 lang=python3 # # [239] Sliding Window Maximum # # @lc code=start from collections import deque class Solution: def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]: q, res = deque(), [] # Use the first element of the deque to store the largest element ...
dbf179adf88e09cd3c1f845209289a06b5babd9b
gogo2497/JenkinsTest
/test.py
260
4.15625
4
"""implementing recursion""" def recursion(k): """recursively adding numbers""" if k > 0: result = k + recursion(k - 1) print(result) else: result = 0 return result print("\n\nRecursion Example Results") recursion(6)
d50a47796a7e6dcd89e5c9e172fe150c4e976b4d
dougbrown1048/ETR107-Projects
/Ch 6 problems/intext 6.4.py
221
4
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 24 12:32:18 2020 @author: dbrown """ def isBetween(x,y,z): if x <= y and y <= z: print("True") else: print("False") isBetween(2,3,4)
a280c818dcf273de647e8a72d31be1ddef291dbc
subedisapana/python-fundamentals
/Python Modules & Packages/module1.py
645
3.734375
4
''' DocString: this module includes binary search implementation ''' def binary_search(l,key): """ Binary search: input a list and a key return True if key exists or else return False """ if len(l)==0: return False else: mid =len(l)//2 if l[mid] == key: return True elif key < l[mid]: return b...
ee04086a6ac0c2620bd33e2c9f480b4e152aef1d
CodeWithSouma/Basic-Python-Code
/string inndex.py
189
3.59375
4
#string indexing language ="python" # position (index number) # p=0, -6 # y=1, -5 # t=2, -4 # h=3, -3 # o=4 , -2 # n=5 , -1 print(language [2]) print(language[-1]) print(language[0:2])
9ba987539b47fdca205a65c6ec61d8197d74e380
jadenPete/AdventOfCode
/2019/day3-part1.py
430
3.703125
4
#!/usr/bin/env python3 with open("day3.txt", "r") as file: def crawl_wire(): loc = [0, 0] for move in file.readline().split(","): delta = {"L": (0, -1), "R": (0, 1), "U": (1, 1), "D": (1, -1)}[move[0]] for _ in range(int(move[1:])): loc[delta[0]] += delta[1] yield tuple(loc) visited = set(crawl...
611b4fe408ffcb218fdd39cc28667681f83eae42
KallenHuang/homework2
/HomeWork0611.py
931
3.921875
4
n1=input("Enter a Number called A: ") n2=input("Enter a Number called B: ") n3=input("Enter a Number called C: ") n4=input("Enter a Number called D: ") n5=input("Enter a Number called E: ") n1=int(n1) n2=int(n2) n3=int(n3) n4=int(n4) n5=int(n5) sum=n1+n2+n3+n4+n5 sum=str(sum) #如果是int無法與字串連接,故重新定義為字串 print("The sum numb...
ee28b407b5a887ca358b682a3b80d716845bc79d
tuxnani/pyrhmn
/Day25/SumNByNPlusOne.py
117
3.90625
4
n = int(input("Enter an integer:")) sum = 0.0 for i in range(1,n+1) : sum += float(float(i)/(i+1)) print(sum)
260a2c17fae48e743924d5db778a4f4b00f8eb32
digitalized-snake/PongGame
/PongGame.py
2,980
3.5625
4
import pygame,sys pygame.init() WHITE = [255,255,255] BLACK = [0,0,0] SCREEN_WIDTH = 1500 SCREEN_HEIGHT = 1000 CIRCLE_RADIUS = 25 PADDLE_WIDTH = 25 PADDLE_HEIGHT = 200 screen = pygame.display.set_mode([SCREEN_WIDTH,SCREEN_HEIGHT]) class Paddle: def __init__(self, xp): self.pxpos = xp ...
61afb266fdc0ae123d091fe4ff9b3d4418d79e5f
GabrielaVasileva/Exams
/Programming_Basics_Online_Exam_6_and_7_April_2019/solution/6ex/cinema_tickets.py
1,794
3.71875
4
total_tickets = 0 student_tickets = 0 standard_tickets = 0 kids_tickets = 0 # • След всеки филм да се отпечата, колко процента от кино залата е пълна # "{името на филма} - {процент запълненост на залата}% full." # • При получаване на командата "Finish" да се отпечатат четири реда: # o "Total tickets: {общият...
43698738aaabaaab8f9c7535aa2f8ec97784de47
marcelohweb/python-study
/9-comprehensions/56-dictionary-comprehension.py
450
3.796875
4
""" Syntax do Dictionary Comprehension {chave: valor for valor in iterável} """ # Ex: dic = {'a': 1, 'b': 2, 'c': 3} ret = {chave: valor ** 2 for chave, valor in dic.items()} print(ret) # Outro exemplo chaves = 'abcde' valores = [1, 2, 3, 4, 5] mistura = {chaves[i]: valores[i] for i in range(0, len(chaves))} pr...
237d83089168fe2e108d46c9ff7896e5c13ad531
lt2nd/My-Apps
/PhoneBook.py
2,129
4.34375
4
# phonebook, simple with only two values, name and phone number # must have sqlite3 to run it import sqlite3 as lite # setting empty phonebook for first time and if you run it again it will fetch all data from sqlite phonebook = {} con = lite.connect('Phonebook.db') cur = con.cursor() con.row_factory ...
8d22c2fdedf178e7a85e57ac97959467c043199e
Existence-glitch/pythonCodes
/simpsonMethod.py
656
3.625
4
import numpy as np from numpy import log #Se define la función a integrar def f(x): return 1 / log(x) #Implementación del método de Simpson #Parámetros: #f es la función a integrar #a el límite inferior de la integral #b el límite superior de la integral #n el número de intervalos def simpson (f, a...
9af97d809106ed8b6c23444d04edcc0f126456b4
eunseo5355/python_school
/line.py
576
4.375
4
""" 두 점의 x좌표, y좌표 를 매개변수로 받아서, 기울기를 반환하는 slope()함수, y 절편을 반환하는 y_intercept 함수 x 절편을 반환하는 x_intercept 함수 를 포함하는 line.py 파일을 정의한다. """ def slope(x1, y1, x2, y2): slope = float(y2 - y1) / float(x2 - x1) return slope def y_intercept(x1, y1, x2, y2): y_intercept = y1 - slope(x1, y1, x2, y2) * x1 return y...
05c9049342cb1b5d3acd6b4db9b179340185b188
rafaelperazzo/programacao-web
/moodledata/vpl_data/10/usersdata/80/11632/submittedfiles/testes.py
133
3.765625
4
# -*- coding: utf-8 -*- from __future__ import division n=int(input('Digite N:')) i=1 while i>(2*n)+1: print(i) i=i+2
1b559d54967e9ce4868378cfe0f60b0d2413a991
409085596/TallerHC
/Clases/Programas/Tarea07/Ejercicio05.py
1,156
3.828125
4
# -*- coding: utf-8 -*- '''Diseñe y programe un algoritmo recursivo que encuentre la salida de un laberinto, teniendo en cuenta que el laberinto se toma como entrada y que es una matriz de valores True, False, (x,y), (a,b), donde True indica uno bstáculo; False, una celda por la que se pued...
9fd3ddfabe5b1c2e8cb0465357811a59c0084320
Eisten1996/Curso-completo-de-Python-3
/Sección 12 - Ejercicios de bucles y condiciones/Ejercicio 2.py
554
3.65625
4
# Creamos una variable 'nota' que tenga el valor 4.5 # Creamos una variable 'trabajo_realizado' que tenga el valor 'si' # Calcular el valor de la variable 'nota_final' teniendo en cuanta que, si la nota_final es mayor o igual a 4, y el # valor de la variable 'trabajo_realizado' es igual a 'si', entonces 'nota_final' se...
b699fd65849ebecfec642dd29791b32b3215f633
nandhakumarm/InterviewBit
/LinkedList/mergeSortedList.py
1,368
3.9375
4
class ListNode: def __init__(self, x): self.val = x self.next = None class Solution(object): def printList(self,A): temp=A while temp!=None: print temp.val, temp=temp.next print "done" def mergeTwoLists(self, l1, l2): head=ListNod...
1c446534668ca47c838bf7274e29d501e21dc2dd
mvanstam/fireworks
/Data_Vuurwerk_sentiment_algorithm.py
3,803
3.578125
4
# coding: utf-8 # In[ ]: # import libraries import pandas as pd import nltk #Natural Language processing - Recognizes words from strings import re #regular expression - to recognize certain patterns in text from textblob import TextBlob #sentiment analysis - pre trained model # df = create dataframe df = pd.read_c...
6f9dd683f880c8cce2fdf90341c721f3a303534f
Johannyjm/c-pro
/AtCoder/abc/abc258/a.py
183
3.53125
4
def main(): n = int(input()) h = 21 + n//60 m = n%60 if m < 10: m = '0' + str(m) print(str(h) + ':' + str(m)) if __name__ == '__main__': main()
bd3b12802fce95b5475aa5f0d572fb94ab4c353f
GuilhermeDallari/desafiomundo1
/ex022.py
320
3.828125
4
n1 = input('Digite seu nome: ') n2 = n1.upper() n3 = n1.lower() print('seu nome em letras maiuscula :{}'.format(n2)) print('seu nome em letras minuscula :{}'.format(n3)) print('seu nome tem {} letras'.format(len(n1) -n1.count(' '))) s = n1.split() print('seu primeiro nome é {} e tem {} letras'.format(s[0], len(s[0])))
aa6bc094c1548a39c342ea30826b57fa7631b726
MBunko/qa-python-exercises
/challenge-of-the-day/1/cotd1_inputtext.py
283
3.890625
4
def alphabet(input): list1=input.split() length=len(list1) sort=sorted(list1) dupdrop=[] for i in range (0,length): if sort[i] not in dupdrop: dupdrop.append(sort[i]) return dupdrop print (alphabet(input("input text here: ")))
be0ca9c30b2884c15622e30c08466bae7db29f84
PravallikaJuturu/Pythonsession
/list_empty.py
88
3.546875
4
myList=[1] if myList==[]: print('myList is empty') else: print('myList is not empty')
0e512206fcc2a3faaad5f342d1ff68bc8b2135b4
prasadkhajone99/prime
/package/own_cal.py
253
3.59375
4
'''calculator related information''' def add(a,b) : return a+b def sub(a,b) : return a-b def mul(a,b) : return a*b def div(a,b) : return a/b if __name__=="__main__" : print(add(10,20)) print(sub(10,20)) print(mul(10,20)) print(div(10,20))
4decf7e84205a10c08922a4d1447efb80aeecd48
spsree4u/MySolvings
/trees_and_graphs/binary_search_tree.py
2,759
4.03125
4
""" Write a function to check that a binary tree is a valid binary search tree. O(n) time and O(n) space. """ class Node: def __init__(self, data): self.value = data self.left = self.right = None def insert_left(self, data): self.left = Node(data) return self.left def...
3ca1adb03fa5d822feda1b680bf7d5cc9625f76c
SpantuTheodor/Laboratoare-PY
/Laborator3/Problema6.py
476
4.125
4
"""Write a function that receives as a parameter a list and returns a tuple (a, b), representing the number of unique elements in the list, and b representing the number of duplicate elements in the list (use sets to achieve this objective).""" string = "Ana has apples. and don't forget, Ana has apples." def uniq...
f5ed13840cc9ad5936538afb1da945c565a75f66
or0986113303/LeetCodeLearn
/python/360 - Sort Transformed Array/main.py
596
3.75
4
class Solution(object): def sortTransformedArray(self, nums, a, b, c): """ :type nums: List[int] :type a: int :type b: int :type c: int :rtype: List[int] """ result = [] for parts in nums: result.append(a*parts**2 + b*parts + c) ...
802ef1d3cc2688c0e6ce6142672b52662fc8c4f2
corinnelhh/public_library
/library.py
2,512
4.21875
4
class Library(object): def __init__(self, my_library): self.my_library = my_library self.library_shelves = [] def create_new_shelf(self, new_shelf): self.library_shelves.append(new_shelf) def report(self): return "The current library, %r, contains the following sections: %r" % (self.my_...
e74b09fd22197b73ae0c59ad24dbff9cb804a125
Eric-Wonbin-Sang/CS110Manager
/2020F_hw5_submissions/donnellyjared/DonnellyJaredP1-1.py
558
3.921875
4
# By: Jared Donnelly # CS 110 - Prof. Kevin Ryan # I pledge my Honor that I have abided by the Stevens Honor System def main(): print("The following program accepts numerical inputs and squares them") print("Please list all the numbers you would like to enter in a list separated by spaces") squarables = in...
66ac22424520e60fe26ca2baf753aa86fb1216a2
msukhare/SnowCrash
/level09/Ressources/script.py
155
3.578125
4
with open("token", "r") as f: token = f.read() final_token = "" for i, v in enumerate(token[:-1]): final_token += chr(ord(v) - i) print(final_token)
4297649ff315dc0f2d1329e53e25a9ed08449af6
ExperienceNotes/Python_Leetcode
/Leet_Code/Binary Tree inorder Traversal.py
2,080
3.796875
4
from random import randint class Node: def __init__(self,value=None): self.value = value self.left_child = None #smaller self.right_child = None #bigger class Binary_tree: def __init__(self): self.root = None def insert(self,value): if self.root == None: ...
acd631014f37f9d2e3076440f7d6dae7f89b4db0
lsiepman/AdventOfCode2016
/Day16.py
2,140
3.90625
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 30 09:55:04 2020. @author: laura """ # IMPORTS # DATA data = "10001110011110000" # GOAL 1 """Start with an appropriate initial state (your puzzle input). Then, so long as you don't have enough data yet to fill the disk, repeat the following steps: - Call the data you ...
b8a81880630b757a069e3204f66b2d9ccb3e3d70
Totillity/totillity.github.io
/_site/jit-project/progress_timeline/journal_5.py
15,459
3.671875
4
from _generate_site.elements import * page = Page("jit-project/progress-timeline/journal-5.html", nav_loc=["JIT Project", "Progress Timeline", "[10] Journal 5"]) page += Title("Journal 5: Weeks 16-19") page += Paragraph("March 21, 2021 - April 17, 2021") page += Heading('Goals for this Journal:') page +...
2ce37d0ad2d5130ea912e2290a28d2a2601a7a3c
alinzel/NOTES
/other/py/text.py
276
3.703125
4
a = [{"issue":"123"},{"issue":"234"},{"issue":"345"}] # for i in a : # if "123" not in i["issue"]: # print(i) res = [i for i in a if ("123" not in i["issue"]) and ("234" not in i["issue"]) ] res = [i for i in a if "123" and "234" not in i["issue"] ] print(res)