blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0ad57069f4cc3bd67479d4dad5e1b2f6d31fd164
semi7semi/warsztat_python
/2001/2001.py
1,074
4.09375
4
import random def multi(score): """funkcja modyfikuje wynik przy rzucie 7 i 11""" roll = roll_dice() if roll == 7: return score // 7 elif roll == 11: return score * 11 else: return score + roll def roll_dice(): """symulacja rzutu koscmi oraz zsumowanie wyniku""" re...
6e16840778a0ad48d409081ce75aa9c9f05cedab
tahniyat-nisar/while_loop-imp
/series of 7.py
127
3.78125
4
n=int(input("enter any number to get series in 7:")) while n>=7: i=n%7 a=n-i if a%7==0: print(a) n=n-7
71b6d251a38727f78e1648966398fcb3ce264251
gurupsv/LearnPython
/HackerEarch/sum-of-primes-7.py
669
4
4
# URL :- https://www.hackerearth.com/practice/math/number-theory/basic-number-theory-2/practice-problems/algorithm/sum-of-primes-7/ import math def prime_or_not(num): pr=True if num == 1: return False if num == 2: return True if num % 2 == 0: pr = False else: for k ...
7ed89041c25acfc00fa04b0f965f96300f3d672f
belachkar/sgcodewars
/day42/day42.py
8,038
3.5625
4
import timeit abdiwoli_setup = ''' from __main__ import abdiwoli_day42 ''' def abdiwoli_day42(cost,box): box = box.split(' ') mn,me = box.count('mon'),box.count('monme') t,pme,= (mn*1) + (me*60),min(cost//60,me) pmn = min(cost-pme*60,mn) mon = [mn,me,t,pmn + pme] if pme *60 + pmn != cost: return 'leaving th...
84d49bafe662456d86b946aa6af48c4237ea754e
gsantovena/exercism
/python/largest-series-product/series.py
827
3.90625
4
def slices(string, n): if n > len(string) or n == 0: raise ValueError("Slice's size should be less than the string length.") slices_list = [] for i in range(0, len(string) - n + 1): one_slice = [] for j in range(i, i + n): one_slice.append(int(string[j:j+1])) sl...
5d156734b8917bac3a301e936c84c0a57c626049
Eshanafix/python-practice
/variable_scope.py
723
3.65625
4
#hello :) #LEGB = Local, Enclosing, Global, Built-in order of checking #local/global x = 'global x' z = 'global z' def test(): global z y = 'local y' x = 'local x' z = 'local z' global a a = 'global a' #print(y) print(x) # local test() #print(y) local so won't show print(x) #gl...
e746ac8273a09a75cbfa7fbccf410f8083d63c7f
TanmayNakhate/headFirstPython
/setVowel.py
339
4.15625
4
word = input("Type the word here : ") word = set(word) print(word) word2 = input("Type another word here : ") union = word.union(set(word2)) print(union) print("chars which are not in word2 are : ",union.difference(set(word2))) print("chars which are in word2 are : ",union.intersection(set(word2))) print("Sorting set :...
2395e7dd0379b681ec9892b7373cb9660aacfcd4
LuisTarma/random-python-scripts
/hola.py
291
4.03125
4
def operar(numero1, numero2): if(numero2 == 0): return numero1 elif(numero2 < 0): return operar(numero1-1, numero2+1) else: return operar(numero1+1, numero2-1) if __name__ == "__main__": print("Sumando 10 y 3:", operar(10, 3)) print("Sumando 5 y -2:", operar(5, -2))
ea3952c4325b5deadcf82f5e7a425aed7819d058
GaganDureja/Algorithm-practice
/sum10.py
365
3.90625
4
# This problem was asked by Microsoft. # A number is considered perfect if its digits sum up to exactly 10. # Given a positive integer n, return the n-th perfect number. # For example, given 1, you should return 19. Given 2, you should return 28. def sum10(n): return [str(n)+str(x) for x in range(1,10) if n+x==...
4455b78072fc5cbc4e1f334575071a6285f187e5
karuns/pylearn
/basic/Assertion.py
430
3.875
4
# Assertion check print ("assertion without comment") print(1) assert True print (2) assert 2+2 ==4 print (3) # assert 2+2==5 #Assert with comment ad inside try catch, finally block with raise try: print("Assert with comment") print(1) assert True, "this comment should not be printed" print(2) ass...
f0099d70d95918a2cfd8fd82958dd0a394821a78
Richard-D/python_excrise
/crawl/第一次.py
395
3.625
4
import urllib.request import urllib.error url = "http://example.webscraping.com" def download(url,num_retries = 2): try: html = urllib.request.urlopen(url).read().decode("utf-8") return html except: html = None if num_retries>2: return download(url,num_retries-1) ...
3dd3ca49b7c514c74655fc388480c73c7e8a56f8
Knln/online-coding-judge
/leetcode/14-longest-common-prefix.py
1,217
4.0625
4
""" Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among...
a95b23be953df25665690dd99b4a6cd6e2d734c9
Sahil4UI/PythonJuneRegular12
/STACK.py
856
4.15625
4
#->stack empty or not #->push (insert) #->pop (remove) def isEmpty(stack): if stack==[]: return True else: return False def push(stack,value): stack.append(value) top = len(stack)-1 def pop(stack): if (isEmpty(stack)==True): return "UnderFlow Error" else: value =...
73ebd9812d9838f39b83e5cbb0663f1f77ee9818
sriniketh28/Python-DSA
/Sorting-Algorithms/quick-sort.py
998
3.609375
4
def partition(arr, start, end): pivot = arr[start] count = 0 for i in range(start, end+1): if pivot > arr[i]: count += 1 pivotIndex = start + count arr[start], arr[pivotIndex] = arr[pivotIndex], arr[start] i, j = start, end while i<j: if arr[i] < pivot: ...
5a9af9c2fe25f8e0810e9f563937bd356a9f139f
whyadiwhy/Awesome_Python_Scripts
/GUIScripts/Pomodoro Timer/promodoro_timer.py
6,700
3.8125
4
# POMODORO TIMER # imported necessary library from tkinter import * import tkinter as tk import tkinter.messagebox as mbox from pil import ImageTk, Image import time # created main window window = Tk() window.geometry("1000x700") window.title("Pomodoro Timer") # image on the main window path = "Images/front.jpg" ...
da216c89461889fe88f8b87b7077c62d75f3e5e9
martakedzior/python-course
/00-intro/Praca_Domowa_1/zad3.py
518
3.546875
4
# Zadanie 3 print("------------------ Sumowanie liczb ------------------") print("Program pyta użytkownika o 4 dowolne liczby całkowite") print("a następnie zwraca ich sumę.") print() user_input1 = int(input("Pierwsza liczba: ")) user_input2 = int(input("Druga liczba: ")) user_input3 = int(input("Trzecia liczba: ")) ...
7dd0171d3310b21d055b2f9963cc6d8de7b1f5c9
vincentt117/coding_challenge
/lc_add_two_numbers.py
2,392
4.0625
4
# Add Two Numbers # https://leetcode.com/explore/interview/card/top-interview-questions-medium/107/linked-list/783/ # You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...
9d35787e98e79fd4670bd16b4bf64c26cb985a23
RubenvanHeusden/EmailClassificatieSoftware
/examples/bilstmclassifier_examples.py
1,049
3.75
4
from configurations import ROOT_DIR from models.bilstmclassifier import BiLSTMClassifier def main(): # first we will initialize the BilSTM classifier that we will used for classification. # In the case of this example we know that the amount of labels present in the dataset is 2 # so we can give that to t...
68b42acada711a89a64e09a5298152169168c199
lxgzhw520/ZhangBaofu
/day025/hw_003_单例对象初始化.py
704
3.546875
4
# _*_ coding:UTF-8 _*_ # 开发人员: 理想国真恵玩-张大鹏 # 开发团队: 理想国真恵玩 # 开发时间: 2019-04-15 21:28 # 文件名称: hw_003_单例对象初始化.py # 开发工具: PyCharm class Person: instance = None start = False def __new__(cls, *args, **kwargs): if cls.instance is None: cls.instance = super().__new__(cls) return cls.ins...
9539c945b6063ffdcd398710f03d371056ec52f7
IlyaTroshchynskyi/python_education_troshchynskyi
/algoritms/algoritms.py
2,512
4.125
4
# -*- coding: utf-8 -*- """calc Implements algorithms: - Binary search - Quick sort (iterative) - Recursive factorial """ def factorial(number): """ Define factorial certain number. """ if number <= 0: return 1 return number * factorial(number-1) print(factorial(50)) tes...
80f9a2e4fb958f3ad8af96ff8e73916da0f76201
LingHsiLiu/Algorithm0
/4. Linear Data Structure II/Optional/36. Reverse Linked List II.py
711
4.15625
4
# 36. Reverse Linked List II # Reverse a linked list from position m to n. # Example # Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. # Challenge # Reverse it in-place and in one-pass # Notice # Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. """ Definition of ListNo...
2d1ee97f6ab1fce4e01e32a4bae2cd1026e3d300
NickjClark1/PythonClass
/Chapter 5/ch5lab2Start.py
783
4.15625
4
def convertDecimalTo(number, base): result = "" while number > 0: remainder = number % base if remainder< 10: result = str(remainder) + result # ELSE IF remainder is equal to 10 THEN # LET result be the result with "A" at the beginning #...
97b882487f2f45c00c075f6285967734bcf642dd
github-mohsinalam/Python
/Map, Filter ,List Comprehension and Zip/passed.py
420
4.25
4
#Below, we have provided a list of tuples that contain students’ names and their final grades in PYTHON 101. #Using list comprehension, create a new list passed that contains the names of students who passed the class (had a final grade of 70 or greater). students = [('Tommy', 95), ('Linda', 63), ('Carl', 70), ('Bob...
3015c748a6ac50ab4febc9c6ed75d3f6630523d7
git-ysz/python
/day18-模块包/03-模块定位顺序.py
728
3.671875
4
""" 当导入一个模块,python解释器对模块位置的搜索顺序是: 1.当前目录 2.如果不在当前目录,python则搜索在shell变量PYTHONPATH下的每个目录 3.如果都找不到,python会查看默认路径。Unix下,默认路径为/usr/local/lib/python 模块搜索路径储存在system模块的sys.path变量中,变量里包含当前目录,PYTHONPATH和由安装过程决定的默认目录 注意: 1.自己的文件名不要和已有模块名重复,否则导致模块功能无法使用 2.使用 “ from 模块名 import 功能 ” 的时候,如果功能名字重复,调用到的是最后定义或导入的...
1c73751eb380da8f82e910e2b69ec5c63b6d3117
llduyll10/backup
/Backup/Algorithms/GreenReview/LS2/5.py
220
3.671875
4
u ,i = map(int, input().split()) x = int(input()) if x % u == 0 and x % i == 0: print('Both') elif x % u == 0 and x % i != 0: print('Upan') elif x % u != 0 and x % i == 0: print('Ipan') else: print('No')
84a1622b0d2917ce67ca93b9758c4ecabdb2590f
hungtienvu/fluent-python
/02-array-seq/test.py
203
3.6875
4
symbols = '!@#$%^' codes = [] for symbol in symbols: codes.append(ord(symbol)) print(codes) #List comprehension symbols2 = '@!#@#@(#*@)' codes2 = [ord(symbol) for symbol in symbols2] print(codes2)
e0dfb7c140a04e880a148b155040e0637f330191
weijiayi1/AID2008
/tcp_server_1.py
889
4.0625
4
""" tcp服务端循环流程1 特点:每次只处理一个客户端,一个完成后才能进行下一个 重点代码!!! """ from socket import* #创建tcp套接字 使用默认值就是tcp套接字 tcp_socket=socket(AF_INET,SOCK_STREAM) #绑定地址 tcp_socket.bind(('0.0.0.0',8888)) #设置监听 将tcp套接字可以被连接 tcp_socket.listen(5) #处理客户端连接 while True: print("等待连接..") connfd,addr =tcp_socket.accept() print("连接:",addr)#客户端地址...
6ad31eeea23666e0c827b702df5021674a3862dd
cagatayonder/Cs50x-2019
/pset6/caesar/caesar.py
648
3.75
4
from sys import argv from cs50 import get_string if len(argv) != 2: exit("Usage: python caesar.py n") if argv[1].isdigit() != True: exit("Usage: python caesar.py n") key = int(argv[1]) plaintext = get_string("plaintext: ") i = 0 print("ciphertext: ", end = "") while i < len(plaintext): ...
dccae8b375929d4195410d8a5122955b1f911400
Anastasiafrolova/Useful-Materials
/4_только квадраты (sqonly).py
290
3.796875
4
def sqonly(some_flag=False): x = int(input()) if x != 0: if sqonly(some_flag): some_flag = True if x ** 0.5 % 1 == 0: print(x, ' ', end='') some_flag = True return some_flag if sqonly() is False: print('0')
e4f0f158e0fc2f920eb371c8a959c3aa8a2de262
iamkoushal21/NLP-Hindi-English
/Tokenization/englishtokenizer.py
1,308
3.859375
4
from nltk.tokenize import sent_tokenize, word_tokenize # TOKENIZER FOR ENGLISH LANGUAGE def main(): example_text = "1066 In this year the monastery at Westminster was hallowed on Childermas day (28 December). And king Eadward died on Twelfth-mass eve (5 January) and he was buried on Twelfth-mass day, in the new...
3251486f3e0fd8b82accf854db9460cd820d0550
anik-ghosh-au7/attainu-course-repo
/assignments/week03/Day5/a1-w3d5.py
1,661
3.765625
4
# 1) Given a sorted array of integers A(0 based index) of size N, find the starting and ending position of a given # integer B in array A. Your algorithm runtime complexity must be in the order of O(log n). Return an array of size # 2, such that first element = starting position of B in A and second element = ending po...
a272c2aa5634ece174d164ab4d0744f0d35f8de9
accts4mjs/PythonFun
/HW20191017.py
4,428
3.546875
4
import sys def func_hw1(dna_seq): result = "" for index in range(0, len(dna_seq)): if dna_seq[index] == " ": continue if dna_seq[index] == "T" or dna_seq[index] == "t": result += "U" else: result += dna_seq[index] result = result.upper() retur...
2443b451b346e76b351d0b1918ba1efef1fb2e1f
ProTrickstar/Simple_Distribution-C-110
/temp.py
623
3.6875
4
from os import name import statistics import pandas as pd import plotly.figure_factory as ff import csv import random import plotly.graph_objects as go df = pd.read_csv("newdata.csv") data = df["temp"].tolist() population_mean = statistics.mean(data) std_deviation = statistics.stdev(data) print("Population...
8de5bbc46c5f7d34fcf37a66fc04e9d4d4e49bb3
JeffreyJewell/intropyclass
/src/jjewellContribution/passwordChecker.py
1,054
3.875
4
import re terminate = 0 while not terminate: try: print ("Syntax: Password must contain at least:") print (" 1 uppercase letter") print (" 1 lowercase letter") print (" 1 number, ") print (" 1 special character ($#!*&)") print (" Minimum length = 8") passWord = ...
5c22b65c2f2386d6100e72a4d4392e1828349c5a
Raviteja-Ainampudi/File-Management-System-Using-Python
/File Editing.py
4,589
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 25 12:48:12 2016 @author: RAVI TEJA """ from shutil import copyfile import sys import os.path print "Enter your choice. 1. Create a destination file. 2. Copy the whole file. 3. Copy Only Few Lines. 4. Whole file with few corrections. 5.Insert few additional dat...
0508f3c9c5eadbcbf2086e7ea150fac40c9d2e08
cerdwin/Combinatorial-Optimisation
/Ford_Fulkerson/main.py
7,425
3.515625
4
#!/usr/bin/env python3 import sys def build_graph(customers, demand, balances, first_run): # Graph: at key has coordinates (column, row), value is a dictionary of ((column, key) : [ lb, current, ub]} graph = {} ##### 1st column tmp = {} for i in range(len(customers)): if first_run: ...
bdb82362b8caf8c2ed12813a3a5cce7015800045
Natacha7/Python
/nivelacion_2_3/unidad_3/Validacion_correo.py
2,360
3.984375
4
''' #Requerimiento -> Determinar si un correo tiene le número de arrobas adecuado (1) correo = input('Ingresar correo: ') numArrobas = 0 for caracter in correo: if caracter == '@': numArrobas += 1 if numArrobas == 1: print('Correo válido') else: print('Correo inválido') correo = input('Ingresar co...
632b541273af656aee9cb90c10de4ea6327b7a03
time2do/python
/ch01/indent.py
408
3.8125
4
#indent(들여쓰기)-4칸:{ }을 대체 n=10 #자료형을 명시하지 않음, 세미콜론을 찍지 않음 if n%2 ==0: #명령문에서 콜론(:)을 사용 print("짝수입니다") print('even') else: print("홀수입니다") print('odd') """ #예시2 print('a') print('b') #앞에 공백이 있으면 에러 뜸. print('c') """ msg = ''' 사과, 배,귤 ''' print(msg)
3b32f638ac4456f461c14513700b5a9158cedb7f
intialD/pythonRep
/python-learn/data_type.py
784
3.546875
4
a,b,c,d = 1, 5.5, True, 4+3j; print(type(a), type(b), type(c), type(d)); print(isinstance(a, int)); ## isinstance 和type的区别 class A: pass class B(A): pass print(isinstance(A(), A)); print(type(A()) == A); # isinstance 会认为子类是一种父类类型 print(isinstance(B(), A)); # type不会认为子类是一种父类类型 print(type(B()) == A); print(ty...
c027385894f2299351dd585df0b00f058a25b6b1
codacy-badger/pythonApps
/printListEvenNumber.py
586
3.796875
4
listNumber = list(map(int, input().split())) evenList = [i for i in listNumber if i%2 == 0] print(evenList) #exit() number = int(input("enter the require range :")) list = [] if number < 0: print("not valid number, enter the positive number ") else: for i in range(0, number + 1): if i % 2 == 0: ...
0939ab6278bb0a03b0cb3029bec0400baee4e70a
yingliufengpeng/algorithm
/数据结构与算法365天刷题特训营/17 树形排序/select_demo.py
621
3.84375
4
# -*- coding: utf-8 -*- import random # 选择排序算法 N = 1000 nums = [random.randint(1, 99) for _ in range(N)] nums2 = nums[:] def select_sort(nums, index): if index == len(nums): return tail = nums[index + 1:] if not tail: return r = min(tail) j = nums.i...
4ef8c9355804c04dbbb04d159062b543f83e0367
xiaojiangzhang/leetcode_Record
/力扣_牛客刷题/model-动态规划/leetcode416分割等和子集.py
2,582
3.71875
4
""" 给定一个只包含正整数的非空数组。是否可以将这个数组分割成两个子集,使得两个子集的元素和相等。 注意: 每个数组中的元素不会超过 100 数组的大小不会超过 200 示例 1: 输入: [1, 5, 11, 5] 输出: true 解释: 数组可以分割成 [1, 5, 5] 和 [11].   示例 2: 输入: [1, 2, 3, 5] 输出: false 解释: 数组不能分割成两个元素和相等的子集. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/partition-equal-subset-sum 著作权归领扣网络所有。商业转载请联系官方授权,非...
f6af02a41cf641c71af5f0eb01f389ab0b46c3bc
raghavpatpatia/Floxus-Education-Python-Bootcamp-101
/Assignment 1/Power.py
80
3.765625
4
n = int(input("Enter power of two: ")) powerOfTwo = 2 << (n-1) print(powerOfTwo)
c73a42ecb84a0430e59646109c0f46cdf130c465
Jyun-Neng/LeetCode_Python
/969-pancake-sorting.py
1,517
4.03125
4
""" Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, then reverse the order of the first k elements of A. We want to perform zero or more pancake flips (doing them one after another in succession) to sort the array A. Return the k-values corresponding to a sequence of pan...
e39524ffe879c5df1527d297a0d1a8f8e1e4b286
gsudarshan1990/Training_Projects
/Unittest_Example/unittest_example5.py
367
3.703125
4
""" This is used to test the functions on area in another method """ import unittest from Unittest_Example import areas class Testing(unittest.TestCase): """ This is used to test area of the triangle """ def runTest(self): result = areas.triangle_area(10,5) self.assertEqual(25,result) ...
61023ab3ea0f2d147fcbb0fe86ca0fb0c6455b69
harshp8l/deep-learning-lang-detection
/data/train/python/0ab18736efba24a3e333a9ad5a84bcc34c456940save_point.py
542
3.546875
4
from pygame import * def addSavePoint(entity): """Turns the given entity into a save point.""" @background def saveDialog(unused_entity, unused_accessor): choice = choiceBox("Do you want to save?", ['Yes', 'No']) if choice == 0: messageBox("Saving...") SaveData....
c2151c14251ab73c8a6c961391b692a1f31bee09
WilmerLab/htsohm
/htsohm/bins.py
830
3.609375
4
def calc_bin(value, bound_min, bound_max, bins): """Find bin in parameter range. Args: value (float): some value, the result of a simulation. bound_min (float): lower limit, defining the parameter-space. bound_max (float): upper limit, defining the parameter-space. bins (int): n...
de68ef995a552ab224692a172a70828aed5e8c63
sanjaydangwal/Python
/sirdhara.py
283
3.5625
4
import math def solve(a, b, c): d = math.sqrt(b**2 - 4*a*c) x1 = (-b+d)/(2*a) x2 = (-b-d)/(2*a) return x1, x2 a,b,c = input("ENTER THE VALUE OF A, B AND C SEPRATE BY ',' ").split(",") x1,x2 = solve(int(a),int(b),int(c)) print(f"value of x1 is {x1} and x2 is {x2} ")
8b6a2de9111e9cd19c8b6c2f483c4f412b1e2826
Aasthaengg/IBMdataset
/Python_codes/p03261/s846445961.py
177
3.703125
4
N = int(input()) history = [input()] for i in range(N-1): w = input() if w in history or history[-1][-1] != w[0]: print('No') exit() history.append(w) print('Yes')
65e1ca8ccfc761269657b3a23761ce68d15caeb9
schenoweth/SampleGitRepository
/hello.py
166
4.25
4
msg = "Hello World, this is Steve" # show what a for loop does print (msg) for x in range(0,10): print ("x =", x) if (x < 5): print("and x is < 5")
8c7292b52f36101ed4de6520b3679e278cf7f94a
GaneshMunna4566/Python_Program
/for loop/23.py
310
4.03125
4
count=0 while count<3: username=input('Enter username :') password=input('Enter password :') if username=='ganesh' and password=='munna4566': print('Success full login') break else: print('Username or password is wrong') count+=1 print("Attempts are completed")
771eec81c266b5c44ce361716e079d9e52d38403
blegloannec/CodeProblems
/Others/ProjectLovelace/17_caesar-cipher.py
391
3.890625
4
def break_caesar_cipher(ciphertext, known_word): known_word = known_word.lower() ciphertext = ciphertext.lower().split(' ') for k in range(26): plaintext = [] for w in ciphertext: plaintext.append(''.join(chr((ord(c)-ord('a')+k)%26+ord('a')) if 'a'<=c<='z' else c for c in w)) ...
8c44fdf7bda91a68fd44c9407f7837ff260fe15d
tielushko/The-Modern-Python-3-Bootcamp
/Section 26 - OOP Part 2/polymorphism.py
566
4.09375
4
#1. Polymorphism and Inheritance - same method name is used different classes class Animal: def speak(): raise NotImplementedError("Subclass needs to implement this method") class Dog(Animal): def speak(self): return "woof" class Cat(Animal): def speak(self): return "meow" class Fis...
9ba30ad98cc894719e7bdaee7b65c5a7b22aaee9
mirmozavr/EPAMHW
/hw3/hw3_t02.py
773
3.578125
4
""" Here's a not very efficient calculation function that calculates something important. Calculate total sum of slow_calculate() of all numbers starting from 0 to 500. Calculation time should not take more than a minute. Use functional capabilities of multiprocessing module. You are not allowed to modify slow_calcul...
59fcbaf9b0edc494d18eb75c73433e25365fb104
wrf/misc-analyses
/random_dna/randomdna.py
1,532
3.546875
4
#!/usr/bin/env python # # v1 basic random dna functions ''' generates random DNA sequences in fasta format randomdna.py -l 1000 -n 100 > random_seqs.fasta selection is unweighted, to make appx 40 percent GC randomdna.py -l 1000 -a AAATTTGGCC -n 100 > random_seq.fasta ''' import sys import argparse import tim...
6a8b57fdf4728c5d83e02851d2338607699e80d7
michaelgy/PROBLEMS_PROGRAMMING
/UVA/100p/gmatrix.py
1,256
3.640625
4
#This code was used for debug the 556 uva problem (my 100th problem) #The mayor part of this code was taken from: #https://stackoverflow.com/questions/7591294/how-to-create-a-self-resizing-grid-of-buttons-in-tkinter from tkinter import * root = Tk() frame=Frame(root) Grid.rowconfigure(root, 0, weight=1) Grid.columncon...
82f13f1a243decfe171ff1de1864fce1c84a83e8
lalitha1201/Leetcode
/May_LeetCode_ challenge/Solutions/Number_Complement.py
329
3.515625
4
class Solution: def findComplement(self, num: int) -> int: # convert decimal to binary using bin function and consider numbers from second index # In the final step complement it and change it to decimal return int(''.join('1' if x == '0' else '0' for x in bin(num)...
402feee890341d32f69e7bbfccc822e6aa61885a
nshin130/python3
/01basic.py
1,498
3.515625
4
import keyword myName = 'Nara Shin' myMajor = 'Information System' print(myName) print(myMajor) myName = 100 myName = True myName = False myName = 3.141519 intro = 'Hello' print(intro) intro = '안녕하세요.' print(intro) nickname = 'Mr. Song' print(nickname) print(keyword.kwlist) #print(keyword.softkwlist) # v3.9에서 추가됨...
6af87c4a0547b630eb2f4cc3fa6f713db85f36af
Gary2018X/data_processing_primer
/E5-18.py
440
3.53125
4
# -*- coding: utf-8 -*- # author:Gary import pandas as pd import numpy as np # ********pandas DataFrame对数据进行摘要统计********# np.random.seed(0) columns = ["apple", "orange", "banana", "strawberry", "kiwifruit"] df = pd.DataFrame() for column in columns: df[column] = np.random.choice(range(1, 11), 10) # 查看所有的摘要统计量 prin...
f05b26d6050d6363bdf2a893fd247f248b47c2e9
patricksile/code_folder
/code_wars/8kyu_unicode_total.py
466
3.96875
4
# Problem: Unicode Total (8kyu) """ You'll be given a string, and have to return the total of all the unicode characters as an int. Should be able to handle any characters sent at it. examples: uniTotal("a") == 97 uniTotal("aaa") == 291 """ # My Solution: def uni_total(string): return sum(ord(i) for i in string)...
76af8e27cae7434dd8b44078392de44ce5a461d7
floydchenchen/leetcode
/060-permutation-sequence.py
1,101
4.21875
4
# 60. Permutation Sequence # The set [1,2,3,...,n] contains a total of n! unique permutations. # # By listing and labeling all of the permutations in order, we get the following sequence for n = 3: # # "123" # "132" # "213" # "231" # "312" # "321" # Given n and k, return the kth permutation sequence. # # Note: # # Giv...
c4a94abe15098e0279be4449f87a82b8c25d2254
danong/ctci-6th-solutions
/pythonsolutions/stacks_and_queues/three_in_one.py
2,751
4.21875
4
class MultiStack: """An implementation of n stacks using a single array Elements are interleaved in a single array. For example, if there are 3 stacks, index 0 belongs to stack 0, index 1 belongs to stack 1, index 2 belongs to stack 2, index 3 belongs to stack 0, etc. This means that shifting elem...
355c0dc2dca5e79c4e326deb1e479e1099f89025
MaryAyla/training-101
/typecasting.py
291
4.09375
4
details="mwende"+str(345) marks=345 #changing an integer to be a string marks=str(marks) print(type(marks)) marks=int(marks) print(bool(marks)) print(bool(0)) #boolean is mostly used in conditional statements if True: print("executes when true") else: print("executes when false")
d236b5a1411948abe27568433c08d32f0d85fbf4
G00387847/Bonny2020
/python weekday.py
319
4.34375
4
# Bonny Chimezie Nwosu # Writing a program that output # Whether or not today is a weekday import datetime now = datetime.datetime.now() day = now.weekday weekend = 7 #assigning to detect the weekday attribute if day == weekend: print (" It is the weekend, yay!") else: print("Yes, unfortunately today is ...
13c23a7b86b279aa3e292eaab3bb1bbabae06e32
ArunPrasad017/python-play
/coding-exercise/algorithm-base/Day2-SortingAlgoRefresher.py
717
3.796875
4
""" quicksort """ def partition(arr, left, right): pivot = arr[left] low = left + 1 high = right while True: while low <= high and arr[high] >= pivot: high -= 1 while low <= high and arr[low] <= pivot: low += 1 if low <= high: arr[low], arr[h...
adefb513320b6ee9a560b696a58da5b61604b232
Travis-Owens/python-examples
/String Formating/datetime_formatting.py
1,617
4.78125
5
# Author: @Travis-Owens # Date: 2019-2-1 # Purpose: Demonstrate how to format datetime.now() using strftime() from datetime import datetime #import the datetime class from the datetime library # Retrieve the current time from the datetime.now() function now = datetime.now() #Example output: 2019-02-01 09:50:4...
0b572774c376a7c215b7024501110c45747c3589
Anton-Naumov/Programming-101-with-Python
/week10/Money_In_The_Bank/client_test.py
2,358
3.671875
4
import unittest from client import Client from exceptions import InvalidPassword class ClientTests(unittest.TestCase): def setUp(self): self.test_client = Client(1, "Ivo", 200000.00, 'Bitcoin mining makes me rich', "ivo@abv.bg") def test_client_id(self): se...
0e307d0cd1ad5715158058dfbe969874b1310916
watersmark/InterestingAlgorithm
/PullDigit/PullDigitAlg.py
285
3.5
4
def removeTarget(nums, val): start = 0 end = len(nums) - 1 mid = 0 while mid <= end: if nums[mid] != val: nums[start], nums[mid] = nums[mid], nums[start] start += 1 mid += 1 else: mid += 1 return start
a6b7ba2edfb7266d726ce8d7301b20e6d870c1d8
cguertin14/PythonRefresher
/args_kwargs.py
310
3.671875
4
def my_method(arg1, arg2): return arg1 + arg2 my_method(5,6) def my_list_addition(list_args): return sum(list_args) def addition_simplified(*args): return sum(args) ## def what_are_kwargs(*args, **kwargs): print(args) print(kwargs) what_are_kwargs(12, 34, 67, name='marty', letsgo=3)
5d287c71ebd70bf907f6d7860eb293716f2a6485
massimo-nocentini/on-python
/UniFiCourseSpring2020/my-script.py
121
3.734375
4
def square(x): """square a number""" return x ** 2 for N in range(1, 4): print(N, "squared is", square(N))
7fa5796d0a3c5ace8a3b08d06f0eab28b6e8645a
uusseerrnnaammeee/py-1902
/29-09/name.py
59
3.71875
4
name1 = input(Please, enter your name: '') print("Hello!")
ab4cb9a10bf5b81bcd3de3b8299e39cb7a9a6a17
l33tdaima/l33tdaima
/pr1706m/find_ball.py
1,428
3.734375
4
from cmath import exp class Solution: def findBall(self, grid: list[list[int]]) -> list[int]: m, n = len(grid), len(grid[0]) # When getting to row_i of grid, the source index of the ball source = list(range(n)) for i in range(m): nxt = [-1] * n for j, pos in...
f69a12121ec708cdc196fa1686b2527e7acc219d
goswami-rahul/aoc
/2020/06_custom_customs/sol.py
536
3.5
4
#!/usr/bin/env python from functools import reduce def Read(): groups = [] with open('in') as f: now = [] for line in f: line = line.strip() if line: now.append(line) else: groups.append(now) now = [] groups.append(now) return groups def Easy(groups): retu...
d980f3feb2f578fa7abf69cd9f457397a19c0a88
Avraj19/assignment-2
/assignment_2.py
854
4.1875
4
# section 1 hero_name = input('Enter hero name: ').capitalize().strip() villain_name = input('Enter villain name: ').capitalize().strip() name_dict = { 'Hero': hero_name, 'villain': villain_name, 'Beginning': 'In the beginning there was a hero but ' 'he called himself '+ hero_name, 'Mi...
65b5fe6a316ee4b9c148bd669cbe58c47e97aec7
pengyuhou/git_test1
/leetcode/429. N叉树的层序遍历.py
728
3.609375
4
# Definition for a Node. class Node(object): def __init__(self, val=None, children=None): self.val = val self.children = children class Solution(object): def levelOrder(self, root): """ :type root: Node :rtype: List[List[int]] """ if not root: ...
8554cc0e9e0fcf569953a9361608c91ba4e22a7f
Lindokuhle1/extracting-text-from-pdf
/extract.py
1,031
3.515625
4
from tkinter import * import PyPDF2 from tkinter import filedialog #clear textbox def clear_text_box(): my_text.delete(1.0, END) #Open pdf def open_pdf(): #grab the filename of pdf open_file = filedialog.askopenfilename( initialdir="file:///home/lindokuhle/pdf_app/", title="open PDF", ...
5470766e4d96269f6d343d0aad408494e13a11f6
MinhVu88/PythonCC_2ndEd_Matthes
/try_it_yourself/ch4/411pg69.py
338
3.875
4
my_pizzas = ['pepperoni', 'mushroom', 'cheese', 'bacon', 'sausage'] friend_pizzas = my_pizzas[:] my_pizzas.append('onion') friend_pizzas.insert(1, 'black olives') print('My fav pizzas:') for pizza in my_pizzas: print('\n\t' + str(pizza)) print("\nMy friend's fav pizzas:") for pizza in friend_pizzas: print('\...
579ec840fa59ee90da829ece9b5d06b324373e93
JohannesBuchner/pystrict3
/tests/data23/recipe-52664.py
1,224
3.65625
4
def Walk( root, recurse=0, pattern='*', return_folders=0 ): import fnmatch, os, string # initialize result = [] # must have at least root folder try: names = os.listdir(root) except os.error: return result # expand pattern pattern = pattern or '*' pat_list = string.splitfields( pattern , ';' ) # che...
41ad5e7691ffce47d569679ea6f73b67d317c30a
EPanukova/14.09.20
/project_2.py
1,175
3.5625
4
import tempfile import os import argparse import json def function(): """Working with Python Console.""" objects_all = argparse.ArgumentParser() # создан объект; objects_all.add_argument('--key', type=str, help = 'Return key\'s dictionary') # описание переменной, которую планируется запсиат...
a8fa1bfb3521fc452277758b9bc97d7a4d46ed29
JohannesKepler/ZorkSaga
/ZorkSaga.py
24,899
3.640625
4
from Tkinter import * #import ZorkLore from os.path import exists def create_vars(): pass print "You've awoken in a dark and scary cave.\nYou can't quite remember how you got here, but you know that you were living in a small village on the edge of a forest.\nYou appear unharmed, and you cannot hear any immediate ...
e8ba6817e267b40601b938ecbcbbcb195469f920
sagostin/NTEN-112
/IP Addressing Lab.py
1,940
3.671875
4
ip_address = input("Input your IP address (CIDR Notation): ") subnet_mask = input("Input your subnet mask (CIDR Notation): ") default_gateway = input("Please input your default gateway (CIDR Notation): ") def validate_ip(s): a = s.split('.') if len(a) != 4: return False for x in a: if not ...
a9c93114e163c8b5f0fc3c0a6dbf5b7359345d05
iwtbam/leetcode
/code/lt1507.py
506
3.859375
4
# https://leetcode-cn.com/problems/reformat-date/ # reformat date class Solution: def reformatDate(self, date: str) -> str: months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] indexs = list(range(1, 13, 1)) months = dict(zip(months, indexs)) ...
871bc176a887fb17863dd3b5a524a96cc8491c1b
hariswb/learningpython
/binarytodecimal.py
346
4
4
##Given an array of ones and zeroes, convert the equivalent binary value to an integer. #Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representation of 1. def binToDec(bin): bit = 0 int = 0 for i in range(4): bit=bin[len(bin)-1-i] if bit == 1: int+=2**i return in...
a12cf6f38da4cf771bab6cfb69f5fc3f12047f79
Robstepa/AARogue
/hotwarmcold.py
1,510
3.765625
4
import random import os def choose_number(): count = 0 digit_list = [] while count < 2: digit = random.randint(0, 9) if digit in digit_list: continue else: digit_list.append(str(digit)) count += 1 return digit_list def input_user(): w...
01565ed82699de9d86cab1c8daf53212eb181ab2
echocho/Leetcode
/Leetcode204_CountPrimes.py
1,136
3.875
4
import math import timeit class Solution1: # Time complexity too high # def isPrime(self, num): if num < 2: return False for i in range(2, int(math.sqrt(num))+1): if num % i == 0: return False return True def countPrimes(self, n): ...
05496daca0f686fdeb43b891be035b3e0d3aaa2c
EarthGhost/42-Summer-Camp
/Intro_to_Python/d04/02_allyourbase.py
273
3.734375
4
import sys n= int(sys.argv[1]) base = int(sys.argv[2]) convertString = "0123456789ABCDEFJHIJKLMNOPQRSTUVWXYZ" def toStr(n,base): if n < base: return convertString[n] else: return toStr(n//base,base) + convertString[n%base] print(toStr(n, base))
b283a19975077b841c9e8f76c3cf3bf216afedc8
Houchaoqun/Daily-Coding
/python-lxf/index2.py
1,268
3.609375
4
# coding=utf8 class Student(object): def get_score(self): return self._score def set_score(self, value): if not isinstance(value, int): raise ValueError('score must be an integer!') if value < 0 or value > 100: raise ValueError('score must between 0 ~ 100!') ...
825c29c0cccfafb2304a824657104e51ae88adfe
LuanChenWei/ngoinhamouoc
/tenary_operator.py
204
3.765625
4
import random num = random.uniform(0,100) intnum = int(num) num_check = intnum % 2 == 0 if num_check : print('{} is even number'.format(intnum)) else: print('{} is odd number'.format(intnum))
2dd71517b0921449f8a14422ea5e596487219df5
pite2019/pite2019s-t2-g2-Nabiz
/task.py
1,018
3.921875
4
#!/usr/bin/python3 class Bank(): def __init__(self,name): self.name = name self.accounts = {} def addAccount(self,client): acc = Account(client) self.accounts[acc.number] = acc def event(self,accNum, evName, money=0): if evName == "deposit": self.accounts[accNum].deposit(money) elif evName == "withdr...
bddc53cc56b7c8598d61e62fb54d55b506f613f9
jfch/Fraud-Detection-Housing-Search-Web-Application
/rental_info/utilities/passive_detector.py
2,159
3.53125
4
from nltk import word_tokenize, tokenize from itertools import dropwhile from tagging import pos_tagger # reference: https://github.com/j-c-h-e-n-g/nltk-passive-voice TAGGER = pos_tagger.get_tagger() def tag_sentence(sent, tagger): """Take a sentence as a string and return a list of (word, tag) tuples.""" as...
42c489b83d1a9bd31854a6bed4fc5549d991622b
dgallab/exercises_in_python
/python_f/basic sorting/SortingStuff.py
1,808
3.703125
4
import random import math class SuperSorter: def __init__(self,lst1,lst2): self.lst1 = lst1 self.lst2 = lst2 def min_diff(self): lst=self.quick_sort(self.lst1) print(lst) min_dif = math.inf for i in range(0,len(lst)-1): if lst[i+1]-lst[i] < min_d...
342839d82b165c447f393496abd367689d9ed567
terrenceliu01/python1
/src/languageBasics/datatype/datatypeHW37.py
343
3.96875
4
sn1 = {1,2,3,4,5} sn2 = {4,5,6,7,8} print("Original sets:") print(sn1) print(sn2) print("Remove the intersection of a 2nd set from the 1st set using difference_update():") sn1.difference_update(sn2) print(sn1) sn1 = {1,2,3,4,5} sn2 = {4,5,6,7,8} print("Remove the intersection of a 2nd set from the 1st set using -= oper...
565b892cd0ef7b9d115a7c25574894cd4819436b
CharmiShah26/Code-Chef
/FLOW016.py
826
3.640625
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 22 22:17:58 2021 @author: charm """ def gcd(x,y): if x > y: smaller = y else: smaller = x for i in range(1, smaller+1): if((x % i == 0) and (y % i == 0)): hcf = i return hcf def lcm(x,y): return int(...
583abd4938567b8520391f89c3148d65078bb6e7
haonanq666/ics3u
/Default/function.py
190
4.0625
4
def factorial(a): fact = 1 for x in range(a): fact = fact*(x+1) return fact f=input('enter factorial: ') print(factorial(int(f)))
a4c3113f66431ef913f7eaad33f0c6d28a7b1566
AChern0v/py_training
/chapter3/Coin (chapter 3).py
268
3.515625
4
import random attempt = 100 eagle = 0 tails = 0 while attempt > 0: result = random.randint(1, 2) if result == 1: eagle += 1 else: tails += 1 attempt -= 1 print("Орел: " + str(eagle)) print("\nРешка: " + str(tails))
3bb6bc57e0aba1ac0600c7b1f30614ef59ceba38
skywalkerqwer/DataScience
/day04/06_aaa.py
272
3.609375
4
""" 轴向汇总 """ import numpy as np data = np.arange(1, 13).reshape(3, 4) print(data) def func(ary): return np.mean(ary) re = np.apply_along_axis( func1d=func, # 接收一维数组的函数 axis=1, # 轴向 arr=data, # ndarry数组 ) print(re)
b532d7b0dbfa67d47203cc572b1f4cedf4ff52b2
jobm/AlgoGalore
/ceaser/ceaser_cipher.py
1,534
4.375
4
# Using the Python, have the function CaesarCipher(str,num) take the str parameter and perform a Caesar Cipher shift # on it using the num parameter as the shifting number. # A Caesar Cipher works by shifting each letter in the # string N places down in the alphabet (in this case N will be num). # Punctuation, spaces, ...
190837652b97ba56de0ae68fa89bc36885608ad0
lacerda92/exercicios-python
/ex004 dissecando uma variável.py
1,255
4.375
4
#tipos de primitivos #int = número inteiros = 7,5,-5,-10,56484 #float = números reais ou números de ponto flutuante = 4.5, 55.2, 3.2, 7.0 #bool = valores lógicos ou boleanos = True, False #str = caracteres ou strings = 'Ola', '7.5', '', 'bunda lele' #004 #Faça um programa que leia algo pelo teclado e mostre na ...
30a9f1e25ed1263eb6bf6b2f6dc6be973296cfcf
bartkowiaktomasz/algorithmic-challenges
/LeetCode - Top Interview Questions/SerializeAndDeserializeBinaryTree.py
1,915
3.75
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def __repr__(self): return f"{self.val}" class Codec: def serialize(self, root: TreeNode) -> str: """Encodes a tree to a single st...
027e6b71035ccb48950399bb8f2b87665c051f24
roselijack/python-masterclass
/programming/python-masterclass/ifchallenge.py
173
4.09375
4
name = input("please input your name") age = int(input("please input your age")) if(18<=age <30): print("welcom {}".format(name)) else: print("it's not fit for you")