blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d432ca2c398593d55593b4946728a3688ee81c4f
Bngzifei/PythonNotes
/学习路线/2.python进阶/day05/06-守护主线程.py
1,161
4.03125
4
""" 守护线程:设置所有的子线程为守护线程,当主线程退出的时候子线程也随之退出.避免了孤儿线程的问题 """ import time import threading # 导入线程模块 def sing(): for i in range(3): print('正在唱歌...%d' % i) time.sleep(1) print(threading.current_thread()) def dance(): for i in range(3): print('正在跳舞...,年龄%d') time.sleep(1) print(threading.current_thread()) # ...
48e4570a83b2d184751339b6434be80e3b87a636
gabriellaec/desoft-analise-exercicios
/backup/user_190/ch149_2020_04_13_19_45_04_778697.py
895
3.890625
4
salario=float(input("salario bruto: ")) dependentes=int(input("numero de dependentes?: ")) if salario<=1045: contribuicao=salario*0.075 elif salario>1045 and salario<=2089.60: contribuicao=salario*0.09 elif salario>2089.60 and salario<=3134.40: contribuicao=salario*0.12 elif salario>3134.40 and salario<=61...
11667c9c09ab76ad34554a654f55fc6629813427
nRookie/python
/mock/mock_weekday.py
770
3.953125
4
import datetime from unittest.mock import Mock import unittest # Save a couple of test days tuesday = datetime.datetime(year=2019, month=1, day=1) saturday = datetime.datetime(year=2019, month=1, day=5) # Mock datetime to control today's date datetime = Mock() def is_weekday(): today = datetime.datet...
ad7f68956c90d8f31ce3793801aca9478d76d641
anmol/algorithm_python
/leetcode/arrays/remove_dupes_from_sorted.py
293
3.796875
4
#!/usr/bin/env python3 def remove_duplicates(nums): count = 0 for i in range(len(nums)): if nums[i] != nums[count]: nums[count+1] = nums[i] count += 1 return count+1 if __name__ == '__main__': print(remove_duplicates([0,0,1,1,1,2,2,3,3,4]))
aee31e75a41b0b0bea86c239ae5207129ba1140a
KonnyLiz/python
/Python2/funciones/areas2.py
1,014
4.125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # clase base class TipoOperacion(object): def __init__(self): self.base = 0 self.altura = 0 self.radio = 0 def cargar_base(self): self.base = float(raw_input("Base:")) def cargar_altura(self): self.altura = float(raw_...
e987e3de6b96aecb4a0baef22a8382aac5176a1d
hyonzin/exercism-python
/meetup/meetup.py
845
4.21875
4
from datetime import date _weekday = { "Monday" : 0, "Tuesday" : 1, "Wednesday": 2, "Thursday" : 3, "Friday" : 4, "Saturday" : 5, "Sunday" : 6, } def meetup_day(year, month, day_of_the_week, which): day = 1 week = date(year, month, 1).weekday() _week = _weekday[day_of_th...
fbaff9a9d2d6bee4f961ee30c065a27b55450fab
2001128/p1805
/08day/04-猜数字.py
330
3.640625
4
import random number = random.randint(1,100) i=0 while i<10: # pc = random.randint(1,100) py = int(input("请输入您猜的数:")) if number < py: print("猜大了") elif number > py: print("猜小了") elif number == py: print("大吉大利,今晚吃鸡") break i+=1
7b5da011d75587bea7de18b426e4d17789aca589
jonasmatu/GalaxyBarFormation
/montecarlo.py
1,676
3.890625
4
import numpy as np import matplotlib.pyplot as plt import galaxy as g def simulate_errors(x, y, yerr, N=1000): """Monte Carlo simulation to estimate the errors. Args: x (np.array): array of the x values y (np.array): array of the y values yerr (np.array): array of the errors of the y v...
cb0ad6f17019d4133e55d2a47bf19044d65b5b40
KristofferFJ/PE
/problems/unsolved_problems/test_655_divisible_palindromes.py
366
3.65625
4
import unittest """ Divisible Palindromes The numbers $545$, $5\,995$ and $15\,151$ are the three smallest palindromes divisible by $109$. There are nine palindromes less than $100\,000$ which are divisible by $109$. How many palindromes less than $10^{32}$ are divisible by $10\,000\,019\,$ ? """ class Test(unittes...
801ce4edfa25186798d4630dad96fd9c04be68f1
AlexEngelhardt-old/courses
/Data Structures and Algorithms/02 Data Structures/Week 1 - Basic Data Structures/x5_max_sliding_window.py
2,184
3.96875
4
from collections import deque def max_sliding_window_naive(sequence, m): maximums = [] for i in range(len(sequence) - m + 1): maximums.append(max(sequence[i:i + m])) return maximums class QueueWithMax: """To be able to use the linear-time max() operation from exercise 4, we need to use stac...
b20e73be71242c410aefcf0825520625f2158601
MiekoHayasaka/Python_Training
/day0210/tk1.py
306
3.765625
4
import tkinter as tk root=tk.Tk() root.title('My Window') # windowタイトルを設定 root.geometry('600x400') #windowの大きさを設定 # 文字出力のためのラベルを作成 label = tk.Label(root,text='Hello World!',font=('Arial',50)) # labelを配置 label.place(x=100,y=100) root.mainloop()
4779fe8001e34f7e344264905aa2ac552dceb478
R-Sg/Learn-Python
/p10.py
464
3.90625
4
""" Question 10: Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically. """ # Taking input from console. input_string = raw_input("Write sequrnce of word: ") # Spliting a given string. string1 = input_stri...
3c289ee68351b9b4e27a495a26191ced0e305e0a
danielor/Structures
/test/QueueTest.py
1,408
3.671875
4
import unittest from ds.linear.Queue import Queue class QueueTest(unittest.TestCase): """ A function that unit tests the Queue """ def _build(self): """ A function that builds a queue """ q = Queue() q.enqueue('A') return q def test...
835dfc815d17494bd930bf83408abd3b7df8c7e6
syurskyi/Python_Topics
/070_oop/004_inheritance/examples/super/Python Super/002_ Single Inheritance.py
3,247
4.21875
4
# Python super function is a built-in function that returns the proxy object that allows you to refer parent class by # super. The super function in Python can be used to gain access to inherited methods, which is either from # the parent or sibling class. # Python super() builtin function returns a proxy object, a s...
ae5df47397c03a962a1670428828d24eea542f00
nickVenuti/packages
/pythonForFinance/data_structures.py
2,130
3.625
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 31 10:18:27 2015 @author: nmvenuti """ ''' Numpy Tutorial/Walkthrough Python For Finance ''' import numpy as np #Creating an array a=np.array([0,0.5,1,1.5,2]) #check type of a type(a) #index 2nd item through fourth item a[1:4] #Built in numpy fu...
e338f1714a8069a05db2b6e02af5fc157587b1b3
Raylow00/OpenCV-Tutorials
/2_Opencv_image_processing/2_geometric_transformation.py
5,679
3.9375
4
import cv2 import numpy as np import matplotlib.pyplot as plt # This function shows an image using the matplotlib functionality def show_with_matplotlib(color_img, title): # pos - position in the figure plot # First convert the BGR image to RGB rgb = color_img[:, :, ::-1] # all items in the array, reverse...
ee88114817fcf8752e0ad69d8e5265a543db2e4a
mahatmaWM/leetcode
/leetcode/editor/cn/917.仅仅反转字母.py
1,372
3.609375
4
# # @lc app=leetcode.cn id=917 lang=python3 # # [917] 仅仅反转字母 # # https://leetcode-cn.com/problems/reverse-only-letters/description/ # # algorithms # Easy (55.19%) # Likes: 46 # Dislikes: 0 # Total Accepted: 13.1K # Total Submissions: 23.7K # Testcase Example: '"ab-cd"' # # 给定一个字符串 S,返回 “反转后的” 字符串,其中不是字母的字符都保留在原地...
4a3b9e0d629f932a76089b55af3b539667a99c0e
rahul-pa/E-Mail-Scraping-Basic-Project
/E-Mail Scraping (Basic Project).py
281
4.0625
4
import re text = "Hello my name is Rahul panchal. My Fature Wifr Name Is vaishali Panchal. and My email Adress Is rp645470@gmail.com. and my second email is rahulsocial143@gmail.com" search = re.compile("[a-zA-Z0-9]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]+") find = search.findall(text) for email in find: print(em...
27ae4a33e582523d9689c0405d3b651bb5989b7c
alphadose/Optum-Stratethon
/main.py
1,132
3.609375
4
import download import reformat import normalise import features import model import performance import dataset if __name__ == "__main__": # We begin by downloading the data. The data will be in the form of # "events" data: each datapoint for each patient will be a recorded event. X, Y = download.download(...
8cee4d23cb8873b099575784fdda00795d6930df
Shaunwei/Leetcode-python-1
/LinkedList/RotateList/rotateList.py
1,319
3.828125
4
#!/usr/bin/python """ Rotate List Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. """ from sys import path as path1; from os import path as path2 path1.append(path2.dirname(path2.dirname(path2.abspath(__fil...
82ee6bcb64f29c285d4fc12a70bd1bac72e8b526
Keegan-Cruickshank/CP1404
/prac_06/languages.py
511
3.828125
4
from prac_06.programming_language import ProgrammingLanguage ruby = ProgrammingLanguage("Ruby", "Dynamic", True, 1995) python = ProgrammingLanguage("Python", "Dynamic", True, 1991) visual_basic = ProgrammingLanguage("Visual Basic", "Static", False, 1991) languages = [ruby, python, visual_basic] dynamic_typed_language...
2b22736255c635251ddb7c355f7cb5d81956cbbd
serlaluz/pwp-capstones
/TomeRater/TomeRater.py
5,308
3.859375
4
class User(object): def __init__(self, name, email): self.name = name self.email = email self.books = dict() def get_email(self): return self.email def change_email(self, address): self.email = address print("Your email address has been updated") def __...
a9cd3fcb621caf354e5997031bf01833d1dbb6c3
ChuixinZeng/PythonStudyCode
/PythonCode-FatherandSon/示例代码/Listing_16-10.py
676
3.65625
4
# Listing_16-10.py # Copyright Warren & Carter Sande, 2013 # Released under MIT license http://www.opensource.org/licenses/mit-license.php # Version $version ---------------------------- # display a beach ball image in a pygame window import pygame, sys pygame.init() screen = pygame.display.set_mode([640,480]) scr...
a5e757563f12ea0fc8698b640d6767b6a4ed71be
swarna123sh/Advanced-Calculator
/main.py
3,849
3.859375
4
import math from tkinter import * import cellpad #Tkinter instance setup window=Tk() window.title("Advanced Calculator") window.geometry('600x600') cellpad.cellpad(window) #Getting the inputs lbl=Label(text="Enter the first number", font=("Arial Bold", 30)) lbl.grid(column=0, row=0) txt = Entry(window,width=10) txt...
2f484312c3bce96c92d3521fd10c0ff44af15445
divyacnair/HelloRepo
/sum.py
131
3.6875
4
#!/usr/bin/env python a = int(raw_input("Enter first Number:")) print type(a) b = int(raw_input("enter a number")) c= a+b print c
86d96e1ef97f237ca5bcad7c2f7a1818d4f1aac7
AlinGeorgescu/Problem-Solving
/Python/1656_design_an_ordered_stream.py
579
3.5
4
#!/usr/bin/env python3 from typing import List class OrderedStream: def __init__(self, n: int): self.ptr = 1 self.chunk = [None] * n def insert(self, idKey: int, value: str) -> List[str]: if idKey == self.ptr: oldPtr = self.ptr while self.ptr < len(self.chunk...
24a46fa1142c7bc2b248e44389296972077a0686
TatiRad/calc
/history.py
329
3.546875
4
def h(x): f = open('history.txt', 'r') for line in f: print(line , "\n") def listadd(x,y,s,z): f = open("history.txt", mode="a+") lst = [x,s,y,z] lst.insert(3, '=') result = "".join(str(lst)) f.writelines(result) f.write("\n") ...
ca08271292cd3e39757dae0f5c662f4eacc98e2d
Fortune-Adekogbe/python_algorithms
/three_sum.py
1,520
4.03125
4
import itertools, numpy as np def three_sum(s): """ Creates a hash table so that pairs from the set can be checked against other elements in constant time. """ if not isinstance(s, set): s = set(s) triples = set() for pair in itertools.combinations(s, 2): third = -sum(pair)...
3923309ab777df24730d41ce4ec6b4d3d6633ece
Wxianpeng/Python_Exercise
/com/study/sclass/Test1/Questionnaire.py
1,241
3.96875
4
class Survey(): # 收集调查问卷的答案 def __init__(self, question): self.question = question self.response = [] # 显示调查问卷的题目 def show_question(self): print(self.question) # 存储问卷搜集的答案 def store_response(self, new_response): self.response.append(new_response) # 请定义实名调查问卷的新...
6fc14ad67c32a559c10815d3cb020cd8701be776
Aman-Mittal/AmanSTPython
/day 3.2.py
267
4.03125
4
def checkEven(): num1=int(input("Enter a no:")) if num1%2==0: print(num1, 'is even') return None def checkOdd(): num1=int(input("Enter a no:")) if num1%2==1: print(num1, 'is odd') return None checkEven() checkOdd()
da1d184fe0e696c296c9bccd3449726839bb9bd7
Bukacha88/softuni_python_fundamentals
/list_basics_exercise/03_football_cards.py
466
3.59375
4
cards = input() list_of_cards = list(cards.split(" ")) list_of_cards = list(dict.fromkeys(list_of_cards)) is_terminated = False team_a = 11 team_b = 11 for char in list_of_cards: if 'A' in char: team_a -= 1 elif 'B' in char: team_b -= 1 if team_a < 7 or team_b < 7: is_ter...
cd355bc46982d2bcc259898e99d09c603826b160
nayan5565/PythonFirstProject
/ErrorHandle.py
331
3.890625
4
a = 5 b = 2 try: print('resource open') print(a / b) k = int(input('Enter a number')) except ZeroDivisionError as e: print('you can not divide number by zero', e) except ValueError as e: print('Invalid input', e) except Exception as e: print('Something went wrong', e) finally: print('resour...
0a0e02c9440aaec301224e00727db9c1f6bb9ace
vsdhanya/guvi
/codekata/num between range or not.py
110
3.796875
4
no=int(input()) num1,num2=map(int,input().split()) if no>num1 and no<num2: print("yes") else: print("no")
9ee9b03b883e8e33465b44ef22a2cfa283ad4381
xiaole0310/leetcode
/572. Subtree of Another Tree/Python/Solution.py
568
3.625
4
class Solution: def isSubtree(self, s, t): """ :type s: TreeNode :type t: TreeNode :rtype: bool """ def is_same(s, t): if s is None and t is None: return True if s is None or t is None or s.val != t.val: return ...
660649c1a4f50dd32d8f05a24c3940376e22e6e0
kumbhar-p/backup
/python_trainning/python/py_programs_assisment/ass4.py
216
4.0625
4
num1 = input("enter number of rows : ") num2 = input("enter number of columns : ") num3 = [[0 for c in range(num2)] for r in range(num1)] for r in range(num1): for c in range(num2): num3[r][c] = r * c print num3
4ccf9483b9285309e53bad6d76744ffa7471ed2a
bhargavpirates/Algorithms
/Binary_search.py
527
4.0625
4
def Binary_search(arr,search_num,start,last): arr.sort() while(last>=start): mid=start + int((last-start)/2) if(arr[mid]==search_num): return 1 elif(arr[mid]>search_num): start=0 last=mid-1 else: start=mid+1 las...
9f0b4166731f7bfbef71a5f04efc3a86ca45b9f1
oisinfarrell00/Python
/hangman.py
2,363
4
4
import random import time print("Welcome to hangman") def get_num_attempts(): while True: num_attempts = input("How many attempts would you like? [1-25]: ") try: num_attempts = int(num_attempts) if 0 < num_attempts <= 25: return num_attempts els...
feddd87ddca60b4960e407e4781e263c6ab6accc
sarureddi/index
/index.py
368
4.09375
4
value=['a','b','c','d','e','f'] index=value.index('a') print("the index of a is:"index) index=value.index('b') print("the index of b is:"index) index=value.index('c') print("the index of c is:"index) index=value.index('d') print("the index of d is:"index) index=value.index('e') print("the index of e is:"index) index=va...
e4db2ec0657c203e1f456b660e5193e134dd65f0
Flywoogi/piPy
/ex6.py
288
3.671875
4
# coding=utf-8 print ('수를 입력하세요') a=int(input()) if a>10 : if a % 2 == 0 : print ('10보다 큰 짝수') else: print ('10보다 큰 홀수') else: if a % 2 == 0 : print ('10이하의 짝수') else: print ('10이하의 홀수')
3a4ec57695706fc4771afffaf978f0b67a331cec
silverstand/analisisdatos
/06_subgraficos.py
871
3.53125
4
# %% # Dibujos con subgráficos import numpy as np import matplotlib.pyplot as plt plt.subplot(1, 3, 1) # Tabla 1x3 y dibujaremos en la celda 1 plt.plot(np.random.randint(100, size=[6]), label="Pedro", color="green") plt.ylim(0, 100) plt.legend() plt.subplot(1, 3, 2) # Tabla 1x3 y dibujaremos en la celda 2...
faebffcb45ff0e5c4d3fe3fccb768f0b16692392
bongsuyeon/MultiCampus
/day4/whileLab5.py
356
3.953125
4
while True: word = input("문자열을 입력하시오 :") wordlength = len(word) if wordlength == 0: break elif wordlength >= 5 and wordlength < 9: continue elif wordlength < 5: print("유효한 입력 결과:", "*", word, "*") elif wordlength > 8: print("유효한 입력 결과:", "$", word, "$")
a844ecfa6a4a2d802fba1339981e194a2d5aa24d
Bounnoy/neuralnetwork
/nn.py
10,117
4.125
4
# Bounnoy Phanthavong (ID: 973081923) # Homework 2 # # This is a machine learning program that models a neural network. # Here, we implement a two-layer neural network with one hidden-layer # to perform handwritten digit recognition. # This program was built in Python 3. from pathlib import Path from math import e imp...
6a76eee98e2a303618586c60309b3f534ab2fe51
bblu/algopython
/lang/myclass.py
681
3.671875
4
class C1: def say(self): return 'c1' class C2: def __init__(self,who): self.name=who def say(self): return 'C2' def __str__(self): return 'C2.name=%s'%self.name #take care of the order of base class for search method in parents class C3(C1,C2): def ...
3dd8b33b5669dc7e3a6702bc317f0f9380a8b152
dsulfaro/datastructures
/python/bst.py
3,182
3.671875
4
class Node(object): def __init__(self, val, left=None, right=None, parent=None): self.data = val self.left = left self.right = right self.parent = parent def die(self): if self.data > self.parent.data: self.parent.right = None self = None ...
94e71ec7d2ca95c9aab45dd31cfce4794df884f7
thaus03/Exercicios-Python
/Aula14/Desafio65.py
1,641
4.0625
4
# Crie um programa que leia vários números inteiros pelo teclado. # No final da execução, mostre a média entre todos os valores e qual foi o maior e o menor valor lido. # O programa deve perguntar ao usuário se ele quer continuar ou não a digirar valores. """ resp = '' maior = 0 menor = 0 media = 0 cont = 0 numaux = 0 ...
877da3d0d3e2e25558c001eec64a730d28069b50
MikeyABedneyJr/python_exercises
/challenge1.py
939
4.0625
4
# coding= UTF-8 import datetime name = raw_input('Yo what yo name sucka?\n>') age = int(raw_input('Just how ancient are you?\n>')) rub_it_in_number = int(raw_input('How many times do I need to remind you of the answer?\n>')) now = datetime.datetime.now() """ calculate when a person will be 100 years old by taking the...
496a68245cca73ed2184d46ca5523471d5f6e438
upuphero/pythonlearning
/day8/14.py
46
3.625
4
list1=[1,2,3,4,5] for a in list1: print(a)
83bd0bf1e8164f15d9aa3fae8d5ffe5b3b40d2db
LiamSimons/Matrix_Add_Higher_Order_Polynomials
/main.py
1,178
3.8125
4
indexes = [] extra_col = [] def make_pol(orde, depth): extra = orde - 1 i = 1 while i < orde: add = (orde - i) * depth extra = extra + add i = i + 1 extra_col.append(extra) # print("Extra: " + str(extra)) p = 1 while p < orde: indexes.append(2+p) p...
0ef68f45d0f0f2646b6f4151ceb368bdc415a8ba
CirXe0N/AdventOfCode
/2019/01/puzzle_01.py
271
3.953125
4
import math def calculate_fuel_from_mass(mass: int) -> int: return math.floor(mass / 3) - 2 total_fuel = 0 with open('input.txt') as f: for line in f.readlines(): total_fuel += calculate_fuel_from_mass(int(line)) print(f'The answer is {total_fuel}')
3dd5e39ce7ebd049eed0c064fece4462a921ec56
AP-MI-2021/lab-1-andreigut
/main.py
1,667
4.125
4
''' Returneaza true daca n este prim si false daca nu. ''' from math import sqrt def is_prime(n): if n == 1 or n ==0: return False if n == 2: return True if n == 3: return True if n % 2 == 0: return False for i in range(3, n // 2, 2): if n % i == 0: return False return True '...
22f1d817b2d292a4b3fae09a77e3013b9d45bd31
KurinchiMalar/DataStructures
/Sorting/NearlySorted_MergeSort.py
1,528
4.125
4
#Complexity O(n/k * klogk) = O(nlogk) # merging k elements using mergesort = klogk # every n/k elem group is given to mergesort # Hence totally O(nlogk) ''' k = 3 4 5 9 | 7 8 3 | 1 2 6 1st merge sort all blocks 4 5 9 | 3 8 9 | 1 2 6 Time Complexity = O(n * (n/k) log k) i.e to sort k numbers is k * log k to sort n/...
daa7d8bd1c16aed74319c321041b6ec3056a0745
ysrodrigues/Fund-Prog-2017
/AD1/questao-4.py
1,122
3.90625
4
### Autor: Yuri Rodrigues ### Matrícula: 15213050337 ### Feito em: //2017 ### Descrição: Verifica se um número é perfeito ou não. ###### Fundamentos da Programação ###### ###### 4ª QUESTÃO ###### ###### COMEÇO - FUNÇÕES ###### # Função que verifica se o número e perfeito def isPerfect(number=1): ...
a25f5bda55ef4d859ab9591e7ec6cb2e11dcd1b9
ZeroILumi/Projetos_de_Teste_ver_0.0.1
/Testes_Complexos/Projetos Python/aula6_Zero_ILumi_ver_1.0.py
2,563
3.734375
4
if __name__ == '__main__': conjunto1 = {1, 2, 3, 4, 5} conjunto2 = {5, 6, 7, 8} conjunto_uniao_1_2 = conjunto1.union(conjunto2) print('União do conjunto 1 com o conjunto 2:\n{conjunto_uniao_1_2}' ''.format(conjunto_uniao_1_2=conjunto_uniao_1_2)) conjunto_intersccao_1_2 = con...
d7e5defa3cb8ddf7afe989da1466404868896c13
Kyle-Post-28/Python-Practice
/FuncPrac19.py
896
4.09375
4
#Filename: FuncPrac19.py #Author: Kyle Post #Date: May 14, 2017 #Purpose: Expand off of exercise19.py #and create my own function. For this #I decided to create a function based off #my bartending days. So this function is #for stocking the bar before an event. def alcohol(liquor, beer): print "I have %r b...
e281a9663e51784f6dcd31cf4348575446e8d3ca
dteklavya/Algorithms
/next-bigger.py
5,660
3.6875
4
#!/usr/bin/env python ''' ''' import sys def cat_digits(digits): number = 0 for index, digit in enumerate(digits): number = number + (digit * (10 ** index)) return number def next_bigger(number): digits = [] tail = 1 while(number > 0): number, tail = divmod(number, 10) ...
dd0913ed78474cbbe622652abd4d278269530ed9
AmirK187/learning-python
/pyhtonfolder/timeconvcond1.py
1,169
4.59375
5
#file timeconvcond1.py #useful conversion factors seconds_per_minute = 60 seconds_per_hour = 60*seconds_per_minute #3600 #get user input in seconds seconds = int(input("Please enter the number of seconds: ")) #1st, compute thenumber of hours in given number of seconds hours = seconds // seconds_per_hour #3...
acec79177172b42a72aeaf068f4ae70204a27a8f
satyam-seth-learnings/python_learning
/Geeky Shows/Core Python/117.Aliasing_List[148].py
166
3.65625
4
a=[10,20,30,40,50] b=a print("A:",a) print("B:",b) print("Modifying A:") a[1]=55 print("A:",a) print("B:",b) print("Modifying B:") b[2]=66 print("A:",a) print("B:",b)
079303914dd52d44d05584bb59d7aa749bfb56be
N140191/Hacktoberfest-JKLU
/data/Add.py
180
4.03125
4
count=int(input("Enter how many times you add no.")) first=1 total=0 while(first<=count): num=int(input("Enter the number")) total=total+num first=first+1 print(total)
90a7efb9379b10582e3000fe5dcb1dca3258b867
PragyanSubedi/MNIST-CNN
/Softmax approach.py
1,435
3.671875
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import matplotlib.pyplot as plt mnist = input_data.read_data_sets("MNIST_data/", one_hot = True) single_image = mnist.train.images[1].reshape(28,28) #plt.imshow(single_image, cmap= 'gist_gray') #plt.show() # PLACEHOLDERS x = tf.place...
aa57a4e41dbd1442cb9669f44a2dbf50a7917a0c
MathisPeyronne/Evolve_Swarm_Fireflies
/classes/swarm.py
4,265
3.5
4
from classes.fireflie import Fireflie import numpy as np import pickle import matplotlib.pyplot as plt class Swarm: def __init__(self, DNA): self.DNA = DNA self.time_phrame = 0.01 self.nb_of_fireflies = 40 #Needs to be even. for the 3rd nei...
3a91efe0db0c629dd4465b16d83d0183567df733
samjbasak/advent-of-code-2020
/Day02/day2.py
1,056
3.515625
4
def read_in_file(file_name): with open(file_name, 'r') as f: for item in f: if item != '\n': password_item = item.replace('\n', '') min_val = password_item.split('-') max_val, letter_to_check, password = min_val[1].split(' ') yield ...
22616058bc02ed8f50db767da39bc6fd2ccf568c
domluther/CupheadTextGame
/RSP.py
2,669
4.28125
4
from random import randint def play_RSP(max, player_name, computer_name): options = ["Rock", "Scissors", "Paper"] print(options) prompt = "What would you like to play? Rock, Scissors or Paper \n> " choice1 = "" choice2 = "" score1 = 0 score2 = 0 # Because Rocky will never play paper. if computer_name == "R...
3973fe43d785f2c6a69205a239c631463b5d73fc
Pharoouzy/pyyyyython
/LPTHW/ex3.py
568
4.25
4
# displays a text on the screen print("I'll now count my chicken:") # displays number of Hens on the screen print("Hens", 25 + 30 / 6) # displays Rosters print("Rosters", 100 - 25 * 3 % 4) print("Now I'll count the eggs:") print(3 + 2 + 1 - 5 + 4 % 2 -1 / 4 + 6) print("Is it true that 3 + 2 < 5 - 7?") print(3 + 2 ...
e9bad7f7f3c8492fe84ba66c3dbf52483433a223
rockinbinbin/AI-planning
/robin_mehta_planner.py
5,169
3.546875
4
# Robin # robimeht # AI Homework 4 import sys import utils from collections import deque import itertools import Queue import copy # Iteration limits # Stop your search when you reach these limits FORWARD_LIMIT = 10000 BACKWARD_LIMIT = 10000 # A useful function to get all possible n-permutations of a set of objects ...
7b929f1d09ef591ef76c5832b3c682bb1323a91c
LeBron-Jian/BasicAlgorithmPractice
/剑指offer/PythonVersion/33_二叉搜索树的后序遍历序列.py
3,494
3.5
4
#_*_coding:utf-8_*_ ''' 题目: 剑指offer 33 二叉搜索树的后序遍历序列 输入一个整数数组,判断该数组是不是某二叉搜索树的后续遍历结果。 如果是则返回true,否则返回false,假设输入的数组的任意两个数字 都互不相同。 参考以下这棵二叉搜索树: 5 / \ 2 6 / \ 1 3 示例 1: 输入: [1,6,3,2,5] 输出: false 示例 2: 输入: [1,3,2,6,5] 输出: true 限制: 0 <= 数组长度 <= 10...
3f7468b5a42f69a6ca35040d7c0a141fe8472301
pessman/sudoku_solver
/sudoku.py
2,164
3.78125
4
import os import sys from exceptions import ArgumentNumberError from board import Board class Sudoku: def __init__(self, file_path): self._board = Board() self._file_path = file_path self._values = None @property def board(self): return self._board @property def ...
ca26c50f2b69733d3f83e507035d3b639a6e570f
kristinnk18/NEW
/Skipanir/Lists/listToTuple.py
826
4.59375
5
# Write a function that takes a list as a parameter, # converts every element in the list to an integer and then returns a tuple comprising of these integer elements. # If the function encounters a character such as 'p' that cannot be converted to an integer, # it throws this error message on the screen: "Error. Pl...
82cd2dd2597baa3563ce47ee7a96d6e5b1ac72ad
galid1/Algorithm
/python/leetcode/datastructure/tree/617. Merge Two Binary Trees.py
1,053
4.03125
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def mergeTrees(self, root1: TreeNode, root2: TreeNode) -> TreeNode: if root1 and root2: node = TreeNode(root1.val + root2.val) ...
5c347c61a182e3d0e0fe55842c5acfccca780e67
ch1huizong/study
/lang/py/rfc/06/generator/gen_countdown.py
267
3.984375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- def countdown(n): print("Counting down from %d" % n) try: while n > 0: yield n n -= 1 except GeneratorExit: # 捕获GeneratorExit异常 print("Only made it to %d" % n)
5d5f0dd4f13f7144dffd5932ad3d49324a17808b
Weikoi/OJ_Python
/leetcode/easy/easy 1-200/66_加一.py
580
3.625
4
import time class Solution: def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ str_raw = '' for i in digits: str_raw = str_raw + str(i) int_raw = int(str_raw) int_plus = int_raw + 1 str_plus_list = list...
75408d2b452904b2be5569abab34ef416dc687ea
dantin/python-by-example
/crash_course/ch05/exec/conditional_tests.py
583
3.78125
4
car = 'subaru' print('Is car == "subaru"? I predict True.') print(car == 'subaru') print('\nIs car == "audi"? I predict False.') print(car == 'audi') s = 'value' print('\nIs s == "Value"? I predict False.') print(s == 'Value') print('\nIs s == "Value".lower()? I predict True.') print(s == 'Value'.lower()) i = 100 ...
b5ff139fe649ecfff3f54facc7d97c6aab24dcaf
davidodza/OverTheWire
/VigenèreKeyCracker.py
4,030
3.78125
4
''' This script is for cracking the Vigenère Cipher Krypton Level 3 → Level 4 (http://overthewire.org/wargames/krypton/krypton4.html) Plan 1) Input 2 text files of cipher text. 2) Divide the cipher text into n seperate files where n = key length 3) Frequency analysis of every key space. ''' from collections import Cou...
5852265b4aa1681a59b6144753f1d5e0b9c9f8fd
tainenko/Leetcode2019
/leetcode/editor/en/[1752]Check if Array Is Sorted and Rotated.py
1,573
3.671875
4
# Given an array nums, return true if the array was originally sorted in non- # decreasing order, then rotated some number of positions (including zero). # Otherwise, return false. # # There may be duplicates in the original array. # # Note: An array A rotated by x positions results in an array B of the same # length...
7efb85e7469982957661b5b039ec5da9d856228d
dryabokon/algo
/recurs_03_dropping_eggs_puzzle.py
1,285
3.71875
4
import numpy # You have N eggs, from which floor in a K-floor building you can drop an egg # Determine the minimum number of attempts to find the critical floor in the worst case # ---------------------------------------------------------------------------------------------------------------------- def min_Egg_Attempts...
c0c22c0efb4af60ddfdddcb923bf8b78993999bd
Ting-Shieh/Python_2020y
/io/recv_file.py
429
3.546875
4
""" 接受一個文件 接收一個文件內容,將其寫入到一個文件裡 """ from socket import * s = socket() s.bind(('127.0.0.1',4294)) s.listen(3) c,addr = s.accept() print("Connet from", addr) # 打開文件 filename = './Data/test.jpg' f = open(filename, mode = 'wb') # 循環接收內容,寫入文件 while True: data = c.recv(1024) if not data: break f.write(data) ...
9859774b2da192e3c91f4c2007cace4bf2e15908
gabriellaec/desoft-analise-exercicios
/backup/user_014/ch54_2020_04_12_14_42_47_932052.py
155
3.734375
4
def calcula_fibonacci (n): F[n] = F[n-1] + F[n-2] F[1] = 1 F[2] = 1 for i in n: F[i]= F [i-1] + F[i-2] return F[n].append(F[n])
633a0fb0c44c0c19130d992b80199e37d51f3192
seanxu229/LeetCodeSummary
/Tree/563.py
465
3.859375
4
'''Notes: the tree tilt is the sum of all node tilt!! for each node, tilt is the difference between two subtree total values build a sum function to calculate the sum value''' class Solution: def findTilt(self, root): """ :type root: TreeNode :rtype: int """ self.ans = 0 def _sum(node): if not node: return ...
8b16d85101b28d0cdae284ad84f8841ff3acb57f
ssydyc/Leetcode_python
/Spiral_matrix_II.py
895
3.59375
4
class Solution: # @return a list of lists of integer def generateMatrix(self, n): matrix=[[0 for i in range(n)] for j in range(n)] # generate n*n matrix if n==0: return [] cur_x=0 #starting point cur_y=-1 value=0 while n>0: #go to right for...
1064f069b7e5f80f7ae14e3e059d972b996e12ac
DanielCT20/PythonMadeEasy
/3- Python Dictionaries/OrderedDict-Stuff.py
2,378
4
4
from collections import OrderedDict ### a regular unsorted dict ##seasons = { "Spring": 2,"Winter": 1, "Summer": 3, "Fall": 4} ## ### using an OrderedDIct to Sort by Dictionary Key ##order_by_key = OrderedDict(sorted(seasons.items(), key=lambda s: s[0])) ##print("Order_by_key's type is: ", (type(order_by_key))) ##prin...
2467e3daf8616a2dc9fb3f83b546884618df140c
BlueMoon78/AoC-2020
/day07/bags.py
2,362
3.671875
4
#!/usr/bin/python3 import sys import argparse import os from collections import * def main(): parser = argparse.ArgumentParser() parser.add_argument("inputfile", help="Input file of bag combinations") parser.add_argument("--bag", "-b", help="Type of bag being searched for, e.g. \"shiny gold\" (the def...
b59e0c64c762a5fde3bbe6e2c0443a7e7957fb65
SimonDemeyere/proefexamen
/opdracht01.py
87
3.59375
4
number = int(input("Geef een getal:")) for i in range(1, number + 1): print(str(i)*i)
9809e48a7efbe7447455e8bd136b609c55ddb53c
Vaspe/Coursera_Python_3_Programming_Michigan
/Python_Basics_Mod1/listsAndStrings.py
6,561
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 29 18:20:46 2020 @author: Vasilis """ #%% Definitions """ string: A single variable which is a concatenation of single strings (nubers,letters, symbols, etc,,,). Empty string is also a single character. They are marked with quotes Example: 'I am a string...
4988385d5b1adebbcd8ddbed7d05bd139b22c0e3
DVEC95/PY4E
/Chapter 3 - Conditionals/PY4E_L3_Ex2.py
613
4
4
# Exercise 2: # Rewrite your pay program using try and except so that your program handles non-numeric input gracefully by printing a message and exiting the program. hours = input("Enter Hours: ") try: float(hours) except: print('Error: Please enter a numeric value.') quit() rate = input("Enter Rate: £...
d97f91a9c2519311710de2a9b2629b0ac52dc9fc
romiof/cc1py
/formulaBashkara.py
677
3.875
4
# A, B ,c # deta < 0 não tem raiz ||| delta = 0 tem uma raiz ||| delta > 0 tem 2 raizs import math a = int(input("Informe o valor de A: ")) b = int(input("Informe o valor de B: ")) c = int(input("Informe o valor de C: ")) delta = (b**2) - (4 * a * c) if delta < 0: print("Delta MENOR que zero, impossível calcula...
e8bedf5867b0dd30128c17052fa453e508c3e688
turnerburchard/turnerburchard.github.io
/files/poker.py
4,727
3.671875
4
# -----------------------------------------+ # Turner Burchard | # CSCI 127, Program 2 | # Last Updated 9/21/2020 | # -----------------------------------------| # Simplified Poker Hand evaluation system. | # -----------------------------------------+ def ...
4a9c85cb7aa4c456097e0488974b3b352b718dd3
guilhermeklai/exercices-python
/ex2.py
312
3.828125
4
#EXERCÍCIO DE MEDIA n1 = float(input('Digite o primeiro número: ')) n2 = float(input('Digite o segundo número: ')) n3 = float(input('Digite o terceiro número: ')) n4 = float(input('Digite o quarto número: ')) print(n1) print(n2) print(n3) print(n4) soma = n1 + n2 + n3 + n4 media = soma / 4 print(media)
9a55f924093561691d84d5f079b4dd07f0fed8f7
pankaj307/Data_Structures_and_Algorithms
/LinkedList/mergeSortedLinkedLists.py
2,068
3.78125
4
import my_LinkedList # # Space: O(n) def merge(l1,l2,mergedList): currentFirst = l1.head currentSecond = l2.head while True: if currentFirst is None: while currentSecond: mergedList.insert(currentSecond.data) currentSecond = currentSecond.next...
1fa0ebd8aaa7e79892b39f6d0058102fdc380514
PontusSven/python-course
/basics/lists.py
283
3.859375
4
my_list = [1,2,3,4,5] mixed_list = ["hello", 1, "World", 4] len(my_list) # concat list total_list = my_list + mixed_list letter_list = ['a', 'c', 'y', 'r', 'b'] letter_list.append("g") print(letter_list) letter_list.pop() print(letter_list) letter_list.sort() print(letter_list)
899679e2750d719a392bb05b5ac289e113675c45
CalvinNeo/LeetCode
/python/leetcode.105.py
1,573
3.859375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] :rty...
b98ebb599cb70155e9bd023249d5bc4c5f5ebbd3
nmpluta/Python
/Exam/I6.py
591
3.515625
4
# -*- coding: utf-8 -*- # I6. usunie puste linie z łańcucha znaków skłądający się z wielu linii. test = " Testujemy taka funkcje,\n" \ "co ma usuwac puste linie.\n" \ "\n" \ "Takie jak ta powyzej i ponizej\n" \ " \n" \ " \n" \ "Zobaczymy zaraz czy działa?\n" \...
39740b7c05ce98e36f0f8c019ad1c6d943f2713f
daniel-reich/ubiquitous-fiesta
/YK9fWNBbRJ9PEc4wR_11.py
151
3.671875
4
def tuck_in(lst1, lst2): lst = [] lst.append(lst1[0]) for i in range(0, len(lst2)): lst.append(lst2[i]) lst.append(lst1[1]) return lst
c91c6cfcefe4bfccf33ed4edd1b86f5853f888c1
llenroc/LeetCode-28
/Array_easy_questions/167_two_sum_sorted_array.py
1,381
3.703125
4
# we categorize this problem as searching for pairs in sorted arrays. hash and two pointers are both O(n). this time we introduce two pointers: # 对于sorted arrays先取最左和最右两个极端值,如果两者之和小于target,那最小的和最大的相加都不够target => 最小的和其他小于max的elements相加就更不够了,因此排除min在wanted pair中的可能=>left index+1 同理两数之和大于target的话就把 right index-1 def two...
e30343a89fe82d35ce2c0822f85031f50d308477
hfpint01/pythonFinal
/IsbellFinal2.py
903
4.4375
4
import math as m def triangle(a, b): """ The Pythagorean equation for a right triangle is a^2 + b^2 = c^2 , where c is the hypotenuse while a and b are the remaining sides. Calculate all values for right triangles when the sides are no greater than 20. The program will ask for side a, side b and then...
dbc658740c9fa7609a045b953b19ed1c84436d9b
vuaphapthuat410/traffic_sign_flask
/utils.py
711
3.578125
4
import os import urllib.request UPLOAD_FOLDER = './uploaded' ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'} def allowed_file(filename): return '.' in filename and \ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS def download_image_from_url(image_url): filename = image...
a8241d3cb723caec505f049da2a0b4966c3547b5
yashwanthguguloth24/HackerRank-Codes
/Python/iter_comb.py
238
3.671875
4
from itertools import combinations def combine(string, num): for i in range(1, num + 1): for j in combinations(sorted(string), i): print(''.join(j)) str, num = input().split() combine(str, int(num))
d3937836b0b11b5fbcd23ed458715a929a5f0f08
rkredux/python-getting-started
/files.py
315
3.5
4
import csv with open('new_animal.csv', 'r') as f: animals = csv.reader(f) for row in animals: print("reading row") if row[-1] == "TRUE": print("{0} is a {1} and is house broken".format(row[0], row[1])) elif row[-1] == "FALSE": print("{0} is a {1} and is not house broken".format(row[0], row[1]))
8e69e9ed6fa0ad44e0112146aa16014a58a03c97
tinda/BullshitGenerator
/自动狗屁不通文章生成器.py
1,459
3.546875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import os import re import random import readJSON data = readJSON.讀JSON文件("data.json") 名人名言 = data["famous"] # a 代表前面墊話,b代表後面墊話 前面墊話 = data["before"] # 在名人名言前面弄點廢話 後面墊話 = data['after'] # 在名人名言後面弄點廢話 廢話 = data['bosh'] # 代表文章主要廢話來源 xx = "學生會退會" 重複度 = 2 def 洗牌遍歷(列表): ...
5313398cdec9337889eb3c590918394b92e70b7d
maxferrain/evm-combinatorics
/containers_generator.py
1,381
3.578125
4
from itertools import combinations_with_replacement def reduce_lst(lst, n): """ Берет список и удаляет из него по элементу, пока сумма элементов не будет равна n Если сумма не будет равна n, то вернет None :param lst: Список контейнеров [3, 3, 3, 5, ...] :param n: Значение, до которого происходит...
93dfcbd8ac5c7573ebe18904818075460b5b8672
perovskite13/perovskite13.github.io
/my-python/p2-starter/students/part3/part3.py
6,690
3.59375
4
import json import plotly.graph_objects as go from datetime import datetime DEGREE_SYBMOL = u"\N{DEGREE SIGN}C" #define functions def convert_date(iso_string): """Converts and ISO formatted date into a human readable format. Args: iso_string: An ISO date string.. Returns: A date forma...
ecf56b003f1c3b2dd6fa80597ce2e67c563c1a03
cbasurto/Intro-to-Python-Coursework
/example.of.an.empty.dictionary.py
491
4.1875
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 26 10:52:20 2015 @author: ESAccount24 """ empty = {} RedFlowers = {"rose" :1,"poppy" :1, "narcissus" :2, "tulip" :1, "carnation" :1, "jasmine" :2} #RedFlowers["rose"] returns 1 d = RedFlowers for key in d: print key #example dictionaries from list ...