blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d62638fb4471dc3b1eff48933d57faa9647488f6
RichCherng/Traffic-Analyzer
/street.py
2,445
3.53125
4
class Street(object): intersection_1 = "" intersection_2 = "" length = 0; #distance between two intersections speeds = {} #list of speeds by the hour travelTime = {} #list of travel time by the hour timeLog = [] speedLog = [] def __init__(self, inte_1, inte_2, l): self.intersection_1 = inte_1 self.inters...
521d54aa8e8c27cee27e03009a1a55742a553099
shylune/mython
/standard_libs/01_basis_knowledge/02_function.py
2,395
4
4
# -*- coding: utf-8 -*- """ ************** 函数 ****************** 定义: 使用def语句定义函数,依次写出函数名、括号、括号中的参数和冒号:,然后,在缩进块中编写函数体,函数的返回值用return语句返回 """ # 1、函数的定义 def my_abs(x): if not isinstance(x, (int, float)): raise TypeError("bad operand type") if x >= 0: return x else: return -x # 2、空函...
e85c29d6ce48d148d5d4ea669b6ed113270e4cbb
kriegaex/projects
/Python/maze/DFS_maze.py
4,748
4.25
4
import turtle from random import randint from time import sleep from stack import Stack from queue import Queue '''Create a search list for positions yet to explore, add the entrance to this stack While the stack is not empty Remove the next position from the search list If it is the exit position, [n-1, n-1...
a88f6ca04268f41db27008184a5a9384dc6cf48e
vdatasci/Python
/Quantitative-Economics/Linear-Algebra/Straight-Line-Function.py
296
4.125
4
def straight_line(gradient, x, constant): ''' returns y coordinate of a straight line gradient * x + constant''' return gradient*x + constant #for x in range(10): # print(x, straight_line(2,x,-3)) # #(0, -3) #(1, -1) #(2, 1) #(3, 3) #(4, 5) #(5, 7) #(6, 9) #(7, 11) #(8, 13) #(9, 15)
42a1d0bc82bcfa21f00b8cfbb92861c1e5dcbfc0
marydeka/coding_practice
/interview_prep/Stacks/2.py
892
3.90625
4
""" Balanced Parentheses: Given an expression string, write a python program to find whether a given string has balanced parentheses or not. """ open_par = ["[","{","("] closed_par = ["]","}",")"] def check(str): stack = [] for i in str: if i in open_par: stack.append(i) el...
29f82fb1284341ec2b2dd88e4c321bb18306b45a
Adi-ti/TICTACTOE
/tictactoe.py
1,737
3.8125
4
from __future__ import print_function import sys ways = [] for x in range (0, 9) : ways.append(str(x + 1)) playerOneTurn = True winner = False def printBoard() : print( '\n -----') print("This Game is developed by Aditi") print("Board looks like-----------------") print( '|' + ways[...
b6c8d400c0717d2b081329b86b8456871a4838a2
aindrila2412/DSA-1
/thread.py
1,488
3.90625
4
import threading import time from threading import Thread def thrdFunc(): print("Starting of thread function.") time.sleep(5) print("Thread function completed.") # thrdFunc() print(threading.activeCount()) thrd = Thread(target=thrdFunc) thrd.start() print(threading.activeCount()) thrd.join() # wait fo...
61798a383c3028aa80c802a2cd28680eb39076b8
reddyachyuth/python_devops
/practice/reveresestring.py
121
3.5
4
def FirstReverse(str): return ''.join(reversed(str)) # keep this function call here print FirstReverse(raw_input())
a6c8cf65873355a9e38210e4030def956d5b46ee
JKReyner/Palindrome-Checker
/palindrome.py
914
4.15625
4
# define inputs to keep letters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" numbers = "0123456789" keep = letters + numbers # get input string = input("Provide an input: ") # remove punctuation my_str = string.casefold() no_punct = "" for char in my_str: if char in keep: no_p...
5a55d60fd48b6ab7e141301955fc174932252358
torourke14/__TannersMenagerie__
/Tweet-Sentiment__cpp/tweet.py
946
3.671875
4
class Tweet: """Represents a single Tweet, including time and location meta data.""" def __init__(self, message, timestamp, position): """ Initialize a Tweet instance. message - a string that includes the full body of the tweet, including hashtags timestamp - a datetime.datetim...
8bde553a49058e5a8026d89366866a9aad6822d0
gdetver/eWallet
/app/db/base.py
2,873
4.0625
4
#!/usr/bin/env python3 # coding=UTF8 import sqlite3 class DataBase: """ Класс работы с базой init - создает коннектор и курсор """ def __init__(self): self.conn = sqlite3.connect(":memory:") self.cursor = self.conn.cursor() def create_db(self): # Создан...
4e5f3e48c2820e80e83642355be4ecfc05c6da40
cabecas/acc_test
/importdata.py
1,438
3.703125
4
import pandas as pd def read_file(fileread, folha): """ Goal: Make data available in Python from the source; Input1: Excel file, with type xls; Input2: Name of the sheet in the file passed as Input1; Output: pandas.df with raw data """ xls = ('.xls') file = fileread + xls xl = pd....
45ef7287abbbc2a2019f1798244914eaee08fd87
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/rphram004/question1.py
3,640
4.0625
4
"""Question 1: programme that brings out options for the uses to choose from. #Rama Raphalalani #15-04-2014""" print("Welcome to UCT BBS\nMENU\n(E)nter a message\n(V)iew message\n(L)ist files\n(D)isplay file\ne(X)it") x = input("Enter your selection:\n") y = x.lower() a = '42.txt' b = '1015.txt' #the start ...
6e253d572af62c7161578078de608e8c69253bee
NAMARIKO/YasashPython_book
/Lesson5.6_12.13.14.py
1,247
4.03125
4
prefectureName = [ "滋賀県", "京都府", "大阪府", "兵庫県", "奈良県", "和歌山県", ] prefectureNum = [ 25, 26, 27, 28, 29, 30, ] """ リスト組み合わせ """ # %% # Sample_12 print("\n[Sample_12]") print("都道府県\t:", prefectureName) print("都道府県番号\t:", prefectureNum) # enumerate print("prefectureName -> ...
70ced87407dd17449fe3a3239d662fb9f848d70d
danielstabile/python
/usp_semana_3/ex2-5.py
221
4.03125
4
n1 = int(input("Digite primeiro numero: ")) n2 = int(input("Digite segundo numero: ")) n3 = int(input("Digite terceiro numero: ")) if n3 > n2 and n2 > n1: print("crescente") else: print("não está em ordem crescente")
7e7b9c7d9e676d033db2c2a4e347c3cab016522c
Kaylotura/-codeguild
/practice/blackjack/deck.py
2,649
3.71875
4
"""Module containing the Deck class""" from card import Card from random import shuffle class Deck: """A class for representing a Deck of cards""" def __init__(self, cards): self.cards = cards def __eq__(self, other): return ( self.cards == other.cards ) de...
0207db6017f0e6dd6805dfaf8efec5b8f9139b54
oznurg/4318
/ba4318_test1_part2_2076396.py
2,534
3.5
4
#Öznur Güngör - 2076396 import pandas as pd import os def group_by_mean(df,gb,m): df_res = df.groupby([gb])[m].mean().reset_index() return df_res #reading files filename = os.getcwd() + "/sudeste.csv" filename2 = os.getcwd() + "/weather_madrid_LEMD_1997_2015.csv" df_brazil = pd.read_csv(filename,usec...
499179d2284a5945c2593c830f3ddc111f52c7e6
Mikhail713-xph/exp
/calculator.py
821
4.09375
4
a = float(input('Введите значение №1: ')) b = float(input('Введите значение №2: ')) operation = input('Выберите операцию: +, -, /, *, mod, pow, div: ') if operation == '+': print(a + b) elif operation == '-': print(a - b) elif (operation == '/') and (b != 0): print(a / b) elif operation == '/' and b == 0...
9e2df41f019d31f60b9cb2f18ef038e54bcea6b2
Aasthaengg/IBMdataset
/Python_codes/p03547/s794988738.py
75
3.828125
4
X, Y = input().split() print("<" if (X < Y) else ">" if (X > Y) else "=")
60d981866b2a5adaff85564d1a7764de42904b25
bradleydavidsmith/Python-Projects
/Tkinter Drill Move .txt files/MoveTextFiles.py
4,854
3.890625
4
# Python Ver: 3.8.1 # # Purpose: Move Text Files/Tkinter Demo. demonstration OOP, Tkinter GUI module, # using Tkinter Parent and Child relationships. # # Tested OS: This code was written and tested to work with Windows 10. # # Future Improvements: # 1) Since the user can edit the f...
7d79217de69ef014ac72c0350d0851f1845bf0d0
harishrenukunta/LearnPython
/Calc.py
179
3.5
4
def add(a, b): return a+b def sub(a, b): return a-b def multiply(a, b): return a * b def divide(a, b): return a / b if __name__ == "main": print(__name__)
38612f0bce3c1d773f455bd2e93be0cc9ec4787a
anInsignificantHuman/AutomaPy
/Automa.py
1,647
3.84375
4
import random new_input = input("The Length Of The Board Should Be: ") new_input2 = input("The Height Of The Board Should Be: ") try: test = int(new_input) test2 = int(new_input2) except: print("Error") quit() generation = 1 def randomizer(): random_number = 2 - random.randint(1, 2) ...
4cd0f1517c0c4fda35b8809a9da4d907eae0029a
MichelleZ/leetcode
/algorithms/python/criticalConnectionsinaNetwork/criticalConnectionsinaNetwork.py
1,094
3.5625
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Source: https://leetcode.com/problems/critical-connections-in-a-network/ # Author: Miao Zhang # Date: 2021-04-16 class Solution: def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]: g = collections.defaultdict(set) ...
b64f5f2a8158e5d1f1a428f334625e9cd5fbb198
diogohxcx/PythonCemV
/desafio063(Sequência de Fibonacci).py
367
3.9375
4
print('-='* 30) print('Sequencia de Fibonacci!') print('-=' * 30) total = int(input('Informe a quantidade de termos: ')) t1 = 0 t2 = 1 cont = 3 print('~' * 30) print('{} - {}'.format(t1, t2), end='') while cont <= total: t3 = t1 + t2 cont += 1 print(' - {}'.format(t3), end='') t1 = t2 ...
755d0e2146a09e1a3b29344b282f73d2e1b043d3
kumarun91/World-Happiness-Report
/finalModel.py
1,983
3.59375
4
# -*- coding: utf-8 -*- """ Created on Thu May 04 03:43:47 2017 @author: arun """ # -*- coding: utf-8 -*- """ Created on Tue May 02 01:21:30 2017 @author: arun """ #from __future__ import division import numpy as np import pandas as py import math import matplotlib.pyplot as plt from sklearn import...
f93fa487d841b7f9e0df233bac514f0d5c2492d8
indayush/Python_Essentials
/Exercise Files/Chap03/collectionBrief.py
873
4.40625
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # [] are used for a list declaration # () are used for a tuple declaration # Difference between tuple & list is that tuple is immutable & list is mutable x = (1, 2, 3, 4, 5 ) for i in x: print('{}'.format(i),end = '; ') ''' 1; 2; 3; 4; 5; ''' pri...
ac54f0de6653ce293be7b240f14efbf72068868d
yinghuihou/MyLeetCode
/1-100/74.py
1,263
3.9375
4
# Definition for singly-linked list. from typing import List def main(): matrix = [[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]] target = 23 print(searchMatrix(matrix, target)) def searchMatrix(matrix: List[List[int]], target: int) -> bool: if matrix == None or len(matrix) == 0: return ...
c5adba43ed82e8b4c6e197725ba2b509f7012746
PIvanov94/SoftUni-Software-Engineering
/Programming Fundamentals Python 2020 Part 2/The Imitation Game.py
796
3.921875
4
encrypted_message = input() data = input() while not data == "Decode": line = data.split("|") command = line[0] if command == "Move": n_letters = int(line[1]) letters_to_move = encrypted_message[:n_letters] letters_left = encrypted_message[n_letters:] encrypted_m...
c6e420d75b599056f7561f8081ea16d7b8268b61
kruug/AdventOfCode
/2020/Day 02/Project 02/main.py
1,371
3.625
4
# First number is minimum count # Second number is maximum count # Third element is the letter def splitLine(line): inputsSplit = line.split() numbersSplit = inputsSplit[0].split('-') output = [numbersSplit[0], numbersSplit[1], inputsSplit[1].split(':')[0], inputsSplit[2]] return output def isPasswordValid(fir...
bdf1c79d5e3fcdc57ed52acedd244fd66b064cfc
ysfscream/my-leetcode
/Algorithms/two_sum.py
342
3.5
4
def two_sum(nums, target): index = {} for i in range(len(nums)): in_index = target - nums[i] in index if not in_index: index[nums[i]] = i if in_index: first = index[target - nums[i]] two = i return [first, two] return [] print(two_su...
0ef3db7fb9965c6f185f87a4485c382780ff1dd0
gabriellaec/desoft-analise-exercicios
/backup/user_265/ch16_2020_09_12_16_08_33_353197.py
144
3.671875
4
a = float (input ('Qual o valor da conta? ')) def porcento(a): y= a*1,1 return y print ('Valor da conta com 10%: R$ {0:.2f}' .format(a))
bbbf5f7ecfea89846b4d85b3e3de52cae8370105
brandonyap/engg3130-finalproject
/strategies/PIDStrategy.py
2,569
3.5
4
import control from utils.BaseStrategy import BaseStrategy import math """ m: mass of pendulum M: mass of cart b: coefficient of friction of the cart (zero in this case) I: inertia of the pendulum (might be 0?) l = length of the pendulum q = (M+m) * (I+m*(l^2))-((m*l)^2) closed loop transfer_function = Theta(s)/Forc...
d5536d8e34ce7027662f048a355d82bb2343d3dc
TemistoclesZwang/Algoritmo_IFPI_2020
/listaExercicios/LISTA_FABIO_ITERACAO/07N_INTEIRO.py
362
3.828125
4
# Leia um número N, some todos os números inteiros entre 1 e N e escreva o resultado obtido. def ler_n(): n = int(input('Digite um numero: ')) contador1 = 0 lista = [] while contador1 < n: contador1 += 1 lista.append(contador1) soma = 0 for numero in range(len(lista)): soma +=...
3c7ca7468aa3c7c6bbd72163c11d9e314219d638
YilK/Notes
/Python-Crash-Course/第一部分 基础知识/第06章 字典/6-10 喜欢的数字.py
496
3.515625
4
''' 修改为完成练习6-2而编写的程序,让每个人都可以有多个喜欢的数字, 然后将每个人的名字及其喜欢的数字打印出来。 ''' message = { 'hjk': [7,3,5,7], 'wy': [5,3,23,54], 'llq': [1,4,3,524], 'ghd': [4,23,65,786], 'wll': [23,324,5645,565675675] } for people in message.keys():#首先遍历键 print(people)#打印出人名 for number in message[people]:#遍历键所对应的列表 ...
ea51589683429076afcab0c577e29a646bd5a057
boaass/Leetcode
/888. Fair Candy Swap/Fair Candy Swap/main.py
1,876
3.921875
4
# -*- coding:utf-8 -*- # Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, # and B[j] is the size of the j-th bar of candy that Bob has. # # Since they are friends, they would like to exchange one candy bar each so that after the exchange, they both have # the ...
63a0349a911d8b3edff7d07e8f28a65230cbc379
pauleclifton/GP_Python210B_Winter_2019
/students/jeremy_m/lesson03_exercises/mailroom.py
3,659
4.1875
4
#!/usr/bin/env python3 # lesson 03 Exercise - String Formatting Lab # Jeremy Monroe import os donors = {'Charlize Theron': [134000], 'Charlie Boorman': [15, 5], 'James Franco': [25, 250, 2, 500], 'Nike': [22000], 'Count Chocula': [1257633, 2532790] } donor_totals = ...
66f284090259ba7d36f21d22b84550f2f4aa2cbc
varalakshmisarathi/guvi
/alphabet.py
142
3.953125
4
#print alphabet froma to z def apha(): print("Alphabets from a - z ") for alpha in range(97, 123): print(chr(alpha), end=" ") alpha()
2ec584e39e4611382dba93db5f0931318c81a4c0
tanmaysharma17/HACKTOBERFEST21-GTBIT-COMPETITIVE
/450 DSA Cracker/PYTHON/Heap/kth_largest_elements.py
556
4.03125
4
#Ques 339 - Kth largest elements '''Given an array Arr of N positive integers, find K largest elements from the array. The output elements should be printed in decreasing order.''' import heapq def kth_largest_elements(N, K, elements): hp = [] for i, element in enumerate(elements): if i < K: ...
649b6c607f1e1e78a99c70896f2744ce8940106e
Brollof/Advent-of-Code
/2019/Day 6/6.py
1,336
3.5
4
class Planet: def __init__(self, idx): self.idx = idx self.next = None self.prevs = [] def __repr__(self): return f"{self.idx}" def build_orbit_map(data): planets = {"COM": Planet("COM")} for rel in data: idx1, idx2 = rel.split(")") if idx1 not in plane...
87f0f2d9b4840500db49464adccead78e50d2744
josholiversilva/sorting
/mergesort.py
2,149
4.25
4
import sys import time # Time: O(nlogn) # Space: O(n) - Auxilliary space to create temporary subarrays # Merge sort uses a "divide-and-conquer" paradigm # 1. Divide - Num of subproblems that are smaller instances of same problem # 2. Conquer - Solve each subproblem recursively # 3. Combine - All solutions to the subpr...
6f51f8744a88aaa9dd4eba94c59cef589f6cf5c8
cathyxingchang/leetcode
/code/107_E(102).py
1,346
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 107_E(102) # Created by xc 23/03/2017 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None import copy class Solution(object): def levelOrderBottom(...
c3192b53c1cd30515525056e70f048af6351fed0
egealpturkyener/Sorting_Algorithms_PyQt
/bubble_sort.py
284
4.0625
4
#EGE ALP TÜRKYENER def bubble_sort(list): for j in range(len(list)-1): for i in range(len(list) - 1): if list[i] < list[i + 1]: #compare the number the the next number list[i], list[i + 1] = list[i + 1], list[i] #according to result replace.
a438847a96a38254a87ffc9b4d5753c27d11f78b
Ahaituka/Interviewbit_Solutions
/Level 2/Level 2 Math/Trailing_zeroes.py
506
3.90625
4
# Trailing Zeros in Factorial # Given an integer n, return the number of trailing zeroes in n!. # # Note: Your solution should be in logarithmic time complexity. # # Example : # # n = 5 # n! = 120 # Number of trailing zeros = 1 # So, return 1 def fact(n): pro = 1 for i in range(1, n + 1): pro *= i ...
11d1cd3912a8f998ea325be94d7425e6a0c2d635
Mo-Foula/Multi-client-chat-application-python
/attacker.py
1,014
4.03125
4
import caeser as cr import os print('This program is for attacking encrypted messages by Caeser Cipher algorithm\n') fileName = 'Decrypted messages.txt' fileExists = False if os.path.exists(fileName): #already exists w by3ml append fileExists = True file = open(fileName, "a") file.write("\n\n") fi...
e6d29635052b738ab4e195cdd6fd0dddb4e566dd
tangyingjin/Hogwarts
/python基础练习/exc_lambda.py
214
3.578125
4
# s=map(lambda x:x*2 ,[1,2,34,5]) # for i in s: # print(i) from functools import reduce # var=filter(lambda x:x%2==0,[2,4,8,9]) # for y in var: # print(y) # var1=reduce(lambda x,y:x*y,[1,2,3,5]) print(var1)
86e3ff211afb76507446f446324ee68a977fe19b
Aso2001142/dai_programming
/python/timezone.py
262
3.609375
4
from datetime import datetime, timedelta, timezone jst = timezone(timedelta(hours=9)) today = datetime.now(jst) print(today) print(today.year) print(today.month) print(today.day) day = datetime.strptime("2030/01/10 06:02:19", "%Y/%m/%d %H:%M:%S") print(day)
ab378bf6891491721c78e3ac2829cb4fc43d23b4
mstrudas/projecteuler
/project22.py
466
3.640625
4
#!/usr/bin/env python3 import sys, os, csv def letter2number(char): return ord(char.lower()) - 96 try: file = sys.argv[1] except: file = input("Enter file to open: ") f = open(file, 'r') reader = csv.reader(f, delimiter=',') for row in reader: list = row f.close() list.sort() total = 0 for name in list: sum ...
98024f8617e4843b7bcf799105b3ffe10bbd2656
Johnnson85/210CT-Programming
/week 2/perfect Sq(1).py
342
4
4
def sq(s): x=int(0) if s>0: while x*x < s: x=int( x+1) if x * x != s: print (s, "is not a perfect square") s=(s-1) sq(s) else: print (s, "is a highest perfect square cause :", x, "*", x, "=",s) return x else: print ("not a good input, sorry") retu...
bc20ebd4dd0666b1f3dfe6358246d65342fc3d1a
aiifabbf/leetcode-memo
/49.py
2,206
4.125
4
""" 把一组array按anagram归类 如果两个字符串的直方图完全一样,也就是说如果统计两个字符串中每个字符出现的频数,发现完全一样,就称这两个字符串互为anagram。其实说直方图,有点限制思维了,因为目标是要找到一种快速判断两个字符串是否互为anagram的方法,而用 ``Counter`` 做直方图是很慢的,关键是 ``Counter`` 是不可hash的,所以要放到结果集里面还需要变成可hash的东西。不管怎样, 用 ``Counter`` 至少是能过的。 后来我想到了直接计算其中每个字符的hash、然后再全部相加的方法,虽然这种理论上是有撞hash的风险的,但是因为python的 ``hash()`` 返回的是一...
7c0c419cb632099958ee47a20753323160791295
zhangbo111/0102-0917
/day11/07-__dir__魔术方法.py
785
3.96875
4
# dir魔术方法 class Apple: color = "red" weidao = "甜的" def eat(self): print("要一口 变成苹果公司") def fall(self): print("从天掉下来 变成万有引力") def __dir__(self): ''' 触发时机:dir(对象)的时候 :return:序列 (列表 集合 元组) ''' # 获取self(plus8)对象可以访问的所有的成员(属性和方法) list1 = obje...
00eebef479fdcfd4e132db8c12b856bd17b5c24a
FauzanDigHub/Binus_TA_Session_Semester_1
/TA day 6.py
238
4.21875
4
def factorial(number): if number == 0: return (1) else: return (number * factorial(number-1)) number=int(input("Input number to result in factiorial : ")) print("") print("result:",factorial(number))
602f67b044ca0a3b0e78469208de1091cce9bcde
oleksa-oleksa/Python
/IT_Security_Beuth_MasterMediaInformatik/01_substitution_code/02_encrypt.py
1,243
3.6875
4
import random from utils import get_alphabet, read_file_to_string, write_string_to_file from constants import INPUT_FILENAME, OUPUT_FILENAME, ALPHABET extra_symbols = [',', '.', ':', '-', '#', '!', '?', '€', '$', ';', "'", "’", '(', ')', '=', '“'] alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l...
51f5f1d2c44bd3c0c4750d4e58b8a0a1592464f6
clara-odebrecht/calculator
/calculator.py
2,323
3.90625
4
class Calculator: __expression: list __priority = ["/", "*", "+", "-"] def get_expression(self) -> list: return self.__expression def get_priority(self) -> list: return self.__priority def set_expression(self, value) -> None: self.__expression = value def set_priority(s...
5c71671f3f81114dd5639caf3a192c8bfc53c6f4
arihantp2/Python-Projects
/Shopping_List.py
954
4.09375
4
''' input = shop items sold = bread = 16 , butter = 21, tea bags = 55, coffee = 26, Paav = 12 add this data in dic. by user. access different elements and add new element named cake=6 and cold drink = 11 ''' k=[x for x in input("Enter the list items : ").split( )] shop_items={} for items in k: print("Enter ...
ee0973e6de6808c989222a469bc0c831cc62331b
CBaud/AdventOfCode
/src/2020/day03.py
740
3.6875
4
class Day03Solution: def __init__(self): file = open("day03.txt", "r") self.items = file.read().split("\n") def partOne(self, slide=3, drop=1) -> int: count = 0 col = 0 for row in range(0, len(self.items), drop): if col >= len(self.items[row]): ...
6d73e715b76d97102ec7a704ea7611e55acf0191
maxdrib/Computation-Tools-For-Big-Data
/week2/exercise1/exercise.py
571
3.546875
4
import sys def read_array(filename): f = open(filename, 'r') matrix = [] for line in f: line = line[:-1] points = line.split(' '); matrix.append(points) #print points f.close(); return matrix def array_to_file(twoDArray, filename): f = open('out.txt', 'w') for i in range(0, len(twoDArray)): for j in ...
e0604a22645ecff79ad1b42be0d27dad3da36de4
amikoj/pythonNotes
/exercises/basics/struct.py
1,768
3.875
4
#!/usr/bin/env python # -*-encoding:utf-8 -*- # multi=lambda x,y:x*y #lambda关键字定义,以':'分割,左边为参数列表,右边为返回结果的表达式 # print multi(2,3) def function(var1,var2="test"): "only print parameter." print var1,var2 # help(function) # function("need","help") # function(var2="var2",var1="var1") # function("var1") class ...
86e1f8a3c2d185b6e71263223d0f574c02d00a28
mitoswami91/mrlinux
/sysdown.py
838
3.9375
4
# !/bin/python # Simple script for shutting down the Raspberry Pi at the press of a button. # by mitesh import RPi.GPIO as GPIO import time import os # Use the Broadcom SOC Pin numbers # Setup the pin with internal pullups enabled and pin in reading mode. # FIRST CHECK PIN INDEX SEE THE PIN GROUP #GPIO.setmode(GP...
f67ce6a4c73f8ca2532499992bc04db9c9705c7b
mjaw10/Functions
/functionsR+R3.py
155
4.25
4
character = int(input("Please enter an ASCII code: ")) ascii_code = chr(character) print("The character for that ASCII code is {0}".format(ascii_code))
65bbacbee6f4b98b09df30fa804cc8fb50df6c92
AndrewGKennedy/python_tasks
/python_scripts/Week1--2/week1-2.py
3,898
4.3125
4
-# Andrew Kennedy/ Ian McLoughlin # A program that displays Fibonacci numbers. def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i # Test the function with the following value. x = 30 ans = fib(x) print("Fibon...
90937a15743cb9639f101125ac44c39c8c7ac1e5
Abhishek-IITM/elo-kaggle
/utils/split_across_zero.py
326
3.546875
4
import pandas as pd def count_greater_than_equal_to_zero(x): x = pd.Series(x) return sum(x>=0) def count_less_than_zero(x): return sum(pd.Series(x)<0) def sum_greater_than_equal_to_zero(x): x = pd.Series(x) return sum(x[x >= 0]) def sum_less_than_zero(x): x = pd.Series(x) return sum(x[x ...
7dfe82b550fbab813d0a881cc86371d5cdaa6822
iggirex/CodeWars-Repo
/reverseStringPython.py
224
4.3125
4
You need to write a function that reverses the words in a given string. A word can also fit an empty string. def reverse(st): arr = st.split(" ") arr.reverse() print (arr) rev = " ".join(arr) return rev
8ea6a304305443b138168e51401c762956768d72
victorbonomi16/infosatc-lp-avaliativo-07
/exercicio03.py
173
3.9375
4
numeroSalvo=[] for x in range(5): numero=int(input("Informe um numero: ")) numeroSalvo.append(numero) func = list(filter(lambda x: x >=10, numeroSalvo)) print(func)
c2ed3ea4e25a8ab7a3b9c380011828fec9d80cc2
warshawd/poxStartup
/topogen.py
936
3.625
4
import networkx numNodes = 14 degree = 3 routing = {} neighbors = {} graph = networkx.random_regular_graph(degree, numNodes) for i in range(numNodes): neighbors[i] = list(graph[i].keys()) neighbors[i].sort() print "Node " + str(i) + " connects to " + str(neighbors[i]) print "Routing Table:\n" ...
13bfe2ced62bfd6016d74b559f9fbb949e97927f
vijaypatha/pytIntro
/learnClass.py
444
3.53125
4
import turtle def drawsq(): rats = turtle.Turtle() #turtle.shape("turtle") count = 0 while count < 4: rats.forward(100) rats.right(90) count = 1+count cats = turtle.Turtle() cats.circle(100) dogs = turtle.Turtle() tri = 0 while tri < 4: dogs.forward(3...
6052b4c9d97d952912502b6aafa4a546e178b79e
Purefekt/Raspberry-Pi-Mini-Projects
/[7]Plotting a graph of current temp, humidity and pressure.py
1,335
3.71875
4
from sense_hat import SenseHat import matplotlib.pyplot as plt import time def plot(filename): #define two lists temp_list = [] humi_list = [] try: #open the file for read file = open(filename,'r') #break file content into lines lines = file.readlines() #go through all lines and dpl...
44037b5fb270110dca1df1002a0f25416f4ce6f2
Ikar20/Programing
/laba5/main.py
1,312
3.578125
4
import math def read_file(file): with open(file, "r") as file: width = int(file.readline()) line = file.readline().split() heights = [] for x in line: heights.append(int(x)) return width, heights def optimiser(heights): heights = sorted(heights, reverse=True) ...
bcd203f0db76621f134cdc8ca03ce77a2dc09db7
lissgomo/twilio
/python_send-multiple-sms.py
1,567
3.734375
4
''' Script ask you to enter the amount of phone numbers, the phone numbers then mass texts the same message to all phones. Provides SIDs for each message and error message for invalid numbers. ''' # pip install twilio -- Use Twilio libraries # pip install python-dotenv -- Used to hold account sid and auth token on sepa...
1bdf9d64f8f2d25c4d026be014b5f242d890186b
AmimoG/Blogging-website-
/tests/test_post.py
1,312
3.734375
4
import unittest from app.models import Post,User class TestPost(unittest.TestCase): """ This is the class I will use to test the posts """ def setUp(self): """ This will create a new post before each test """ self.new_post = Post(title = "Haha") def tearDown(self):...
652e4b7cf9e3d1a705bdb92ae4b25a4e9b7e5082
wh-acmer/minixalpha-acm
/LeetCode/Python/clone_graph.py
1,247
3.734375
4
#!/usr/bin/env python #coding: utf-8 # Definition for a undirected graph node class UndirectedGraphNode: def __init__(self, x): self.label = x self.neighbors = [] class Solution: # @param node, a undirected graph node # @return a undirected graph node def cloneGraph(self, node): ...
4f4a4875701ea2d2f1e2a1df25f3f84dd0b25d17
obonhamcarter/cs300fall2019
/0_lessons/06_17Sept2019_genesAndAlleles/mySandbox/misc/working/functions.py
653
3.96875
4
#************************************* # Honor Code: This work is mine unless otherwise cited. # Janyl Jumadinova # CMPSC 300 Spring 2016 # Class Example # Date: February 11, 2016 # Purpose: illustrating functions #************************************* # here we define/implement the function that sums up # the squar...
2cfd024ef37d855f53eba2014648c07509d587a8
AreAllUsernamesTaken/ChessProject-Python
/src/ChessBoard.py
4,367
3.875
4
from termcolor import colored from pieces import * from PieceColor import PieceColor class ChessBoard: # Init chess board 8x8 def __init__(self) -> None: self.BOARD_WIDTH = 8 self.BOARD_HEIGHT = 8 self.board = [[None for i in range(self.BOARD_WIDTH)] for j in range(self.BOARD_HEIGHT)] # Convert from chess co...
508c73a742a646f1c223f329251a43fb982a3523
zhangxiping1/ml
/andrew_ml/2/test2.py
5,112
3.546875
4
#coding=utf8 import numpy as np import pandas as pd import matplotlib.pyplot as plt path = 'ex2data1.txt' data = pd.read_csv(path, header=None, names=['Exam 1', 'Exam 2', 'Admitted']) data.head() positive = data[data['Admitted'].isin([1])] negative = data[data['Admitted'].isin([0])] # fig, ax = plt.subplots(figsize...
2d120d55efd75af719fe2f76f56c77a73f22e2cc
101guptaji/Python-programmes
/operator.py
1,192
3.890625
4
import operator x=input("enter two no.") a,b=x.split() a=int(a) b=int(b) print(a,"+",b,"=",operator.add(a,b))#a+b print(a,"-",b,"=",operator.sub(a,b))#a-b print(a,"*",b,"=",operator.mul(a,b))#a*b print(a,"/",b,"=",operator.truediv(a,b))#a/b print(a,"//",b,"=",operator.floordiv(a,b))#a//b print(a,"**",b,"=",operator.pow...
68e4cd3317dc8db81b308d3e6c2bf81ffd8436f9
DS-PATIL-2019/DP-3
/MinFallingPath.py
781
3.65625
4
""" Running on Leetcode Time complexity - O(N) The approach here is to iterate the 2-D array from backwards. Add the min value amoungst the available elements to add from the previous row. keep on doing this until you reach the first row. and finally the minimum element sum in the first row indicates the correct minim...
2af8e1361d309d5c428bcab4c031530c0170e539
thasleem-banu/python
/thaa8.py
69
3.546875
4
fr=int(input()) thas=0 for i in range(fr): thas=thas+i print(thas)
605a40e31d2fde5e13863a30ca75dd28324a36fd
tristaaa/lcproblems
/hindex.py
2,310
3.640625
4
class Solution: def hIndex(self, citations): """ Given an array of citations of a reasearcher, return his max h-index. A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations e...
a66a860bda3ecf81e7962211f76d1d952c948892
NischalGowdaHV/Project1
/Project/problem1.py
607
3.75
4
""" Problem1 Implement a group_by_owner function that: 1) Accept a dictionary name containing file owner name for each file name. 2) Returns a dictionary containing a list of file name for each owner, in any order. """ Input_dict = { 'Input.txt': 'Randy', 'Code.py': 'Stan', 'Output.txt': 'Randy' } # Inpu...
5fea8a9192cc4f1401f78d59a8d79dc98cbaa19a
guitianyi/ichw
/pyassign3/wcount.py
1,602
3.65625
4
"""wcount.py: count words from an Internet file. __author__ = "Gui Tianyi" __pkuid__ = "1700011801" __email__ = "1700011801@pku.edu.cn" """ import sys from urllib.request import urlopen def wcount(lines, topn=10): """count words from lines of text string, then sort by their counts in reverse order, output...
80104a4e2e41e0f8a819f001e71e456d9aebf2d5
cmput229/Lab_Test
/src/main.py
372
3.546875
4
from argparse import ArgumentParser from functools import lru_cache @lru_cache def fib(n: int) -> int: # TODO: implement your method here return 0 def main(): parser = ArgumentParser(description='Fibonacci number generator.') parser.add_argument('n', type=int) args = parser.parse_args() print(...
6676d9b320ab911c1a3a82f6015339d6398e4342
Sukunyuan/cp1404practicals
/prac__04/quick_picks.py
448
3.765625
4
import random def main(): picks = int(input("How many quick picks?")) for n in range(picks): quick = CONSTANTS() for i in quick: print(i, end=" ") print() def CONSTANTS(): constants = [] for i in range(6): num = random.randint(1, 45) while num in c...
82843314badae97b8e38bdb6741f10bcae2585fc
adzarrini/dynamic
/dp.py
1,172
3.5625
4
n = 12 # number of months k = 3 # number of cities NY = 0; # these are the corresponding rows in the city matrix LA = 1; # also the corresponding row / col in the opportunity matrix DEN = 2; # so just reference them # set up the # hardcoded (gross) city_items = [8, 3, 10, 43, 15, 48, 5, 40, 20, 30, 28, 24, 18, 1, 3...
4e9bd475baf7ac472ba15d1d4d6bd0365878446a
tuanh610/AlgorithmSolutions
/Array/MagicIndex.py
1,022
3.53125
4
from random import randint class Solution: def magicIndexNoDuplicate(self, arr): def find(start, end): if end < start: return None mid = start + (end-start)//2 if arr[mid] == mid: return mid elif arr[mid] > mid: ...
4b1cc0240dab583f935b1fafd5870315cdaa19f7
shilpavijay/Algorithms-Problems-Techniques
/Puzzles/Hourglass_2D_array.py
1,387
4.21875
4
''' Given a 6X6 2D Array: 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 An hourglass is a subset of values with indices falling in this pattern as a graphical representation: a b c d e f g An hourglass sum is the sum of an hourglass' values. Calculate the hourglass sum for every hourglass ...
9c3bed72ed86e363afa8d0d6ccea429185d3dcf5
aryabartar/learning
/interview/stack-queue-deque/Deque.py
354
3.53125
4
class Deque(object): def __init__(self): self.array = [] def add_front(self, item): self.array = [item] + self.array def add_rear(self, item): self.array.append(item) def remove_front(self, item): return self.array.pop(0) def remove_rear(self, item): retur...
12e75ec45424ce34815ac5c59dca0ae72c59fdbf
alexthemonkey/interviewBit
/Math/Grid_Unique_Paths.py
1,006
4.125
4
""" Grid Unique Paths https://www.interviewbit.com/problems/grid-unique-paths/ A robot is located at the top-left corner of an A x B grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid. How many possible unique paths are there? N...
f70c3fae128b36b8149ef2639fb8916152bf7034
andprogrammer/crackingTheCodingInterview
/python/chapter3/5/solution.py
1,230
4.1875
4
class SortStack(object): def __init__(self): self.stack = [] def push(self, elem): if self.is_empty(): self.stack.append(elem) return temp_stack = [] while self.stack and self.top() < elem: temp_stack.append(self.top()) self.pop() ...
c9675b0eb8290b9646ee9102f8a31df77262c6cf
smallsharp/mPython
/advanced/tkinter使用/gui2.py
867
3.625
4
import tkinter as tk import os window = tk.Tk() window.title("my window") window.geometry("500x300") # 创建输入框entry,用户输入任何内容都显示为* # e = tk.Entry(window, show='*') # e.pack() # 创建一个文本框用于显示 t = tk.Text(window, width=15, height=2) t.pack() # 定义触发事件时的函数(注意:因为Python的执行顺序是从上往下,所以函数一定要放在按钮的上面) def insert_point(): t.inse...
10d594acd7154fc6b6c14afd8a5d4e43bed284d6
jgoldsher/Simulation
/ChallengeProjects/barracat.py
3,827
3.8125
4
import random from random import randint cards =[] started = 0 def populate_deck(): global cards global started if started == 0: started = 1 else: cards = [] #Populate values for non face cards and aces #4 of each value, suit is irrelevant for j in range (...
9ed1dec286873463df902de959e11ceeafdbb327
AliceZhang97/Self
/USF/CS110/slotmachine.py
1,042
3.96875
4
__author__ = 'alicezhang' import random import time def roll(): print('The slot machine is rolling!') time.sleep(1) def main(): startingBalance = 20 print('Your starting Balance is $20.') roll() playAgain = 'y' while startingBalance > 5 and (playAgain == 'y' or playAgain == 'Y'): ...
0bed4514d1c725bc5b4c3e55e8ef1f6414863e07
Tubbz-alt/target-finder
/target_finder/types.py
4,285
3.578125
4
"""Contains basic storage types passed around in the library.""" from enum import Enum, unique @unique class Color(Enum): """Contains colors for the AUVSI SUAS Interop Server. These colors can be used for both the background color and the alphanumeric color. Note that Color.NONE can be used if a co...
76fa1066028d3aa3a5a6c091816f69ef09ae621e
wilsonwong2014/MyDL
/Tensorflow/demo/python/demo_list.py
774
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ######################### # 向量表 list使用范例 # ######################### # # 使用范例: # python3 demo_list.py # ################################ #定义向量表并赋值 list1 = ['elm1','eml2','elm3']; #访问 print(list1); print(list1[0]); print(list1[-1]); #追加 list1.append('elm4'); print(l...
1d9d04e02f9d949d0db257b10dfbda410e42a6ff
divya-rajput/Codeforces-Solutions
/41A.py
88
3.59375
4
s = input() r = input() sr = s[::-1] if(r == sr): print("YES") else: print("NO")
3cf5ba2244a4846a9c44c9259ad614a365bedbe9
beigerice/LeetCode
/Contest/386.py
450
3.609375
4
class Solution(object): def lexicalOrder(self, n): res = [] def print_numbers(k, n): for i in range (0, 10): if (k+i)<= n: res.append(k+i) print_numbers((k+i)*10, n) for k in range (1, 10): if k <= n: ...
f70718b1b01b6e1024aeac199f22f50a2f0c74cd
sethArrow/autoTesst
/work__/forloop.py
288
3.953125
4
#lower = input("Enter the lower bound : ") #upper= input ("Enter the upper bound :") #sum=0 #for count in xrange (lower ,upper+1): # sum= sum + count for number in [1,4,6]: if(number==3): print "hello" else : print "Hey" break
8fbfbc2e38337c7829fb2a139c59e50c79eb60d0
BorthakurAyon/Algorithms
/leetcode/Cousins in Binary Tree.py
789
3.59375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isCousins(self, root: TreeNode, x: int, y: int) -> bool: self.dx, self.px = -1, None ...
e7ea00fbc09dc0c544449960d37cc44c43b1aea5
papasanimohansrinivas/c-language
/test3.py
76
3.65625
4
max=input('Enter a postive integer: ') i=0 while i<max: i=i + 1 print i
077f05e6cb673cfec97a94000a3e75899267212c
kchanhee/pythonpractice
/rotateRight.py
1,682
4.09375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param A : head node of linked list # @param B : integer # @return the head node in the linked list def rotateRight(self, A, B): nodes = [] whi...
e460be0c9f7df4d60566281f3b04837609d1d469
vijaymaddukuri/python_repo
/training/twoSum.py
376
3.84375
4
def two_sum(numbers, target): for i in range(len(numbers)): for j in range(1, len(numbers)): if numbers[i]+numbers[j]==target: return i,j return None def two_sum1(numbers, target): return [[i, numbers.index(target - numbers[i])] for i in range(len(numbers)) if target - n...
d88af5c47ae9efd62b8e6fdbe06467f0612e7430
w1476423/mind-game
/src/edugame/main.py
5,179
3.796875
4
""" This simple animation example shows how to move an item with the mouse, and handle mouse clicks. If Python and Arcade are installed, this example can be run from the command line with: python -m arcade.examples.move_mouse """ import arcade #equivalent of set PYTHONPATH=src import os, sys path=os.path.abspath(__fi...