blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
a7ab3c06b4f87fb2d79910e3c5f751d53dadc6d9
gtagohdev/pyautomation
/course-4/start_date_report.py
2,104
3.84375
4
#!/usr/bin/env python3 import csv import datetime import requests import operator FILE_URL = "https://storage.googleapis.com/gwg-content/gic215/employees-with-date.csv" def get_start_date(): """Interactively get the start date to query for.""" print() print('Getting the first start date to ...
3032542165abd54a81e4767dad3bbc73be6d9b33
JunyoungChoi/python
/0201_구구단찍기(가로).py
235
3.515625
4
i,k,guguline=0,0,'' for i in range(2,10): print("%7s" %("#"+str(i)+"단 #"), end='') print(guguline) for i in range(1,10): guguline ='' for j in range(2,10): guguline+=str("%2dX%2d=%2d" %(j,i,j*i)) print("%10s"%guguline)
b96728227fe84868228017314711cd183c2948d6
JunyoungChoi/python
/0131_실습1_시험지찾기.py
445
3.875
4
list_ex1 = ['risk','issue','test','maintenance','maturity'] list_ex2 = ['security','plan','design','systematic','safety'] list_ex3 = ['maintenance','verification','validation'] test=[list_ex1,list_ex2,list_ex3,'list_ex1','list_ex2','list_ex3'] for a in range (0,3): if 'maintenance' in test[a] and len(test[a])>=5: ...
5b0b3e930edd5f670d0303542b5f931f0f21575a
JunyoungChoi/python
/0202_함수응용.py
412
3.53125
4
def calc(v1,op,v2): result = 0 if op == '+': result =v1+v2 elif op == '-': result = v1-v2 elif op == '*' : result = v1*v2 elif op == '/' : if v2 == 0: return ('나눌 수 없습니다.') result = v1/v2 elif op == '**': result = v1**v2 else : print('잘못 입력하셨습니다.') return result print(...
908dc4c37144c85144de715a0afb6b5c5f511065
JunyoungChoi/python
/0131_실습1번.py
71
3.90625
4
list1=['a','c','d','b','e'] list1.sort() list1.reverse() print(list1)
a75aef38373d35c8b18d3b8ba1f4e01f9b2e1669
JunyoungChoi/python
/0202_함수만들기(대문자로).py
260
3.765625
4
def my_upper(a): for b in range(0,len(a)): if ord(a[b]) >= ord('a') and ord(a[b]) <= ord('z'): print(chr(ord(a[b])-32),end='') else : print(a[b],end='') _소문자모임=input('알파벳을 적어주세요 : ') my_upper(_소문자모임)
065c50e0058de8ea551258873efefa7ca550510c
Sharmistha-K/Code
/fibdyna.py
300
3.75
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 23 18:32:36 2021 @author: Sharmistha """ def fib(n,d = {}): if str(n) in d.keys(): return d[str(n)] elif n<=2 : return 1 else: d[str(n)]= fib(n-1, d) + fib(n-2,d) return d[str(n)] print(fib(50))
2c200173290ae220570aeef770c48b3afb136e2e
aihealthx/3d-image-review
/dicom_to_png.py
1,690
3.640625
4
import pydicom import numpy as np from PIL import Image import os import matplotlib.pyplot as plt # TASK: In the same folder as this .py file you will find a DICOM file # that is called instance.dcm. Your goal is to save it as a png file. # You must apply a WW/WC transform in order to map values to grayscale. # 1. U...
75cfea334db35a5322a31eb3f55197f08f75542d
TaT0n/untitled
/6.py
170
3.875
4
word = '1234543212' word1 = word[-1::-1] if word1 == word: print('это слово полиндром') else: print('это слово не полиндром')
f0136f341c4d5d2ac13ca9455f9e5d14d9448622
phaoliop/0aPygrammer
/Ejemplos/Semana_1/4_oper_relacionales.py
541
3.984375
4
''' Author: Paolo EJEMPLO OPERADORES RELACIONALES ''' a = "Hola" b = "HOLA" print("Igualdad: {}".format(a == b)) print("Igualdad: {}".format(a == "Hola")) print("-"*30) print("Distinto: {}".format(a != b)) print("Distinto: {}".format(a != "Hola")) print("-"*30) num1 = 10 num2 = 20 print("Valor num1: {}".fo...
5c97290f1743394dd00e0e0d6edb598fb1c1abb7
phaoliop/0aPygrammer
/Ejemplos/Semana_1/3_oper_aritmeticos.py
399
3.859375
4
''' Author: Paolo Ejemplo Operadores aritmeticos ''' a, b = 4,18 print("-"*30) print("\tOPERADORES DE ARITMETICOS") print("-"*30) print("Suma: {}".format(a + b)) print("Resta {}".format( b - a)) print("Multiplicación: {}".format( a * b)) print("División: {}".format( b/a)) print("División entera: {}".format( ...
d4b98b8dc0d358ec62eb3e59f9d08a7b45c527e6
kangli-bionic/edX_MIT_6002
/Final Exam/die.py
2,327
3.90625
4
import random import pylab # You are given this function def getMeanAndStd(X): mean = sum(X)/float(len(X)) tot = 0.0 for x in X: tot += (x - mean)**2 std = (tot/len(X))**0.5 return mean, std # You are given this class class Die(object): def __init__(self, valList): """ valL...
b751678480fa5623004462aa868c45df80e2b1bb
Yarne/PyhtonCrashCourse
/chapter_6/6.5_Rivers.py
366
3.90625
4
major_rivers = { 'volga': 'russia', 'thanlyin': 'china', 'niger': 'guinea' } for river, country in major_rivers.items(): print(f'The {river.title()} runs through {country.title()}.') print() for river in major_rivers.keys(): print(river.title()) print() for country in major_...
3a99c874ba6be18451d4ecd6896fbf115f279c74
Yarne/PyhtonCrashCourse
/chapter_4/4.13_Buffet.py
214
3.78125
4
foods = ('noodles', 'spaghetti', 'vlees', 'vis', 'fruit') for food in foods: print(food) print('') foods = ('noodles', 'spaghetti', 'vlees', 'kreeft', 'frieten') for food in foods: print(food)
508bdfa5c7dd23afa91d74ef60affab6c0808102
Yarne/PyhtonCrashCourse
/chapter_3/3.8_Seeking_The_World.py
343
3.828125
4
places = ['rome', 'dublin', 'praag', 'shanghai', 'madrid'] print(f'{places}\n') print(sorted(places)) print(places) print(f'\n{sorted(places, reverse=True)}') print(places) places.reverse() print(f'\n{places}') places.reverse() print(places) places.sort() print(f'\n{places}') places.sort(reverse...
9e175a01abdf4afbfac7810c8a0564ff5a549c95
amni/SMSmart
/backend/util.py
770
3.5
4
class PhoneNumbersUtil(): PHONE_NUMBERS_US = ["+14159856984", "+19195848629", "+14082143089", "+15733093911", "+15852285686"] PHONE_NUMBERS_UK = ["+447441906017", "+447441906514", "+447441906376", "+447441906383", "+447441906394"] PHONE_NUMBERS_CA = ["+12894320286", "+15813183824", "+14184781054", "+158778...
e4bd01b07f438226178112163781b3cac3cd8bd6
midnitedev101/Python-Scripts
/Selenium/ReadImgurPostsFromInfiniteScroll.py
2,128
3.6875
4
# Script Solution based on https://stackoverflow.com/questions/20986631/how-can-i-scroll-a-web-page-using-selenium-webdriver-in-python from selenium import webdriver from selenium.common.exceptions import TimeoutException, WebDriverException from selenium.webdriver.support.ui import WebDriverWait # available since 2.4....
a86d6c9c4a57da83d8041b489e643439bb6677cc
midnitedev101/Python-Scripts
/ReadRecipes.py
2,193
4.0625
4
# import csv # with open('Recipes.csv') as csvfile: # readCSV = csv.reader(csvfile, delimiter=',') # for row in readCSV: # print(row) # print(row[0]) # print(row[0],row[1],row[2],) # import csv # with open('Recipes.csv') as csvfile: # readCSV = csv.reader(csvfile, delimiter=',') # recipeName = [] # ingredients = ...
73611e1a72bb91e58e1761502ed597a25f6d8e57
cvdb/kenosym
/peno/tables.py
3,293
3.53125
4
def load_pay_table(): # We play games 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 40 pay_table = [] # 20 numbers are drawn but use 21 here # because ZERO also pays in some cases one = [0] * 21 one[1] = 3 pay_table.append(one) two = [0] * 21 two[2] = 12 pay_table.append(two) th...
7f246b36115afa196cf7ff1e5492f325eb5b95f4
Pika-Codes/Unit1-Proj
/ProtoU2.py
4,219
3.84375
4
#Credit To Mr. Miskew from tkinter import * from tkinter import filedialog #1a2634 #203e5f #eec550 #f9e3a3 #VARIABLES #This list stores menu items using the format [day,food] menuItems = [] days = [ 'Enter Day', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday'...
22885d4e9a7cd7752609e54796aede07b7770e4c
folk85/projectEuler-solutions
/1/1_main.py
300
3.609375
4
#!/usr/bin/python # -*- coding: utf-8 -*- summ = 0 def solution_1(val): """Solution Problem 1 in Project Euler""" summ = 0 for i in xrange(1,val): if(i % 3 == 0 or i % 5 == 0): summ += i return summ if (__name__ == '__main__'): num = 1000 summ = solution_1(num) print summ
334a94c7df4305ffcac5e7bb64b0b8ba71ae12fd
jack0820/lhj-his-dream-girlfriends
/01.py
725
3.921875
4
import tkinter from tkinter import * import random top = Tk() top.title("缘分检测器") f1 = Frame(top) L1 = Label(f1,text="你的名字") L1.pack(side=LEFT) E1 = Entry(f1,width =30,bd = 2,fg = "green",cursor = "plus") E1.pack(side = RIGHT) f1.pack() f2 = Frame(top) L2 = Label(f2,text="TA的名字") L2.pack(side=LEFT) E2 = ...
24191f7cd42bae5639d6b6170c5a6b9cbf4e309e
rhanak/skydiveproto
/keep/testing/pythonclasses.py
292
3.96875
4
#!/usr/bin/env python class A: x = [] def add(self): self.x.append(1) class B: def __init__(self): self.x = [] def add(self): self.x.append(1) x = A() y = A() x.add() y.add() print "A's x:",x.x x = B() y = B() x.add() y.add() print "B's x:",x.x
14e59cc156b21ba438f31e852a797bed7bcddca2
StepDan23/MADE_algorithms
/hw_1/d.py
685
4.0625
4
def merge(left, right): global N_swaps m = len(left) + len(right) i, j = 0, 0 arr = [] while i + j < m: if j == len(right) or (i < len(left) and left[i] < right[j]): arr.append(left[i]) i += 1 else: arr.append(right[j]) j += 1 ...
de3da113c7e0bbc9f73c2f2182539b2b0bb266c6
frankPairs/head-first-python-exercises
/chapter_4_functions_modules/vsearch_set.py
235
4.1875
4
def search_for_vowels(word: str) -> set: """Returns any vowels found in a supplied word""" vowels = set('aeiou') return vowels.intersection(set(word)) print(search_for_vowels("francisco")) print(search_for_vowels("sky"))
3d578126f0d27e60c62019e3350216da9a359a8e
TorridGlacier/Intro-to-Computer-Science-2015
/Lab 10/Lab 10.py
3,111
3.671875
4
# 1. def ftc(fahrenheit): celsius = 5/9*(fahrenheit -32) return celsius def ctf(celsius): fahrenheit = celsius*9/5+32 return fahrenheit # 2. def reverse_list(l): a = [] for i in range(1, len(l)): a.append(l[-i]) a.append(l[0]) return a print(reverse_list([0, 1, 2, 3])) # 1...
2fbc0271d9aa49b5c5edf896726c7fd55b171349
TorridGlacier/Intro-to-Computer-Science-2015
/Lab 11/Lab 11.py
2,786
3.828125
4
def multiplier(lst): lst2 = [] for item in lst: for i in range(2): lst2.append(item) return lst2 print(multiplier([1,2,3])) def consumer(lst): lst2 = lst.copy() a = max(lst) lst2.pop(lst2.index(a)) return lst2 print(consumer([1, 2, 5, 5, 3])) def blender(lst): sum...
1e1e247316ae3eac63c76a8e31f2dfd213c2a778
TorridGlacier/Intro-to-Computer-Science-2015
/Homework 2/le.py
919
3.890625
4
__author__ = 'Titas' def move(self, board, spaces): self.location.occupants.remove(self) previous = self.location.position for i in range(spaces): if len(self.location.next) == 1: self.location = board[int(self.location.next[0])] else: ...
06f29ee6daea845b18c9e61f218eb90c5a1b5fde
ggjung/project-euler
/001.py
731
3.875
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 31 21:06:46 2017 @author: g Project Euler Problem 1 Finds the sum of multiples of 3 and 5 below 1000. """ sumOfThrees = 0 sumOfFives = 0 sumOfFifteens = 0 upper = int(input("Give a positive integer: ")) upper -= 1 multiplesOfThree = upper//3 mu...
7e811cd361b5dcdff1c3a2cae7cc9e53794a2d19
rajendercheraku/mempage_resume_search
/word.py
1,147
3.71875
4
import glob import os file_list = glob.glob(os.path.join(os.getcwd(), "word", "*.txt")) words = int(input("enter the number of words you want to search")) words_list = [] finding_words = {} def unique_values(x): return list(dict.fromkeys(x)) for i in range(words): x = input("enter the word") words_list.app...
c51c30000bdf875ca72b3a3b18486c46aa0e93e1
tharunpeddisetty/Hierarchical-Clustering-on-Customers
/HierarchicalClustering.py
1,557
3.96875
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('/Users/tharunpeddisetty/Desktop/Machine Learning A-Z (Codes and Datasets)/Part 4 - Clustering/Section 24 - K-Means Clustering/Python/Mall_Customers.csv') X = dataset.iloc[:,3:].values #Using dendrogram to find the optimal ...
a33738ed14b445f655b401d4ea3ac4556ad716e5
lcacciagioni/hackerrank
/algorithms/combinatorics/handshake/handshake.py
560
3.625
4
#!/usr/bin/env python3 # This script will try to solve the problem described in: # https://www.hackerrank.com/challenges/handshake from math import factorial def get_handshake(people): if people == 1: combinations = 0 else: combinations = factorial(people)/(( factorial(2)) * (facto...
f46dfccb20a0e910145e6e99d316975bc4a1936a
lcacciagioni/hackerrank
/algorithms/warmup/MaximizingXOR/maximizing-xor.py
382
3.8125
4
#!/usr/bin/env python3 # Problem: https://www.hackerrank.com/challenges/maximizing-xor from itertools import * def maxXor(l, r, max_xor): for i in combinations_with_replacement(range(l,r+1),2): c = i[0]^i[1] if c > max_xor: max_xor = c return max_xor if __name__ == '__main__': l =...
65268b86a2ed7ddfbf5f59db5e5b86577d3b9363
jeffkwiat/minesweeper
/app.py
2,961
4.125
4
import random class Minesweeper(object): """ Implementing a simple Minesweeper board. """ def __init__(self, width, height, number_of_mines): self.width = width self.height = height self.number_of_mines = number_of_mines self.board = self.generate_board() self...
a8bf6aacd9ba3820adeecf4fe84467c8845a1b54
evilfrog262/LabScripts
/FastaPPERemoval.py
2,383
3.578125
4
#!/usr/bin/env python import sys # Removes desired regions of the genome from FASTA file input. Specifically for # use on PE/PPE genes and IS regions. Requires two input files: one that lists # the starting locations of all the removal regions and one that lists all the # ending locations of all the removal regions...
594777535accd6b38e4c7e3f5defdcc33f0c6cf0
johnwu130/LV2018-Python-demos
/2. Calling a Cloud Service/cloud_speech.py
1,358
3.921875
4
""" This Python code takes a path input (i.e. Test.wav), calls the google speech recognition API, and gets the result text. Original Python code: https://github.com/Uberi/speech_recognition/blob/master/examples/audio_transcribe.py Edited by John Wu, 9/5/2018 """ import numpy as np import speech_recogn...
ada052e8786c0b5220001a491a2df4c7ab838de0
cadenmr/tapestorage
/make_video.py
1,192
3.671875
4
# This project is to create a video that is recordable onto a VHS tape # which contains data. # This script creates a video using the specified file or folder. # Setup section import argparse import os import video # Set up the argument parser parser = argparse.ArgumentParser(description='Makes a recordable video ...
b04289538010c698448c75863a740a41f8560096
deep-r/Sign-Language-Translator
/Hack_CNN.py
3,315
3.84375
4
# building the CNN from keras.models import Sequential # initialize NN from keras.layers import Convolution2D # used for conv step and to add conv layer from keras.layers import MaxPooling2D # add pooling layers from keras.layers import Flatten # to make 2D vector from keras.layers import Dense # add fully conn ...
1378071857b3c73390530d77fc72dfa0b287142f
GauravR31/Solutions
/Numbers/Change_calculator.py
1,145
3.96875
4
cost = input("Enter the cost ") money = input("Enter the money given ") two_thousand, five_hundred, two_hundred, hundred, fifty, twenty, ten, five, two, change, tot_change = 0,0,0,0,0,0,0,0,0,0,0 if(money < cost): print("Please pay complete amount.") else: change = money - cost tot_change = change if(change > 20...
53e9e59370cad6cfcf69c3219783070f35df4f81
GauravR31/Solutions
/Classes/Flower_shop.py
1,883
4.15625
4
class Flower(object): """docstring for ClassName""" def __init__(self, f_type, rate, quantity): self.type = f_type self.rate = rate self.quantity = quantity class Bouquet(object): """docstring for ClassName""" def __init__(self, name): self.name = name self.flowers = [] def add_flower(self): f_type =...
f69933981114d0baa09ffd63db7cf4b133603417
GauravR31/Solutions
/Networking/Bandwidth_monitor.py
679
3.53125
4
import psutil import time def main(): interval = input("Enter time interval to monitor data in seconds ") old_sent_value = 0 old_recv_value = 0 while True: sent = psutil.net_io_counters().bytes_sent received = psutil.net_io_counters().bytes_recv if old_sent_value: curr_sent = sent - old_sent_value c...
3d478aea2b3f294567922f9dae0b858511005dd5
GauravR31/Solutions
/Databases/SQL_Query_Analyzer.py
1,205
3.859375
4
import sqlite3 def main(): conn = sqlite3.connect("myTable.db") crsr = conn.cursor() while True: print("1. Create table\n2. Update table\n3. Read table\n4. Delete table\n5. Exit") ch = input("Enter your choice ") if ch == 1: create_query = "CREATE TABLE emp (staff_id INTEGER PRIMARY KEY,\ fname TEXT N...
a4c6fe324521f479ec8ca9e0841f54769aa0076c
GauravR31/Solutions
/Numbers/Tax_calculator.py
327
4
4
from decimal import Decimal cost = input("Enter the cost of the item ") tax_rate = input("Enter the tax rate in % ") tax_rate = (Decimal(tax_rate)/100) tax = Decimal(cost) * tax_rate total_cost = tax + Decimal(cost) print("The total tax is {} and the total cost is {}".format(round(tax, 2), round(Decimal(total_cost...
67bb5e7c1cbf87d3bda10ccb9cc2c6b2c09fc0a0
GauravR31/Solutions
/Text/String_encrypt.py
2,840
4.0625
4
def caesar(plaintext): key = input("Enter the key ") ciphertext = '' for character in plaintext: if character.isupper(): character = ((ord(character) + key - 65) % 26) + 65 elif character.islower(): character = ((ord(character) + key - 97) % 26) + 97 else: character = ord(character) character = c...
c792f74ece7e2ef0c875e97403df429578faf7f8
madmaxieee/Big-One-Car-Car-Class
/python/maze.py
1,722
3.765625
4
from node import * import numpy as np import csv import pandas from enum import IntEnum import math class Action(IntEnum): ADVANCE = 1 U_TURN = 2 TURN_RIGHT = 3 TURN_LEFT = 4 HALT = 5 class Maze: def __init__(self, filepath): # TODO : read file and implement a data structure you like...
7ec388968746957e99f6ce2e777475b57bd20566
JE-BONG/python__basic
/pkg/패스트캠퍼스-알고리즘 이론/Chapter15-병합 정렬-live.py
3,409
3.65625
4
# <병합 정렬> # 참고 : https://visualgo.net/en/sorting # 데이터가 4개인 경우 # data = [1, 9, 3, 2] # 1. 먼저 [1, 9], [3, 2]로 나눈다 # 2. 다시 앞 부분 [1],[9]로 나눈다 # 3. 다시 정렬해서 합친다 [1, 9] # 4. 다음 [3, 2]는 [3][2]로 나누고 # 5. 다시 정렬해서 합친다 [2, 3] # 6. 이제 [1, 9], [2, 3]을 합친다. # - 1 < 2 이니 [1] # - 9 > 2 이니 [1, 2] # - 9 > 3 이니 [1, 2, 3] # - 9 밖에 없으니 [...
dded29e79c0311b41642b2f0ec7ab8b609be9a07
JE-BONG/python__basic
/section05-3-q.py
4,315
3.546875
4
# 퀴즈 # 1. 아래 딕셔너리에서 '가을'에 해당하는 과일을 출력하세요 print('1. 아래 딕셔너리에서 ""가을""에 해당하는 과일을 출력하세요.') q1 = {'봄':'딸기', '여름':'토마토', '가을':'사과'} for k in q1.keys() : if k == '가을' : print(q1[k]) # items 사용 print('<items> 사용') for k,v in q1.items() : if k == '가을' : print(v) print() print('--------------------------...
0bd15f96fb19218f1de875fd6389eaa957e59b2a
davisnyabwari1/Text-based-game
/python_text_based_adventure game.py
5,122
3.625
4
import time # Responses from the user response_A = ['A', 'a'] response_B = ['B', 'b'] response_C = ['C', 'c'] response_Y = ['Yes', 'Y', 'y'] response_N = ['No', 'N', 'n'] required = '\n\nA,B,C are the only acceptable choices.Please select a new choice\n\n' # GameOVer function: def gameover(): print(''' ...
7bb1b73f6c731154533e68a861c45bb48c220137
PoCInnovation/Elivia-AI
/RASA_assistant/actions/weather.py
520
3.515625
4
import requests def get_weather(city): api_address = 'http://api.openweathermap.org/data/2.5/weather?appid=0c42f7f6b53b244c78a418f4f181282a&q=' url = api_address + city json_data = requests.get(url).json() format_add = json_data['main'] print(format_add) print("Weather is {0} Temperat...
ce97aff7408d5808d33756c8bb72e2910bbe77a4
ngrq123/learn-python-3-the-hard-way
/pythonhardway/ex30.py
732
4.34375
4
# Initialise people to 30 people = 30 # Initialise cars to 40 cars = 40 # Initialise buses to 15 buses = 15 # If there are more cars then people if cars > people: print("We should take the cars.") # Else if there are less cars then people elif cars < people: print("We should not take the cars.") else: prin...
e604c575a28cb957fb22751c04322217b36c9be3
ngrq123/learn-python-3-the-hard-way
/pythonhardway/ex8.py
783
3.890625
4
# Initialise formatter with 4 variables that can be inserted formatter = "{} {} {} {}" # Insert 1, 2, 3, 4 into formatter and print - prints 1 2 3 4 print(formatter.format(1, 2, 3, 4)) # Insert one, two, three, four into formatter and print - prints one two three four print(formatter.format("one", "two", "three", "fou...
7fe4bda152ddab47dcc4dba47fb2f4449e2593dc
bhfwg/py_learn
/messy/justify.py
157
3.625
4
print "3".rjust(2, '0') print "3".rjust(3, '0') n = 100 ds = len(str(n)) numbers = map(lambda i: str(i).rjust(ds, '0'), range(1, n)) print ' '.join(numbers)
8278cbb32a69c0d523a128b5ada35b6e46496a21
Amoon2003/quiz_adventure
/adventure.py
7,226
3.515625
4
# An adventure game Hp = 20 Cp = 3 rat1 = 6 boss1 = 80 from random import randint def health_loss(n): global Hp, Cp Hp = Hp - n if Hp <= 0: print("") game_over() def game_over(): print("\n"*2) print('GAME OVER!!') print('YOU DEAD') def bossatk(n): global boss1 ...
42215df080f33d994211f8886196a709396a7022
tomaszleszczynski1980/python
/BubbleSortViz.py
1,017
3.703125
4
import pygame import numpy # Set parameters win_width = 700 win_height = 400 values = numpy.random.rand(1,win_width)*win_height # Initialize pygame pygame.init() win = pygame.display.set_mode((win_width, win_height)) pygame.display.set_caption('Bubble Sort Visualization') # Create my loop run = True ...
02920122faa74578707e0945caccc6e8bbecbf65
dale-nelson/ift101
/lab02p2-d.py
571
4.03125
4
print("This program calculates the value of a $5000 principal investment annually.") princ = 5000 apr = 3 def check_if_valid(): while True: try: val = float(input("How many years do you want to calculate? Decimals are also accepted. ")) except ValueError: print("Tha...
d61c6db3c3889e24794719d0d8e7c9a4c6a3732e
dkahuna/basicPython
/Projects/calcProgram.py
241
4.5
4
# Calculating the area of a circle radius = input('Enter the radius of your circle (m): ') area = 3.142 * int(radius)**2 # int() function is used to convert the user's input from string to integer print('The area of your circle is:', area)
5dbf3b63d6bb744d4a02aba9f41acd9ad64372c2
dkahuna/basicPython
/FCC/ex_09/ex_09.py
714
4.15625
4
fname = input('Enter file name: ') if len(fname) < 1 : fname = 'clown.txt' hand = open(fname) di = dict() #making an empty dictionary for line in hand : line = line.rstrip() #this line strips the white space on the right side per line of the file words = line.split() #this line splits the text file into an arr...
cddbc541800c312f4efa65c93885368e8d16ccf5
ONE-18/PrecioLuzScraping
/mainFiltrar.py
937
3.5625
4
from bs4 import BeautifulSoup import requests url = 'https://tarifaluzhora.es' page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser') # Horas horasRaw = soup.find_all('div', class_='col-xs-9') hora = list() for i in horasRaw: hora.append(i.text.split(': ')) horas = list() # Lista con ...
f164802d0ebb45593969d7736755758c3c84b03d
Siddharth46/first
/classp.py
703
4.3125
4
class Movie: '''this code is property of siddharth dixit''' def __init__(self,movie, actor, femaleactor, ratings): self.movie=movie self.actor=actor self.femaleactor=femaleactor self.ratings=ratings def info(self): print("Move name {}".format(self.movie)) pri...
7597901ddca44e5053d3098df56090692eb244e3
Siddharth46/first
/leftplay.py
331
3.859375
4
h=7 m=(2*h)-2 for i in range(0,h-1): for j in range(0,m): print(end=" ") m=m-2 for j in range(0,i+1): print("* ", end="") print("\r") m=-1 for i in range(h-1,-1,-1): for j in range(m,-1,-1): print(end=" ") m=m+2 for j in range(0,i+1): print("*", end=" ") p...
3cb94932022c186826a03fabdebce4da6addb14e
dayanandtekale/Python-Programs-
/for_over_dict.py
293
3.875
4
a = {'A':30, 'B':54, 'C':67, 'D':12, 'E':89, 'F':45} # for i in a: # print(a[i]) # # print(a['C']) # print every number on separate line using for loop # for i in a: # print(i, a[i]) # for i in a.values(): # print(i) # if 'Z' in a: # print("Key is present")
b183770d690fdc835a2d42c444dcb10be19f5473
dayanandtekale/Python-Programs-
/generators.py
860
4.03125
4
# def cube(n): # result = [] # for i in n: # result.append(i**3) # return result # print(cube([1,2,3,4,5])) # def dummy(): # for i in range(1,10): # print(i) # if i==5: # break # dummy() # dummy() # dummy() # dummy() # dummy() # def cube_generato...
4eae068e239b8bf9eb74f7daae726b85784ef865
dayanandtekale/Python-Programs-
/for_over_list.py
355
3.96875
4
a = [30, 54, 67, 12, 89, 45] # # print every number on separate line using for loop # for i in a: # print(i) # # print every index, value using for loop # for index, value in enumerate(a): # print(index, value) # # print every number on separate line using for loop using index number # for i in ra...
a944727519340e3bc5c1b7a780cad7f224043672
dayanandtekale/Python-Programs-
/encapsulation.py
965
3.9375
4
# Encapsulation # self.variable_name - Public variable # self._variable_name - Protected variable # self.__variable_name - Private variable class Encapsulate(): __class = '3' def __init__(self): self.name = 'ABC' self._marks = 78 self.__role = 'A1' def display(sel...
2c760b31fe919bee525d801ebbd4474a81b88b5b
dayanandtekale/Python-Programs-
/fun_def_default_values.py
950
3.890625
4
#functions with arguments and default values # def multi(a=10, b=20): # return a * b # print(multi(5)) # def area_of_circle(radius, pi=3.14): # return pi * radius * radius # print(area_of_circle(10)) # def multi_dynamic(*args): # print(args) # mul = 1 # for arg in args: # ...
19195ae5e8a70a676733a504cc318489b3cc0d44
trinnawat/30-day-leetcoding-challenge
/week4/day22-subarray-sum-equals-k.py
666
3.609375
4
''' https://leetcode.com/problems/subarray-sum-equals-k credit: https://leetcode.com/problems/subarray-sum-equals-k/discuss/591831/Python-simple-O(n)-algorithm-explained ''' from collections import defaultdict class Solution: def subarraySum(self, nums: List[int], k: int) -> int: track_sums = defa...
2a3f191e13b46c21fcd3a4b4a245c4aae9f4d15b
trinnawat/30-day-leetcoding-challenge
/week1/day5-best-time-to-buy-and-sell-stock-ii.py
350
3.515625
4
''' https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii ''' class Solution: def maxProfit(self, prices: List[int]) -> int: accum_sum = 0 for i in range(1, len(prices)): prev_px = prices[i-1] curr_px = prices[i] accum_sum += max(curr_px - prev_px...
8ffbc1f7e6f2daf7481278a6184795edfd9b7856
trinnawat/30-day-leetcoding-challenge
/week4/day25-jump-game.py
409
3.53125
4
''' https://leetcode.com/problems/jump-game credit: https://leetcode.com/problems/jump-game/discuss/596454/Python-Simple-solution-with-thinking-process-Runtime-O(n) ''' class Solution: def canJump(self, nums: List[int]) -> bool: last_i = len(nums)-1 for i in range(len(nums)-2, -1, -1): ...
dd83323038376ed1a5fcdb072025de66769f2eae
trinnawat/30-day-leetcoding-challenge
/week4/day28-first-unique-number.py
600
3.640625
4
class FirstUnique: def __init__(self, nums: List[int]): self.set = set() self.dict = collections.OrderedDict() for n in nums: self.add(n) def showFirstUnique(self) -> int: return next(iter(self.dict.keys()), -1) def add(self, value: int) -> None: if val...
4151335b80dc7a007e14c1184054b4e99ffd4979
PeterZhangxing/codewars
/dig_pow.py
322
3.515625
4
#!/usr/bin/python3.5 def dig_pow(n, p): sn = str(n) iter_n = sum(int(v)**(i+p) for i,v in enumerate(sn)) if str(iter_n/n).split('.')[1] == '0': return int(iter_n/n) else: return -1 if __name__ == "__main__": print(dig_pow(89, 1)) print(dig_pow(46288, 3)) print(dig_pow(92, 1...
7d506ef1cf523b0afeecac61d6f9f2f8ed7fa24a
PeterZhangxing/codewars
/DNA.py
243
3.640625
4
#!/usr/bin/python3.5 def DNA_strand(dna): DNA_dic = {'A':'T','C':'G','T':'A','G':'C'} res = "" for st in dna: rs = DNA_dic[st] res = res + rs return res if __name__ == "__main__": print(DNA_strand("AAAA"))
5de094d0d47572331eb6aded2bc7dc4f2de75c67
PeterZhangxing/codewars
/RGBToHex.py
566
3.515625
4
#!/usr/bin/python3.5 def check_num(i): if i < 0: i = 0 elif i > 255: i = 255 return i def rgb(r, g, b): r = check_num(r) g = check_num(g) b = check_num(b) hl = [] rh = hl.append(hex(r).split('x')[1].upper()) gh = hl.append(hex(g).split('x')[1].upper()) bh = hl....
44b5d0703b1b33a404853df4e6bc6436c463a1e1
PeterZhangxing/codewars
/find_rightnum.py
325
3.6875
4
#!/usr/bin/python3.5 import math def find_rightnum(): res = [] for i in range(1,10): for j in range(1,10): num = 1000*i + 100*i + 10*j + j if math.sqrt(num) == int(math.sqrt(num)): res.append(num) return res if __name__ == "__main__": print(find_rightnu...
0d76bfe78f4a0d6b4ba575895d72bd7cd0544cac
PeterZhangxing/codewars
/multling.py
276
3.640625
4
#!/usr/bin/python3.5 def accum(s): li = list(s) reps = [] for i,item in enumerate(li): item = item.lower() reps.append(item.upper()+item*(i)) return "-".join(reps) if __name__ == "__main__": result = accum("tyuiuiuist") print(result)
4c4c6d0bf6c3718b2be64331be3709ade580c8dd
PeterZhangxing/codewars
/AI/data_analysis/ad_hist2.py
543
3.5625
4
import pandas as pd from matplotlib import pyplot as plt file_path = "data_source/IMDB-Movie-Data.csv" df = pd.read_csv(file_path) # print(df.head(3)) # print(df.info()) rate_data = df["Rating"].values # print(rate_data) max_rate = rate_data.max() min_rate = rate_data.min() # print(max_rate,min_rate) # 构建直方图的x坐标的值...
604aa9e0783655fb69ec7bf3379988c7af3430f0
PeterZhangxing/codewars
/gui_test/guess_num.py
927
3.5
4
import random import easygui mynum = random.randint(1,10) total_count = 7 count = 1 while True: if count >= 7: exit('you have used all your opportunities!') gnum = easygui.enterbox( msg='enter a number between 1 and 9:' ) if not gnum: easygui.msgbox('you must input a number l...
c674ffe188a1f3d53e51b15a78bf8eaaf8d5c82d
olletokstolle/python
/quizzing.py/quizzing.py
3,019
3.921875
4
""" Simple multiple choice quiz program for answering questions. Could potentially be useful for studying, I guess. Reads the questions from a .csv-file (semicolon delimited) with the following four columns: id (just a number, use not yet implemented) question (the actual question) alts (the different choices) correc...
0a8ebf448388bc31cb20a45469ca9237f10dac65
fhqvst/practice-python
/exercises/C-4.9.py
300
3.703125
4
def find_min_max(arr, i, min, max): if i == len(arr) - 1: return (min, max) if min is None or arr[i] < min: min = arr[i] elif max is None or arr[i] > max: max = arr[i] return find_min_max(arr, i + 1, min, max) assert find_min_max([2, 0, -1, 57, 58, 19], 0, None, None) == (-1, 58)
4d9fc1b8d009086036d361a63e911950544f9462
fhqvst/practice-python
/exercises/C-4.16.py
132
4.03125
4
def reverse(word): return word[0] if len(word) == 1 else word[-1] + reverse(word[:-1]) assert reverse('pots&pans') == 'snap&stop'
19d21221a2656329c7faa07084a2781ef1d9ee14
fhqvst/practice-python
/exercises/C-10.31.py
505
3.578125
4
def sieve(m): A = [True] * 2 * m A[0] = A[1] = False primes = [] for (i, is_prime) in enumerate(A): if is_prime: primes.append(i) for j in range(i**2, 2 * m, i): A[j] = False return [ p for p in primes if m <= p <= (2 * m) ] assert sieve(10)...
83e7bad276f4d768706b40e256a5181a9b6083e0
fhqvst/practice-python
/exercises/C-4.14.py
1,630
3.671875
4
class TowersOfHanoi: def __init__(self, size = 4): self.size = size self.a = Pin([ i + 1 for i in range(self.size) ]) self.b = Pin() self.c = Pin() def solve(self): print(self.a) print(self.b) print(self.c) print('Solving...') calls = self...
2984490a26bba70d18ea7493329bd202fa0b1b9e
fhqvst/practice-python
/exercises/P-1.36.py
303
3.734375
4
def count_words(words): counter = dict() words = words.split() for w in words: counter[w] = counter.setdefault(w, 0) + 1 return counter assert count_words("hello my baby hello my honey").get("hello") is 2 assert count_words("hello my baby hello my honey").get("kevin", 0) is 0
d63daf81fd89fffa3986bcd52e224d433e8b4ddc
TheCoinTosser/MachineLearningGoogleSeries
/recipe_6/recipe_6.1.py
3,111
3.625
4
################################################################################################################# # Train an Image Classifier with TensorFlow for Poets - Machine Learning Recipes #6 # # https://www.youtube.com/watch?v=cSKfRcEDGUs ...
4570ebcf19efd49afb1ef0a3a5f4e899cd738d37
dekshitha/python
/avg_mbox.py
428
3.59375
4
# Use the file name mbox-short.txt as the file name tot=0.0 count=0.0 fname = input("Enter file name: ") try: fh = open(fname) except: print('cant open file:',fh) quit() for line in fh: line=line.rstrip() if not line.startswith("X-DSPAM-Confidence:") : continue pos=line.find(':') ...
fa0df8b285ef9a72633c152bb1fef5009453f654
rupert96/python
/twitshit/tweet.py
1,858
3.625
4
import twitter import datetime import urllib import urllib2 #importing libraries user = 238760074 #My Twitter user ID file = open("twitter credentials.txt") creds = file.read().split('\n') file.close() #My Twitter credentials in a text file - loading into python file and splitting by line cHistoryFile = open("/Users...
05c6e1ecabdd69d7c6d3535b9b7b2777a0331082
RustingSword/adventofcode
/2020/18/sol1.py
954
4.03125
4
#!/usr/bin/env python3 def evaluate(expression): operators, operands = [], [] expression = expression.replace(" ", "") def calc(): if operators and operators[-1] != "(" and len(operands) >= 2: op = operators.pop() first, second = operands.pop(), operands.pop() ...
ecfe7da8cee6b57ab65108992a3c333f2e0dc283
RustingSword/adventofcode
/2020/01/sol2.py
315
4.125
4
#!/usr/bin/env python3 def find_triple(nums, target=2020): for first in nums: for second in nums: if (third := target - first - second) in nums: return first * second * third if __name__ == "__main__": nums = set(map(int, open("input"))) print(find_triple(nums))
28c8083d379effaba608807ef8144dc412cf544d
RustingSword/adventofcode
/2020/16/sol1.py
758
3.828125
4
#!/usr/bin/env python3 def scan(rules, tickets): def span(spec): start, end = spec.split("-") return set(range(int(start), int(end) + 1)) all_valid_numbers = set() for rule in rules: name, valid = rule.split(": ") first, second = valid.split(" or ") all_valid_numbe...
acce64316c266de8cd40497e2240b24244c8fab1
RustingSword/adventofcode
/2020/03/sol1.py
386
3.953125
4
#!/usr/bin/env python3 def number_of_trees(data): nrows, ncolumns = len(data), len(data[0]) row = column = ntrees = 0 while row < nrows - 1: row += 1 column = (column + 3) % ncolumns ntrees += int(data[row][column] == "#") return ntrees if __name__ == "__main__": data = o...
f7638228d4f2d06f726f996eda424d300c099471
agatanyc/fridays
/recursion/sum.py
187
3.671875
4
def sum(xs, a=0): if xs: return sum(xs[1:], a + xs[0]) else: return a # return sum(xs[1:], a + xs[0]) if xs else a xs = [1, 2, 3, 4, 5, 6, 7] print(sum(xs))
897857adbb6584cc810e1a7bc3772129de650b97
ieferreira/aws-scaffold
/hello.py
155
3.890625
4
def add(x, y): return x + y # var = result = add(1, 2) # print(f"this is the sum: 1 + 2 = {result}") print("this is the sum: 1 + 2 = %s" % result)
24db681da40b5d22288e7f72dddbd7a2a31909aa
981377660LMT/algorithm-study
/tmp/20211129/833. 字符串中的查找与替换.py
1,058
3.71875
4
from typing import List # 用新的字母组替换原有的字母组 # 如果 x 从原始字符串 S 中的位置 i 开始,那么就用 y 替换出现的 x。如果没有,则什么都不做。 # 保证在替换时不会有任何重叠 # 总结:先`倒着排序`再替换 # 这样的好处是替换后长度变化不会再干扰我们 # `倒着排序`再替换 class Solution: def findReplaceString( self, str: str, indices: List[int], sources: List[str], targets: List[str] ) -> str: ...
9fd935bf6691c72c7273b88e968c587140ad7e76
981377660LMT/algorithm-study
/前端笔记/thirtysecondsofcode/python/python的typings/22_final.py
838
3.75
4
# Final names, methods and classes # 最终名称是在初始化后不应该重新分配的变量或属性。它们对于声明常量很有用。 # 最终方法不应在子类中被重写(最后的方法)。 # 最后的类不应该被子类化(最后的类)。 from typing import Final, final RATE: Final = 3000 class Base: DEFAULT_ID: Final = 0 RATE = 300 # Error: can't assign to final attribute Base.DEFAULT_ID = 1 # Error: can't ...
6b66929197c953974669b4b41147fe464a77074d
981377660LMT/algorithm-study
/22_专题/最少操作次数/Number of Decrements to Reach Zero.py
433
3.890625
4
# In one operation you can either # Decrement n by one # If n is even, decrement by n / 2 # If n is divisible by 3, decrement by 2 * (n / 3) # 求到0的最少操作次数 import functools class Solution: @functools.lru_cache(None) def solve(self, n): if n <= 1: return n return min(...
e98891ba06de768b0097beb73c79284f57d3893c
981377660LMT/algorithm-study
/20_杂题/pythonic/1933. 判断字符串是否可分解为值均等的子串.py
467
3.828125
4
from itertools import groupby # 一个字符串的所有字符都是一样的,被称作等值字符串。 # 如果有且仅有一个等值子字符串长度为2,其他的等值子字符串的长度都是3.就返回真 class Solution: def isDecomposable(self, s: str) -> bool: match = set(len(list(g)) % 3 for _, g in groupby(s)) return sum(match) == 2 and 1 not in match print([list(g) for e, g in group...
f84fa6bf70e75889131f43530de6be0f6ba470f2
981377660LMT/algorithm-study
/22_专题/字典序列删除/1081. 包含所有不同字符的字典序最小子序列.py
1,117
3.71875
4
# 1081. 包含所有不同字符的字典序最小子序列 # 返回 s 字典序最小的子序列,该子序列包含 s 的所有不同字符,且只包含一次。 # 需要保证每个数最后正好出现一次 # !是否能加:使用visited保证最多出现一次 # !是否能删:使用remain防止多删 from collections import Counter class Solution: def smallestSubsequence(self, s: str) -> str: """返回 s 字典序最小的子序列,该子序列包含 s 的所有不同字符,且只包含一次。""" remain =...
34d3d7de278d2f3f1a78a92efa836019de6b5d9b
981377660LMT/algorithm-study
/6_tree/经典题/545. 二叉树的边界.py
1,684
3.625
4
from typing import List, Optional class TreeNode: def __init__( self, val: int = 0, left: Optional['TreeNode'] = None, right: Optional['TreeNode'] = None ): self.val = val self.left = left self.right = right # 给你一棵二叉树的根节点 root ,按顺序返回组成二叉树 边界 的这些值 # 二叉树的”三“视图,左视...
82705c07b12afda0016aff736156c7ffb8a82272
981377660LMT/algorithm-study
/6_tree/经典题/1339. 分裂二叉树的最大乘积.py
888
3.53125
4
# 请你删除 1 条边,使二叉树分裂成两棵子树,且它们子树和的乘积尽可能大。 from collections import defaultdict from typing import Optional MOD = int(1e9 + 7) # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right ...
6db0d973158ede26a82180ba171f4e9d72873596
981377660LMT/algorithm-study
/12_贪心算法/经典题/字符串排序/5984. 拆分数位后四位数字的最小和.py
467
3.546875
4
# 请你使用 num 中的 数位 ,将 num 拆成两个新的整数 new1 和 new2 # new1 和 new2 中可以有 前导 0 ,且 num 中 所有 数位都必须使用 class Solution: def minimumSum(self, num: int) -> int: digits = sorted(list(str(num))) num1 = digits[0] + digits[2] num2 = digits[1] + digits[3] return int(num1) + int(num2) print(Sol...
22eae7b95ce5871c88d857e0ff1ab6b03de839ff
981377660LMT/algorithm-study
/20_杂题/滴滴历届编程题真题/3_火车编组题-验证栈序列.py
269
3.75
4
nums = [1, 2, 3, 4] target = [4, 1, 3, 2] stack = [] index = 0 for num in nums: stack.append(num) while stack and index < len(target) and target[index] == stack[-1]: stack.pop() index += 1 print('Yes' if len(stack) == 0 else 'No')