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
ce1a87b1eecec2297d01e659db08ff7db34e6ae5
jubic/RP-Misc
/System Scripting/Problem13/creatingTablesInsertDataQuery.py
1,372
4.34375
4
import sqlite3 # conn = sqlite3.connect("albums.db") # conn.execute("PRAGMA foreign_keys = 1") conn.execute("CREATE TABLE albums (id INTEGER PRIMARY KEY, name TEXT NOT NULL, artist TEXT NOT NULL)") conn.execute("CREATE TABLE tracks (id INTEGER PRIMARY KEY, name TEXT NOT NULL, album_id INTEGER NOT NULL REFERENCES albums...
db724b5c3178e379cb951d95a16d9dda55d8bc77
ivo-bass/SoftUni-Solutions
/programming_basics/more_exercise/nested_loops/safe_passwords_generator.py
675
3.578125
4
x_end = int(input()) y_end = int(input()) max_passwords_count = int(input()) a = 35 b = 64 while max_passwords_count > 0: for x in range(1, x_end + 1): for y in range(1, y_end + 1): a_ascii = chr(a) a += 1 if a == 56: a = 35 b_ascii = chr(b) ...
3599714a3da382eda4b3dc48125948da21d428ba
pjhu/effective-script
/lintcode/lintcode/trailing_zeros.py
515
4.125
4
# -*- coding utf-8 -*- """ second http://www.lintcode.com/en/problem/trailing-zeros/ Write an algorithm which computes the number of trailing zeros in n factorial. """ class TrailingZero(object): """ :param n: a integer :return: ans a integer """ def trailing_zeros(self, n): counter = 0 ...
b0570dc1ce63929990a2a5899110d894f9ad338e
DaVinci42/LeetCode
/116.PopulatingNextRightPointersinEachNode.py
790
3.921875
4
# Definition for a Node. class Node: def __init__( self, val: int = 0, left: "Node" = None, right: "Node" = None, next: "Node" = None, ): self.val = val self.left = left self.right = right self.next = next class Solution: def connect(...
3d9588be5856aaecce597101fc10ea07a10dd5f3
niknameovich/Python_Geek
/Exercise2.py
214
3.6875
4
seconds = int(input('Введите количество секунд: ')) myformat = f'часы = {seconds // 3600};минуты = {(seconds % 3600)//60};секунды = {(seconds % 3600) % 60};' print(myformat)
5f8fa42898d7bea5aa1356f093c541324a7aebe8
denyadenya77/beetroot_units
/unit_2/lesson_13/presentation/11.py
246
4.125
4
# С помощью функции map преобразовать список строк в список чисел: [‘1’, ‘2’, ‘3’, ‘4’] => [1, 2, 3, 4] l = ['1', '2', '3', '4'] ll = list(map((lambda x: int(x)), l)) print(ll)
e8943ead541674b92ca5b619eac9105105f7614e
theavgroup/Pyhon_Basics
/04.py
627
4.03125
4
first_name = "arvind" last_name = "sharma" full_name = first_name + " " + last_name print(full_name) first_name = "arvind" last_name = "sharma" full_name = first_name + " " + last_name print(full_name.title()+"!") first_name = "Arvind" last_name = "Sharma" full_name = first_name + " " + last_name pri...
9a1e48f9f439ca7c542f14383082af31e0ced752
Megscammell/METOD-Algorithm
/src/metod_alg/objective_functions/shekel.py
1,481
3.921875
4
def shekel_function(point, p, matrix_test, C, b): """ Compute the Shekel function at a given point with given arguments. Parameters ---------- point : 1-D array with shape (d, ) A point used to evaluate the function. p : integer Number of local minima. matrix_test : 3-D ...
5cd02c1910f5cbc2b346cfe7a126ec024407efb5
MixedRealityLab/nottreal
/nottreal/controllers/c_abstract.py
2,337
3.8125
4
import abc class AbstractController: def __init__(self, nottreal, args): """ Abstract controller class. All controllers should inherit this class Arguments: nottreal {App} -- Application instance args {[str]} -- Application arguments """ se...
aaa1c8600f58fa1846e7b5c08dbf0cdb3935be2e
arifanf/Python-AllSubjects
/PDP 3/pdp3_72.py
218
4
4
from sys import argv def main(): n=int(input()) if((n>=5) and (n<=6) or (n>=10)): benar=True else: benar=False print("5<={}<6 atau {}>=10 {}\n".format(n,n,benar)) if __name__ == '__main__': main()
52db54372025d184abf1cd48eb33bb58cbb5482a
oscar503sv/basicos_python
/diccionarios/llaves.py
214
3.53125
4
diccionario = {'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8} resultado = diccionario.keys() print(resultado) resultado = diccionario.values() print(resultado) resultado = diccionario.items() print(resultado)
06add00394967fa3224b7a3c9cddad3ee832da5a
jgross21/Programming2Jonah
/Recursion/Recursion.py
2,738
4.125
4
# Functions can call functions def f(): print('f') g() def g(): print('g') f() # Function calling itself def f(): print('f') f() #f() # we can controll the recursion depth def controlled(level, end_level): print('Recursion level:', level) if level < end_level: controlled(level +...
3af7d3f4e1f42adb2a3a86002efc7a26e96ca732
RostSLO/ML
/Linear Regression/linearRegression.py
1,683
3.890625
4
''' Created on March 05, 2021 @author: rboruk ''' import pandas as pd import numpy as np import sklearn from sklearn import linear_model from sklearn.utils import shuffle import matplotlib.pyplot as plt import csv #preparing pandas dataframe data = pd.read_csv("student-mat.csv", sep=";") #shuffle data data = shuffle...
339d0517cc3a1eaf1d6a8d3894169e633b87938d
tahniyat-nisar/if_else
/arti gayatri.py
806
4.03125
4
arti=int(input('enter age of arti:')) gayatri=int(input("enter age of gayatri:")) vaishnavi=int(input("enter age of vaishnavi:")) if (arti>gayatri and vaishnavi): print("arti is elder") elif gayatri<vaishnavi: print('vaishnavi is second elder\ngayatri is younger') if vaishnavi>gayatri: print("ga...
d88927f3f1d94de5db21d4e6d457005435dd4cab
alexandrucatanescu/neural-program-comprehension
/stimuli/Python/one_file_per_item/jap/104_# str_if 14.py
159
3.78125
4
bunsyou = "I am a" gengo = "cat" if len(gengo) > 3: print(gengo) elif bunsyou[-1] == gengo[1]: print(bunsyou) else: print(bunsyou + " " + gengo)
2c3c54422345861dcdb5e1f2cea80cdaddbd2a64
tcloud1105/Apache-Spark-and-Python
/RB-Python/SparkMLUseCaseClustering.py
3,302
3.515625
4
# -*- coding: utf-8 -*- """ Spark with Python Copyright : V2 Maestros @2016 Code Samples : Spark Machine Learning - Clustering The input data contains samples of cars and technical / price information about them. The goal of this problem is to group these cars into 4 c...
c21e3de892f3b3de13635a7e60678a5d09d03c8e
lixiang2017/leetcode
/problems/0003.0_Longest_Substring_Without_Repeating_Characters.py
2,118
3.78125
4
''' two pointers / sliding window T: O(N) S: O(26 + 26 + 10 + 1) = O(1) Runtime: 112 ms, faster than 38.09% of Python3 online submissions for Longest Substring Without Repeating Characters. Memory Usage: 14 MB, less than 49.19% of Python3 online submissions for Longest Substring Without Repeating Characters. ''' clas...
92e38e84ce3eec08256ecaeb1db2d5cfedc3a6f9
rubyway/lintcode-python
/最大连续乘积子数组.py
716
3.703125
4
def maxlist(aList): maxMul = aList[0] for i in xrange(len(aList)): temp = 1 for j in xrange(i, len(aList)): temp *= aList[j] if temp > maxMul: maxMul = temp return maxMul a = [-2.5, 4, 0, 3, 0.5, 8, -1] print maxlist(a) def newMax...
b2b7153ac65ffea4d3dde5da19e45945a2048b3f
Electron847/MasterFile
/IntroToProgramming/seth_weber_hw3_extra_credit.py
603
3.953125
4
numbers = [76, 93, 3, 35, 30, 74, 8, 27, 19, 96, 33, 16, 16, 56, 98, 28, 19, 14, 63, 53, 2, 60, 4, 93, 61, 3, 56, 31, 25, 74] x=numbers y=[] a=[] print('Welcome') print('Would you like to count the odd numbers (type 1), or count the even numbers (type 2)?') x=eval(input('Enter 1 or 2 here: ')) if x==1: f...
2f1aeeeec6e89c21ab1f82d9fed1f72f8f772878
bholaa72429/01_Maths_HW_Assign
/00_MHC_base_v10.py
9,848
3.953125
4
# import statement import pandas import operator # ********** Function Area ********** # checks units, accepts cm, mm, m, question repeated if user response invalid def num_check(question,error,int_error,value,place): valid = False while not valid: try: if place == "integer" : ...
5f7959f188b48f058c1c065c646a5f73e31f4c60
graalumj/CS362_In-Class_Testing
/test_word_count.py
708
3.84375
4
# Word Count Unittest # By: Jason Graalum import unittest import word_count class test_wordcount(unittest.TestCase): def test_true1(self): self.assertEqual(word_count.count("To be or not to be"), 6) def test_true2(self): self.assertEqual(word_count.count(""), 0) def test_true3(self): ...
fd6b76ca1a79628904c19f0861aef01323601023
Daviswww/Toys
/Python Programming/EXC 031 - 7-1-0.py
881
4.1875
4
list2 = [5, 6, 7, 8] print('(1):') list1 = [1, 2, 3, 4] list1.append(list2) print("Append: ", list1) list1 = [1, 2, 3, 4] list1.extend(list2) print('Extend', list1) print('(2):') list2 = ['t', 'e', 's', 't'] list1 = [1, 2, 3, 4] list1.append(list2) print("Append: ", list1) list1 = [1, 2, 3, 4] list1...
0262a14f51d867207b6e8c0d458fd6a5b14cf5ae
hashrm/Learning-Python-3
/Python Is Easy Assignments - Hash/03 If Statement/main.py
1,333
4.46875
4
""" Create a function that accepts 3 parameters and checks for equality between any two of them. Your function should return True if 2 or more of the parameters are equal, and false is none of them are equal to any of the others. # Extra Credits: Modify your function so that strings can be compared to i...
41b7bba94dd017ce7a75f9cf07bd09a130e74ff1
bensonCode/tensonflowTest
/neuralNetwork/cnn.py
3,671
3.53125
4
# https://github.com/fchollet/keras/blob/master/examples/mnist_cnn.py from __future__ import print_function import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout, Flatten from keras.layers import Conv2D, MaxPooling2D from keras import backend as K # 定...
64bbea2e01fc88e8bc422fc6474f5afa9cc1f0a7
edu-athensoft/ceit4101python_student
/ceit_191116/py200111/output_1_format.py
894
3.875
4
""" output formatting string format() string template """ greeting = "Hello, Athens. How are you?" # print(greeting) greeting = "Hello, Helen. How are you?" # print(greeting) greeting = "Hello, Marie. How are you?" # print(greeting) greeting = "Hello, Cindy. How are you?" # print(greeting) # placeholder name1 = '...
31e98cdca36c16490b1bc25aaf0d7da9950a7c07
Northwestern-CS348/assignment-3-part-2-uninformed-solvers-drewmyles15
/student_code_game_masters.py
13,959
3.65625
4
from game_master import GameMaster from read import * from util import * class TowerOfHanoiGame(GameMaster): def __init__(self): super().__init__() def produceMovableQuery(self): """ See overridden parent class method for more information. Returns: A Fact object ...
93d8d5661e0064a14f6bc1a1d29949c7ab30991a
bingo957/MyStudyProject
/MyProjects/workspace/甲鱼Class/lect22/power.py
144
3.90625
4
""" 计算x的y次幂 """ def power(x, y): if y == 1: return x else: return power(x, y - 1) * x print(power(2, 10))
d503b867ca704df3ad0f37b50f097f781a115aec
lifez/bahttext
/test_bahttext.py
5,702
3.53125
4
# -*- coding: utf-8 -*- # Convert float decimal number to Thai text number # Copyright (C) 2014, Morange Solution Co.,LTD. # This file is distributed under the same license as the bahttext package. # All rights reserved. # Seksan Poltree <seksan@morange.co.th>, 2014. import unittest from bahttext import bahttext cla...
b33d74155fa553207d4b7bee21c1974a84ad90b0
cybelewang/leetcode-python
/code301RemoveInvalidParentheses.py
6,158
3.90625
4
""" 301 Remove Invalid Parentheses Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters other than the parentheses ( and ). Examples: "()())()" -> ["()()()", "(())()"] "(a)())()" -> ["(a)()()", "(a()...
1fa1f0f1addfc3dfca0f0a9c5d6417ef214026de
sava666/savyakPI3
/lab62.py
478
3.671875
4
#python3 # coding=utf-8 import sys import math import random year = int(input('Enter number of years you want to wait (years) ')) sumget = int(input('Enter sum what you have (UAH) ')) proc = float(input('Enter rate what you want (%) ')) proc = (proc/100) def banc(sumget, proc, year): count = 0 while year > count :...
50baac72d16f1c34dd8f303a2703a733a3338fe0
Mounika2010/20186099_CSPP-1
/cspp1-practice/sample-assignment/Practice_problems/Same first digit/Solution.py
355
3.734375
4
def same_first_digit(x, y): ''' return True, if first digit in both the numbers are equal otherwise return False ''' temp1 = str(abs(x)) temp2 = str(abs(y)) i=0 if temp1[i] == temp2[i]: return True return False def main(): x = int(input()) y = int(input()) p...
f58f0ddb5d03c5ddee50bb40f0fb3e384c585bac
GWSzeto/code_Qs
/WordPattern.py
726
3.859375
4
def wordPattern(pattern, str): pattern_map = {} word_map = {} words = str.split(" ") if not len(words) == len(pattern): return False for i in range(len(words)): if pattern[i] not in pattern_map: pattern_map[pattern[i]] = words[i] if not pattern_map[pattern[i]] =...
78c508c90b618449bdf697e924e04399fd046387
jcolaso/Python-For-Data-Science
/Codes and Data/Codes/Data Manipulation.py
5,286
3.59375
4
# -*- coding: utf-8 -*- """ Created on Wed May 04 12:45:21 2016 @author: Gunnvant """ import pandas as pd from pandas import DataFrame,Series import numpy as np import os os.chdir('\') data=pd.read_csv('oj.csv') print data.head() print data.shape print type(data['brand']) print type(data[['brand']]) print type(da...
17ec93843fe18dda15e740fab1895faad9810cfd
brianchiang-tw/leetcode
/No_0162_Find Peak Element/find_peak_element_by_binary_search.py
1,872
4.09375
4
''' A peak element is an element that is greater than its neighbors. Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fine. You may imagine that nums[-1] = nums[n] = -∞. Exa...
54f169342b7e01ef6a07ed88f35b62f301f048b6
janerleonardo/Python3CodigoFacilito
/funciones/asignarfuncion_variable.py
300
3.53125
4
""" Se puede asignar una funcion a variable de la siguiente manera se crea la variable y se igual a la funcion sin los paretesis """ def centigrados_farhenheit(grados): return grados * 1.8 +32 function_variable= centigrados_farhenheit resultado = function_variable(32) print(resultado)
1675e657bf9c7faa1f126c72ea07a05e1866a298
lqo202/assignment7
/lqo202/script_as7.py
1,478
3.59375
4
"""Program for question 1: Uses a Matrix class (which is a subclass or numpy) and calculates the arrays asked in Q1 The function used returns a list of arrays of the answers """ import numpy as np import functools __author__ = 'lqo202' class ExceptionMatrix: def __init__(self, msg): self.msg = msg c...
514d39889e67c505d3260adee40f1e4f38a4c85f
Introduction-to-Programming-OSOWSKI/3-10-reversal-KatyMartin23
/main.py
143
3.96875
4
def reversal(w): word = "" for i in range(len(w), 0, -1): word = word + w[i-1] return word print(reversal("potato"))
1ccc0da9cd5900f098153e5e3ccc663e1b92bacd
TheCrazyCoder28/HacktoberFest-Starter
/Python/TicTacToe.py
5,721
4.15625
4
# Write a python program to make a game called Tic Tac Toe. import random import time name = input("\nWhat is your name? : ") name = name.lower() board_positions = [' ' for position in range(10)] def InsertLetter(letter, position): board_positions[position] = letter def IsSpaceFree(position): return boar...
9f68e841d13da0f5b575e14dcea3821c6135a42b
Anish0494/BikeShare
/bikeshare_project_1.py
6,991
4.3125
4
import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day to analyze. Returns: (str) city - name o...
80f39b99794219e3e722fe58c5e91d1632afb219
MD-Levitan/cryptanalyst
/DiscreteLog/BSGS.py
1,100
3.5
4
# A baby-step giant-step import math def russian_peasant(x, y, z): s = 1 while x > 0: if x % 2 == 1: s = (s*y) % z x = x//2 y = (y*y) % z; return int(s) def egcd(a, b): if a == 0: return b, 0, 1 else: g, x, y = egcd(b % a, a) return g...
43a3efcf6e2b9b206cf6cfc917e0d467ed629626
jk990803/Python_Study_Plan
/Test100/Test17.py
462
4.125
4
# -*- coding:utf-8 -*- # 题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符 # 的个数。 s = raw_input('input a string:\n ') letters = 0 space =0 digit=0 others=0 for c in s: if c.isdigit(): digit+=1 elif c.isalpha(): letters+=1 elif c.isspace(): space+=1 else: others +=1 print 'char = %d,spa...
07ef259cda98d129c98ea23660267fda8efbc5df
xuelang201201/FluentPython
/08_对象引用、可变性和垃圾回收/fp_07_为一个包含另一个列表的列表做浅复制.py
789
3.84375
4
# http://www.pythontutor.com l1 = [3, [66, 55, 44], (7, 8, 9)] l2 = list(l1) # l2 是 l1 的浅复制副本。 l1.append(100) # 把 100 追加到 l1 中,对 l2 没有影响。 l1[1].remove(55) # 把内部列表 l1[1] 中的 55 删除。这对 l2 有影响,因为 l2[1] 绑定的列表与 l1[1] 是同一个。 print('l1:', l1) print('l2:', l2) # 对可变的对象来说,如 l2[1] 引用的列表,+= 运算符就地修改列表。这次修改在 l1[1] 中也有体现,因为它是 l2[1] ...
b4210ae728eea5e5a44e833f8eaa0762457cf9d5
marshalloffutt/files_and_exceptions
/common_words.py
726
4.15625
4
def common_words(filename, word): """Count the number of times a specific word appears""" try: with open(filename, encoding='utf-8') as file_object: contents = file_object.read() except FileNotFoundError: message = "Sorry, the file " + filename + " was not found." print(m...
af5a8c855b5e55415004540bdcccdc2bd1e5a890
iromeroh/c-tools
/dynamic_LCS/dynamic_lcs.py
1,717
3.53125
4
#!/usr/bin/env python def naive_LCS_len(str1,str2,m,n): #print "running "+str(m)+" | "+str(n) + "\n" if m==0 or n ==0: return 0 # if the last characters of str1 and str2 are the same, the LCS len has at least 1 plus the length of # LCS of str1[0..m-1],str2[0..n-1] if str1[m-1] == str2[n-1]:...
1356c78b68e2b7cbab1be221e84fd72a94d7ea77
Mar2ck/DotaPlayerPerformaceCalculator
/src/main.py
7,812
3.671875
4
#!/usr/bin/env python3 """ Program Frontend - CLI/GUI Interface """ # Built-in modules import argparse # Local modules import player_performance_score import data_scraper def DisplayMenuOptions(): options = ["Set up match", "List all players"] ##Always add new menu options here for i in range(len(options)): ...
70b37934368233bbf85c71890d59cd65f994ddda
plum-umd/tech-plus-research-PBT
/ex3.py
1,302
4.34375
4
''' Reverse a list. E.g. reverse([1,2,3]) = [3,2,1] Example property: - reverse(reverse(l)) is equal to l ''' def reverse(l): if len(l) > 0: return l[::-1] ''' Remove every occurrence of an element from a list. E.g. remove(2,[1,2,3]) = [1,3] Example property: - the result of remo...
945f91983196ffdd6d50b88bda15f00caf67c16a
YooGunWook/coding_test
/탐욕법/조이스틱.py
1,378
3.625
4
import string ''' 우선 위 아래는 간단하기 때문에 이 과정을 먼저 함수로 구현 그 다음 양옆으로 가는 것을 구현해야되는데, A의 여부에 따라 판단하면 좋을 듯 하다 ''' def count_alpha(alpha): up = 0 down = 0 alpha_list = list(string.ascii_uppercase)[1:] alpha_list_reverse = alpha_list[::-1] if alpha == 'A': return up for alpha_up in alpha_list:...
9f12682201ec27ebe49c335e6b5907b8cd0b720b
blakely4206/package_delivery_website
/graph.py
1,153
3.671875
4
class Vertex(object): def __init__(self, label): self.label = label def __str__(self): return self.label class Graph(object): def __init__(self): self.adj_list = {} self.distances = {} def load_graph(self, number_of_vertices): for i in range(number_of_vertices)...
87b92583b498e4001e067625305fb40bd6c79286
abhishek-jana/Leetcode-Solutions
/easy/268-Missing-Number.py
605
4.0625
4
''' Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Input: [3,0,1] Output: 2 Example 2: Input: [9,6,4,2,3,5,7,0,1] Output: 8 Note: Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra ...
1a35670807d8fa529ad24032c82bae164714f9a9
harishtm/learningpython
/coding_programs/ProblemSolving/subset_sum.py
661
3.953125
4
def subset_sum(numbers, target, partial=[]): """ # For product combination if len(partial) == 2: s = partial[0] * partial[1] else: s = 0 """ s = sum(partial) # check if the partial sum is equals to target if s == target: print("sum(%s)=%s" % (partial, target))...
9a7a68fbecc54af9e35d0ae07988a8315d2409e3
natp75/homework_5
/homework_7/homework_7_3.py
2,385
3.65625
4
#Реализовать программу работы с органическими клетками, состоящими из ячеек. #Необходимо создать класс Клетка. #В его конструкторе инициализировать параметр, соответствующий количеству ячеек клетки (целое число). #В классе должны быть реализованы методы перегрузки арифметических операторов: # - сложение (​__add__()...
e41314770c26fc8daa61d32e23e30776086abc90
will-hossack/Python
/examples/optics/lens/RayAberrations.py
592
3.96875
4
""" Example program to plot the Ray Aberrations for a lens Author: Will Hossack, The Unievsrity of Edinburgh """ import optics.lens as len import optics.wavelength as wl import matplotlib.pyplot as plt import optics.wavefront as a import math import tio def main(): # Get lens and other info lens = len.Da...
c93f756049b856974d76bbbd4de5b4130d138574
GhalyaJohar/edge-project-2021
/seats available.py
1,462
4.09375
4
# print("python project") # #Day 1 # s#Hello, Welcome to S&G's cenima! Type Hey to see the available services! # s# 1-List of movies + Age requirement # s# 2-Ehtraz if vaccinated y if not vaccinated print "sorry you cannot access the cenima" # s# 3-List of movie showtime (each movie printed with it's showtime) # g# 4-i...
cbe1269dfe396b590938bc62b5355e46a5f99804
steellsas/fundementals1
/100 chalenge of singnals/find_common__num_in2string/Itertools Kit/Rock Paper Scissors.py
785
3.84375
4
""" The greatest ever Rock-Paper-Scissors Championship will take place in your town! The best players will battle each other to see who's the best player in the world. Each player will compete against each other player twice, once home and once away. Given the list of the players, your task is to come up with the list...
95e9340b4ba1a86ead551aea75bf55c8005724f7
Shiesu/ProjectEuler
/ProjectEuler5.py
456
3.578125
4
# -*- coding: utf-8 -*- """ Created on Wed Sep 07 16:53:02 2016 Project Euler #5 Time Complexity: O(1) @author: Jan Henrik Wiik """ import time from math import * start_time = time.clock() #----------------------------------------------------------------------------- output = 16*9*5*7*11*13*17*19 #-----------------...
762f269c2fd917f734e55d2bb6c47d2237cd859f
nelsonhenrique/Nelson-Henrique-Duarte
/Estruturas de Repetição e Dados/Lista 1 - Animais Zoologico.py
549
3.53125
4
qtdC = 0 qtdM = 0 mediaT = 0 pesoT = 0 qtdT = 0 def add(): tipo = input("") peso = float(input("")) pais = input("") if tipo == 'macaco': global qtdM qtdM = qtdM + 1 elif tipo == 'cobra' and pais == 'Venezuela': global qtdC qtdC = qtdC + 1 elif tipo == 'tigre': global pesoT global ...
60bcfb78f0457e4d459c989051b85b554b1756a4
ShubhamKulkarni1495/List_python
/List/even_odd_avg.py
498
3.90625
4
elements = [23, 14, 56, 12, 19, 9, 15, 25, 31, 42, 43] i=0 sum=0 sum1=0 count=0 count1=0 while(i<len(elements)): if(elements[i]%2==0): sum=sum+elements[i] count+=1 else: sum1=sum1+elements[i] count1+=1 i+=1 print("the sum of Even numbers:",sum) print("count of odd numbers",c...
9fedbcda18aa5199fee768fc3ee0fa73c41f906e
ASairithwikmahateja/cspp-1-assignment
/Exam/p3/digit_product.py
695
4.1875
4
''' Given a number int_input, find the product of all the digits example: input: 123 output: 6 ''' def main(): ''' Read any number from the input, store it in variable int_input. ''' int_input = int(input()) prod = 1 prod1 = 1 if int_input > 0: while int_input > 0: tem...
f72890fb046a5bfb59ea74e58003677bf61ed9a5
xiaomuding/project
/1128/test.py
1,482
3.9375
4
import string #去除空格 a = " sdf dfg " print(a.strip()) print(a.rstrip()) print(a.lstrip()) print(a) #字符串链接 s1 = "sdf" s2 = "fghf" print(s1+s2) #大小写 s = "dgfdgfdg" print(s.upper()) print(s.upper().lower()) print(s.capitalize()) #位置比较 s1 = "sdfsdfdsg" s2 = "dfdgfsdsfsdf" print(s1.index("dsg")) try: print(s2.index(...
b17fff2eedf5e6c0c9bda2b8588e4f1c2b1e6ba8
suyashpujari/PythonTrial
/assignment_using_functions.py
1,801
4.3125
4
# 1) Reverse a String and print it on console "Python Skills" print("\n---Answer 1---") str="Python Skills" print("\nOriginal string: ",str) print("\nReversed string: ",str[::-1]) # 2) Assign String to x variable in DD-MM-YYYY format extract and print Year from String. print("\n---Answer 2---") import datetime date = ...
17d8ce9e037818cf3f7ab97be7e60a423e180a37
gijs/python-design-patterns
/adapter.py
875
3.953125
4
#!/usr/bin/env python """Example of the adapter pattern. The Adapter Pattern is useful to either either map two different interfaces or to just modify (wrap) an existing API. """ from datetime import datetime class AnnoyingAPI(object): def method_with_annoying_arguments(self, month, date, year, minute, second)...
cc49dd75ecc558189b66be7cb5742f134b77fd7f
oleksiiberezhnyi/BeetrootAcademy
/Graphs/dfs_task1.py
1,715
3.640625
4
from collections import defaultdict class Graph: def __init__(self, count_of_vertex): self.count = count_of_vertex self.graph = defaultdict(list) def add_edge(self, start, end): self.graph[start].append(end) def dfs(self, vertex, visited_vertex): visited_vertex[vertex] =...
107b23adc0bda9b34dd68247e31bddcf25e99982
msuriar/euler
/029/solution.py
270
3.5625
4
#!/usr/bin/env python def distinct_powers(a,al,b,bl): data = set() for base in xrange(a,al+1): for power in xrange(b,bl+1): data.add(base ** power) return data def main(): print len(distinct_powers(2,100,2,100)) if __name__ == "__main__": main()
2b8961c816f63170583433859108d5232645d4a1
rithotwheelz/perry2017
/Decoder.py
12,057
3.609375
4
""" Program is used to decode the data from CAN bus messages originating from the BMS. Program takes in a large string containing bytes in hex form. Multiple CAN bus messages are contained in this string. Each CAN bus message is 36 bytes long. Program updates paramter values for the BMS from these CAN bus messages a...
7223fca65f0ae3de6f02c8cbbdfb17827c4b8be6
Ruia-ruia/Small-Tools
/atoi.py
681
3.625
4
def integer(x): digits = list('0123456789') found = list() #correspond and preserve index of digit to string present in x string for j in x: i = 0 while i < len(digits): if digits[i] == j: found.append(i) i += 1 final = 0; ...
6563b2526edb897f9008acb74f3a77d338f45a03
RakaPKS/StructuresAlgorithmsAndConcepts
/exercises/Arrays and Strings/stringCompression.py
763
4.375
4
# implement a method to perform basic string compression using the # counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. # if the compressed string would not become smaller then return the original string # string only has upper and lower case characters def stringCompression(s): ...
3ba0362641fa997d9c9d07c925a869e1a4c84a22
silviafrigatto/python-exercicios
/e033_MaiorMenor.py
727
4.125
4
# Faça um programa que leia três números e mostre qual é o maior e qual # é o menor. n1 = int(input("Primeiro número: ")) n2 = int(input("Segundo número: ")) n3 = int(input("Terceiro número: ")) if n1 > n2 and n2 > n3: print(f"O maior número é {n1}.\nO menor número é {n3}.") elif n1 > n3 and n3 > n2: print(f"O...
c5f3da4fcbbee9a45bd181a63b9810ae925090b5
umanav/Lab206
/Python/Fundamentals/Stars.py
1,165
4.125
4
#Stars #Part I #Create a function called draw_stars() that takes a list of numbers and prints out *. # def draw_stars(arr): # for index in range(len(arr)): # counter = 0 # string = "" # while counter < arr[index]: # string += "*" # counter+=1 # print string ...
389c617c4dc3ac0ea5e32706b860890502a73efe
beb777/Python-3
/001.py
239
4.09375
4
grade = float(input('enter your result ')) if grade >= 90: print(f' congratulation !!!\n "A"') elif grade >= 80: print("B") elif grade >= 70: print("C") elif grade >= 65: print("D") else: print("Failing grade")
e92d2546f58e3b1c07ebe46e15f2d661b0f58647
Krystalllll/newtry
/hw1_answer.py
5,418
3.609375
4
# import cv2 import numpy as np def cross_correlation_2d(img, kernel): '''Given a kernel of arbitrary m x n dimensions, with both m and n being odd, compute the cross correlation of the given image with the given kernel, such that the output is of the same dimensions as the image and that you assume th...
3c45f0a6f3f432901fc9f612d51aacefbfc4cbac
Krzemyksc/python_bootcamp_2018
/zjazd_4/mathematica/algebra/matrices.py
1,030
3.609375
4
# def add_matrices(): # X = [[12, 7, 3], # [4, 5, 6], # [7, 8, 9]] # # Y = [[5, 8, 1], # [6, 7, 3], # [4, 5, 9]] # # result = [[0, 0, 0], # [0, 0, 0], # [0, 0, 0]] # # licznik_r = [] # # for i in range(len(X)): # for j in range(...
a99ace172c436e9ebf88490ae7952dbd20d745a5
emilwillems/adventofcode_2020
/day1/part2.py
546
3.671875
4
INPUTFILE = "day1/input" puzzle_input = set(int(l) for l in open(INPUTFILE, "r").readlines()) def find_solution(puzzle): for pi1 in puzzle: for pi2 in puzzle: if pi1 == pi2: continue for pi3 in puzzle: if pi1 == pi3 or pi2 == pi3: ...
9e71f039dd2f93ace59526c3ee0fd4e075590965
SurrealAI/torchx-public
/torchx/utils/tracker.py
5,591
3.625
4
import time from contextlib import contextmanager from threading import Thread, Lock class SimpleTimer(object): def __enter__(self): self.start = time.time() return self def __exit__(self, *args): self.end = time.time() self.interval = self.end - self.start print('elap...
a8a2321e0cf6cde920893cad152b825dcda76cfc
YasinRadi/DataStructures
/Tree/Red_Black_Tree/red_black_tree.py
8,055
4.03125
4
from collections import deque from enum import Enum # Possible colors of Red Black Tree nodes. COLOR = Enum('COLOR', 'RED BLACK') class Node: """ Tree Node implementation class. Attributes: ----------- data : int Data held by the node. color : COLOR Color of the node. ...
22792e4828fcb4a30cf4d1d18c68521c0e17caf7
Chainso/HLRL
/hlrl/core/algos/algo.py
4,210
3.859375
4
from abc import ABC, abstractmethod from typing import Any, Dict, Optional class RLAlgo(ABC): """ An abstract reinforcement learning algorithm. """ def __init__(self, logger=None): """ Creates the reinforcement learning algorithm. Args: logger (Logger, optional): Th...
d5dbadd2c097a39f94a1709f6acb98a8768a8eb0
kranz912/ProjectEuler
/Problem 1 Multiplesof3and5.py
84
3.84375
4
sum =0 for x in range(3,1000): if(x%3==0 or x%5 == 0): sum+=x print(sum)
968efae7fbdc9620baadbcb129b804feb8538e51
robin9804/RoadToDeepLearningKing
/Jinu/week3/example253.py
202
3.65625
4
def fun(n) : if n == 0: return 1 elif n % 2 == 1: return fun(n-1) * 2 - 1 else : return fun(n-2) +3 for i in range(10) : print(fun(i), end = ' ')
0a55adf0f018a8b317d711564cd5f46103c4b7c0
Xiaoyin96/Algorithms_Python
/interview_practice/66Questions/8. NextNode.py
1,287
3.734375
4
#!/usr/bin/env python # encoding: utf-8 ''' @author: Xiaoyin ''' ''' 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。 inorder traversal: pNode->left->right ''' class TreeLinkNode: def __init__(self, x): self.val = x self.left = None self.right = None self.next = N...
b57abc18767bdcfcd30a15d54ba776b74fea91d0
SOURADEEP-DONNY/WORKING-WITH-PYTHON
/souradeep codes/apparel.py
1,801
3.78125
4
class Apparel: def __init__(self,apparelBrand,Type,price,InStock): self.apparelBrand=apparelBrand self.Type=Type self.price=price self.InStock=InStock class Store: def __init__(self,apparelList): self.apparelList=apparelList def checkApparelAvailability(s...
10363f96b72bb070de8774dbb638447a420b26de
kuhlin/Python_MIT.6.00.1x
/BabySteps/W2 - 03 - Simple Algorithms/While Iteration 01.py
888
4.0625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 19 18:12:07 2019 @author: gdiaconu What is the value of the variable count that is printed out (at the print statement) on iteration 0? What is the value of the variable count that is printed out (at the print statement) on iteration 1? What is the value of the variable ...
cf990c9c278704dee7c3813e0a6d81ed5f7c0354
FelixTheC/python_morsels
/format_ranges.py
744
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @created: 16.10.19 @author: python morsels """ from collections import Counter def format_ranges(numbers): pairs = [] counts = Counter(sorted(numbers)) while counts: start = end = None for n in counts.keys(): counts[n] -= 1 ...
a9b945dec7d99694464ef803d56a24e4898279c3
MNikov/Python-Advanced-September-2020
/Tuples_and_Sets/05_softuni_party.py
416
3.578125
4
def collect_guests(n): all_guests = [input() for _ in range(n)] return all_guests def get_not_arrived_guests(guests: list): while True: guest = input() if guest == 'END': break guests.remove(guest) print(len(guests)) [print(g) for g in sorted(guests)] guests_c...
69f88947ed85c7e764dd8dfb19fd604e4afb4555
chandur626/ClassMateBot
/cogs/voting.py
6,678
3.6875
4
# Copyright (c) 2021 War-Keeper """ This File contains commands for voting on projects, displaying which groups have signed up for which project. """ import csv import discord from discord.ext import commands import os class Voting(commands.Cog): """ Class provides various methods to manage voting of mult...
629439aa3b5c17d997042a977ae009fa80b61404
gabriellaec/desoft-analise-exercicios
/backup/user_311/ch32_2019_04_04_16_35_39_112815.py
155
4.03125
4
x = input("dúvidas?") while x != "não": print ("pratique mais") x = input("dúvidas?") if x == "não": print("Até a próxima")
3c0628265dbcbecbfa37b94fa35cbf82a9c411dd
witameoliveira/lista_de_exercicios_pythonbrasil
/lista_de_exercicios_pythonbrasil/1_estrutura_sequencial/ex_004.py
527
3.828125
4
''' Faça um Programa que peça as 4 notas bimestrais e mostre a média. ''' bim_1 = float(input('Digite a primeira nota bimestral: ')) bim_2 = float(input('Digite a segunda nota bimestral: ')) bim_3 = float(input('Digite a terceira nota bimestral: ')) bim_4 = float(input('Digite a quarta nota bimestral: ')) media = (bi...
3b822118c8f52131f43714b345dc26486a5c7a75
conicRelief/Random-Things-from-my-Comp
/Miscellaneous Projects/Non Web/Miscellaneous Scripts/test_lists.py
196
3.609375
4
list_a = [10,11,13,14,15] list_b = map(lambda x: x+10, list_a) mergedlist = zip(list_a, list_b) print mergedlist a_dict = {'test': None, 'another_test': None} for x in a_dict: print "yo"
10b8ab2d74230e7e1f0e683733b7b1ac79164eae
yoh786/HFHSpy
/Playground.py
803
3.640625
4
sumlist = [] for x in range (10): sumlist.append(str(x)) print(str(sumlist)) def split_list(alist, size): list_of_lists = [] while len(alist) > size: abit = alist[:size] list_of_lists.append(abit) alist = alist[size:] list_of_lists.append(alist) return list_o...
9285f0e2adfe9f094693ba021b4efc24ebc37fb9
SebastianPEZROE/Reto-18
/main.py
770
3.5
4
class Gun: def __init__(self, gun_charger): self.bullet = 0 self.number_of_bullet = gun_charger self.seguro = 0 def charger(self, bulletscharged): if (bulletscharged + self.bullet) <= self.number_of_bullet: self.bullet += bulletscharged return 'cargada' ...
5232777768b4a9ece1f94ab3dce3c949c505a219
wajahata99/myrepo
/classes/helpers_2/cars_classes.py
320
3.578125
4
class car: def __init__(self,price,engine): self.price=price self.engine=engine def car_type(self): if self.price > 10000 and self.engine < 1500: str = "likely a sedan" else: str = "likely a cross over" return print(str)
ed43ddd385f027f91df9c45bb48b1b5d1ff6c2e1
KB-perByte/CodePedia
/Gen2_0_PP/Homeworks/leetcode_mostFrequentSubtreeSum.py
868
3.578125
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 findFrequentTreeSum(self, root: TreeNode) -> List[int]: if not root: return [] def help...
9bedc59e215e145afb0b0997fcccab6899262376
NerdJain/Python
/empty_list.py
756
3.859375
4
def main(): l = [] #1st List l1 = [1,2,'3',4.7,5] l.append(l1) #2nd list l2 = [] l.append(l2) #3rd list l3 = ['A','b','h','i','s','h','e','k'] l.append(l3) #4th list l4 = ["Python","Numpy","Pandas","Lambda"] l.append(l4) #5th list l5 = [] l.append(l5) for item in l: ...
a04cfae37b908795299f9a244de01f581724045e
robin9804/RoadToDeepLearningKing
/YR/week3/problem213.py
192
3.8125
4
# probelm 213 num = input('new number') while len(num) != 1: new_num = 0 for i in num: new_num += int(i) new_num = str(new_num) num = new_num print(num)
64a91f42fcbbc1195ba3a11221826556bf93d735
Mikcoolski/Python
/TaxCalculator.py
609
4.375
4
#This is a simple tax calculator and display prompt #Obtain the name of user name = input("What is your name?\n") #obtain the amount the user purchased the product for amount = float(input("How much did you spend on your product?\n")) #obtian the tax bracket the user was taxed at tax = float(input("What is the tax bra...
89ccec0a007e7922c9b6183afa6c8782986235e0
LuceRest/learn-numpy
/Lat 4 - Indexing, Slicing, dan Iterasi/Main.py
754
3.96875
4
import numpy as np a = np.arange(10) ** 2 print(a) print("---------------------------------\n") # -----------| Indexing (Mengambil Nilai) |----------- print('Element ke 1 dari a adalah', a[0]) print('Element ke 7 dari a adalah', a[6]) print('Element ke akhir dari a adalah', a[-1]) print("-------------------------...
6ba2c0ddbc152c62b6847e46c58338f955885972
KiranJoshi25/10_char_password_generator
/main.py
1,002
3.71875
4
import string import random def upper_char(): letters = "" for i in range(2): k = random.choice(string.ascii_uppercase) letters+=k return letters def lower_char(): letters = "" for i in range(4): k = random.choice(string.ascii_lowercase) letters += k ...
34aabdc7d221d4e046d4c6dbb4071029e6f7ce32
mr-rider/python_basic_07_09_20
/homeworks/les2/task1.py
624
3.90625
4
''' 1. Создать список и заполнить его элементами различных типов данных. Реализовать скрипт проверки типа данных каждого элемента. Использовать функцию type() для проверки типа. Элементы списка можно не запрашивать у пользователя, а указать явно, в программе. ''' list_data = [1, 1.2, True, False, 'Some string', [1, 2...
1e3093f172d1a85fe657dfd9032da8a0db022769
AvishDhirawat/Python_Practice
/even_odd_cla.py
257
3.734375
4
import sys print(sys.argv) for i in range(1,len(sys.argv)): sys.argv[i] = int(sys.argv[i]) if sys.argv[i]%2==0: print('This is {} even number'.format(sys.argv[i])) else: print('This is {} odd number'.format(sys.argv[i]))
35ef6eae3d736486bbdc3e0969d54fdacd640901
javedhassans/Headfirst_Python
/Harshad_number.py
1,737
4.40625
4
# write a function that determines if a number is a Harshad number # and then uses this function to write another function that determines the ith Harshad number. # # A Harshad number is an integer that is divisible by the sum of its digits. For example, 81 is a Harshad number, # because 8+1 = 9 and 81/9 = 9. The first...
4f95e116c01461d4b8c0c181dbd1269a8102e759
kevich/projecteuler
/Problem0006.py
769
3.84375
4
#! /usr/bin/env python # Sum square difference # Problem 6 # The sum of the squares of the first ten natural numbers is, # 12 + 22 + ... + 102 = 385 # The square of the sum of the first ten natural numbers is, # (1 + 2 + ... + 10)2 = 552 = 3025 # Hence the difference between the sum of the squares of the # first ten...
f1c0f14a15b3c8cc68b08ebf7106970ba757afff
AntoData/MarriageEqualityWorldwide
/Wrappers/MarriageEqualityChartGeneratorWrapper.py
5,839
3.9375
4
''' Created on 21 jul. 2019 @author: ingov ''' #We use pandas to create and manage dataframes and dataseries with our data import pandas as pd #We use matplotlib.pyplot to build and plot graphs import matplotlib.pyplot as plt #We use os to get our current folder so we can manage files import os #We use DonutChartGener...