blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a7c3457276ecc11d0cff0a1821cfab073e544811
mansipurohit11/100-Days-Python
/GuessTheGame.py
865
3.984375
4
import random from art import logo print(logo) print("Welcome to gussing game!\nI'm thinking of a number between 1 to 100.") type = input("Choose a difficulty. Type 'easy' or 'hard': ") answer = random.randint(1, 100) if type == "easy": chances = 10 elif type == "hard": chances = 5 else: prin...
94de3a8fce5a89456e90984a65b204e87101f565
saulquispe/My-Solutions-to-The-Python-Workbook-By-Ben-Stephenson-122-of-174-
/Introduction to Programming Exercises/ex31.py
476
4.0625
4
''' Exercise 31: Sum of the Digits in an Integer Develop a program that reads a four-digit integer from the user and displays the sum of the digits in the number. For example, if the user enters 3141 then your program should display 3+1+4+1=9. ''' num = int(input('Enter your four digit number: ')) num_list = l...
c717bbca497cbbd86acaea0a27900b713f5a626f
thylaco1eo/practice
/datastructre/graph.py
1,168
3.78125
4
def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if start not in graph: return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return n...
f1f022b40c04c440eb34cbb69099e30398a09b80
omadara/Educational-Software
/Educational Software/extra/example exercise.py
872
4.03125
4
# exercise description goes here # use question marks(?) if needed to help user complete the exercise def func(words): count = 0 for word in words: if ????????? and ?????????: ???????? return count # dont forget to return a value to use on testing # only the code above this line gets s...
e517f10d472716263b3fb4601ddb6d42a26ec8a2
quixoteji/Leetcode
/solutions/508.most-frequent-subtree-sum.py
926
3.546875
4
# # @lc app=leetcode id=508 lang=python3 # # [508] Most Frequent Subtree Sum # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def findFrequentTreeSum(self, root: Tree...
7cddbc18ea9642f622e095d103391a8f1b57cbf1
amaldare93/myCode
/Structures.py
5,635
4
4
class node(object): def __init__(self, data=None): self.data = data self.next = None self.prev = None class linked_list(object): def __init__(self, head=None, tail=None): self.head = head self.tail = tail def appendFront(self, thing): # create node for data if type(thing) != type(node()): thing = ...
4d681ad4ff51a47d4b0e8983405772065c68006d
ToruTamahashi/practice_python
/ファイル操作/seek.py
375
3.609375
4
with open('text.txt', 'r') as f: # test.txtのなかで今何文字目を見ているかを表示 print(f.tell()) # 現在の位置の文字を読み込んで次の位置に移動 print(f.read(1)) # 5文字目に移動 f.seek(5) print(f.read(1)) # 戻ることもできる f.seek(1) print(f.read(1)) f.seek(10) print(f.read(1))
125f823ae1dc2b59a23238113b0c12f8f3fbbac7
Chestnut-lol/MIT-6.006
/ps6/rubik/solver.py
2,407
3.703125
4
import rubik def shortest_path(start, end): """ Using 2-way BFS, finds the shortest path from start_position to end_position. Returns a list of moves. You can use the rubik.quarter_twists move set. Each move can be applied using rubik.perm_apply """ if start == end: return []...
8f07afe6290baa07f560820d2547c247e063b6c5
ajakaiye33/pythonic_daily_capsules
/analyze_age_in_dict.py
893
3.765625
4
from statistics import mean def analyze_age_dict(lst): """ Receives a list of dictionaries, pulls the value associated with key "age" from each dictioanry, and return a new dictionary with two keys: *"average": The average age of the inpu dict *"dictionary_count": The number of lelement processed...
f10646f9c6ef894a46373b115fc4c9f7b0c26aba
nstvn/Chess
/main.py
3,609
3.875
4
class Chess: #Создали класс для обработки координат def __init__(self): self.k = int( input('Введи координату первой клетки по горизонтали (1-8): ')) # x self.l = int( input('Введи координату первой клетки по вертикали (1-8): ')) # y self.m = int( input(...
2cd9f7700bf18c7226cc0f362f2c969dcad5424d
battulakarthik/my-file2
/check sub of sting.py
65
3.53125
4
n,m=input().split() if m in n: print("yes") else:print("no")
dcdda281c8cc0399a537dfb5e5bc5b018161adb7
CiceroLino/Learning_python
/Curso_em_Video/Mundo_1_Fundamentos/Usando_modulos_do_python/ex016.py
407
3.78125
4
#Desafio 016 do curso em video #Programa que mostra sua poção inteira #https://www.youtube.com/watch?v=-iSbDpl5Jhw&list=PLHz_AreHm4dm6wYOIW20Nyg12TAjmMGT-&index=17 from math import trunc num = float(input('Digite um valor: ')) print(f'O valor digitado foi {num} e sua porção inteira é {trunc(num)}') #Outro método #pr...
17d7c2abdd72edfbaf3850e170f54c9061d20972
Aasthaengg/IBMdataset
/Python_codes/p03852/s447757723.py
80
3.828125
4
s = input() x = 'aiueo' if s in x : print('vowel') else : print('consonant')
aedc4d833eb0fc2070338ef92ed82bf90ed7a622
yunieom/Study.2-Algorithm
/프로그래머스/lv1/42748. K번째수/K번째수.py
299
3.765625
4
def solution(array, commands): answer = [] arr = [] for i in range(len(commands)): num1 = commands[i][0] num2 = commands[i][1] num3 = commands[i][2]-1 arr = array[num1-1:num2] arr.sort() answer.append(arr[num3]) return answer
b1531fd8b6ba35a322cddfcfd73e790516762d7f
manondesclides/ismrmrd-python-tools
/ismrmrd_to_nifti/flip_image.py
366
3.640625
4
import numpy as np def flip_image(img): """ Parameters ---------- img : image to flip and rotate to have the same orientation than the real nifti image Returns ------- flipped_img : the flipped image """ #permute all dimensions to have yxz order img = img.transpose(1, 2, 0)...
8af272d5a7ed8075724cde28d431fa1618dc736e
shalevy1/coldbrew
/src/examples/add.py
422
3.8125
4
import argparse parser = argparse.ArgumentParser(description="calculate X + Y") parser.add_argument("x", type=int, help="the first operand") parser.add_argument("y", type=int, help="the second operand") parser.add_argument("-v", "--verbose", action="store_true") args = parser.parse_args() answer = args.x+args.y if arg...
8bee0fe382d9fe0f9520aba5e2ef861080f66476
jshuster7484/VI-Viewer
/test.py
498
3.546875
4
#!/bin/python3 import sys #a0, a1, a2 = input().strip().split(' ') #a0, a1, a2 = [int(a0), int(a1), int(a2)] #b0, b1, b2 = input().strip().split(' ') #b0, b1, b2 = [int(b0), int(b1), int(b2)] a0, a1, a2 = [1,2,3] b0, b1, b2 = [1,4,1] aliceScore = 0 bobScore = 0 def compare(a, b): global aliceScore global ...
ee222cfec5964fab2209134abfdf4d809125dede
SuryakantKumar/Data-Structures-Algorithms
/Object Oriented Programming/Method-Overriding.py
1,305
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Mar 6 16:50:09 2020 @author: suryakantkumar """ class Vehicle: def __init__(self, color, maxSpeed): self.color = color self.__maxSpeed = maxSpeed # private attribute def print_vehicle(self): print...
fce3ac790f278296a527c5c72e7e26808bf3bc68
ColonelKASH/Image-Classifier
/untitled1.py
1,835
3.65625
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 3 00:00:21 2018 @author: hp """ #1 CREATING CNN from keras.models import Sequential from keras.layers import Convolution2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense #initializing CNN classifier = Sequential...
c406189c6557e72b8b5fcf15182cc99275f8ed0b
umair3/pytorial
/basics/concat.py
183
4.03125
4
# Use plus sign to concat stringA = "Hello" stringB = "world!" print(stringA + " " + stringB) intA = 1 # print(stringA+intA), can only concat str to str print(stringA + str(intA))
cd4fb79bdf161c93120ccf52c3d87cc9732e8a1b
Felipe017/intropython
/aula2.py
1,046
3.515625
4
import math as mate print('Aula 2') print('') print('Exercicio 1') print('') largura = 17 altura = 12.0 delimitador = "." print('largura/2 = ', largura/2) print('Tipo do resultado',type(largura/2)) print('') print('largura/2.0 = ', largura/2.0) print('Tipo do resultado',type(largura/2.0)) print('') pr...
aff0435bbd23e6a3df9528302bf52001b0c835b0
flavio0567/DojoAssignments
/Python/FilterByType/FilterByType.py
403
3.703125
4
''' Filter by Type ''' # Integer sI = 45 if sI >= 100: print("That's a big number!") else: print("that's a small number!") # String bS = "Tell me and I forget. Teach me and I remember. Involve me and I learn." if len(bS) >= 50: print("Long sentence.") else: print("Short sentence.") # List aL = ...
e48d64c44a9442436fbbbfc203b62d44d73e1388
citroen8897/Python_basic_hw
/lecon_sept/sort_list.py
919
4
4
def sort_ascending(x): # вариант 1 # temp_2 = [j for j in range(len(x)) if x[j] == -1] # x.sort() # x = [j for j in x if j > 0] # for q in temp_2: # x.insert(q, -1) # return x # вариант 2 temp_1 = [j for j in x if j != -1] temp_1.sort() for i in range(len(x)): if...
a758e353acb0b2432f3f87bb46fabd2e94c1f75a
SpeddieSwagetti/CP1404_Practicals
/prac_01/electricity_bill_estimator.py
374
4.09375
4
"""electricity bill estimator""" price = float(input("Enter price in cents per kWh:")) daily_use = float(input("Enter kWh usage per day:")) num_of_days = int(input("Enter number of days in billing period:")) estimated_bill = price * 0.01 * daily_use * num_of_days print("Congradulations you millenials! Your bill is: {...
16258c39051e3c1c6be8aaa76c8a353db2b5dc18
AdamZhouSE/pythonHomework
/Code/CodeRecords/2627/40186/316228.py
224
3.734375
4
n = int(input()) for i in range(n): a = input() if a=='22 15': print(3.02408) elif a=='20 7': print(0.66403) elif a=='20 6': print(0.48148) elif a=='20 5': print('0.33020')
28114f6d4bb9fe9b40abbebe481dda49f6378592
leonarita/Python
/Projetos/_Failed/GUI.py
274
3.65625
4
from tkinter import * def clicked(): app.destroy() app = Tk() lab = Label(app, text="Write: ") lab.grid(row=0, column=0) en = Entry(app) en.grid(row=0, column=1) btn = Button(app, text='click here!', command=clicked) btn.grid(row=1, columnspan=2) app.mainloop()
24f0c4bb322343b551b71d6d3458c973d05a5598
hasant99/Python-Class-Projects
/decrypter.py
3,299
4.4375
4
###Author: Hasan Taleb ###Class: CSc110 ###Description: A program that decrypts an ### encrypted file selected by the user. ### It first .combines the encrypted file and ### index files into a list in the order ### they are read. Then this program reorders ### ...
b9ebb5f6d0c4cc3e87bda12b0c3a22f381f87fbe
sevenbella/test
/python/3. 运算符.py
453
3.828125
4
# + - * / 加减乘除 a = 10 b = 20 c = a + b print(c) d = a * b print(d) e = a - b print(e) f = b / a print(f) # 取整除 // a1 = 13 b1 = 3 c1 = a1 // b1 print(c1) # 取模 取余数 % -- 判断奇偶性 如果对2取余数为0,该数则为偶数 left = 9 right = 2 result = left % right print(result) # 取幂 ** first = 5 second = 3 then = first ** second print(then) ...
2ed75d99d9c401ba741032aa94367f20a68ee784
cobalt-blue0626/The-Blackjack-Game
/hw4_p1.py
5,212
3.671875
4
continue_or_not="y" while continue_or_not=="y": rank=["ACE","2","3","4","5","6","7","8","9","10","JACK","QUEEN","KING"]#牌的大小 suit=["SPADE","HEART","DIAMOND","CLUB"]#牌的花色 deckcard=[] for i in rank:#總共五十二張牌 for j in suit: deckcard.append(i+"-"+j) import random random.shuffle(deckcard)#洗牌 index=random.randint(...
1a2eae5dbd63453d1885ee561d6652dc233309b5
imsure/tech-interview-prep
/py/fundamentals/sorting/radix_sort.py
942
3.96875
4
def radix_sort(array): """ Radix sort on array of non-negative integers. :param array: :return: """ if not array: return [] max_key_len = len(str(max(array))) array = [str(n)[::-1] for n in array] sorted_array = array for i in range(max_key_len): buckets = {str...
e0e93e77df2c2c20b18bcb53f7a395f72598004c
niushufeng/Python_202006
/算法代码/面向对象/模块/模块的开发原则/__name__模块.py
720
3.890625
4
# 可以提供全局变量、函数、类, 注意:直接执行的代码不是向外界提供的工具 # 开发原则-- ,每一个文件都是应该可以被导入的 # 一个独立的python 文件就是一个模块 # 在导入文件时, 文件中所有没有任何缩进的代码都会被执行一遍 # 导入模块 # 定义全局变量 # 定义类 # 定义函数 # 在代码的最下方 def say_hello(): print("你好你好,我是 say hello ") # 如果直接执行模块,得到的值永远是__main__ if __name__ == "__main__": print(__name__) # 文件被导入时,能够执行的代码不需要被执行 p...
836207c3db3a9d7a5212b24e3d559b83c8d70252
DigitalCrafts/gists
/Data_Analytics/python training/logical expressions/class exercise solutions/hello-world-multi-non-blank.py
505
4.1875
4
user_input_name = input("Enter a name: ") length_of_name = len(user_input_name) if length_of_name > 0: user_input_place = input("Enter a place: ") length_of_place = len(user_input_place) if length_of_place > 0: message = "Hello, %s! Welcome to %s!" % (user_input_name, user_input_place) else: ...
65e595b5d9aa1b1deb8b4f588e68dcbf5c2b6f97
GrindelfP/preparing_to_exam
/task_17/17_03_28.py
587
3.59375
4
count = 0 summary = "" max_good = None def binar(num) -> int: num = bin(num) num = num.replace("0", "", 1) num = int(num.replace("b", "", 1)) return num def digits_sum(num) -> int: sum = 0 while num > 1: digit = num - num // 10 * 10 sum = sum + digit num = num // 10 ...
2c15acd1289edc33d0915dbfcfe809e1e9ef1e36
PranshuRaj/PyBattery1.2
/PyBattery1.2/main.py
4,423
3.828125
4
# python script showing battery details # If you do not have psutil, pygame module you can install with using pip in Terminal import psutil # (pip install psutil) import time from win10toast import ToastNotifier toaster = ToastNotifier() # function returning time in hh:mm:ss def convertTime(seconds): ...
643eb9317bf145386fb377fc20295ad7de9a8348
ICANDIGITAL/crash_course_python
/chapter_8/large_shirts.py
311
4.0625
4
def make_shirt(text='i love python', size='large'): """Displays the size and text printed on the shirt.""" print("The selected shirt is a size " + size.lower() + " with a text of: " + text.title() + ".") make_shirt() make_shirt('i love python','medium') make_shirt('top of the world ma', 'grande')
be020b5de8be2481d03de0eb936179cb1c567b93
puzzz21/covid-19-data-visualization
/Covid 19 visualization.py
1,480
3.578125
4
#!/usr/bin/env python # coding: utf-8 # WHO COVID 19 data visualization using matplotlib # In[1]: import pandas as pd import numpy as np import matplotlib.pyplot as plt import matplotlib.axes.Axes as ax import statsmodels.api as sm import seaborn as sns sns.set() # In[2]: fullData = pd.read_csv("https://covid.ou...
af5aaecfc365941a9fd47bd6cb50ff270af9995c
Shin-jay7/LeetCode
/0402_remove_k_digits.py
356
3.53125
4
from __future__ import annotations class Solution: def removeKdigits(self, num: str, k: int) -> str: digits = [] for digit in num: while k and digits and digits[-1] > digit: digits.pop() k -= 1 digits.append(digit) return "".join(digi...
b0ba166c29bf75e8112079a7d17007a018fb02a8
xiaolinangela/cracking-the-coding-interview-soln
/Ch3-StacksAndQueues/3.6-AnimalShelter.py
1,049
3.90625
4
from LinkedList import LinkedList from LinkedList import LinkedListNode class AnimalShelter: def __init__(self): self.dog = LinkedList() self.cat = LinkedList() self.order = 0 def enqueue(self,animal,type): if type == "dog": self.dog.add([animal],"dog",self.order) ...
f742000fef7316430be53c63a1f6819fa8206779
kyasui/python_lab
/main.py
2,281
4
4
"""Rock Paper Scissors""" from random import randint class Player: def __init__(self, is_human=False): self.is_human = is_human def play(self): if self.is_human == False: return randint(0,2) else: is_recognized_input = False while is_recognized_input == False: play = raw_inp...
d35ffabcd7f1863d68b80d7accb2ab5d0d6f7a25
bhaktijkoli/python-training
/example11.py
227
4.09375
4
def checkPrime(x): for i in range(2, x): if x % i == 0: print("Not a prime number") break; else: print("Print number") x = int(input("Enter any number\n")) checkPrime(x)
9eda5983a75b5e8e381a1812999172d6670acd85
lucascv/Python
/PycharmProjects/guppe/sec7_p1_ex16.py
310
3.859375
4
A = [] cont = 0 while cont < 5: A.append(float(input('Digite um valor: '))) cont = cont + 1 codigo = int(input('Digite o código: ')) if codigo == 1: print(A) elif codigo == 2: A.reverse() print(A) elif codigo == 0: print('Fim.') else: print('Codigo inválido.')
f53955ba654339dbef22693d261860b21d1bc503
hanrosen/206-final-project
/date.py
3,765
3.78125
4
def date_conversion(date): split = date.split() year = str(date.split()[-1]) if "January" in date: month = '01' if len(split[1]) == 4: day = '0' + split[1][0] release = "{}-{}-{}".format(year, month, day) else: day = split[1][:2] release = ...
8826a67eb7e86248a2ce567fafa34d2d084ee9d8
maxmyth01/unit1
/stringAnalysis.py
787
4.15625
4
#Max Low #9-1-17 #stringAnalysis.py - Studies a sentance and counts the amount of words letter and scans for a letter and word sentance = input('Enter a Sentance') sentance = sentance.upper() space = (' ') totalWords= (sentance.count(space)+1) totalCharactures = len(sentance) totalLetters = (totalCharactures-totalWord...
c2f47c69e1d85f5e5a7249b8482039a28e42383c
roshan-shahi/basicpython
/assignment.py
294
3.65625
4
v=25 u=0 t=10 a=(v-u)/t print(a) f_name=input"(enter first name") l_name=input("enter last name") full name=f_name+" "+l_name print(full_name) #question 3 user_input=(input("enter something") print(user_input +10) #question 4 print(type(4)) print(str(45)) print(eval("2+3")
13145c8d90d36f5915ce4ddca79d74f1142b91e9
abecus/Queues
/pyqueues/heap.py
1,338
3.65625
4
def heapify(arr: list, *, i: int=None) -> None: def helper(i): # goes from parent to the child (down) """ comparing children and spawing parent to min of children if exist, and doing same on swapped parent node """ while i<nTillLastRow: ch1 = 2*i +1 try: if arr[ch1]>arr[ch1+1]: ch1 += 1 exce...
4f3122886e73268be07b9d8f6e2cc3c151f0701b
xdkernelx/fundamentals_of_cs
/interactive_python_p1/guess_the_number.py
2,858
4.125
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui, random, math secret_number = 0 secret_range = 100 guesses = 0 message = "Welcome!" # helper function to start and restart the game ...
0b7240eb61885f354ee22282ace2166661e0374a
chjdm/PythonCrashCourse
/learning_complete/dream_resort.py
467
3.875
4
dream_resorts = {} active = True while active: name = input("Thank you for take in the poll, what's your name, please?") resort = input("If you could visit one place in the world, where would you go?") dream_resorts[name] = resort repeat = input("Would you like to take another poll?(yes/no)") if...
3f75d473f0522f86bd5f578f44bb1e2be41059bf
kemingy/daily-coding-problem
/src/prefix_map_sum.py
1,412
3.953125
4
# Implement a PrefixMapSum class with the following methods: # • insert(key: str, value: int): Set a given key's value in the map. # If the key already exists, overwrite the value. # • sum(prefix: str): Return the sum of all values of keys that begin with # a given prefix. # For example, you should be able to ru...
82b50e1c6ba982ba840a70206ab157bcf7d0552d
newfull5/SW-Expert-Academy
/2025. N줄덧셈.py
80
3.640625
4
n = int(input()) temp = 0 for i in range(0,n+1): temp += i print(temp)
98eb14f1737d85be3a3a5477c7eef01e67d812b7
bond400apm/MetroHasting
/lib/pdfs.py
1,048
3.53125
4
import numpy as np import math # This defines a Gaussian pdf with mean value "a" and standard deviation 1 def gauspdf(x,a): ''' input:x function variable(float) input:a Gaussian mean(float) output: The corrsponding value of x for the given Guassian mean(float) ''' N = np.sqrt(np.log(a)/(2*np.pi...
c2cbbe84babd60c1e5c7f52920552fd0da142d3f
MATATAxD/untitled1
/10.22/计数排序.py
454
3.640625
4
from typing import List from randomList import randomList def countSort(List): if len(List) <= 1: return List maxv = max(List) count_list = [0] * (maxv + 1) for i in range(len(List)): count_list[List[i]] += 1 sort_list = [] for i in range(len(count_list)): for j in rang...
22cd8e457c474f9b9dbbcdf16f023769393f0175
Artem-max-eng/lesson1
/dtypes.py
396
3.859375
4
a = input("Как вас зовут? ") print(f'Пошел нахуй, {a}!') b = int(input("Сколько вам лет? ")) if (b < 18): print('Не получилось, не фартануло(') elif (b > 18): print('Welcome to the club, buddy!') else: print(f'Неплохо тебя жизнь поматала, я в свои {b} еще в горшок ходил...')
fcb7da07131c68db22ca06f808757e4babf2db79
coreyarch1234/Tweet-Generator
/random-dict/main.py
1,319
3.96875
4
#The goal is to take the words text file and create a program that takes in an integer representing #a number of words, n, takes a random set and outputs that set in a sentence (grammar/sentence structure does not matter) #Handles reading text file def read_in(word_text): words = open(word_text, 'r') word_lis...
00c2578b02e0d96648a494620210693e5f5cc0d1
Rylan12/Project-Euler
/solved/p51.py
3,183
3.75
4
from math import sqrt from solved.p27 import is_prime from solved.p46 import get_primes def list_primes(start, stop): result = [True for _ in range(stop)] result[0], result[1] = False, False for i in range(round(sqrt(stop) + 1)): if result[i]: for j in range(i * i, len(result), i): ...
de3f0b2d8ff4066e7d02882a4eb8c5f0f0b3b9fe
yanfriend/python-practice
/variables/class_obj.py
816
3.5625
4
class TestClass(object): c = 299792458 #this is a class variable def __init__(self): self.e = 2.71 #instance variable def phiFunc(self): self.phi = 1.618 #will become an instance variable after phiFunc is called x=224 #this is a method variable and can't be accessed outside this...
fc0301fc1de493a983e1853355453bc23e3276e2
Cuize/data-structures-and-algorithms
/quicksort/main.py
1,322
3.921875
4
nums=input("input nums with . to separate") try: nums=[int(x) for x in nums.split(".")] except: nums=nums.split(".") print(f"your input is {nums}") print("*"*10) choice=input("find kth smallest element or simply sort the array? (enter 0 for kth smallest element 1 for sorting)") while choice not in "01": choice=inpu...
948bff87c6165853e7f6f59c5e1c54c559d8a2cb
bevisLee/portfolio
/Pythonproject/about_python/abuout_python_0909_numpy.py
2,317
3.984375
4
import numpy as np L = list(range(10)) L L2 = [str(c) for c in L] L2 type(L2[0]) L3 = [True, "2", 3.0, 4] L3 [type(item) for item in L3] import array L = list(range(10)) A = array.array('i', L) A # integer array: np.array([1, 4, 2, 5, 3]) np.array([3.14, 4, 2, 3]) np.array([1, 2, 3, 4], dtype='float32') # nest...
fdda3cc80293b04b785fb99be0d3b8e9d0485f4d
ursueugen/Rosalind_Bioinformatics_Problems
/Enumerate_Gene_Orders/gene_orders.py
913
3.96875
4
n = 5 def factorial(n): if n == 0 or n == 1: return 1 else: return factorial(n-1) * n def all_permutations(n): permutations = [] # elements of list elements = list(map(str, range(1, n+1))) #permutations.append(elements) # first, natural ordering # initialization ...
84968c0de10f36b4b3146b9f64133de27f107d37
jlunder00/blocks-world
/world.py
4,175
4.03125
4
''' Programmer: Jason Lunder Class: CPSC 323-01, Fall 2021 Project #4 - Blocks world 9/30/2021 Description: This is an object representing the world that blocks live in. It has a set of locations and blocks distributed in those locations, according to the number of places and number of blocks passed in in the init...
24e7d078ff7b03e86e77050a9ff7203f61a2141a
dvdgatik/python_basico
/aproximacion.py
557
3.890625
4
objetivo = int(input('Escoge un numero: ')) epsilon = 0.0001 #que tan_ cerca queremos llegar de la respuesta paso = epsilon**2 #numero mas pequeño 0.01*0.01 respuesta = 0.0 #abs valor absoluto while abs(respuesta**2 - objetivo) >= epsilon and respuesta <= objetivo: #la segunda iteracion nos protege contra negativos ...
d9b37faeaef7a76b6802edd21a5cc193009b5bf8
TeamAkatsuki/TeamAkatsuki
/team-akatsuki/kimhr/world_cup.py
2,356
3.546875
4
import random france = ["돈까스", "짜장면", "햄버거", "냉면", "덮밥", "초밥", "삼겹살", "라면"] random.shuffle(france) f = [] def ideal_type(): if len(a)%2 == 0: loop = len(a) // 2 for i in range(0, loop): while True: if loop == 1: print("<<결승>>\n") els...
bdbc0649db0bdb0587a778ac139ded3882f46812
siddhant283/Python
/Generators/fib.py
206
3.875
4
def fib(number): f0 = 0 f1 = 1 for i in range(number): yield f0 temp = f0 + f1 f0 = f1 f1 = temp for item in fib(8): print(item)
51e6916967527c638f29fdef6d32caeacf77e789
starlordali4444/ALI_INFY
/GENERIC/PROGRAM/PYTHON/while.py
93
3.9375
4
#WAP to take input untill alpha is given a="" while (a!="alpha"): a=input("Enter a word")
ecb625664c7559f017a5dc4d1411a1ebe9579e0f
chachout/Python-petits-programmes
/Convertisseur de degrés fahrenheit en degrés celsius et inverse.py
469
3.859375
4
b=int(input("Est ce que la température de départ est en fahrenheit [mettre 1] ou en celsius [mettre 0] ou en Kelvin [mettre 2] : " )) if b==1 : f=float(input("température en °F : ")) c=(f-32)/1.8 print (f,"°F=",c,"°C") elif b==2 : k=float(input("température en °K : ")) c=k-273.15 f=c*1.8...
0806650eef0c3b5ef2ab5274b2d2454313a428e3
srknthn/InformationSecurity
/TheKey/Columnar_Encrypt_KeyString.py
1,105
3.78125
4
__author__ = 'sr1k4n7h' import re # def sort_indices(word): # FAILING FOR DUPLICATE LETTERS IN THE KEY # """ sorting the indices in the key """ # h, k = {}, 0 # for i in sorted(word): # h.__setitem__(i, k) # k += 1 # return [h[i] for i in word] # SORTING THE INDICES OF T...
3bcda5c77649694afc33a194dc72307c60350cd5
tommady/Hackerrank
/Algorithms/strings/sherlock_and_anagrams.py
480
3.625
4
# http://www.geeksforgeeks.org/anagram-substring-search-search-permutations/ from collections import defaultdict for _ in range(int(input())): s = input() len_s = len(s) d = defaultdict(int) for i in range(len_s): for j in range(1, len_s-i+1): sub_s = s[i:i+j] sub_...
6ca3b9eba574bce83ea095d2f2dc8fd4369012ee
mkmad/ctci
/ctci/trees_graphs/dfs_bfs.py
1,984
4.0625
4
import pprint pp = pprint.PrettyPrinter(indent=4) import Queue myqueue = Queue.Queue() # supports put() and get() # Check if empty using empty() # This is a adjacency set. Sets are used # as its much better since they eliminate # duplicate entry. graph = {'A': set(['B', 'C']), 'B': s...
4a6f84e6dfd4184ed924bdc46b9bdadfdfc67375
phaustin/pythonlibs
/pyutils/pyutils/translate.py
789
3.8125
4
#http://stackoverflow.com/questions/638893/what-is-the-most-efficient-way-in-python-to-convert-a-string-to-all-lowercase-str import string letter_set = frozenset(string.ascii_lowercase + string.ascii_uppercase) ## tab = string.maketrans(string.ascii_lowercase + string.ascii_uppercase, ## string.a...
b2c039093374d5b0bdc0f37af63629da930c822a
CarlVs96/Curso-Python
/Curso Python/1 Sintaxis Básica/Video 6 - Funciones Parametrizadas/Funciones_parametrizadas.py
103
3.546875
4
def suma(num1, num2): resultado=num1+num2 return resultado almacenaRes=suma(5,8) print(almacenaRes)
2dd4c16eeadb05beb1f1cc0e44e7c09a2bc3f798
Khushisomani/codes
/29099417.py
125
3.5
4
# cook your dish here import math for _ in range(int(input())): a,b=map(int,input().split()) print((2*math.gcd(a,b)))
851ce203ef5aac5e3e6867c02eda07b3da84fdf4
shanbumin/py-beginner
/026-image/demo08/main.py
1,807
3.546875
4
import random from PIL import Image, ImageDraw, ImageFont # Pillow中有一个名为ImageDraw的模块,该模块的Draw函数会返回一个ImageDraw对象, # 通过ImageDraw对象的arc、line、rectangle、ellipse、polygon等方法, # 可以在图像上绘制出圆弧、线条、矩形、椭圆、多边形等形状,也可以通过该对象的text方法在图像上添加文字。 def random_color(): """生成随机颜色""" red = random.randint(0, 255) green = random.randin...
b679dc21315dd8c732528f6ae9b5fa813bf85148
MaliYudina/AdPY
/HW2/countries_parser.py
1,140
3.640625
4
import json SOURCE_FILE = 'countries.json' FILE_TO_WRITE = 'countries_link.txt' """ Написать класс итератора, который по каждой стране из файла countries.json ищет страницу из википедии. Записывает в файл пару: страна – ссылка. """ class WikipediaData: def __init__(self, FILE_TO_WRITE, output): self.cou...
49727e39eeb0d01c83cf1847d1d1c476bd99c471
IIT-Lab/sumo-rl
/agents/agent.py
533
3.5
4
from abc import ABC, abstractmethod class Agent(ABC): def __init__(self, state_space, action_space): self.state_space = state_space self.action_space = action_space @abstractmethod def new_episode(self): pass @abstractmethod def observe(self, observation): ''' To...
eee7ca33cb637679d21d9eb85fb3762faee1dee2
ttong-ai/repl-vendor-management
/utils.py
858
3.625
4
from typing import Any BIG_NUMBER = 100_000 def ifnone(a: Any, b: Any) -> Any: """`a` if `a` is not None, otherwise `b`.""" return b if a is None else a def levenshtein(s: str, t: str, ignore_case=False) -> int: """ Implementation of classic Levenshtein edit distance. """ if s is None or t is None:...
9d3c7c23828758141ffceef8a47e817b9356b15e
tomviner/project-euler
/problem-5.py
1,227
4.03125
4
""" 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ import itertools from collections import Counter from common import prime_factors, product def divisibl...
350e6c9c135545e4c0c1c4a4ca4a3b73d77f0da3
riemannzeta1191/PyDev
/Multithreading/Threading_experiments.py
3,766
3.96875
4
import threading, math from multiprocessing import Process # # Py_BEGIN_ALLOW_THREADS # sleep((int)secs); A thread can bypass the GIL by releasing it when it enters a I/O blocking # Py_END_ALLOW_THREADS instruction,during which other threads can run in parallel untill is asks # ...
08cedf0a93b6ec05555c16f917eb0dad790ac4fb
MaximOksiuta/for-dz
/dz7/1.py
3,220
3.671875
4
class Matrix: """перегрузка конструктора""" def __init__(self, matrix): self.matrix = matrix """перегрузка __str__""" def __str__(self): self.result = '' # очистка итоговой строки self.matrix = self.checker(self.matrix) """формирование матрицы""" for i in self....
04a51dd1d8febc64518da9c2b924f8e5c59ad130
dev-arctik/Basic-Python
/2. Data type.py
297
3.78125
4
name="Dev" age=17 sex="male" hobby=["guitar","mechatronics"] #type keyword will show the datatype of keyword print("data type of",name, " is ", type(name)) print("data type of",age, " is ", type(age)) print("data type of", sex, " is ", type(sex)) print("data type of", hobby, " is ", type(hobby))
92bcc845b38c034232a03b6a8841a451ce914991
mur78/PythonPY100
/Занятие1/Домашнее_задание/task1/main.py
413
3.90625
4
# Напишите ваше решение # Напишите ваше решение speed = float(input('Задайте скорость передачи данных: ')) time = float(input('Время скачивания: ')) coast = float(input('Цена за 1 ГБ: ')) size = (time * speed) # Б за время size_gb = size // (1024 * 1024) coast_gb = (size_gb * coast) print(size_gb) print(coast_gb)
36390b2bd3234a89c3d601e26fb3b65ebe76f748
iftikhar1995/Python-DesignPatterns
/Creational/Builder/ComputerBuilder/SubObjects/hard_disk.py
895
4.25
4
class HardDisk: """ HardDisk of a computer """ def __init__(self, capacity: str) -> None: self.__capacity = capacity def capacity(self) -> str: """ A helper function that will return the capacity of the hard disk. :return: The capacity of the hard disk. :rt...
2a119025f1fc545c0b541ee1cf6f7f74f49f7c79
jhanse9522/toolkitten
/Python_Hard_Way_W2/ex15.py
997
4.53125
5
from sys import argv script, filename = argv txt = open(filename) #the open command takes a parameter, in this case we passed in filename, and it can be set to our own variable. Here, our own variable stores an open text file. Note to self: (filename) and not {filename} because filename is already a variable label c...
f40c2e15549842e0a96344d4c6d92bfa9d18527b
stcatz/hackerrank
/warmup/find-digits/main.py
147
3.5
4
num = input() for i in range(num): x = raw_input() count = 0 for i in x: if( int(i)!=0 and int(x) % int(i) == 0): count += 1 print count
440ecfcb604be2ed9d23dc9c296ca5a89001a6ab
JLLangy/74hc595
/random_example.py
1,060
4.03125
4
# Example of displaying eight-digit random numbers using # 8 x seven-segment displays controlled by 74HC595 shift register # Author: John-Lee Langford # Last update: 26-July-2021 # URL: mr.langford.com import time import ssd74hc595 import random # Define GPIO outputs dataPin = 11 latchPin = 15 clockPin = 13 # Creat...
ba7c817bc94abdab6cb620e39d71e0fa176df978
shimoishiryusei/school_programing_backup
/Code_Py/selection_sort.py
365
3.703125
4
def selection_sort(li): l = li.copy() n = len(l) for i in range(n): min_num = i for j in range(i,n): if l[j] < l[min_num]: min_num = j l[i], l[min_num] = l[min_num], l[i] return l n_len = int(input("配列の要素数:")) li = [int(input()) for _ in range(n_len...
c7fcbf2081ddeb126ebf304b44a51093e30c31a6
Zylophone/practice
/airbnb/find_median.py
655
3.734375
4
import sys def find_median(nums): n = len(nums) start, end = -sys.maxint - 1, sys.maxint if n % 2 == 0: return float(find_k(nums, n / 2 - 1, start, end) + find_k(nums, n / 2, start, end)) / 2 else: return find_k(nums, n / 2, start, end) def find_k(nums, k, start, end): if start >...
64917c8ea283c73aaa626b16276c4919d1153f8c
miaopei/MachineLearning
/LeetCode/github_leetcode/Python/jump-game-ii.py
1,098
3.78125
4
# Time: O(n) # Space: O(1) # # Given an array of non-negative integers, you are initially positioned at the first index of the array. # # Each element in the array represents your maximum jump length at that position. # # Your goal is to reach the last index in the minimum number of jumps. # # For example: # Given ...
0e0d3e616a3c1658b0202c990ed4e569692e3b19
deepshikha-hub/C179
/project_C179.py
1,875
3.671875
4
from tkinter import * import random root = Tk() root.title("Encapsulation") root.geometry("500x400") root.config(bg="white") label_score = Label(root, text="Score : 0",font=("Bahnschrift Light",15,"bold") ,bg="white") label_score.place(relx=0.1,rely=0.1, anchor= CENTER) label_name = Label(root,font=("Arial",40)...
972264af5c4f31025982a6dff82e6decd279dd31
RogerWoodman/simple-image-zoom
/zoomregion.py
3,268
3.53125
4
# -*- coding: utf-8 -*- """ Simple example allows for a selected region to be zoomed. The selected region is resized and joined horizontally to the main image @author: Roger Woodman """ import cv2 import numpy class ZoomRegion(): def __init__(self, image): """Initialise drawing variables""" ...
a7a57c23a4eead638ca64a2cc27a515bf5621db6
ddgvv/dd
/bs22.py
64
3.578125
4
n=input() rn=n[::-1] if (n==rn): print("yes") else: print("no")
2074279bd49c8301220952574ca8fd8ba4378ebb
MrHamdulay/csc3-capstone
/examples/data/Assignment_5/hrdtim002/question2.py
1,073
4.1875
4
"""Vending Machine Tim Hardie 16-4-14""" def calc_change (remaining): # calculating the different number of each coin num_dollars = remaining//100 remaining %= 100 num_25c = remaining//25 remaining %= 25 num_10c = remaining//10 remaining %= 10 num_5c = remaining//5 rema...
5351f25080022c776eaa4dacc5ed9711433be566
akshitbhalla2/10-days-of-statistics
/62.py
338
3.59375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import sys mystdin = [] for line in sys.stdin: mystdin.append(line) arr = mystdin[0].split(" ") arr = [float(a) for a in arr] lam1, lam2 = arr e1 = 160 + 40*(lam1**2 + lam1) e2 = 128 + 40*(lam2**2 + lam2) print("{:.3f}".format(e1)) print("{:...
97900b474c12a27042348dd84bda6cf2df6180c8
Adil-Anzarul/Pycharm-codes
/OOPS 5 Class methods in python T56.py
576
3.890625
4
class Employee: no_of_leaves=8 def __init__(self,a,b,c): #this is constructor self.name=a self.salary=b self.role=c def printdetails(self): return f" The name is {self.name}, salary is {self.salary} and role is {self.role} " @classmethod def change_leaves(cls,newle...
368e44f656262bede1918067e516f96d493d97a2
maelizarova/python_geekbrains
/lesson_2/task_3/main.py
795
3.71875
4
seasons_as_list = [[12, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11], 'fall', 'summer', 'spring', 'winter'] seasons_as_dict = {(12, 1, 2): 'winter', (3, 4, 5): 'spring', (6, 7, 8): 'summer', (9, 10, 11): 'fall'} month = int(input('Please, enter the number of month: ')) # первый вариант для списка: for idx in range(...
d7a1f102cc9862394b025f6c76064ba2c753d2b3
jgonzalezzu/MinTIC2022-UNAB-G63
/CICLO-1/EjerciciosClase/S4/DiccionariosYTuplas10.py
436
4.125
4
# Semana 4 - Clase 2 - Diccionarios y tuplas - Ejercicio 10 #TODO: Acceder a los elementos del diccionario diccionairo = {'four':'cinco'} diccionairo1 = {'one':'uno', 'two':'dos'} # Cuando de busca un valor existente este va a retornar el valor asociado a ese valor, de lo contrario imprime 'not está' dato = diccionairo...
f0eff5a456adcc8e731f1c2c8baac79e82cddce5
JamesMsuya/algorithms.
/theft_141044093.py
1,758
3.625
4
""" This algorithm finds the possible maximum values in the next column. It assumes the values in first columns are the maximum values the in the second values for each row the maximum value can be sum of itself and the left top(X[i][j] + X[i-1][j-1]) or left(X[i][j] + X[i][j-1]) or left bottom(X[i][j] + X[i-1][j...
857cec22c729161d21d60703d22a6798015aa009
Amrutak2/Python
/ClassNdObject.py
248
3.609375
4
class MyClass(): name = "" rno = "" def display(self): print("Name:", self.name) print("Roll number:",self.rno) p1 = MyClass() p1.name = "A" p1.rno = 1 p1.display() p1.name = "B" p1.rno = 2 p1.display()
29fa455bb84dadc0835bdbe2968b9e9acc926e08
notalexg/Ch.04_Conditionals
/4.3_Quiz_Master.py
4,144
3.6875
4
''' QUIZ MASTER PROJECT ------------------- The criteria for the project are on the website. Make sure you test this quiz with two of your student colleagues before you run it by your instructor. ''' corr = 0 wrng = 0 ans = int(input("\n\033[1;34mHow many wins does NA have at worlds 2020?")) if ans == 2: print("\...
0c54c9540df623bbd5b56c5629bdcfb9849f9d30
varijak454/python-learning
/sort-numbers.py
371
3.9375
4
# Importig libraries import random # to generate random number list numbers = random.sample(range(1, 50), 7) # printing result print ("Random number list is : " + str(numbers)) # Sorting on Ascending order numbers.sort() print("Sording Ascending order:", numbers) # Sorting on descending order numbers.sort(revers...
4b99ed12510ec3412cba7a6126b6d88aa6192813
andrecrocha/Fundamentos-Python
/Fundamentos/Aula 21 - Funções (parte 2)/exercicio101.py
681
4.0625
4
"""Desafio 101. Crie um programa que tenha uma função chamada voto(). Ele vai receber o parâmetro de o ano de nascimento de uma pessoa, retornando um valor literal, VOTO OBRIGATÓRIO, VOTO OPCIONAL, NÃO VOTA""" def voto(ano): from datetime import date # Você pode fazer a importação dentro de uma função atual ...
936b3abfafeee8de92355161e81f2cf35625caf2
kuaikang/python3
/基础知识/1.语法基础/13.dict字典-增删改查.py
658
3.71875
4
print("字典是key-value的数据类型".center(50, "-")) print("字典是无序的,key不能重复") info = {"stu1": "tom", "stu2": "jack", "stu3": "lucy"} print(info) # 添加 info["stu4"] = "bob" # 修改 info["stu1"] = "zhang" # 删除 # info.pop("stu2") # 标准删除方法 # del info["stu3"] # 查找 print('-----',info.get("stu11")) # 不存在的时候返回 # print(info["stu0"]) # 不存在时会报...