blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
696f44599b5fd975ba811bbe15d6ee57817c7007
sachinyadav3496/PythonInternBatch2018
/Core_Python/OOPS_in_Python/Codes/class3.py
324
3.640625
4
class Robot: robot_count = 0 def __init__(self,name,work): Robot.robot_count += 1 self.name = name self.work = work def show(self): print("Robot name = ",self.name) print("Robot Work = ",self.work) def count(self): print("Total Robot : ",Robot.robot_count...
1c60058c2c019051c5dd12b84eba25fd78f041af
ansid63/algorithms_and_data_structures
/lesson3/lesson3_task5.py
855
4.09375
4
# В массиве найти максимальный отрицательный элемент. Вывести на экран его значение и позицию в массиве. # Примечание к задаче: пожалуйста не путайте «минимальный» и «максимальный отрицательный». Это два абсолютно разных значения. import random lst = [random.randint(-20, 20) for i in range(20)] print(f'Рандомный лист...
e6840305b9444a7bef9b220f748eb6a205149aec
lukexingdbmgr/ACE
/subSets.py
2,288
3.96875
4
''' s = [1,2,3] s = [] -> [] s = [1] -> [], + [1] s = [1,2] -> [], [1], + [2], [1,2] s = [1,2,3] -> [], [1], [2], [1,2] + [3], [1,3], [2,3], [1,2,3] ''' import copy def subSets(s): res = [[]] for c in s: sz = len(res) for i in range(sz): t = copy.deepcopy(res[i]) #t = ...
94c4433ecfd34fdb8318530a87e04e36f963bacb
ankursharma7/100-Days-Of-Code
/Day 5/01_dictionary_synatx.py
260
3.9375
4
mydict = { "Fast" : "In A Quick Manner", "Ayush" : "Coder", "Marks" : [1,4,5], "A_dict" : {'ayush' : 'Player'} } # print(mydict['Fast']) # print(mydict['Ayush']) mydict["Marks"] = [45,89] print(mydict['Marks']) print(mydict['A_dict']['ayush'])
c581e7fc8ee760e9fa86051a6cc06096a56e8a37
zenbert5/data_analytics
/panda_dataframe/basic_lambda.py
347
3.796875
4
import pandas as pd mylambda = lambda x: x[0]+x[len(x)-1] print(mylambda('This is a string')) mylambda2 = lambda x: "Welcome to BattleCity!" \ if x > 13 else "You must be over 13" print(mylambda2(4)) df = pd.read_csv('employees.csv') print df get_last_name = lambda x: x.split(" ")[-1] df['last_name'] = df.name.app...
5756aecad573de37d7ef10be29fe125293a47e2d
ironsketch/pythonSeattleCentral
/Chapter 7/02_19_16.py
140
3.859375
4
def sumDigits(n): string = str(n) added = 0 for num in string: added += int(num) return added print(sumDigits(19))
e5c15a01e5c22e41427561fd2833602c2fb4bb65
USAMAWIZARD/datastructure
/Python/Tree/Linked List implementation/Binnary Tree/Binnary Search Tree/Binnary search Tree.py
1,727
4.09375
4
#genral tree implementation class Tree: Root=None toSearch=None locy=0 def __init__(self): self.Root=Node(int(input("enter the value of root node"))) def insert(self,value,i): if self.Root==None: self.Root=Node(value) return while True: p...
63b4e5c7ab569c5221da45271b9921bd684a3e2c
AshishGoyal27/Text-to-speech
/text_to_speech_in_male_or_female_voice.py
949
3.734375
4
import pyttsx3 import datetime #sapi5 is Speech API developed by Microsoft. engine = pyttsx3.init('sapi5') voices= engine.getProperty('voices') #getting details of current voice print(voices)#to get no. of voice my computer have print(voices[0].id)#name of this voice print(voices[1].id)#name of this voice ...
69f46646d855b27a49fec6fc72277f1f587cd909
qpham01/udacity
/sdcnd/CarND-Advanced-Lane-Lines/sobel.py
3,529
4.4375
4
""" Various uses of the Sobel operator for edge gradient thresholding. """ import numpy as np import cv2 def gray_rgb(img): """ # Convert to grayscale """ return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) def absolute_threshold(img, orient='x', kernel=3, thresh=(0, 255)): """ Define a function that...
4034c31889d891aea61dc7604217b931d04dbe40
thejaredchapman/JMC_Python
/whilex.py
104
4.125
4
x = 0 while x < 25: print (f'The current value of x is {x}') x += 1 else: print("X IS NOT")
b413fd27c3ea0ad4f352495c4183eff241707235
bhargav-inthezone/Ineuron_assignments
/python_basic_programming_assignment/Programming_Assignment3/Question1.py
278
4.28125
4
''' Question1) Write a program to Check if a Number is Positive, Negative or Zero?''' number = float(input("Enter a number: ")) if number>0: print("Entered number is positive") elif number<0: print("Entered number is negative") else: print("ENtered number is zero")
2abe0963b90cb70711f8741ee71186b70c3be6fe
bit-shashank/ProjectEulerSolutions
/python/p_023.py
1,087
3.5
4
############################################################# # # # Problem Statement : https://projecteuler.net/problem=023 # # # # ########################################################### # O(sqrt...
8261df0a5d7e0b03d9864de5445a6e5c672b528c
Alexidis/algorithms_basics_py
/main/lesson1/task8.py
572
4.0625
4
# 8. Вводятся три разных числа. Найти, какое из них является средним (больше одного, но меньше другого). def main(): (a, b, c) = input('Введите три числа ').split() (a, b, c) = (float(a), float(b), float(c)) avg = 0 if a < b < c or c < b <a: avg = b elif b < a < c or c < a < b: avg...
de2e775f6f4213d868bc7051c822826658eafd5b
DanMayhem/project_euler
/002.py
774
3.734375
4
#!python """ Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued t...
fbd7976b1a677a94855cc20a75e425d1a1c7daba
CCreek96/UT-coursework
/CS313E/Graph.py
10,463
3.71875
4
# File: Graph.py # Description: Graph class # Date Created: 4/24/18 # Date Last Modified: 4/27/18 class Stack (object): def __init__ (self): self.stack = [] # add an item to the top of the stack def push (self, item): self.stack.append ( item ) # remove an item from the top of ...
065ec36d918e2c00f3b6f6f161e41771727e69aa
FyzHsn/data_structures_and_algorithms
/algorithms/sort_stack.py
717
4.09375
4
from collections import deque def insert_at_bottom(s, element): if len(s) == 0 or element >= s[-1]: s.append(element) else: top = s.pop() insert_at_bottom(s, element) s.append(top) return def sort_stack(s): """Time Complexity: O(n^2), Auxilary Space Complexity: O(n)""...
517e65b59a2fc96a7bca42e9e6de7007cddf5eee
cuitianfeng/Python
/python3基础/6.Python修炼第六层/13 requests模块(url请求).py
17,424
3.578125
4
基本GET请求(headers参数 和 parmas参数) \1. 最基本的GET请求可以直接用get方法 response = requests.get("http://www.baidu.com/") # 也可以这么写 # response = requests.request("get", "http://www.baidu.com/") \2. 添加 headers 和 查询参数 # 如果想添加 headers,可以传入headers参数来增加请求头中的headers信息。如果要将参数放在url中传递,可以利用 params 参数。 import requests kw = {'wd':'长城'} headers ...
4eddf5e555fe8417cb559436dfa364bef1af8421
ron-weasley/python-practice
/basic/010time.py
573
3.828125
4
import time, datetime from datetime import datetime, date, timedelta from time import sleep dt = date.today() - timedelta(5) print("Current Date :", date.today()) print("5 days before Current Date :", dt) print(datetime.fromtimestamp(int("1284105682")).strftime("%Y-%m-%d %H:%M:%S")) start = time.time() for ...
b16fca6e6407bbafae36dca1ed1c8f42c1e1fde4
jiangjiang0727/homework
/hw04/main.py
812
3.90625
4
class Rectangle(object): def __init__(self,length,width): self.length=length self.width=width def area (self): return self.length*self.width class Square(Rectangle): def __init__(self, width): self.length=width self.width=width class Ellipse(object): π=3.1415926 ...
5ec73722d3d8371217e0631f091915f8d800fcd8
raamav/BisectionSearch_Example
/guessing_game.py
1,044
4.375
4
""" @author: ramavishwanathan """ """ The program works as follows: you (the user) thinks of an integer between 0 (inclusive) and 100 (not inclusive). The computer makes guesses, and you give it input - is its guess too high or too low? Using bisection search, the computer will guess the user's secret number! """ ...
f8cf9474c03c3e88c16830be6ec2db78f375aa99
kunalJa/leetcodeforces-etc
/LeetCode/medium/713_subarray_product_less_than_k.py
1,223
3.78125
4
""" https://leetcode.com/problems/subarray-product-less-than-k/ Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. """ """ Accepted Time Complexity: O(n) Space Complexity: O(1) Solution Explanat...
0c90dc6b8dd5f28319df11ebbd22fb966616baa5
abeelashraf98/pgm-lab-abeel
/CO1Pg5.py
256
3.765625
4
n=[] s=int(input("Enter a limit:")) print("Enter values") for i in range(0,s): n.append(int(input())) print("list values") print(n) print("The list after assigning:") for i in range(0,len(n)): if n[i]>=100: n[i]="over" print(n)
b26578cac25ae1c680ef24f889e667f5414e18c2
drewbrew/advent-of-code-2019
/day06.py
1,287
3.5
4
with open('input6.txt') as infile: lines = [line.strip().split(')') for line in infile if line] def parse_graph(inputs): input_map = { source: dest for dest, source in inputs } return input_map def dist_to_center(graph, node, dist=0): orbiting = graph[node] dist += 1 if orbitin...
468f8b661b701f7c85fa43979edae7049a692ad3
GeorgeFan444/GUI
/gui3.py
2,836
4.40625
4
# import everything from tkinter module from tkinter import * # creating the expression variable for later, displaying any button press expression = "" root = Tk() root.configure(background="light grey") root.title("Basic Calculator") root.geometry("444x666+4+8") # StringVar() is the variable class #...
07cf5f4d96e6057f5f7de1874da6de4f316c2059
LeonardoMancilha/Seno-Cossente-e-Tangente
/desafio18.py
398
3.828125
4
import math ângulo = float(input('Digite o valor do ângulo: ')) seno = math.sin(math.radians(ângulo)) print('O seno do Ângulo {} é de {:.2f}'.format(ângulo, seno)) cosseno = math.cos(math.radians(ângulo)) print('O Cosseno do Ângulo {} é de {:.2f}'.format(ângulo, cosseno)) tangente = math.tan(math.radians(ângulo)) print...
a13835f8632433fd6f6af554e03493dfc70895f6
lcgly123/leetcode
/239. Sliding Window Maximum.py
1,271
4.125
4
239. Sliding Window Maximum Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. Example: Input: nums = [1,3,-1...
df7ef0137f1ad9465507c94a45fa01cf5eecddb7
vsmolyakov/euler
/p019.py
433
4.03125
4
#How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? import datetime def p019(): res = 0 for year in range(1901, 2001): for month in range(1, 13): if datetime.date(year, month, 1).weekday() == 6: res += 1 r...
5436f363205809c8f0478b832470620ab8b029d3
joonholee95/Sibu-taikai
/sibu/sample_programs/python/파이썬/C090103/306304300314275343300300277353_300332267341261270301266_260255300307274322275272/filteringEx.py
1,261
3.59375
4
# 필터링 : 리스트 컴프리헨션(list comprehension) li = [1,10,23,11,-21, 4,-11, -3, 5] # list comprehension print([ n for n in li if n > 0]) print([n for n in li if n<0])# 음수만을 출력하는 필터링 plus_number = (n for n in li if n>0) for x in plus_number: print(x) # filter() 이용 : filter() 함수는 iterator를 생성한다. li_1 ...
241a148ec26bd8608a22860f89a3ae010c4fd178
eggeggmaybe/New-to-programming-engineering
/multiplylist_test.py
389
3.515625
4
import unittest from jsoncsvgenerator import multiplylist lst = range(1, 11) class TestUsermaker(unittest.TestCase): def test_length(self): # test if list length is equal to the input self.assertAlmostEqual(len(multiplylist(lst, 3)), 10) # test if the output is equal to the expect...
a2583432a2244f6e1ca7082e41f3b51209e6c307
ronj1901/ICS_32
/practice code/guessing_game.py
618
4.25
4
""" this is a simple guessing game using python """ # this whole section deals with modules , library import random #print(random.randint(0,100)) # generates the random numbers from o to 100 ### guessing game # we are going to use if else and random compGuess = random.randint(0, 50 ) while True: userGues...
3f950fc272da79c75195ec4e2d659858ead4ade4
Warble13/evil
/rockpaperscissors.py
3,693
4.375
4
from random import randint def user_choice(computerscore, userscore, drawscore): """ Takes the user input and returns it. Arguments: - computerscore (int): How many times the computer has won. - userscore (int): How many times the user has won. - drawscore (int): How many times a draw has occ...
8d94f1366e0b4fd816e1e5a6c9e1680ccf70acf8
manuswath/PythonWork
/Basics/Iterator.py
391
4.34375
4
#Object mytuple = ("apple", "banana", "cherry") myit = iter(mytuple) print(next(myit)) print(next(myit)) print(next(myit)) #string mystr = "banana" myit = iter(mystr) print(next(myit)) print(next(myit)) print(next(myit)) print(next(myit)) print(next(myit)) print(next(myit)) #looping thru an Itera...
1f741f9cc01ad6c6624ca9726840f709576cdcbc
jpowellstm/Text-Based-Adventure
/text_based_adventure_8.py
3,257
4.21875
4
""" This is part of a series of files that builds up a text based adventure programme based on https://projects.raspberrypi.org/en/projects/rpg. The rest of the files can be found at https://github.com/jpowellstm/Text-Based-Adventure This file will add functionality for the get function to allow us to collect items an...
0c2aeb32026e90c9c4c2d7ca04df62f6181437d0
pronob1010/Data_Science_Project_with_Edu_data
/problem solve/venv/hackerRank-2.py
189
3.828125
4
lst = [] n = int(input("Enter number of elements : ")) for i in range(0, n): ele = [input(), int(input())] lst.append(ele) data = lst print(data) data.sort(lst.sort()) print(data)
379881c08e6dec3324b202ad62acd5abcc9c6086
JosephHerzog/My-Python-Examples
/Shapes Simulation/custom_program.py
4,611
3.703125
4
# Write your code here :-) from three_shapes_game import * import random class Bacteria: def __init__(self, wid, hei): self.size = random.randint(20,30) self.x = random.randint(0+self.size+10,wid-self.size-10) self.y = random.randint(0+self.size+10,hei-self.size-10) self.x_velocity ...
70d1ac0f588b328d90c59bcc58cc20c07609070f
hakunamatata0314/leetcode_python
/array/33搜索旋转排序数组.py
1,650
3.578125
4
''' 33. 搜索旋转排序数组 假设按照升序排序的数组在预先未知的某个点上进行了旋转。 ( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。 搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回 -1 。 你可以假设数组中不存在重复的元素。 你的算法时间复杂度必须是 O(log n) 级别。 示例 1: 输入: nums = [4,5,6,7,0,1,2], target = 0 输出: 4 示例 2: 输入: nums = [4,5,6,7,0,1,2], target = 3 输出: -1 来源:力扣(LeetCode) 链接:https://leetcode...
780e56b3a067f0a285767c0ac4032ad27e3b4260
faltad/aoc
/day1/part1.py
2,673
3.953125
4
def substract_lowest(values, f_direction, s_direction): if values[f_direction] > values[s_direction]: return f_direction, values[f_direction] - values[s_direction] return s_direction, values[s_direction] - values[f_direction] def calc_distance(d, starting_position="north"): #first get a clean inpu...
3a445d692e307240b56b38c4e39fd6acd4b88cc2
shoucheng0/spmcmm
/simpleDataImporter.py
1,101
3.578125
4
import numpy as np class SimpleDataImporter: """ Simple class which import csv data with the :class:`numpy` function :func:`numpy.loadtxt`. """ def __init__(self, i_file_name, i_delimiter=' '): self._data = np.array([]) self.read_table(i_file_name, i_delimiter) # ----------------...
4907ef063a7cef1731b42acc6193a72f3b99be4d
ardeiuconstantin/GitDemo
/pythonDemo/loops.py
446
3.859375
4
greeting = "Good morning" if greeting == "Morning": print(" Conditions matches") print("second line") else: print("conditions do not match") print("if else condition code is completed") # for loop obj = [2, 3, 5, 7, 9] for i in obj: print(i*2) # sum of first natural numbers 1+2+3+4+5 sum1 = 0 for j ...
8af6f1fdac2f2475583392cdb273e93fbba5ccf5
hkamra/Python
/python-masterclass-udemy/datesanddatetime/timechallenge.py
1,675
4.625
5
# Create a program that allows a user to choose one of # up to 9 time zones from a menu. You can choose any # zones you want from the all_timezones list. # # The program will then display the time in that timezone, as # well as local time and UTC time. # # Entering 0 as the choice will quit the program. # # Display the...
4c6fe0618aae1a49d413aeb25e89617fc4e90050
EduardoLovo/Estudo-Python
/ex020.py
532
3.9375
4
# O mesmo professor do desafio 019 quer sortear a ordem de apresentação de trabalhos dos alunos. Faça um programa que leia o nome dos quatro alunos e mostre a ordem sorteada. from random import shuffle a1 = input('Digite o nome do primeiro aluno: ').title() a2 = input('Digite o nome do segundo aluno: ').title() a3 = i...
461bdbfd64dd03605bf9a247a2eb51a1d14bc556
commanderkid/edx
/Paying Debt Off in a Year.py
1,997
4.46875
4
#Now write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months. By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each month. #In this problem, we will not be de...
e289a04bdd1b93bc4f1b83ce266842a1fabb7ad0
Spuntininki/Aulas-Python-Guanabara
/ex0051.py
406
3.578125
4
#Progressão aritimetica n = int(input('Insira o primeiro termo da progressão aritimetica: ')) r = int(input('Insira a razão da progressão: ')) soma = n + r print('\033[1;32mSegue a Progressão aritimetica:\033[m') print('({}'.format(n), end=',') for c in range(1, 10): if c == 9: print('{}'.format(soma), end...
189d7100afbb71677af66c926dfb9ac5bcdafd17
StRobertCHSCS/fabroa-Alex-224
/Working/ClassExamples/2_1_1.py
150
3.78125
4
has_dog = True print("Do I have to walk the dog?") # The print on line 8 ONLY happens if # hasDog is True. if has_dog: print("Yup, I sure do!")
1bb5550137893e1abc1bf6dd6a9fb3723bce7b0d
lxh1997zj/Note
/廖雪峰python3教程/廖雪峰python3基础部分/LXF_map_reduce0301.py
561
3.6875
4
# -*- coding: utf-8 -*- from functools import reduce def str2float(s): n=s.index('.') # 找出小数点位置 s=s[:n]+s[n+1:] # 去除小数点,因为pop无法在str使用 return reduce(lambda x,y:x*10+y,map(int,s))/(10**len(s[n:]))# 先取整再除以10的次方让小数点归位 # 测试 ...
3fbb2d20e961cae5c02dc324ebf9fbe41e7698d3
ajgrinds/adventOfCode
/2021/algorithms/dates.py
257
3.5625
4
import datetime def days_between(d1, d2): if isinstance(d1, str): d1 = datetime.datetime.strptime(d1, "%Y-%m-%d").date() if isinstance(d2, str): d2 = datetime.datetime.strptime(d2, "%Y-%m-%d").date() return abs((d2 - d1).days)
7ba55d30fb796545008197c93efc1e1e1a030746
Outfenneced/mesa
/python/classes.py
13,952
3.515625
4
import json from datetime import datetime, date, time, timedelta class CalendarSet: """ Set of user calendar data, used to determine whether attendees are available at a certain time. """ def __init__(self, calendar_list): self.calendar_list = calendar_list def is_required...
e85340875c3cc2b15b09f18629c80d77f05b5256
ehalt/pp2nd
/problemsolving/python/skproblem1.py
120
4.125
4
num = int(input('Enter a number to check even or odd: ')) if (num % 2) == 0: print('True') else: print('False')
6f51950e40d7fa14ac50d9a4aae4c853fc74ea2a
vroomgit/P1
/Kar_Multi 20171224.py
2,266
3.875
4
# def karatsuba_product(n1,n2): """ Parameters ---------- n1 : int FIRST NUMBER TO BE MULTIPLIED. n2 : int SECOND NUMBER TO BE MULTIPLIED. Returns ------- INT PRODUCT OF TWO NUMBERS n1 and n2. """ sn1 = str(n1) sn2 = st...
c1e019cbf7980b78e5dfd88c24ddb57f027f60ac
EvertonSerpa/Curso_Guanabara_Python_Mundo01
/Exer_10.py
652
4.25
4
# Exercício Python 10: Crie um programa que leia quanto dinheiro uma pessoa # tem na carteira e mostre quantos dólares ela pode comprar. print() real = float(input('Digite quanto de dinheiro você tem na carteira R$: ')) dolar = real / 5.17 #valor do dolar em 27/07/2021# print('Você pode comprar US$ {:.2f} dolar(s)'.for...
9953436dd8bd2f7880c5f15b4442286295e37809
juhan-tarn/WallBreaker
/week1/sort-array-by-parity.py
709
3.84375
4
class Solution: ''' Approach 1: Use two arrays to record even and odd ''' def sortArrayByParity(self, A: List[int]) -> List[int]: even = [] odd = [] for i in A: if i % 2 == 0: even.append(i) else: odd.append(i) r...
8a30cdbaf3edea100a849000bedb66938b3cb4d9
joeynosharefood/estudos
/Python/Exercicios/89.py
932
3.59375
4
medias = [] temp = [] while True: nome = str(input('Insira o nome do aluno: ')) a = float(input('Insira a primeira nota: ')) b = float(input('Insira a segunda nota: ')) ms = (a+b)/2 temp = [nome, a, b, ms] medias.append(temp[:]) temp.clear() brk = str(input('Deseja continuar ? ')) if...
3fb48f4f937e600f28a44dbc4ddee8c99e64a409
lancelafontaine/coding-challenges
/hackerrank/algorithms/02-implementation/append-and-delete/python3/append-and-delete.py
653
3.625
4
def append_and_delete(s, t, k): # Determine number of identical prefix characters num_prefix_chars = 0 for i in range(len(s)): if s[i] == t[i]: num_prefix_chars += 1 else: break # delete suffix characters from s nums_chars_to_delete = len(s) - num_prefix_char...
36647c4c6b373daef30e1a6b446895359b5a784a
SydorenkoArtem/Practice-in-group
/Practice in group/Practice_2.py
400
4.125
4
number = int(input()) star = '*' if number <= 0 or number % 2 == 0: print('Введите другое число') elif number >= 0 and number % 2 != 0: for a in range(1, number + 2, 2): indent = int((number - a) / 2) print(' ' * indent, str(star)*a) for i in range(number, 0, -2): indent_1 = int((n...
a88a39b0c99ec06b1f460888fa707b987381297b
wmm98/homework1
/视频+刷题/第二到三章/拆分数字.py
116
3.578125
4
num = int(input()) ab = num // 100 cd = num % 100 if num == (ab+cd)*(ab+cd): print("1") else: print("0")
5f60943a9988be30d9fad34766a1646e9212a607
Upsurge-11/Python_Programming_Journey
/18_sets.py
1,172
4.3125
4
utensils = {"Spoon", "Fork", "Knife", "Knife", "Knife"} utensils.add("napkin") # Adds the element in the set. utensils.add("Kadhai") utensils.remove("napkin") # Removes the element from the set. for x in utensils: print(x) utensils.clear() # Removes all the element from the set. for x in utensils: ...
d2477e639eb3af93e053a9a1bb95dc640250d96c
ECGonzales/Pythonpractice
/numpypractice.py
5,939
4.03125
4
# https://docs.scipy.org/doc/numpy-dev/user/quickstart.html # My worked through notes import numpy as np from numpy import pi from numpy import newaxis a = np.arange(15).reshape(3,5) print a #If want to run in a code must use print statement. print a.shape print a.ndim a.dtype.name #If running in c...
b948e11a4b50ff21337917b8c909eca271382369
Kaciras/leetcode
/easy/Q268_MissingNumber.py
334
3.765625
4
from typing import List class Solution: def missingNumber(self, nums: List[int]) -> int: """只缺失一个数的话可以直接减出来""" return len(nums) * (len(nums) + 1) // 2 - sum(nums) if __name__ == '__main__': print(Solution().missingNumber([3,0,1])) print(Solution().missingNumber([9, 6, 4, 2, 3, 5, 7, 0, 1]))
967500ea47b65dabb6b35ae84e6af535acb86133
Cornejo99/Tarea_05
/TAREA005.py
5,116
3.53125
4
#Autor: Ricardo Cornejo Lozano #Programa que contiene 7 programas para escoger. Entre este programa podras dibujar figuras geometricas, aproximarPi, imprimir piramides de numeros y calcular cuantos numeros de pueden dividir entre 17. import random from math import* import math import pygame ANCHO = 800 ALTO = ...
0daae96982922d9c0aeadd29db5c31fcfba817c5
Gabrielatb/Interview-Prep
/leetcode/company specific problems/Amazon/OOD/deck_cards.py
3,944
3.953125
4
# https://en.wikibooks.org/wiki/Think_Python/Inheritance#Decks # Design data structures for generic deck of cards. # Lets assume that the deck is a standard 52-card set #52 deck of card: spades(13, black), clubs(13,black), hearts(13, red), # diamond(13,red) #Encoding for Suits # Spades ----> 3 # Hearts ----> ...
1f5ffcd3d6ca60d0d791b5308d317e0185a98552
raheemtaha11/python
/Chapter_5/536.py
1,896
4.0625
4
import random rock = 2 paper = 3 scissors = 1 you = input("rock, paper, scissors:") bro = random.randint(1,3) x = 0 y = 0 z = 0 if you == bro: print("Draw") z += 1 if (you == rock) and (bro == paper): print("You are rock, the Computer is paper.") print("You lose") y += 1 if (you...
99d44b2b2a2d1cc03c95820a75c31fc72da95695
codeblaster7/TypingSpeedGame
/TypingSpeedGame.py
3,731
3.625
4
from tkinter import * import random from tkinter import messagebox def wordTyper(): global count, typing_words text = "Welcome to Typing Test Game" if count >= len(text): count = 0 typing_words = "" typing_words += text[count] count += 1 font_label.configure(text=typ...
c2e937a45e7e43e5992a6393589dfb8c2a518e0c
dmitry-moroz/python_examples
/e4.py
800
3.546875
4
def pairSum1(arr, k): if len(arr)<2: return arr.sort() left, right = (0, len(arr)-1) while left<right: currentSum=arr[left]+arr[right] if currentSum==k: print arr[left], arr[right] left+=1 #or right-=1 elif currentSum<k: left+=1 ...
5a62c8b0d04eeaae6358fb654225e8e17c0f8a39
gbaranov99/AdventOfCode2019
/Day6/part1.py
2,927
3.84375
4
''' Thought process: I will create a class that has suborbital planets / children, and a parent class, as well as a depth number Planets can be stored in a dictionary, to keep track of all the ones that exist The first planet being the root of the tree of planets When all planets are stored, I will do a search through ...
ccc4ce8580b6c73037621dc2688317b16aac2e57
owenflannagan/Cryptopals-Python
/set2/level15.py
387
3.90625
4
def validate_padding(data): length = len(data) pad = data[length-1] for i in range(ord(pad)): if data[length-1-i] != pad: raise Exception("Invalid padding") return data[:-ord(pad)] def main(): print validate_padding("ICE ICE BABY\x04\x04\x04\x04") print validate_padding("ICE...
95f1fdc208447dbd35b61e871b5a48d06fa33c54
marjoriecarlson/Advent_of_Code
/2b.py
505
3.84375
4
#!/usr/bin/python input = open('input/2.txt','r') lines = input.readlines() input.close() # Only two numbers in each row CAN evenly divide each other. checksum = 0 for line in lines: for currVal in line.split(): for compareVal in line.split(): if currVal != compareVal: # don't divide by itself...
e2f45a9468ea23249a2bb0d82e599c61b4bfcda5
calvinwkchu/Module_Material
/2020-11-03-Files/03-Ins_Dicts/Solved/dictionaries.py
1,488
3.984375
4
import os os.path. # Unlike lists, dictionaries store information in pairs # --------------------------------------------------------------- # A list of actors actors = ["Tom Cruise", "Angelina Jolie", "Kristen Stewart", "Denzel Washington"] acters_2 = actors[0:3] # A dictionary of an ...
1125ae9318cadd78926a30cbd20734983114f906
k3nnet/Machine-Learning-hello-world
/helloWorld.py
675
4.09375
4
#Kgadi Kenneth Mphele #11/1212017 #machine learning hello world equivalent example using classification between oranges and apples . from sklearn import tree #features : weight , texture #label: orange or apple #0 represents bumpy then one for smooth features=[[140,1],[130,1],[150,0],[170,1]] #0 represents apple a...
51222574183013cbf072d30d140b98691da6b57b
yyqAlisa/python36
/Python 基础课/day15.py
2,359
3.65625
4
# list1 = ['a','b','c'] # for i in list1: # print(i) # for i in range(10): # print(i) # for i,j in [(1,2),(2,3)]: # print(i,j) # list2 = [1,2,3,4,5] # for i in list2: # for j in list2: # print(i,j) # 99乘法表 # for i in range(1,10): # for j in range(1,i+1): # print('%s*%s=%-2s'%(j,...
6db6df7afcdfbd071f781c2442b1147dfaea71c4
betessier/E6
/python/python chaine de caractère/tp chaine de caractere exo 5.py
504
3.6875
4
b =str(input("entrez une phrase :")) b = list(b) minuscule = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] majuscule = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] for i in range(0,len(b)): ...
076bc4ec2ad33a585e28ab4cf723e32de3ea09a8
JokerTongTong/Numpy_learn
/3.1将NumPy数组保存成文本文件并装载数组文件.py
883
3.59375
4
''' NumPy常用函数 1.读写文件的函数 2.与数组相关的函数 3.数学与统计分析函数 ''' # 3.1将NumPy数组保存成文本文件并装载数组文件 import numpy as np ''' 将NumPy数组保存成文本文件并装载数组文件 1.savetxt("filename",a,fmt="%d") "filename" -> 保存后的文件名(如:"a.txt")|(可以是路径[如:../../../a.txt]) a -> 被保存的数组 fmt="%d" -> 指定为整数 默认为科学计数法 %.2f 小数...
5dd0e856a5332369ce27047cf0429fe09309e016
Phomint/Upload_GSheets
/model/queries.py
1,672
3.671875
4
import pandas as pd import os.path import shutil class Query(): def __init__(self, query_path): ''' Query is an object that contains a dataframe created by a sql file Args: query_path (str): the path where is storage a sql file. Attributes: dataframe (DataF...
53c9cdae0c264873b1be756ddd1fe077464da854
salpoe/code-guild-labs
/quantify_words.py
831
3.71875
4
from operator import itemgetter import string def quantify_words(text): # new_text = text.replace(".", "").replace(",", "").replace("?", "").replace('"', "")\ # .replace("!", "").replace("-", "").replace(":", "").replace(";", "").lower().split() text = text.lower().replace('\n', '') for p in string.pu...
edaf56667d18f575d452483b400abdfc9bc18ddd
mcguiremichael/Mines
/MineMap.py
10,813
3.75
4
import random import GridSquare import EventSquare import pygame class MineMap: OFFCOLOR = (210, 210, 210) ONCOLOR = (140, 140, 140) BACKGROUNDCOLOR = (0, 0, 0) #each box in the grid is 37 pixels across boxWidth = 39 margin = 1 leftButtonNum = 1 rightButtonNum = 3 debugMode = Fals...
9bfd18fe189cafe5c79f28bbabe172ff9a50a88b
TonySteven/Python
/fibonacci.py
647
3.75
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @Time : 12/1/20 16:50 # @Author : StevenL # @Email : stevenl365404@gmail.com # @File : fibonacci.py import sys class Solution: def fibonacci(self, n): # 生成器函数 - 斐波那契 a, b, counter = 0, 1, 0 while True: if (counter > n): ...
d05d03f5acfa1aeac189bf1b49b3455741cd92a3
ArturKow66/python-hangman
/Topics/While loop/Rich man's world/main.py
168
3.578125
4
start_value = int(input()) interest_rate = 1.071 counter = 0 while start_value <= 700000: start_value = start_value * interest_rate counter += 1 print(counter)
9a50b7d0d26b9d8d851eab4a7cebd3b09063dd75
gavrie/pycourse
/examples/gen_tree4.py
864
3.625
4
tree = ["chapter 1", ["section 1.1", ["paragraph 1.1.1", "paragraph 1.1.2", "paragraph 1.1.3",], "section 1.2", ["paragraph 1.2.1",]], "chapter 2", ["section 2.1", ["paragraph 2.1.1", "...
8224f3c89a15db6d2689d8805584b555b47c6140
jinurajan/Datastructures
/LeetCode/recursion/sum_of_array_with_recursion.py
463
4.28125
4
""" Find the sum of array using recursion 1. Tail recursion 2. non Tail recursion """ def sum_non_tail_recursion(nums): if len(nums) == 0: return 0 return nums[0] + sum_non_tail_recursion(nums[1:]) def sum_with_tail_recursion(nums): def helper(nums, s): if len(nums) == 0: return s return helper(nums...
20230181c7df8dcb9546d62bdfef2dc663b1e470
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/grains/51dedbfd39544b77967dde1a3ed9db1f.py
921
4
4
# This version implements a fun way of caching the outcomes # of the square computations. The idea for the approach was # to compute the values for a square only once and use the # cached values after this. # # This cache implementation does not outperform the code # with only computations though. The implementation t...
656a9a0d7fa016f69616b2a8837c75bc3aa207ed
JosephZYU/Python-3-Advanced
/22.Run Code Concurrently Using the Threading Module_2 (thread pool executor).py
850
3.5
4
import concurrent.futures import threading import time start = time.perf_counter() def do_something(seconds): print(f'Sleeping for {seconds} second(s) ...\n') time.sleep(seconds) print('Done Sleeping ...\n') # 🆕 ThreadPoolExecutor with concurrent.futures.ThreadPoolExecutor() as executor: secs = ...
6635c5d0dc355f652108882b6ff4300f1b06a4ca
Pasquale-Silv/Bit4id_course
/Some_function/kata3_first_character.py
473
3.5
4
def first_non_repeated(s): diz = {} for carattere in s: if carattere in diz: diz[carattere] += 1 else: diz[carattere] = 1 for carattere in s: for k, v in diz.items(): if diz[carattere] == 1: return carattere primo = fir...
f4fe16896fefe48d8735494509396a9a6ad49f66
chadheyne/project-euler
/problem086.py
666
3.625
4
#!/usr/bin/env python from math import sqrt def cuboids(target=1000000): ''' Reference for combinatorial arguments found at: http://www.mathblog.dk/project-euler-86-shortest-path-cuboid/ ''' side_l, count = 2, 0 while count < target: side_l += 1 for side_wh in range(3,...
9fa7312cd5232798a97306f960a68deea6f2f84c
pramithaprasad/python-programming
/Beginner Level/armstrong no between interval.py
245
3.671875
4
n1=int(input("enter the number 1")) n2=int(input("enter the number 2")) for i in range(n1,n2+1): s=len(str(i)) temp=i sum=0 while(i>0): dig=i%10 sum=dig**s+sum i=i//10 if (temp==sum): print(temp)
818500d99dd57c0a56a8df62d20faff2aa35d715
TianyiZhang0315/LeetCodeNote
/4_1.py
397
3.875
4
#1 #字典模拟哈希表 def twoSum(nums, target): print("nums",nums) hashmap={} for i,num in enumerate(nums): print("i=%d"%i) print("map before add",hashmap) if hashmap.get(target - num) is not None: return [i, hashmap.get(target-num)] hashmap[num] = i print("map afte...
83c327543b10b7ce3d9d73dfe2e2559a6816a498
tedwu13/algorithms-python
/Chapter2/kthtoLast.py
365
3.65625
4
def kthtoLast(head, k): if k <= 0: print "invalid k" pointer1 = head pointer2 = head #it is k-1 and not k for i in range(k-1): if pointer2 == None: return None pointer2 = pointer2.next while pointer2.next != None: pointer1 = pointer1.next point...
ec8edbee78186c2f0a599406b7e5f6f650b58c28
yyzz1010/hackerrank
/Shape_and_Reshape.py
94
3.546875
4
import numpy as np arr = input().strip().split(' ') print(np.array([arr], int).reshape(3,3))
32f689e200fbe743373f337148defb56d3aa5189
mycherrylarry/leetcode
/python/python-126/sortList.py
1,374
3.96875
4
#!/usr/bin/env python from unittest import * from util.List import * #print root ''' Description: Time Complexity: Result: Time limit exceeded ''' class Solution: def quickSort(self, head): if head == None or head.next == None: return (head, head) pivot = head head_left = ListNode(-1) ...
40be20db4f16ab52cbc54bc39888cc895ca55277
ZoeHope/Python
/GuessingGame.py
1,050
4.3125
4
print("Hello, you're about to play a Guessing game.") print("I'll give you a hint and you have to guess the word.") print("But, the trick is you have a limit of 3 guesses.") print("ALL THE BEST AND ENJOY!!") secret_word = "money" print("\nHINT: Root of all evil.") guessed_word = "" guess_count = 0 guess_limit = 3 o...
ff1a753f879eeab7a8ba3d9a005b79deada5ee67
Jibinjoychan/luminarpython
/functions/sample.py
320
3.765625
4
def add(): a=10 b=20 print("addition") print((a+b)) add() def mul(): a1=10 a2=20 print("multiplication") print((a1*a2)) mul() def div(): a3=20 a4=10 print("division") print((a3/a4)) div() def sub(): a5=20 a6=10 print("substraction") print((a5-a6)) sub()
474594a4f9671b7d8a2fef1bf80243d68d078d77
JinnieJJ/leetcode
/648-Replace Words.py
1,215
3.625
4
class Solution(object): def replaceWords(self, dict, sentence): """ :type dict: List[str] :type sentence: str :rtype: str """ class Trie: def __init__(self): self.next = {} self.end = False def...
52e5929f6ccbb03f75ea4aba3b6677a6aa513c0d
alessndro/Project-AmstelHaege
/code/algorithms/random_points_ascending_hillclimber.py
3,519
3.671875
4
######################################################################### # random_points_ascending_hillclimber.py # # Minor Programming # # Kiara Evers, Alessandro Degenkamp, Daniel Siha # # Bevat het random ascending hill climber algoritme ########################################################################## f...
a82f9fd888fd9923db23c00ba16511deaec196c0
helenamagaldi/logictest
/testes/teste.py
399
4.09375
4
# recebe um numero e tem que retornar 'true' # se ele for PRIMO, 'false' se não for primo numeroPrimo = input("Please type a numer: ") if numeroPrimo > 1: for i in range (2,numeroPrimo): if (numeroPrimo % i) == 0: print(numeroPrimo, "is not a prime number") else: print(numeroPrimo...
a59fe2c22610fa19a305d1acbf88726a4ab234cc
zhangwei19980131/Python-course
/Tuple.py
624
4.15625
4
numbers = (1, 2, 3) # numbers.__doc__ magic method 魔术方法 # numbers[0] = 10 × 元祖不可变 print(numbers[0]) coordinates = (1, 2, 3) x, y, z = coordinates print(x) print(y) print(z) customer = { "name": "John Smith", "age": 30, "is_verified": True } # 键值对唯一 print(customer["name"]) print(customer.get("birthdat...
54bdd9188e094aa4edf0c031c834f5d2058685ac
chikii/DS-Algo-Competetive
/Tree/Recover BST.py
399
3.5625
4
# 2 values swapped in BST, find those value. def inOrder(self, root): # O(H) if root == None: return self.inOrder(root.left) if self.prv > root.val: if self.swapA == None: self.swapA = self.prv self.swapB = root.val else: self.swapB = root.val ...
a923de29afdfa3b0eaa0467ebf3b1dc6a211cae0
Aneesh540/Competitive
/Python/inorder_preorder_tree_construct.py
1,611
3.859375
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def __str__(self): return str(self.data) def constructTree(inorder, preorder, startIndex, endIndex, current, max_len): if (current > max_len): return None print(...
8e18bf9cc041596acb023cd5d68c0933f432f6cd
hitsumabushi845/Cure_Hack
/addSongInfoToDB.py
1,167
3.65625
4
import sqlite3 from createSpotifyConnection import create_spotify_connection def add_songinfo_to_db(): db_filename = 'Spotify_PreCure.db' conn = sqlite3.connect(db_filename) c = conn.cursor() spotify = create_spotify_connection() albumIDs = c.execute('select album_key, name from albums;') s...
3f0302afd421c126c36baf7f6fa24382b584953e
sage-jordan/cs-module-project-hash-tables
/applications/no_dups/no_dups.py
558
3.75
4
def no_dups(s): newS = s.split(' ') counts = {} newString = '' for word in newS: if word not in counts and word != ' ': counts[word] = word newString = f'{newString} {word}' print(newString) print("newString: ",newString, "here") return newString.strip...
12555330f52c3168681ebf8a996f0ce192602e89
priyankakshetty/tic-tac-toe-python
/src/tictactoe.py
3,960
3.734375
4
from PyQt5.QtWidgets import * from gui import AppWindow class Game(AppWindow): def __init__(self): super().__init__() self.set_comp() #Add action to clickable buttons self.b1.clicked.connect(self.action) self.b2.clicked.connect(self.action) self.b3.clicked.connect...
01dd25415e6335de2f07feb6a050aefcb20ca7b5
vijaychow/vijay
/oddoreven.py
120
3.96875
4
inp=int(raw_input('input number:')) a=inp%2 if a==0: print 'the number is even' else: print 'the number is odd'
544a1dfa12c919f3ca09b5a9b6a8cb4ca64ab550
jmery24/python
/ippython/matrices_251.py
1,171
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sun May 5 08:07:42 2013 @author: daniel """ #programa: matrices_251.py #multiplica una matriz por un numero (miltiplica cada elemento de la matriz #por el numero) #ejercicio 251 #paso 1: Dimension de la matriz y numero m = int(raw_input('Numero de Filas: ')) n = int(raw_input...