blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
39028014bbbd853b158e5a88d269e0f6cbbd17ad
Soooyeon-Kim/Algorithm
/palindrome_for.py
368
4.125
4
def is_palindrome(word): word_reverse = '' for w in word: word_reverse = w + word_reverse if word_reverse == word: return True else: return False # 테스트 print(is_palindrome("racecar")) print(is_palindrome("stars")) print(is_palindrome("토마토")) print(is_palindrome("kay...
3ccff68379e3be80ba59a0b7cbf4793f1a5fa521
taanguyen/data_structures
/Digraph/topological_sort.py
507
3.734375
4
# implementation of topological sort using dfs from Digraph.dfs import * def topo_sort_util(v, G, marked, stack): marked[v] = True for i in G.graph[v]: if not marked[i]: topo_sort_util(i, G, marked, stack) stack.append(v) def topological_sort(G): marked = [False] * G.V stack = [...
0b9ccced72c6f6588242ac2ccabc4760813a4585
pndx/learn-to-use-python
/PythonQuickTips8.py
212
4.03125
4
# Tuple Decomposition - Python Quick Tips def func(): return 1, 2, 3 t1 = (1, 2) t2 = (1, 2, 3) x, y = t1 print(x, y) x, y, z = t2 print(x, y, z) print(func()) # Tuple x, y, z = func() print(x, y, z)
72ae1c556ff5f3effe31b51be520f81da32b9173
amitkanojiya/sms_system
/main.py
705
3.5625
4
from tkinter import * from tkinter.ttk import Combobox Window=Tk() v1=IntVar() r1=Radiobutton(Window,text="male",variable=v1,value=1) r2=Radiobutton(Window,text="Female",variable=v1,value=2) r1.place(x=20,y=100) r2.place(x=70,y=100) var=StringVar() var.set("One") data=("One","Two","Three","Four") cb=Co...
e3a6952f766e136aff5c82b7f1b4d76b881226cc
tjwl0418/Computational-thinking-and-coding
/11j1-2.py
209
3.578125
4
x= int(input("x값을 입력하세요")) y= int(input("y값을 입력하세요")) z= int(input("z값을 입력하세요")) sumx = x + 1 sumy = y + 1 sumz = z + 1 print("변경된 갑은: " , sumx, sumy, sumz)
673ed79884191ab140e3cd095aed5062c08921b5
ptrvela/Proyecto-IA-Mangos
/2-DatosEntradaRNA.py
2,788
3.75
4
# -*- coding: utf-8 -*- """ - Aplicacion para leer los recortes de las carpetas especificas, creadas por "RecorteMango" - Redimensionar las imagenes con un algoritmo sin perdida (ANTIALIAS) dejando las imagenes de tamaño 40 x 10 - Normaliza los datos entre 0 y 1 con tres decimales agrega 3 datos al final,...
9279cb02633b3fb2f1601c47d1f49afc0c424133
Heahr/training
/machine_learning/acting/stepFunctionTest.py
1,184
3.625
4
import numpy as np import matplotlib.pylab as plt # Don't use Numpy def simple_step_function(x): if x > 0: return 1 else: return 0 # possible use Numpy def np_step_function(x): y = x > 0 return y.astype(np.int) def simple_np_step_finction(x): return np.array( x > 0, dtype = np.int)...
3328185db605d800b0eb3383798dc2ca5db68e66
stevenweaver/projectrobo
/code/beagleboard/objects/computations.py
1,910
3.8125
4
import math #two dead reconing distance calcuation def calcDistance(pt1, pt2): return math.sqrt(math.pow((pt2[0] - pt1[0]),2)+math.pow((pt2[1] - pt1[1]), 2)) def calcAngle(pt1, pt2): #now we need to find angle A, since we know sinA is height/distance we can just find the inverse sine distance = calcDis...
7be9ae5765e90982ce6b67bd69f54c4f9d3082cc
mylittlecat/python_prac
/prac5-13.py
191
3.90625
4
#!/usr/bin/env python def TimeTrans(): 'transform time into minutes' a=raw_input("Enter a time: ") aList=a.split(':') return int(aList[0])*60+int(aList[1]) print TimeTrans()
be107de6e1431639fbcc703ae5c84604ef4cef86
darksinge/python-C-extensions
/Cython/bubble_sort.py
256
4.0625
4
""" A bubble sort algorithm. :param a: a list of numbers to sort """ def sort(a): for i in range(len(a)): for j in range(len(a)): if a[i] < a[j]: temp = a[j] a[j] = a[i] a[i] = temp
014bd8635a2fd181ddc222c20586edd49342e484
bijoyvbabu123/TicTacToe_CLI
/TicTacToe_CLI.py
2,080
3.5625
4
# optional multi time play without clear screen b = {7: ' ', 8: ' ', 9: ' ', 4: ' ', 5: ' ', 6: ' ', 1: ' ', 2: ' ', 3: ' '} def printsampleboard(): for i in range(1,10): b[i] = ' ' print() print() print(' ' + '7' + ' | ' + '8' + ' | ' + '9') print('-----------') ...
ea12c2d408dd3b956770fd46c8f214150b69608f
cercerona/python_course
/catch_the_ball/ball.py
2,750
3.78125
4
import tkinter from random import choice, randint canvas_width = 400 canvas_height = 300 canvas_color = "white" ball_initial_number = 20 #Число шариков для игры ball_minimal_radius = 15 ball_maximal_radius = 40 ball_available_colors = ["green", "blue", "red", "#FF00FF", "#FFFF00"] def click_ball(event): """Обрабо...
66fc34b6bc03983ea789327ba848ed5b4f128130
cercerona/python_course
/examples/dz_2.py
564
3.890625
4
def question_6(): a1 = input('Введите a1: ') a2 = input('Введите a2: ') b1 = input('Введите b1: ') b2 = input('Введите b2: ') a1 = int(a1) a2 = int(a2) b1 = int(b1) b2 = int(b2) a1 = a1*b2 + b1*a2 a2 = a2*b2 print('Результат a1/a2 = %d/%d'%(a1, a2)) def question_7(): x =...
8c89e2c85286032107f338233bad1c9e6ab7090d
bardler/lpthw
/38_doing_things_to_lists/38_study_drills.py
591
4.1875
4
#Study drills for lesson 38 my_int_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] my_string_list = ['test', 'word', 'balls', 'jump'] print my_int_list print my_string_list my_string_list.append('work') print my_string_list my_string_list.extend('numbers') print my_string_list my_int_list.insert(5, 5.5) print my_int_list ...
13e6bbea17e5d7d51801a0410c975e7891d2b82f
hi-im-gosu/abstraction
/Abstraction Summative.py
1,488
4.09375
4
import random input("Abstraction of REFUGEE ESCAPE.") #Choice of Advanced or Basic Abstraction methodOfAbstraction = input(""" 1. Advanced Abstration 2. Basic Abstraction""") def choiceOfOneOrTwo(x): for i in range(100): if x != "1" and x != "2": print("Please type 1 or 2") ...
54d1574b4978c964c1cef2049d84cb0e3c2a24fe
roksanapoltorak/Tester_school_dzien_5_i_6
/mediana.py
180
3.953125
4
a = 12 b = 11 c = 11.5 if b <= a <= c or b >= a >= c: print ("a jest mediana") elif a <= b <= c or a >= b >= c: print ("b jest mediana") else: print ("c jest mediana")
3531d0ca9ce704d59832eac9152ba06e8a491ccc
roksanapoltorak/Tester_school_dzien_5_i_6
/zad_dict_1.py
228
3.859375
4
dict1 = {'bar': 'foo', 'spam': 'eggs', 'baz': 'foo', 'ban': 'foo', 'fried': 'eggs'} dict2 = {} for key, value in dict1.items(): if value not in dict2: dict2[value] = [key] else: dict2[value].append(key)
7e48aa6be0e0a14f48a57e35ebdf662c23f9025b
WayneHsiao0225/100daysPython_Day21
/Day21/snake.py
1,406
3.859375
4
from turtle import Screen,Turtle STARTING_POSITION = [(0, 0), (-20, 0), (-40, 0)] MOVE_DISTANCE=20 UP= 90 DOWN= 270 LEFT= 180 RIGHT= 0 class Snake: def __init__(self): self.segments=[] self.create_snake() self.head=self.segments[0] def create_snake(self): for position in STARTI...
b80e3fc3058d6fd85fae6539dd4b83c3c13dc485
Ekulina/hello
/yl10.py
231
4.03125
4
fruits=["apple","orange","pear", "cherry"] if "apple" in fruits: print("Yes 'apple' in the list.") print (len (fruits)) fruits.append ("banana") print(fruits) fruits.remove ("orange") print (fruits) fruits.sort() print (fruits)
e7a10ec00a275ed392a52a0c0c04b1d0b538c24a
JPunter/The-Python-Bible
/P2.py
454
4.40625
4
# Ask user for name name = input("What is your name?: ") # Ask user for age age = input("What is your age?: ") # Ask user for city city = input("What city do you live in?: ") # Ask user what they enjoy hobby = input("What is your favourite hobby?: ") # Create output text conc = "Hello {}! You are {} years old ...
2d8a79d5b0cfb5ffe7da96c607e2aebda022edca
88sanjay/Backtracking-2
/power_set.py
1,296
3.875
4
class Solution(object): def subsets(self, nums): """ Function to create a power set of distinct integers Approach : consider a power_set([1,2,3]) -> [[1],[2],[3],[1,2],[2,3],[1,3], [1,2,3]] power_set([1,2,3]) = power_set([1]) + [s.add(1) for s in power...
b274a670403b3a40de947cc8f772f6f5ccd71617
mariosever/hw_12.5_igra_sa_promjenom_levela
/hw_12_5_functions.py
1,591
3.859375
4
import json import random import datetime def play_game(level="easy"): secret = random.randint(1, 30) attempts = 0 score_list = get_score_list() change_level = "hard" while True: guess = int(input("Guess the secret number (between 1 and 30): ")) attempts += 1 ...
634086f92475f601237651d05d93df932035f7b0
bnicholl/GradientDescent_vs_NewtonOptimization
/optimization_intuition.py
4,911
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 8 23:49:24 2018 @author: bennicholl """ # packages for analyses import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D """hashtagged functions show the rosenbrock equation, and its firs...
e49b1929cb1e727c791604f0e9f24ab6f4ec8fb0
Daedgomez/IC-6200-Prediccion_Votaciones
/tec/ic/ia/pc1/g09/__init__.py
11,632
3.59375
4
import csv # Para abrir el archivo csv y cargar los datos import random # Para generar numeros aleatorios import os # Para cargar el archivo de datos desde la ruta de instalacion # Variables globales PARENT_DIR = os.path.dirname(os.path.dirname(__file__)) csvURL = os.path.join(PARENT_DIR, 'g09', 'DatosTSE.csv')...
a3e4a2bff8a5193f2dfbf5e2c2391b39dc95fe9a
DiR081/CodiPy-Prof
/conceptos/busqueda.py
573
4.34375
4
# Metodos y Herramientas para los strings texto = "En el siguiente texto tenemos varias palabras, para hacer las pruebas." # Con el metodo contar resultado = texto.count("texto") print(resultado) # Uso de la palabra reservada "in" resultado = "texto" in texto print(resultado) # Uso de la metodo encontrar resultado ...
e6a50971444fb0f7a2ce62ab91ca29433e3ecb1e
DiR081/CodiPy-Prof
/ciclos_condicionales/condicionales.py
172
3.5625
4
# Condicionales IF color_luz = "verde" if color_luz == "verde": print("Puede continuar") elif color_luz == "amarillo": print("atención") else: print("Stop")
584c56c352f58f70bc8f0d620597c431e6d0051b
DiR081/CodiPy-Prof
/conceptos/entrada.py
507
4
4
# Entrada datos desde Consola # Pregunta para interactuar print("Cúal es tu nombre?") # Siempre entra es de tipo String nombre = input() print("Cúal es tu edad?") # Se formatea la cadena a un número Entero edad = int(input()) # Imprime y recive entrada peso = float(input("Cúal es tu peso?")) # + ajuste - Salto de l...
a45609583cb5c4486cce36d8420eadfec111da4b
taiannlai/Pythonlearn
/CH4/CH4_L15.py
196
3.734375
4
v = eval(input("請輸入飛機起飛的速度:")) a = eval(input("請輸入飛機的加速度:")) distance = v **2 / (2*a) print("飛機起飛時所需的跑道長度為:%10.2d" % distance)
f6d2aa31f16787e18f6c7a3408a6614b293ffd95
taiannlai/Pythonlearn
/CH3/CH3_10.py
482
3.96875
4
x = -10 print("以下輸出abs()函數的應用") print(x) print(abs(x)) x = 5 y = 3 print("以下輸出pow()函數的應用") print(pow(x,y)) x = 47.5 print("以下輸出round(x)函數的應用") print(x) print(round(x)) x = 48.5 print(x) print(round(x)) x = 49.5 print(x) print(round(x)) print("以下輸出round(x,n)函數的應用") x = 2.15 print(x) print(round(x,1)) x = 2.25 print(x) p...
a33a6b1269055180f1cb9b96ffb1e3b5bc526a56
taiannlai/Pythonlearn
/CH4/CH4_L12.py
399
3.5625
4
x1, y1 = eval(input("請輸入第一個點的座標:")) x2, y2 = eval(input("請輸入第二個點的座標:")) x3, y3 = eval(input("請輸入第三個點的座標:")) dist1 = (((x1 - x2) ** 2) + ((y1 - y2) ** 2)) ** 0.5 dist2 = (((x1 - x3) ** 2) + ((y1 - y3) ** 2)) ** 0.5 dist3 = (((x2 - x3) ** 2) + ((y2 - y3) ** 2)) ** 0.5 p = (dist1 + dist2 +dist3) / 2 print("三角形面績:%10d" %p...
7b96a318d128be7eda7d831d81a5ce2436947ef5
taiannlai/Pythonlearn
/CH3/CH3_22.py
135
3.765625
4
str1 = "Hello! \nPython" print("不含r字元的輸出") print(str1) str2 = r"Hello! \nPython" print("含r字元的輸出") print(str2)
f97b988268fc316cf965dff2966e61259d57ffc9
machine21/Learning_for_Text_and_Graph_Data
/2nd-Graph Kernels/lab2_solutions/part3/kernel_eval.py
3,340
3.546875
4
#!/usr/bin/env python """ Graph Mining and Analysis with Python - Master Data Science - MVA - Feb 2017 Graph Classification """ import numpy as np import math from sklearn import svm from sklearn.model_selection import (KFold,ShuffleSplit,StratifiedShuffleSplit) from sklearn.metrics import accuracy_score def norm...
9256ab14396d576ab91f21a48541915618bce4ca
lorcaheeney/tkmultikey
/__init__.py
3,261
4.03125
4
""" tkmultikey is a python library intended to make the process of binding actions to key combinations easier in tkinter. tkmultikey redefines tkinter's core binding functions to allow commands to be bound to key strokes such as "<Ctrl>+<Left>". Example Usage: --------------------- import tkinter import tkmultikey win...
d90c9536dbbdce19483212c9c3927bff2ca00133
Antaine/ETLabs
/lab2/approxSqrt.py
512
4.125
4
#Lab 2 - Antaine O Conghaile - G00347577 # Adapted from https://tour.golang.org/flowcontrol/8 def sqrt(x): z = 1.0 #Keep getting better estimate for the square root #of x, until you are within two decimal places. while abs(z*z - x)>= 0.0001: #Get a better approximation for the square root. ...
e616abe49af2f904f291bfa0feefa3a0dde21543
MichielDepraetere/Algoritmen-14-10-intro-ex-Michiel-Depraetere
/exercises/oef2.py
577
3.578125
4
number1 = 2 number2 = 1 outcome = 0 total = 0 while(outcome < 4000000): outcome = number1 + number2 if(number1 == 2): if(number1 % 2 == 0): total += number1 number1 = outcome else: if(number1 < number2): if(number1 % 2 == 0): total ...
d6cd7fcc766a2c69514e0d859b5b7928bf8b457c
Mando75/CS450
/kNN/kdTree.py
9,491
3.65625
4
import numpy as np import heapq class kdTree: def __init__(self, points): """ Initialize a new k-dimensional tree. The k will be automatically determined by the shape of the points :param points: Expects a numpy array of tuples of the form ([coordinates], index) """ ...
990610a77041abd9f5326a1b5f42ffda23fd872a
umangi-jain/IR_NLP
/Methods/Baseline_VSM/tokenization.py
2,361
3.546875
4
from util import * # Add your import statements here from nltk.tokenize import TreebankWordTokenizer class Tokenization(): def naive(self, text): """ Tokenization using a Naive Approach Parameters ---------- arg1 : list A list of strings where each string is a single sentence Returns ------- li...
75b82da41d08e0a0aa6a2e888a07c10f1c60284a
CourseraK2/ADA1
/week4/PythonTry/SCC/scc.py
6,557
4.0625
4
# Algorithms: Design and Analysis Part 1, Coursera # Week 4 Material: Computing Strongly Connected Components in Directed Graph using Depth First Search ''' Download the text file here[http://spark-public.s3.amazonaws.com/algo1/programming_prob/SCC.txt]. Zipped version here[http://spark-public.s3.amazonaws.com/algo...
70eab9ef162d9b499dbe361494a7f6ce329375d0
kaeli5892/Python-Codes
/CheckerboardKarel.py
1,391
4.0625
4
from karel.stanfordkarel import * """ File: CheckerboardKarel.py ---------------------------- When you finish writing it, CheckerboardKarel should draw a checkerboard using beepers, as described in Assignment 1. You should make sure that your program works for all of the sample worlds supplied in the starter folder. "...
10e777a220bdde0c093ee0c960a68f5beaa98e84
rashrey2308/python-basics
/operators.py
249
3.984375
4
a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) avg=(a+b+c+d+e)/5 if(avg>=90): grade='A' elif(avg>=80): grade='B' elif(avg>=70): grade='B' elif(avg>=60): grade='B' else: grade='F' print(grade)
a3969d0677cf1a02bdaf6940caf6e2bb09b911ca
rashrey2308/python-basics
/flow-controls.py
840
4.5
4
'''Anna likes to draw right angled triangles. She recently learnt how to code in Python, and she is curious to see if it can be used to print the same. You need to help her out by writing a program which takes an input number n from the user and prints a right angled triangle of height n. Anna also wants that the trian...
66004d888ec47e2ec55e0363fa6d0311ec0922c1
FedericoPaini/Python
/passwordWithWeight.py
1,410
4
4
#!/usr/bin/python import random letters = ['a','b','c','d','e','f','g','h','i','l','m','n','o','p','q','r','z','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', '@','!','$','%','&','(',')','^'] numbers = ['1','2','3','4','5','6','7','8','9','0']...
3fb1792b724081d9695156d650bdeec19919d46a
FedericoPaini/Python
/censor.py
581
3.8125
4
#!/usr/bin/python import sys, os, os.path, urllib2, re, cookielib, time, datetime, locale, random def censor(text, word): lst = text.split() lst_items = len(lst) word_lenght = len(word) for w in lst: if w == word: lst[lst.index(word)] = "*" * word_lenght error = False ...
750a1e5b876a17fd847f2b85cb1bccb333f5895d
lesp/microdotphat
/flash-Les.py
1,551
3.515625
4
#!/usr/bin/env python import time import math from microdotphat import clear, show, set_pixel, WIDTH, HEIGHT from random import randint t = 0.1 print WIDTH while True: """ rand_x1 = randint(0,45) rand_y1 = randint(0,6) rand_x2 = randint(0,45) rand_y2 = randint(0,6) rand_x3 = randint(0,45) ...
1287fa0f2bd55a250dcda1abaf27099b308322d4
GalMeirom/petelina_tips
/Main/employees.py
3,019
4.09375
4
class Employee(): ''' main class for the waiters has two methods to calculate the total money an employee has earned in cash and in credit ''' def __init__(self): self.cash_person = None self.credit_person = None self.hours = None def cal_cash(self, cash_per_hour): ...
b648d0c9c171733d23b8daf4b6152f1ea2762823
hryxna/Java-Algos
/HillCipher/Hill_Cipher.py
3,423
3.5625
4
d = {'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25} e = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u'...
ee518a2275cfb7a3ff8e5f256d350e9c7eaaadd7
Lanooo/lista-de-exercicios-5
/exerc07.py
344
4.125
4
#Escreva um algoritmo que receba dois números e exiba para o usuário todos os valores intermediários a eles, veja exemplo: #Primeiro número: 5 #Segundo número: 15 #Resultado: 6 7 8 9 10 11 12 13 14# n1 = int(input("Digite um número: ")) n2 = int(input("Digite outro número: ")) while n1 < n2: print (n1) ...
0ec24cb682cabbae7fdc2ae4389f628fedd9df70
mbledkowski/HelloRube
/Python/cipher.py
173
4
4
word = "Hello World!" encrypt = "" s = 5 for alpha in word: encrypt += chr(ord(alpha) + s) decrypt = "" for alpha in encrypt: decrypt += chr(ord(alpha) - s) print decrypt
8a27f31f5ba137ee5f4d56580a3d7297805f350e
Abdurrohman006/python-darslarim
/11-DARS. if, elif, else,.py
4,687
3.75
4
############## 11-DARS. if, elif, else ############### # son=50 # # if son<0: # print("Manfiy son") # else: # print("musbat son") # yosh=int(input("Yoshingiz nechchida!")) # if yosh<=4: # narx = 0 # elif yosh<=12: # narx=5000 # elif yosh<=18: # narx=8000 # else: # narx=10...
ae080c3bce9d94facf2ef0b4f713dddf85dba0f8
arbazkhan678/Email-slicer
/email slicer.py
363
3.984375
4
# Email slicer while True: email = input(" what isn your email || Do you want to continue again ? (y/n)").strip() if email.lower() == 'n': break user_name = email[:email.index('@')] domain_name = email[email.index('@')+1:] output = " Your name is '{}' and Your domain is '{}'".format(...
0b0c904ef0fa194b820383052fd8404260ca9344
sadimanna/project_euler
/p35.py
884
3.890625
4
import time from math import ceil,sqrt def isprime(num): sqnum = ceil(sqrt(num)) limit = int(ceil((sqnum-1)/2))+1 if num == 2 or num == 3: return 1 elif num % 2 == 0: return 0 else: for n in xrange(1,limit): if num % (2*n+1) == 0: return 0 return 1 def rotate_num(num,nplace,lnum): div = 10**(lnum...
fc81aabad6b89e74ca5c293f2fe5d77b2dedd122
sadimanna/project_euler
/p41.py
1,343
3.8125
4
from math import factorial, sqrt def isprime(n): for i in range(2,int(sqrt(n))+1): if n%i==0: return 0 return 1 def prime_lex(s): seq = list(s) # there are going to be n! permutations where n = len(seq) for _ in range(factorial(len(seq))): # print permutati...
d27b3a533fcc49a2ae736faf210c8d6423c31369
sadimanna/project_euler
/p46.py
598
3.671875
4
# GOLDBACH'S OTHER CONJECTURE from math import sqrt, ceil def isprime(n): for i in range(2,ceil(sqrt(n))+1): if n%i==0: return 0 return 1 if __name__ == '__main__': found = 0 n = 35 while(found == 0): i = 0 satisfied = 0 while not satisfied: i+=1 temp = n - 2*i*i if temp ...
cc8f84380865ebec5c7164df4954d728f1215051
santoshray02/Puzzle
/PuzzleSolver.py
5,024
3.703125
4
# coding=utf-8 class WrongInputException(ValueError): def __init__(self, code, message): self.code = code self.message = message def __str__(self): return "Error code: {}. Message: {}".format(self.code, self.message) class PuzzleSolver: ''' FindWords should return the number ...
60a11d75840b00c133e58aedd82ebc983908767c
charliegriefer/advent2019
/day_03/day_03_01.py
1,113
3.53125
4
from typing import List from shapely.geometry import LineString, MultiPoint def main(): with open("day_03.txt") as f: wires = f.readlines() wire_1 = LineString(get_coords(wires[0])) wire_2 = LineString(get_coords(wires[1])) intersections = wire_1.intersection(wire_2) closest_intersectio...
a6b9c22d038c1a81db29f5c26fb7dd9870289871
Ady-6720/python
/BMI calculator_AND&OR.py
773
4.4375
4
#BMI calculator and Category showing w=float(input("Enter your Weightin Kg: ")) h=float(input("Enter your Height in meter: ")) print("You entered",w,"as your weight &",h,"as your height.") #bmi calculation #formula BMI=w/(h*h) bmi=(w/(h*h)) print("Your BMI is : ",round(bmi,2)) #bmi category determinati...
e5480f03c6e6ce38331382ec7d0756182cacfaf9
Ady-6720/python
/BMI calculator method 2.py
758
4.40625
4
#BMI calculator and Category showing w=float(input("Enter your Weightin Kg: ")) h=float(input("Enter your Height in meter: ")) print("You entered",w,"as your weight &",h,"as your height.") #bmi calculation #formula BMI=w/(h*h) bmi=(w/(h*h)) print("Your BMI is : ",round(bmi,2)) #bmi category determinati...
f826552481862933b60481498254f255f17f8d3b
Ady-6720/python
/Booleans.py
645
4.125
4
myBoolean= True #dont use quotes, if used it will act as astring type(myBoolean) num1=float(input("Enter a number: ")) num2=float(input("Enter second number: ")) print(num1>num2) #here as condition satisfies it will write TRUE print(num2>num1) #here as condition doesnt satisfies it will give FALSE as...
0785f0abc32433e0ca445f57d120575c7274a19f
py1-10-2017/StephanieArtati-py1-10-2017
/fun_with_functions.py
696
4.25
4
def odd_even(): for i in range(1,2001): if (i%2 == 0): print ("Number is: "+str(i)+". This is an even number.") else: print ("Number is: "+str(i)+". This is an odd number.") def multiply(arr,multiplier): new_arr = [] for i in arr: new_arr.append(i*multiplier)...
1f558bfb66903f18ba50531666beedebde50a128
py1-10-2017/StephanieArtati-py1-10-2017
/multiples_sum_average.py
487
4.125
4
# Multiples Part 1 print("Multiples - Odd Numbers") odd_numbers = [] for i in range(0,1001): if (i%2!=0): odd_numbers.append(i) print(odd_numbers) # Multiples Part 2 print("Multiples - Multiples of 5") multiples_numbers = [] for i in range(5,1000001): if (i%5==0): multiples_numbers.append(i) pr...
2983ee9f45f4ef99fcc3e2ab88e45e5d4af7bf44
SprihaDeshpande/Hangman-Game
/pick_word.py
1,801
3.859375
4
import random class Guessing: def __init__(self): input = raw_input("Would you like to Play? y/n: ") if input == "y": words = ["Animal", "Doctor", "People", "World", "Coding"] self.word = random.choice(words) self.hidden_words = "*"*len(self.word) se...
1cedc2f6f9147e4debf4a36685214760b6dce547
etikrusteva/python_scripts
/discount.py
1,388
4.125
4
#!/usr/bin/env python3 def disc(): print("""Please type in the next lines the information for your ticket: Are you with child? Have you discount for loyal client? Have you bonus giftcard? \nNote that you can use only one discount and you use only the giftcard bonus if you have it! \n""") chil...
9fa3479b681b966ce2ffe7762d05931b7125ecce
Akay999/cs50Problemsets
/pset6/credit/credit.py
662
3.546875
4
from cs50 import get_int from sys import exit h = get_int("Enter the number: ") s = str(h) l = len(s) sum = 0 count = 0 for i in s[::-1]: i = int(i) if count % 2 != 0: i *= 2 if i > 9: i -= 9 sum += i else : sum += i count += 1 else : ...
8c1378adf658fae61a7bd953ce2c4c1c46357545
amygdalama/cracking-the-coding-interview
/5-bit-manipulation/bittasks.py
467
3.6875
4
def get_bit(num, i): """Get the ith bit of num.""" return num & (1 << i) != 0 def set_bit(num, i): """Set the ith bit of num to 1.""" return num | (1 << i) def clear_bit(num, i): """Set the ith bit of num to 0.""" return num & ~(1 << i) def update_bit(num, i, v): """Set the ith bit of num...
c639e498e135f9ef36bb9f2680da6642c0236b1b
amygdalama/cracking-the-coding-interview
/2-linked-lists/2.py
577
4.125
4
from singly import LinkedList def nth_to_last(l, n): """Find nth to last element of the singly linked list, l.""" current = l.head runner = current for i in range(n): if runner.next: runner = runner.next else: raise ValueError("%s is larger than the list!" % n) ...
c8bd5e47f620b32e0ffb3a936088d63fcd813a2a
amygdalama/cracking-the-coding-interview
/2-linked-lists/3.py
409
3.828125
4
from singly import LinkedList def delete_node(node): if node and node.next: node.cargo = node.next.cargo node.next = node.next.next else: raise IndexError("Node out of range!") if __name__ == '__main__': l = LinkedList() for i in range(10): l.append(i) delete_node(l...
2109162cf8bb7da5ff6e70ebf0e946539141a279
Jesusprzr/Making-Of-A-Data-Scientist
/Documentation - Supplemental Content/Programming Fundamentals/Assigments/Quizes/QuizW6.py
12,236
4.0625
4
#TODO: Passed the exam (11/13). But should check answers 3 and 12 because both are wrong. #? 1- What is printed by the following code? def merger(L): merger = [] for i in range(0, len(L), 3): merger.append(L[i] + L[i + 1] + L[i + 2]) return merger print(merger([1,2,3,4,5,6,7,8,9])) #//[...
388793cc6497462f34ceaa1166657b2865bd0272
Jesusprzr/Making-Of-A-Data-Scientist
/Documentation - Supplemental Content/Programming Fundamentals/Assigments/Quizes/FinalExam.py
7,696
4.375
4
#FINAL EXAM #? 1- Select the expression that evaluates to int: 8 % 6 #* 8.0 % 4 #! Yes but not, the result is 8.0 8 + 3 #* 7 + 8.5 #! #? 2- Consider the following code: a = 7 b = a + 3 a = 9 #? What does b refer to? 10 #? 3- Consider this code: def f(x): y = x*3 return y ...
fac6b8cd27656b678e451b4787e230d9b122c7f1
eamonnofarrell/Python_exercises
/Week6_Factorial.py
979
4.40625
4
#Eamonn O'Farrell #Write a Python script containing a function called factorial() #that takes a single input/argument which is a positive integer #and returns its factorial. The factorial of a number is that #number multiplied by all of the positive numbers less than it. #For example, the factorial of 5 is 5...
c89c3e8f16c82a45b7c4f34fa0af66a0fe848b06
julvei/eth-assertion-protocol
/assertion/test_functions.py
1,587
3.71875
4
""" Author: JV Date: 2021-05-03 Unit test of functions structure """ import unittest from assertion.functions import FUNCTIONS class Test_Functions(unittest.TestCase): def test_get_function(self): ret_function = FUNCTIONS.get_function_by_id(0) self.assertTrue(callable(ret_function)) ...
498f9ee50eae409ff01d23d2ad6324d227797319
MrDrDAVID/leetcode-answers
/leetcode-stuff/median_of_2_arrays.py
1,644
3.578125
4
def findMedianSortedArrays(nums1, nums2): median = 0.0 if not nums1 : if len(nums2) == 1 : median = float(nums2[0]) return median if (len(nums2) % 2 == 0) : middle_num = len(nums2) // 2 - 1 middle_num2 = middle_num + 1...
6319fa8571cb75b1244daa8889e86308ab4e367f
Moran96/word-frequency
/main.py
4,561
3.671875
4
#coding=utf-8 import tkinter.filedialog as filedialog from tkinter import * import os from tkinter import * import re import collections import os #*********************************************************************************** def traverse(f): fs = os.listdir(f) all_files_path = open("all_files...
9ad98167d2fbf55dc2cf14f6a01f8b0cf4167c68
xlb233/DandA
/quick_sort.py
1,611
3.859375
4
import random def quick_sort(arr, left, right): if left >= right: return low = left high = right pivot = arr[left] # 不断循环这个过程,直到left指针和right指针相遇。 while left < right: while arr[right] >= pivot and left < right: right -= 1 # 此时pivot从数组中消失,取而代之的是从右往左发现的第一个小于piv...
b7e13b0165740db49d198969552ba36afb9a676a
GroupGO/Cufflinks
/SamSort.py
3,554
3.5625
4
#!/usr/bin/env python """ Author: Henry Ehlers WUR_Number: 921013218060 A script designed to sort a given SAM file and save it to a BAM file. Inputs: [1] A string specifying the path to a sam file. [2] A string specifying the overwrite option [True/False] should existing files ...
be022aeb2806250c6f96fa1787efa3226530b5dc
AaronWendell/MIS3640
/Session 05/Exercise3.py
1,547
3.703125
4
import turtle import math def l_polyline(t, n, length, angle): for i in range(n): t.fd(length) t.lt(angle) def l_arc(t, r, angle): arc_length = 2 * math.pi * r * angle / 360 n = int(arc_length / 3) + 1 step_length = arc_length / n step_angle = float(angle) / n l_polyline(t, n,...
cddd3793dea0f12ea3dd279015546ee7339f39e3
AaronWendell/MIS3640
/Session 02/calc.py
1,465
4.09375
4
import math print("\nSession 01 Work") #Time (in seconds) t = 42 * 60 + 42 print("42 minutes and 42 seconds is equal to " + str(t) + " seconds") #Distance (in miles) d = 10 / 1.61 print("10 kilometers is equal to " + str(round(d,1)) + " miles") #Pace (in seconds per mile) p = t / d #Speed (in miles per hour) s = d...
02e5ffdca5a69dbf289300ba4bd71ee38e2b3762
CornerstoneII/Startng
/First-Task.py
402
4.15625
4
# Python First Task: # Create Basic Calculator for Area of a Circle # Write a Python program which accepts the radius of a circle from the user and computes the area. def r(): # Set up name variable with input value = int(input('Enter the radius value: ')) # Check whether name has a vowel area = 22/7...
a15bab3d1adfb2975c566ad1aa69c8c1ddf50697
toddbranch/blackjack
/main.py
4,238
3.953125
4
from blackjack import Blackjack ################################################################ # Helper Functions ################################################################ def getPlayerBet(bank): bet = 0 while bet > bank or bet < 1.0: try: print("Bets must be more than 1 and less...
1f9191ecc1d6a4f5ee4f2e78d65172846f7140c5
DonkeyZhang/Python
/stage1/day02/game3.py
1,689
4.09375
4
#-*-coding:utf-8-*- ## # counter = 1 # user = 0 # com =0 # while counter <= 3: # import random # all_choice = ['石头', '剪刀', '布'] # win_list = [['石头','剪刀'], ['剪刀','布'],['布', '石头']] # # prompt=""" # (0)石头 # (1)剪刀 # (2)布 # Please input your choice(0/1/2):""" # # computer = random.choice...
6e4ff0ddebb1ecfd20bb5942b4e01566a5930c8e
DonkeyZhang/Python
/stage1/day01/zxw01.py
562
3.953125
4
print('hello world!') if 3 > 0: print('yes') if 3 > 10: print('haha') print('jjk') if 3 > 0: print('abc') # #################################### print('hello world!') print('hello', 'world!') print('Hello', 'world!', 10, sep='***') # print('Hello'+'world') # number = input('number:') #ks...
8680c51cc3efac9340cf56e46f8e3190bb5fa51b
DonkeyZhang/Python
/stage2/day03/toys.py
792
3.796875
4
#-*-coding:utf-8-*- class Vendor: def __init__(self, company, ph): self.company = company self.phone = ph def call(self): print('Calling %s...' % self.phone) class PigToy: #定义玩具类 def __init__(self, name, color,company,ph): self.name=name self.color=color ...
f4a9cc526f23133bb502e87f50c68ffba8c4b55a
DonkeyZhang/Python
/stage1/day02/login2.py
256
3.609375
4
#-*-coding:utf-8-*- import getpass username =input('username:') password=getpass.getpass('password:') if username == 'bob' and password == '123456': print('Login successful') else: print('Login incorrect') #到命令行执行
717142eefa3f990bb1490f219b7d53ee0fa6796b
FrancoPalau/Fuzzy-logic-controlller
/PenduloInvertido.py
1,706
4.25
4
from math import sin from math import cos from math import pi class PenduloInvertido: """ Clase que modela el comportamiento del pendulo Invertido Su constructor toma como parametros iniciales: 1_Angulo inicial 2_Velocidad angular inicial 3_Masa del carro (en kg) 4_Masa de ...
0a328d9e5d17187c384f4d09b5d3f8990ecaf034
quintg1991/aisObjectRecognition
/Docs/pythonGuidelines.py
919
3.609375
4
# Required header block ''' Name: pythonGuidelines.py Author(s): Chocolate and Peanut Butter Description: Brief description of purpose of this file ''' # PYTHON STYLE GUIDELINES # Leave a space between comment syntax and the comment itself # Lines should end at line 80 # A note on functions # Good code shou...
9ade4cb90e865650614e19e0b06a5ccd7118d31a
shockim3710/Programmers-Algorithm
/Level 1/12930_이상한 문자 만들기.py
644
3.625
4
def solution(s): answer = '' count = 1 for i in s: # 문자가 알파벳이고 # 0번째부터 대문자이므로 1부터 count를 하여 # 홀수번째면 대문자 짝수번째면 소문자로 # 규칙을 변경하여 answer에 추가 if i.isalpha() == True: if count % 2 != 0: answer += i.upper() else: answe...
03a7830c3e6a4f0fe3af1015bd89f5ab42054f96
shockim3710/Programmers-Algorithm
/Level 1/1845_폰켓몬.py
388
3.640625
4
def solution(nums): choice = len(nums) // 2 nums = set(nums) # 중복 제거를 위해 집합으로 변환 # 선택하는 마리보다 중복없는 폰켓몬이 적으면 # 폰켓몬의 마리수를 출력 if len(nums) < choice: answer = len(nums) # 그렇지 않으면 선택하는 마리수를 출력 else: answer = choice return answer
9adad31361a55b2609acbd6429e49ee4743295eb
KaanPY/PythonListelerinFonksiyonu
/Listelerin Fonksiyonları 2.Extend.py
705
3.703125
4
""" ============================================= liste1 = ["Öyle", "üçe", "beşe", "bakamam!"] # Listemiz 1 liste2 = ["Gelir", "gider", "bir gün", "paralar"] # Listemiz 2 liste1.extend(liste2) #burada extend fonksiyonu ile listeler birleştirilmiştir. print(liste1) =============================================...
af44bd06fd2462b66564544d1a66c701977dd61b
Victor-Foscarini/Programming_Fundamentals
/Python/Data.py
1,796
3.75
4
#Victor-Foscarini #plots básicos from matplotlib import pyplot as plt import random class Plots: def __init__ (self): self.variavel = 0 def simple(self): years = [1950, 1960, 1970, 1980, 1990, 2000, 2010] gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3] #create a line chart, years on x...
98b3e7082b37bcbde256e4fc4eb85d9c4a211001
DavidHan6/Week1
/PythonFurstthings/BMIcalculator.py
722
4.40625
4
#bmi calculator to see if ur fat. print("HELLO. WELCOME TO THE AUTOMATED BMI CALCULATOR TO SEE IF YOUR FAT") Unit = input("Metric or Customary/Imperial ") if Unit == "Metric": hight = input("Please enter hight in meters ") weight = input("Please enter weight in kilos ") hight = float(hight) weight = fl...
3944c4654db21f347c93f0589c8e9b82213e3e5c
GabrieliRamos/Exercicios_Python
/Exercicio_Aula12/exercicio07.py
1,168
3.953125
4
####################################################################################################### # Conta espaços e vogais. Dado uma string com uma frase informada pelo usuário (incluindo espaços em branco), # conte: # quantos espaços em branco existem na frase. # quantas vezes aparecem as vogais a, e,...
1932dcd8597ab0f3a0d3c4d1bddba31fe30aac70
sp-moribito/pythonbasic
/0503_02.py
394
3.6875
4
import time import datetime now=datetime.datetime.now() mid=datetime.datetime(now.year, now.month, now.day) + datetime.timedelta(1) while True: now=datetime.datetime.now() if now==mid: print("at time") now=datetime.datetime.now() mid=datetime.datetime(now.year, now.month, no...
5b25ff6a03ced3b4cc092decad6231d010730af1
ryamoore/program-arcade-games
/Lab 07 - Adventure/main_program.py
1,165
4.09375
4
#!/usr/bin/env python3 # main_program.py # Ryan Moore # 11/20/2017 """ runs a map then the game """ current_room = 0 done = False room_list = [ ] room = ["You have just awoken in a jail cell of a ship(can only go North)",0,None,None,None] room_list.append(room) room = ["You are in a big hallway",1,None,None,None] r...
0d9d1b0da3b636cf14e27c4c86b8ce17b7ce91c0
Muhammedasel/vize-notu-hesaplama
/vize final notu.py
750
3.625
4
vize1= float(input("kısa sınav notunuzu girin : ")) vize2= float(input("vize notunuzu giriniz : ")) final= float(input("final notunuzu giriniz : ")) vize1= (vize1*30)/100 vize2= (vize2*30)/100 final= (final*40)/100 sonuç= vize1+vize2+final print("SINAV SONUCUNUZ : ", sonuç) if(sonuç>=90): print(...
c275f6129cbe4b20eb4faea4633802f956f0e1e3
jeffwindsor/learn
/Coursera/Data Structures and Algorithms/C1 Algorithmic Toolbox/W4 - Divide-and-Conquer/inversions/iv.py
1,096
3.671875
4
# Uses python3 import sys def merge_sort_and_count(A): if len(A) == 1: return 0 m = int(len(a)/2) (lc, L) = merge_sort_and_count(A[:m]) (rc, R) = merge_sort_and_count(A[m:]) (ac, A) = merge_and_count(L,R) return lc+rc+ac, A def merge_and_count(A,B): C = [] count=i=j=0 la =...
d5207c113dba709c64da7518a4dacbc59f459163
jeffwindsor/learn
/Coursera/Data Structures and Algorithms/C1 Algorithmic Toolbox/W3 - Greedy Algorithms/dot_product/dot_product.py
374
3.734375
4
#Uses python3 import sys def min_dot_product(xs, ys): xs = sorted(xs) ys = sorted(ys, reverse=True) products = [x*y for x, y in zip(xs, ys)] return sum(products) if __name__ == '__main__': input = sys.stdin.read() data = list(map(int, input.split())) n = data[0] a = data[1:(n + 1)] ...
979f15df20fd56745f732540e8babb672eb2c972
rajeshchangdar/Python-Introduction
/CntrlFlowNdLooping/SticksGame.py
447
3.984375
4
sticks=21 while True: print("Stricks Left: ",sticks) sticks_taken=int(input("Take Sticks(1-4): ")) if sticks==1: print("You took the last stick..you lose") break if((sticks_taken>=5)or(sticks_taken<=0)): print("Wrong Choice!!!..Try Again") continue p...
79142eb3bea2030410fc1f2a640df556974524b1
rajeshchangdar/Python-Introduction
/VariableNdOperators/StringFormating.py
589
4.25
4
#Introduction to String Formatting #Tuple Packing and Unpacking data=("Rajesh Changdar","1193923","TCS") # Tuple Packing name,empid,company=data # Tuple Unpacking print(name,empid,company) #Python_v<3.6 String Formatting name="Rajesh Changdar" roll="it1217" college="CEM,Kolaghat" msg="My name is {0} and m...
4555e4f6625bfe9fa2f8332763339becdb122308
rajeshchangdar/Python-Introduction
/CntrlFlowNdLooping/ControlDemo.py
434
4.1875
4
#Introduction to Python Control Flow and Looping num=int(input("Enter a Number: ")) if (num<100): print("The Number is Less than 100") elif (num==100): print("The Number is equal to 100") else: print("The Number is more than 100") if num: pass # pass is used to skip the statements in the scri...
e84a1a38d0a9bd3bb6d99d65e9bb1527a48dca21
rajeshchangdar/Python-Introduction
/CntrlFlowNdLooping/LoopListDemo.py
984
4.15625
4
#Introduction to Python List with application of Loop """ list1=["Rajesh","IT1217",1193923,"TCS","Kolkata"] print(list1) print(list1[1]) print(list1[-1]) print(list1[0:5]) print(list1[0:-1]) print("Kolkata" in list1) print("CTS" in list1) print(len(list1)) if list1: print("List is not Empty") e...
88e201ef0e1b690e637d4ccfac788d9b7fc2fe7e
vmred/codewars
/katas/5kyu/String incrementer/solution.py
569
4.375
4
# Your job is to write a function which increments a string, to create a new string. # If the string already ends with a number, the number should be incremented by 1. # If the string does not end with a number. the number 1 should be appended to the new string. # Examples: # foo -> foo1 # foobar23 -> foobar24 import...