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
deb0fd276135d9a634835cfd67e6a5bf96a254cf
nanareyes/CicloUno-Python
/Acumuladores Contadores/7_ejercicio_contadores.py
335
3.78125
4
# 7 """ Realizar un algoritmo para sumar consecutivamente y cuando la suma sea superior a 100 deje de pedir números y muestre el total. """ n = 0 suma = 0 numero = 0 while suma <= 100: n = float(input("Digite un número: ")) suma = suma + n numero = n + 1 promedio = suma / numero print("El total es: ", ...
09db9780bc26c56191551748452edf5b31cc3cda
nanareyes/CicloUno-Python
/Nivelacion_1/condicionales_nivelacion.py
1,375
4.3125
4
# Para los condicionales utilizo comparadores de decisión ''' En los diagramas de flujo el condicional se expresa en rombo utiliza comparadores de decisión (> < == !=) y operadores lógicos ( y(and) o(or) no(not)) ''' ''' Se necesita saber si el estudiante tuvo alto, medio o bajo rendimiento [0;3) Rendimiento bajo [3;...
d08c35f45d56d17b8ed271901bbbe9e06a5cdcc3
nanareyes/CicloUno-Python
/operaciones_con_cadena/metodos.py
231
4.03125
4
# Métodos de los String # x.upper() # Este método devuelve una copia de la cadena convirtiendo las letras en mayúscula frase = "curso de python" print(frase.upper()) # x.lowe() frase = "CURSO DE PYTHON" print(frase.lower())
ffebce985975962495b6698d90e759783f4daa5f
nanareyes/CicloUno-Python
/FuncionesParaColeccionesDatos/funciones_anonimas_FilterLambda.py
1,167
4.65625
5
# FUNCIONES ANONIMAS """ Habrá ocasiones en las cuales necesitemos crear funciones de manera rápida, en tiempo de ejecución. Funciones, las cuales realizan una tarea en concreto, regularmente pequeña. En estos casos haremos uso de funciones lambda. ------------------------------------------------- lambda argumento : ...
78b4a346738a02468e0dc31c5f1c89ef83c27d3e
nanareyes/CicloUno-Python
/Modulo1/Ejercicios de Repaso Reto2/ejercicio15.py
406
3.90625
4
#15. Leer un número entero y determinar si es múltiplo de 7. def es_multipl(a): if a == 0: return False elif a % 7 == 0: return True else: return False print('\n') numero = int(input("Digite un numero: ")) respuesta = es_multipl(numero) if respuesta == True: print("El núme...
8a3b5d04684070110a39d5a151549aa28351dc78
nanareyes/CicloUno-Python
/Condicionales/ejercicio9_condicional.py
1,356
4.03125
4
''' Permita calcular el total a pagar por la compra de N camisas. Si se compran entre 1 a 4 camisas se aplica un descuento del 12.5%, si se compra una cantidad comprendida entre 5 y 8 camisas se aplica un descuento del 20% y si se compran cantidades mayores, se aplica un descuento del 31.5% sobre el total de la compr...
89a084a1aa3079549a31480002f1614c38e5bf48
m0nT3cR1s70/Diferencias-Finitas
/df.py
3,318
3.65625
4
""" @author Define las aproximaciones de diferencias finitas """ import numpy as np import pandas as pd def fx(ux,x): """ Evalua una expresion en formato tipo python. Args: ux: Cadena con formato numerico python. x: Numero o arreglo donde se desea evaluar la ...
83a11efd3f08b468a4017ec1b77c50bb14abf289
Tulsani/PCA_Analyisis_Statistics
/index.py
5,430
3.6875
4
#PCA (principal component analysis) algorithm used for feature # extraction and for dimensionality reduction. #also can be used for explaining data behaviour #Used in analysis of genome data and gene expression #helps identify patterns based on correlation between features #PCA aims to find directions of maximum varia...
cc423dc4865cb455655ed3a0727b75e2b87cdd4e
pdsmith90/codesignal
/arcade/python/drilling_the_lists/58.py
157
3.5625
4
#! /usr/bin/env python3 def groupDating(male, female): return [[x for x, y in zip(male, female) if x != y],[y for x, y in zip(male, female) if x != y]]
29dd5558be3dff10f07dfb0d0f6d8289c348bd2c
pdsmith90/codesignal
/arcade/intro/7.py
584
3.5625
4
#!/bin/python3 def almostIncreasingSequence(sequence): count = 0 i =0 size = len(sequence) if(sequence[0]>sequence[1]): sequence.pop(0) count+=1 size-=1 while(i<size-1): if sequence[i]>=sequence[i+1]: count+=1 if(sequence[i+1]<=sequence[i-1]...
e4d8b6cba564c68d7a2bef84331c1842eba21444
kongruksiamza/PythonBeginner
/Phase2/Functions/EP4.py
573
3.515625
4
# Arguments / Parameter def myData(a,b,c): print("ชื่อ = ",a," นามสกุล = ",b,"อายุ = ",c) def addition(a,b): print("ผลรวม = ",a+b) x=5 y=9 addition(x,y) # Arguments => ค่าที่ส่งเข้าไปใน function => fname , lname , age (ตอนที่เรียกใช้ฟังก์ชั่น) # Parameter => ค่าตัวแปรที่รับข้อมูลที่ส่งมาทำงาน (...
bce2173fa5d3c87ec99f226b717e64bc8ed101bf
kongruksiamza/PythonBeginner
/Phase2/Functions/EP9.py
331
3.765625
4
# function return ค่า def randomNumber(x): if len(x)<3 : return if x == "100": print("ถูกหวย") return 1000 else : print("ไม่ถูกหวย") return 0 money=randomNumber("100") print("เงินรางวัล = ",money)
4bb4253b47123e8791aa1b674881f30da6a4f03c
kongruksiamza/PythonBeginner
/Phase2/EP39.Assignment3.py
491
4.125
4
# Assignment หากลุ่มเลขคู่ / เลขคี่ number=[] odd=[] #เลขคี่ even=[] #เลขคู่ while True: x=int(input("ป้อนตัวเลขของคุณ :")) if x<0: break if x%2 == 0: even.append(x) else : odd.append(x) number.append(x) print("ตัวเลขทั้งหมด =>" ,number) print("เลขคู่ => ",eve...
6a7352b15ce156585422d470e70897f70becd0e5
kongruksiamza/PythonBeginner
/Phase1/EP18.Assignment2.py
320
3.84375
4
# เขียนโปรแกรมหาตัวเลข มาก / น้อย a=int(input("ป้อนตัวเลขที่ 1 :")) b=int(input("ป้อนตัวเลขที่ 2 :")) if a>b : print(a," มากกว่า ",b) else : print(a," น้อยกว่า ",b)
db949acf9883676af846335b01e7bcd411e44cf9
kongruksiamza/PythonBeginner
/Phase1/EP25.py
248
3.640625
4
# โครงสร้างควบคุมแบบทำซ้ำ summation=0 for i in range(1,11): # summation print("รอบที่ = ",i) print("ผลรวม = ", summation) print("เฉลี่ย = ", summation/10)
f0f46d93372eb152164d02f3d0d3a3d33df406e4
kongruksiamza/PythonBeginner
/Phase2/Functions/EP1.py
457
3.828125
4
# สาเหตุที่เราต้องเขียน function a,b,c,d=10,23,40,50 if a%2 == 0: print("เลขคู่") else : print("เลขคี่") if b%2 == 0: print("เลขคู่") else : print("เลขคี่") if c%2 == 0: print("เลขคู่") else : print("เลขคี่") if d%2 == 0: print("เลขคู่") else : print("เลขคี่")
8b5ea0c285e1b2a8687eba3f0dc81e353ffc777a
kongruksiamza/PythonBeginner
/Phase1/EP27.py
348
3.859375
4
# แม่สูตรคูณ start=int(input("ป้อนแม่สูตรคูณเริ่มต้น = ")) # 1 stop=int(input("ป้อนแม่สูตรคูณสุดท้าย = ")) # 4 for x in range(start,stop+1): print("แม่ = ",x) for y in range(1,13): print(x,'x',y ," = ",(x*y))
cf54ae67607c1fb680822cb6f74b59f5624b6b60
kongruksiamza/PythonBeginner
/Phase1/EP20.Assignment4.py
776
3.96875
4
#แลกเงินและหาจำนวนแบงค์ # 2000 => 1000 => 2 ใบ # 1500 => 1 ใบ , 500 = 1 ใบ # 1800 => 1 ใบ , 500 = 1 ใบ , 100 => 3 ใบ # 100 => 50 => 2 ใบ number = int(input("ป้อนจำนวนเงินของคุณ : ")) # 1500 if number>=1000: print("1000 บาท = ",number//1000,"ใบ") # 1 ใบ number%=1000 # 1500 % 1000 = 500 if numbe...
2da4869d6b0ef02c530321ac38f1203aba05c89d
kongruksiamza/PythonBeginner
/Phase1/EP22.Assignment6.py
710
4.09375
4
weight=int(input("ป้อนน้ำหนักของคุณ (kg):")) high=int(input("ป้อนส่วนสูงของคุณ (cm) :"))/100 bmi = weight/(high**2) if bmi>=0 and bmi<18.0: result="ผอม" elif bmi>=18.5 and bmi<=22.9: result="สมส่วน" elif bmi>=23.0 and bmi<=24.9: result="น้ำหนักเกิน" elif bmi>=25.0 and bmi<=29.9: result="โรคอ...
e1b028c1a2ab7869866a38c18ac7d44b8ee158bf
Ivan-Yovchev/NEAT-Flappy-Bird
/functions.py
1,020
3.890625
4
from parameters import * def closest_pipe(birds, pipes): # All of the birds are located at the same x-location # so only the first bird x-location can be used bird_x = birds[0].x # Closest pipe is unknown to begin with. # The value of None can also be used for # debuging in case something goe...
3799ba0947b5b9679dc543b1e897bbe57d80b487
BrandonMcAlonan/cp1404practicals
/prac_05/word_occurrences.py
527
4
4
word_to_length = {} length_words = 0 string = str(input("Please enter some text: ")) words = string.split() words.sort() for word in words: amount = word_to_length.get(word, 0) word_to_length[word] = amount + 1 for word_length in word_to_length.keys(): if len(word_length) > length_words: length_w...
14dbf2c50466a7a35415231b8b0703ba63a333bf
BrandonMcAlonan/cp1404practicals
/prac_06/programming_language.py
669
3.9375
4
class ProgrammingLanguage: def __init__(self, name="", dynamic="", reflection=bool, year=int): self.name = name self.dynamic = dynamic self.reflection = reflection self.year = year def is_dynamic(self): if self.dynamic == "Dynamic": dynamic_status = True ...
063a9b7f6bc449579ac41bbebc2ede92e9eeeb14
lucy72384/ctpython
/HW01(solve).py
299
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 21 16:31:30 2021 @author: user """ import random data = [] while len(data) != 6 : n = random.randint(1,49) if data.count(n)==0: data.append(n) print(data) data.sort() data2=data print(data2)
4eb5180d8382c3fbbe24df4a44c5bdee2a7fb613
shrikantkarve/Python-exercises
/rainfall_exercise.py
272
3.765625
4
rain = {} while True: city = input("City: ").strip() if not city: break mm_rain = input("Please provide rainfall in mm: ").strip() rain[city] = rain.get(city, 0) + int(mm_rain) for city, mm_rain in rain.items(): print(f'{city}: {mm_rain}')
8585127a333dfb64b4895f28c878dc2e3f782117
moyuliang/Python
/src/little/slit.py
225
3.5
4
# -*- coding: utf-8 -*- L = range(1, 101)#range()函数可以创建一个数列 print(L[:10]) print(L[2:100:3])#3的倍数 print(L[4:51:5])#不大于50的5的倍数。 print(L[-10:]) print(L[-46::5])#最后10个5的倍数。
e2b5759e9d644947a352e1be12c335ef561b5077
moyuliang/Python
/src/little/flower.py
583
4.03125
4
import turtle # Draws a diamond def draw_Diamond(some_turtle): for i in range(1, 3): some_turtle.forward(50) some_turtle.right(50) some_turtle.forward(50) some_turtle.right(130) # Draws a flower def draw_flower(): window = turtle.Screen() window.bgcolor("black") # Draws...
70348b676fba1699fd5783a0e231ff5d321d5bb1
ShivaPrasadhegde101/tic_tac_toe_vs_comp
/tic_tac_toe_vs_comp.py
4,296
3.984375
4
import random def draw(board): print("-----------------------------") print() print("%c | %c |%c"%(board[1],board[2],board[3])) print("___|___|___") print("%c | %c |%c"%(board[4],board[5],board[6])) print("___|___|___") print("%c | %c |%c"%(board[7],board[8],board[9])) ...
16480d775773b026e8157ce03de8988614e905b9
Yggdrasil09/Project-Euler-Python
/projecteuler36.py
146
3.53125
4
sum=0 for x in range(1,1000000) : if str(x)==str(x)[::-1] and str("{0:b}".format(x))==str("{0:b}".format(x))[::-1] : sum+=x print(sum)
e1a16e2fe47b1bb4c5fd3b02290ca2f92c8b135a
Harjacober/HackerrankSolvedProblems
/Python/Validating phone numbers.py
305
3.5625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import re def validate(string): pattern = re.compile(r'[789][0-9]{9}$') if bool(re.match(pattern, string)): print("YES") else: print("NO") n = int(input()) for i in range(n): validate(input())
4e9dcaa32b8662fb64d27faa933a01d47cc0caf8
Harjacober/HackerrankSolvedProblems
/Python/Regex Substitution.py
311
4.15625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import re def substitution(string): string = re.sub(r'((?<=\s)&&(?=\s))','and', string) string = re.sub(r'(?<=\s)\|\|(?=\s)','or', string) return string N = int(input()) for i in range(N): print(substitution(input()))
2cd912ed19672606c338591cb465c9f76452aec0
Harjacober/HackerrankSolvedProblems
/Python/Validating and Parsing Email Addresses.py
397
3.5625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import email.utils import re def parse(string): emailAdress = email.utils.parseaddr(string)[1] pattern = re.compile(r'([A-Za-z][A-Za-z_.0-9-]+)@([A-Za-z]+)\.([A-Za-z]{1,3})$') match = re.match(pattern, emailAdress) if bool(match): ...
49055347ce4377fb1177a9479aa1b3a5f9b8e1f6
Harjacober/HackerrankSolvedProblems
/Python/sWAP cASE.py
108
3.796875
4
def swap_case(s): ans = [i.lower() if i.isupper() else i.upper() for i in s] return ''.join(ans)
556dd4737390509320e979ebf206791cccddbf0c
hennri/OPE_agendamento
/ac07/infra/db.py
870
3.5625
4
import sqlite3 create_sql = [ """ CREATE TABLE IF NOT EXISTS Cliente( id INTENGER PRIMARY KEY, nome TEXT NOT NULL, email TEXT, cpf TEXT NOT NULL, rua TEXT NOT NULL, bairro TEXT NOT NULL, cidade TEXT NOT NULL, numero_casa TEXT NOT NULL ); """, """ CREATE TABLE IF NOT EXISTS Agenda...
45063d790455032ec43c9407c1e71b4453845f5d
adityarsingh/python-blockchain
/backend/util/cryptohash.py
799
4.15625
4
import hashlib #it is library that includes the sha256 function import json def crypto_hash(*args): """ This function will return SHA-256 hash of the given arguments. """ stringed_args = sorted(map(lambda data: json.dumps(data),args)) #Lambda functions can have any number of arguments but only one ex...
47abe941bae483b1704bccbd94c6e25c69894be2
arevish/fruit-divider
/fruitDivider.py
596
4.09375
4
try: n = int(input("Enter number of apple harry got: ")) mn = int(input("Enter the minimum number of students: ")) mx = int(input("Enter the maximum number of students: ")) except ValueError: print("Enter integer values only") if mn >= mx: print(f"It's not a range minimum {mn} should be less than ma...
920815de98c336ce8cc6f0675d9337ee580a9fd3
MohamedBakrAli/N-Puzzle
/search.py
5,826
3.65625
4
import queue from board import * from copy import deepcopy import math def bfs(board): Q = [] Q.append(board) vis=[] intial_state=board.tiles goal_state = None while Q: temp_list = Q.pop(0) vis.append(temp_list.tiles) if temp_list.goal_test(): goal_state = ...
34a4c64c73fcc8f4c59ccb085a295a6e4ee23a74
KatamariJr/dwelling-of-duels-scripts
/videoCreator/uploadVideo/name_split_test.py
883
3.8125
4
import unittest from utils import splitName, mergeSplits class MergeSplits(unittest.TestCase): def test_combining(self): input = ["ZZ", "atomic", "guy", "Potato Salad Game", "Look at my Song", "DoD"] combineString = "0 1,2 3 4 5" mergeCharacter = "-" expect = ["ZZ", "atomi...
eb90e1cce8b3de49d86ef2b1cb36d4dcb67d5e5e
gustavofariaa/EncryptImage
/DES.py
9,694
3.640625
4
import textwrap def apply_PC1(pc1_table, keys_64bits): """ This function takes Permutation table and initial key as input and return 56 bits key as output""" keys_56bits = "" for index in pc1_table: keys_56bits += keys_64bits[index-1] # Python list index start with 0 # so index -1 will cover the differe...
7e6cc4a35c75c7cf36f006ebef92a827d9c5e629
jimfrancois/Python_Challenges
/main.py
52,076
3.75
4
import math import random from typing import Pattern from array import * import csv from tkinter import * #Challenge01 fname = input("What is your first name? ") print('Hello', fname) #Challenge02 fname = input('what is your firstname? ') surname = input('what is your surname? ') print('Hello', fname, s...
f2e566ec99e3837e65b538018d8d3f967761d5e0
erdyneevzt/stepik_python
/block_1/task_6th.py
378
3.90625
4
num_pro = int(input()) if num_pro % 10 == 1 and num_pro % 100 != 11: print(str(num_pro) + " программист") elif(num_pro % 10 == 2 or num_pro % 10 == 3 or num_pro % 10 == 4) and (num_pro % 100 != 12 and num_pro % 100 != 13 and num_pro % 100 != 14): print(str(num_pro) + " программиста") else: print(str(num_pr...
0ba7221e5e22618f39d62835b2c442cb615ab94e
briancmorris/Programming-Languages-Group-L
/src/proj3/Card.py
1,936
3.640625
4
# List of Suits, Club, Spade, Diamond, Heart suits = "Clubs Spades Diamonds Hearts".split(" ") # List of ranks. String representation. Will be 2-10 plus J Q K A ranks = 'A'.split(" ") + [str(i) for i in range(2, 11)] + "J Q K".split(" ") class Card(object): # Assigns value to each rank. EX giving 2 a value of ...
232e1a712e24725d692b6f7425f2cdf0a947eba3
briancmorris/Programming-Languages-Group-L
/src/proj2/Bartok.py
10,765
3.828125
4
from Card_Game_Base import * import random class Hand: """ Hand of cards. Belongs to a player. In Bartok, this will start off as five cards. """ def __init__(self): self.owner = None self.cards = [] self.jack_present = False self.queen_present = False self.king_prese...
45dfba85261ba921c0cd16b2da68556f74a15817
chaeminsoo/jump2python
/selection_sort_pract.py
346
3.59375
4
import time start_time = time.time() array=[7,5,6,9,1,4,2,8,0,3] for i in range(len(array)): min_index = i for j in range(i+1,len(array)): if array[min_index] > array[j]: min_index = j array[i], array[min_index] = array[min_index], array[i] print(array) end_time = time.time() print('t...
7df755f0210dc53c79625ab2982673a64f5f4f45
Jonesb5977/csc121
/Jones_M3P1.py
588
4.09375
4
#Brandon Jones #2/26/19 #Jones_M3P1 #This program will find the highest,lowest,average,and total of a set of data def main(): num=int(input("Enter how many numbers you would like to enter: ")) my_list=[0]*num for index in range(num): number=int(input("Enter a value: ")) my_list[in...
b203734313ba2be1f1a679082bf551ccacc313db
Jonesb5977/csc121
/cw_27.py
1,053
4.0625
4
#CW_27 #Demo how to throw exceptions print ("Menu") print ("1. Create textfile") print ("2. Average Vales") print ("3. Total value") print ("4. Test for file exceptions") print ("5. test for value error exception") input (print("Enter your Choice: ") ##try: ## num=int(input("Enter how many numbers you want...
bd15f3db91684061c49dcd253b57e9689ac4ddfc
eccentricOrange/9608-22-PRE-O-N-20
/Standalone Compiled Program.py
5,067
3.84375
4
# # 9608/22/PRE/O/N/2020 # # Standalone Compliled Program # # The code below is for every task combined into one, and can run independently. ## Arrays which are supposed to be pre-populated ItemCode = ["1001", "6056", "5557", "2568", "4458"] ItemDescription = ["Pencil", "Pen", "Notebook", "Ruler", "Compass"] Price = ...
f33d2c6622a7854ae05c905dee4e07284a8bb082
sanveg-rane-13/Leetcode
/May _challenges/Number Complement.py
407
3.546875
4
class Solution: def findComplement(self, num: int) -> int: int_fmt = bin(num)[2:] # converting to binary string ans_str = '' # flipping each characted of the binary string for i in int_fmt: if i == '0': ans_str += '1' else: ans_str += '0' ...
73360fd8ee9d676b35b9a9e8103eb244ae76af9a
fja0kl/LeetCode-Path
/917.Reverse-Only-Letters/reverseOnlyLetters.py
562
3.625
4
""" 双指针 """ class Solution: def reverseOnlyLetters(self, S): """ :type S: str :rtype: str """ S = list(S) left, right = 0, len(S)-1 while(left<=right): if(S[left].isalpha() and S[right].isalpha()): S[left], S[right] = S[right], S[le...
1c453823abd9ececb9f79bedcbf84283070a4771
edwindixon99/COSC364-Internet-Technology-and-Engineering
/Assignment 2/assignment.py
5,479
4.09375
4
def get_source_nodes(): source_nodes = input("enter amount of source nodes: ") ## THIS IS Y while True: try: if int(source_nodes) >= 1: return source_nodes else: print("source_nodes needs to be greater than one") source_nodes = inp...
c819106c7d0f98d7b08372dbd3da67ed91d082b3
mljarman/Graphs
/lecture_notes/word_ladder.py
1,554
3.953125
4
''' How to solve any graph problem 1. translate the problem into graph terminology 2. build the graph 3. traverse it Word Ladder problem -------------------- begin: hit end: cog hit -> hot -> cot -> cog begin: sail end boat sail -> bail -> tail - ''' def find_ladders(begin_word, end_word): visited = s...
650500f1502746c013ec2725b0f8b6ccf5adbeec
Gabriel88Alejandro/bootcamp
/dino.py
747
3.578125
4
class Dino: def __init__(self,un_nombre, un_color, un_gusto, canti_patas=2, un_genero=None): self.nombre= un_nombre self.color= un_color self.gusto= un_gusto self.patas= canti_patas self.genero= un_genero print("acabo de nacer mira abajo") print() pri...
af5db938215545bdd10cb3f776c8ddccd421692f
marhs/adventofcode2018
/5/day5.py
1,498
3.8125
4
from string import ascii_lowercase def check_reaction(a, b): """Given two units, check if they react""" return (a.lower() == b.lower()) and (a != b) def chain_reactions_recursive(input, current_index=0): """ Doesn't work with current python recursive conditions """ for index in range(current...
5bc1a6eb0e6474a2164ba0275651420721e22aac
henrywalters/AdventOfCode2020
/solutions/sandbox_ctl.py
575
3.5
4
from utils import Timer, Vec2, pi, get_distribution, fibb, fibb_recursive import math DAY=4 PART='a' print("###############################") print ("Running solution for day {d} part {p}".format(d=DAY, p=PART)) print("###############################") timer = Timer() # Write your code here result = 0 result = fi...
6701a7fa14f875053e9bee98239881d99749d2ab
alvanieto/herausforderung
/herausforderung/algorithm.py
1,083
3.703125
4
import re def algorithm_pipeline(algorithm=''): """Factory that return a pipeline of algorthms. :param alghritom: Name of the algorithm pipeline :return: A list of algorithm to apply """ return _ALGHORITM_PIPELINES.get(algorithm, []) def _lowercase(value: str) -> str: return value.lower() ...
3b9ab20ee568f506e8635d8bd9d31952ca126349
alvanieto/herausforderung
/herausforderung/generator.py
646
3.65625
4
import csv from copy import copy from decimal import Decimal, ROUND_UP def generate_file(data): """Generate merged csv file. Ratio precision set to 3 decimals round up. :param data: data of type 1 and 2 """ with open('merged_data.csv', 'w') as csv_file: fieldnames = ('id_store', 'var1', 'var2...
ced0c38b1e967cf42655ca2f7147920db1c1ca57
jakeoverall/ops-challenges
/05/menu.py
639
3.65625
4
import os import time def printMenu(): clear() print(""" 1 - Encrypt File 2 - Decrypt File 3 - Encrypt Message 4 - Decrypt Message 5 - Encrypt Directory 6 - Decrypt Directory 7 - Quit """) choice = ...
22c94a33fb7d983669097ce061c954e529b99715
amritasharma05/Data_Structures_Algorithms
/Arrays_and_Strings/check_permutation_ctci_1.2.py
394
4.09375
4
""" Given two strings, write a method to decide if one is a permutation of other Approach - Sort the string using in-built sorted function which uses Timsort algorithm under the hood Time Complexity - O(nlogn) Space Complexity - O(1) """ def is_permutation(st1,st2): return sorted(st1) == sorted(st2) print(is_pe...
b521af673c02c88204349ae39e158ca1335c214e
YingChen1996/leetcode_daydayup
/leetcode分类/字符串/151-翻转字符串里的单词.py
841
3.640625
4
##### convert to list class Solution: def reverseWords(self,s): if s is None or len(s)==0: return s s=s.split() start=0 end=len(s)-1 while start<end: s[start],s[end]=s[end],s[start] start+=1 end-=1 return " ".join(s) ###############################遍历法空格判断 class Solution: def rev...
2254cbfcfc95a689eeac05e1a6d44746613fc9f8
DrCondor/AStar
/main.py
488
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Loading classes from other files from graph import Graph from astar import AStar # Loading txt file with maze maze_file = open('maze.txt', 'r+') maze = maze_file.readlines() maze_file.close() # Parsing maze to matrix of nodes graph = Graph(maze) # Generating AStar ob...
4a3a7330b8fb7d6f67dbb634ce395abe20d3991a
vjishnu/python_101
/ex_7.py
447
4.0625
4
days = "Mon Tue Wed Thu Fri Sat Sun" months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug" # months seperated by new line character print(" The days are : ", days) # print days print(" The months are : \n", months) #print months print(""" There's something going on here. With the three double-quotes. We'll be able to ty...
968e67c487bc93767de11e74957b8af63e716fe9
vjishnu/python_101
/quadratic.py
591
4.15625
4
from math import sqrt #import sqrt function from math a = int(input("Enter the 1st coifficient")) # read from user b = int(input("Enter the 2st coifficient")) # read from user c = int(input("Enter the 3st coifficient")) # read from user disc = b**2 - 4*a*c # to find the discriminent disc1 = sqrt(disc)# thn find the...
d9ba170ee96a3459218cfeb01dec6501421040cc
ghbonne/PMConverter
/PMConverter/src/visual/charts/linechart.py
1,411
3.546875
4
__author__ = 'Project management group 8, Ghent University 2015' from visual.charts.twoDimVisualization import TwoDimChart class LineChart(TwoDimChart): """ :var title: title of the chart :var labels: labels on the x and y-axis. Format: [x-axis,y-axis] :var data_series: data Format: [ ...
b29cfd8b38fb4d054ee2f85fe8ecf9ab210e5d92
akashpawar6474/Competitive_Programming
/Geeks For Geeks/MEDIUM/Find Prime numbers in a range.py
611
3.796875
4
## Question link : https://practice.geeksforgeeks.org/problems/find-prime-numbers-in-a-range/0 prime[0] = 0 prime[1] = 0 number = 2 while number*number <= 1000002: if prime[number]: for multiples in range(2*number, 1000002, number): prime[multiples] = 0 number += 1 no_of_test = int(input()...
4d933080ebae59f92cb7e25bbeaf96594ca285e9
akashpawar6474/Competitive_Programming
/Geeks For Geeks/MEDIUM/Excel Sheet | Part - 1.py
505
3.765625
4
## Question link : https://practice.geeksforgeeks.org/problems/excel-sheet/0 for _ in range(no_of_testcases): ans = "" number = int(input()) while number > 0: remainder = number%26 if remainder == 0: ans += "Z" number = number // 26 - 1 else: ans ...
10cb064b0c9b093975c34b9ab6c66f54db81f1da
noe98/Cayley
/parser/functions.py
1,516
3.84375
4
""" Authors: Justin Pusztay Filename: probability.py Project: Research for Irina Mazilu, Ph.D. Contains the Probability class. The class creates a probability function object, which can have variables with values plugged into them. It also can evaluate an equation by translating the function to postfix notation and ev...
d8195b5b1e5a7a97e98fa1ed5381758c059bbf66
noe98/Cayley
/examples/simulateTemp.py
973
3.84375
4
""" Example code for how to set up a simulation that needs temperature data. This module run a Cayley Tree. """ import Cayley as cy #Creating network and monte carlo objects network = cy.CayleyTree(3,3) monte = cy.MonteCarlo(network) #Set temperature of each generation """ This gives each generation a temperature i...
c3940d6bd2885340623e534714bf10ac65155394
noe98/Cayley
/research/variables.py
4,223
3.75
4
""" @author: Justin Pusztay Filename: variables.py Project: Research for Irina Mazilu, Ph.D. Contains the Variables class. Holds the most common data values for running simulations on graphs. Gives the ability to create data and then to change the values for the data within the object. """ __author__ = "\n".join(['J...
fd7b805579cf158999eebd8cb269c0de1f288b80
lucasgcb/daily
/challenges/Mai-19-19/Python/solution.py
815
4.15625
4
def number_finder(number_list): """ This finds the missing integer using 2O(n) if you count the set operation. """ numbers = list(set(number_list)) ## Order the list # Performance of set is O(n) # https://www.oreilly.com/library/view/high-performance-python/9781449361747/ch04.html expected_i...
b2b77dd044a502d457595bfadac170714fe9f842
kogulko/cracking_coding_interview
/stacks_and_queues/3_6.py
1,173
3.921875
4
from stack import Stack from abc import ABC class Animal(ABC): def __init__(self, name): self.order = 0 self.name = name def set_order(self, ord): self.order = ord def is_older_than(self, animal): return self.order < animal.order class Dog(Animal): pass class Cat(Ani...
c78ea6dd0db3062179b06f90b33c4bc93cea7416
Gaoyang0/RacingGame
/ai_logic_使用tensorflow框架/game_generate_data.py
4,897
3.84375
4
# 通过手动玩游戏生成操作数据并保存,用于模型的训练 import pygame from pygame.locals import * import math from game_logic import my_item import numpy as np BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) YELLOW = (255, 255, 0) WALL_COLOR = (75, 60, 40) WALL_WIDE = 12 lines = [] data = [] res...
9fbf85740e7f3aa9f1e438ff0a51c5939294dac4
Meenawati/competitive-programming
/dict_in_list.py
522
4.40625
4
# Write a Python program to check if all dictionaries in a list are empty or not def dict_in_list(lst): for d in lst: if type(d) is not dict: print("All Elements of list are not dictionary") return False elif d: return False return True print(dict_in_list(...
1cc1d5ab688115d8757426eba0a21a40e5939c56
CircArgs/CodingDojo
/problems/PaintedHouses/solution.py
2,451
3.828125
4
# This problem was asked by Facebook. # A builder is looking to build a row of N houses that can be of K different colors. He has a goal of minimizing cost while ensuring that no two neighboring houses are of the same color. # Given an N by K matrix where the nth row and kth column represents the cost to build the nt...
bbbc61b4bf1abc6c85e411a97e8429e7b612478c
marlinpohlman/bioinformatics
/gototest.py
346
3.6875
4
from goto import with_goto @with_goto def range(start, stop): i = start result = [] label .begin print("at .begin") if i == stop: print("goto end") goto .end result.append(i) i += 1 print("goto .begin") goto .begin label .end print("at ....
43142e34fdca6e180c2801dfbcc34583dee23c0b
mayad19-meet/y2s18-python_review
/exercises/conditionals.py
97
3.671875
4
a=0 for i in range (101): if i %2==0: a=a+i else: print(" ") print(a)
5b34bd44ba3e794a2467b9977168f5bfc8a14873
kwujciak/Final-Project-ES2
/FP time.py
4,696
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Apr 25 15:05:01 2020 @author: katewujciak """ import time #print(time.localtime()) year = time.localtime()[0] month = time.localtime()[1] day = time.localtime()[2] hour_military = time.localtime()[3] minute = time.localtime()[4] day = time.localtime()...
de2186a8e12b13db3d1144fb76fe7286a0a0fef7
anilachacko/python
/C01/co3a.py
104
3.890625
4
list1 = [2,3,-4,-6,10,-11,23] for num in list1: if num >= 0: print(num, end = " ")
67af72d1ade48726d1c7e36cdb371740e74f213a
anilachacko/python
/CO2/C001.py
98
4.15625
4
a=int(input("enter a number")) f=1 for i in range(1,a+1): f=f*i print("factorial is",f)
f963b200f68c8c9564c929d51e0efd0af0c27324
anilachacko/python
/C01/co16.py
133
3.75
4
a=input("Enter 1st string:") b=input("Enter 2nd string:") x=a[0:2] a=a.replace(a[0:2],b[0:2]) b=b.replace(b[0:2],x) print(a,b)
f0174a18e18a01c489b2e0f3ae7114a5bac17555
haoxiangyang89/NBAFantasy
/Optimizer/Archive/NBA_Prediction_Pre2.py
14,766
3.59375
4
# -*- coding: utf-8 -*- """ Created on Fri May 27 10:59:00 2016 @author: hyang89 """ import csv import datetime from operator import add #import pdb #pdb.set_trace() # This is the code to build up the predictor spreadsheet: try No. 2 # The spreadsheet should have columns: Name, team, last three games stats, home co...
33c78632116ac3314a8c59b589b8215d1535d4ed
ap9891/Python-Basics
/formatfunction.py
279
3.84375
4
''' format function ''' users = ['a','b','c','d'] computer=['c1','c2','c3','c4'] # for i in range(0,len(users)): # print(users[i], " is ",computer[i]) for i in range(0,len(users)): template = "computer used by {} is {}" print(template.format(users[i],computer[i]))
b7336657e06a311bf6dc44f4fa84a634ae1e3771
MagnoCarlos/Word_Machine_Py
/Word_Machine/main.py
1,410
3.84375
4
file = open("/Volumes/PC/ProjectsProgramming/LearningPython/Problems/Word_Machine/input.txt") for sentence in file: print(" ") print("line: " + sentence) # print line of command stack = [] # define empty stack for word in sentence.split(): print("Operation => ", end="") print(word) ...
7dbde646c4cce1bc3cb6ff5152686ee65e6a4d4a
sonhs99/gomoku
/game/board.py
866
3.53125
4
from . import type from abc import ABCMeta, abstractmethod __all__ = [ 'Board', 'State', 'Action' ] class Board(metaclass=ABCMeta): def __init__(self): pass @abstractmethod def place(self, player, action): assert isinstance(action, Action) @abstractmethod def get(...
28fdb41bd93baec491f2ac920fa2c7a3c0160085
PETAR-BOT/crossword
/crossword.py
17,785
3.609375
4
# crossword class # crossword object creates an empty board with word bank and clues # nee to find a file w words and their definition -> (word: [definitions]) # how to open all the json files in a folder and read all of them? import re from pathlib import Path import random import string from collections import defau...
40d9f9e8e046e5b41d83213bbea3540365d123e0
alfem/gamespit
/games/crazy-keys/__init__.py
1,577
4.15625
4
#!/usr/bin/python # -*- coding: utf8 -*- # Crazy Keys # My son loves hitting my keyboard. # So I made this silly program to show random colors on screen. # And maybe he will learn the letters! :-) # Author: Alfonso E.M. <alfonso@el-magnifico.org> # License: Free (GPL2) # Version: 1.0 - 8/Mar/2013 import ran...
d98f264a483efbbe24190937c230cbaa7365f7da
vazzup/AIT
/create_db.py
935
3.859375
4
#!/usr/bin/env python3 import sqlite3 as sql import random def main(): print("Creating databases...") connection = sql.connect("./.flights.db") cursor = connection.cursor() print("Creating table...") cursor.execute("""CREATE TABLE IF NOT EXISTS bookings(name varchar(40) not NULL, booking_ref int pr...
8f57a109864c1cd04e1ad1df806ba7bfe1994301
ThienHi/python-tranning
/tranning-python/myclass.py
894
3.625
4
class Users: def __init__(self, username,password, roles): self.username = username self.password = password self.roles = roles def myFunc(self): print ('Username: ' + self.username + '\nPassword: ' + self.password + '\nRole: ' + self.roles) a = Users('ThienHi',str(12345),'Adm...
3f7e78c32248070d526c664e35de4006559c8064
ThienHi/python-tranning
/tranning-python/for-in.py
205
3.515625
4
name =['thienHi',07,'ThienKim',2603] for i in name: if i == 'ThienKim': break; print i # for a in "Kim Thien" : # print a #range(start,stop,stepsize) for x in range(2,15,2): print x
e3d8013cc7f3265312d1d13f1e4724c5e512b430
GuillermoForero/competitive-programming
/CF-A/Games.py
358
3.515625
4
number_of_teams = input() array_of_teams = [] counter = 0 for x in range(int(number_of_teams)): array_of_teams.append(input().split(' ')) for x in range(len(array_of_teams)): for n in range(len(array_of_teams)): if x == n: continue if array_of_teams[x][0] == array_of_teams[n][1]: ...
c7807d6e29601abaa11e70ff208e8f40be220010
GuillermoForero/competitive-programming
/CF-A/LightMoreLight.py
324
3.5
4
import math import sys while True: bulbs = 0 try: bulbs = int(sys.stdin.readline()) except EOFError: pass if bulbs == 0: break else: square = math.floor(math.sqrt(bulbs)) if square * square == bulbs: print('yes') else: print('...
6c1834eb76f1279c778c211a3398435a1cf15b4e
GuillermoForero/competitive-programming
/CF-A/AntonandDanik.py
201
3.671875
4
input() string_input = input() anton, danik = string_input.count('A'), string_input.count('D') if anton > danik: print('Anton') elif anton < danik: print('Danik') else: print('Friendship')
52265fb258d06e8217d2f20a4af6e813b9691ae4
ymjrchx/myProject
/pythonStudy/python-demo/Day04/for4.py
322
3.984375
4
from math import sqrt num = int(input("输入一个正整数: ")) end = int(sqrt(num)) is_prime = True for x in range(2,end + 1): if num % x == 0: is_prime = False break if is_prime and num != 1: print("%d 是素数"%num) else: print("%d不是素数"%num) if __name__ == '__main__': pass
e13468afe2fbfc7c8947e4caf735af756d18d6e6
ymjrchx/myProject
/pythonStudy/python-demo/Day07/tuple.py
613
4.375
4
""" 元组的定义和使用 Version: 0.1 Author: 骆昊 Date: 2018-03-06 """ def main(): t = ('骆昊', 38, True, '四川成都') print(t) print(t[0]) print(t[1]) print(t[2]) print(t[3]) for member in t: print(member) # t[0]='王大富' t = ('王大锤', 20, True, '云南昆明') print(t) person = list(t) print(pe...
f6897f014119f1bf7d070b9ba4f19a533d8a11e4
ymjrchx/myProject
/pythonStudy/python-demo/Day10/gui3.py
637
4.09375
4
""" 使用tkinter创建GUI - 在窗口上制作动画 Version: 0.1 Author: 骆昊 Date: 2018-03-14 """ import tkinter import time def play_animation(): canvas.move(oval,2,2) canvas.update() top.after(50,play_animation) x=10 y=10 top=tkinter.Tk() top.geometry('600x600') top.title("动画效果") top.resizable(False,False) top.wm_attributes('-...
28374d28e84a38789ce5810c2ffa642be798d855
ymjrchx/myProject
/pythonStudy/python-demo/Day09/car2.py
990
4.3125
4
""" 属性的使用 - 使用已有方法定义访问器/修改器/删除器 Version: 0.1 Author: 骆昊 Date: 2018-03-12 """ class Car(object): def __init__(self, brand, max_speed): self.set_brand(brand) self.set_max_speed(max_speed) def get_brand(self): return self._brand def set_brand(self, brand): self._brand = bran...
fa71dbd7ac1a328b5eadb83f67237fac65a31e97
ymjrchx/myProject
/pythonStudy/python-demo/Day11/csv1.py
387
3.765625
4
""" 读取CSV文件 Version: 0.1 Author: 骆昊 Date: 2018-03-13 """ import csv filename='example.csv' try: with open(filename) as f: reader = csv.reader(f) data = list(reader) except FileNotFoundError: print("无法打开文件",filename) else: for itme in data: print("%-30s%-20s%-10s"%(itme[0],itme[1],itm...
da4199473308b99e312b5b542252423592417d85
nabrink/DailyProgrammer
/challenge_218/challenge_218.py
342
4.15625
4
def to_palindromic(number, step): if len(number) <= 1 or step > 1000 or is_palindromic(number): return number else: return to_palindromic(str(int(number) + int(number[::-1])), step + 1) def is_palindromic(number): return number == number[::-1] number = input("Enter a number: ") print(to_pa...
a18a55afbca05837d8f50ebae769fd67c0b0b175
Bylundc/ME-499-Python
/Lab-2/gcd.py
820
4.09375
4
#!/usr/bin/env python #The greatest common divisor (GCD) of a and b is the largest number that divides both of them with no remainder. One way to find the GCD of two numbers is based on the observation that if r is the remainder when a is divided by b, then gcd (a,b) = gcd(b,r). As a base case, we can use gcd(a,0) = a...
3493ca90e098295a357d2b50bf2c9dea6a13794f
Bylundc/ME-499-Python
/Lab-5/circle.py
559
4.0625
4
#!/usr/bin/env python import numpy as np # circle class class Circle: def __init__(self, radius): self.radius = radius def __str__(self): return 'Circle({0})'.format(self.radius) def area(self): return np.pi*(self.radius ** 2) def diameter(self): return 2 * self.radius def circumference(self): retu...
bb556fc9e5749a0e9a7eb664955c709d5b5c9a39
bucs110/final-project-fall20-ravioli
/bin/melee.py
2,539
3.609375
4
import pygame import bin.functions ### THIS CLASS IS PRETTY OBSOLETE ### class Melee(pygame.sprite.Sprite): def __init__(self, sword_length, filename): """ initialzes melee weapons Args: sword_length --> (int) pixel length of the sword filename --> (str) the name of the fi...
b6cfa7c7a7e25707a3b7f33ea633683508af4668
v1ct0r2911/semana9
/ejercicio2.py
292
4.0625
4
#2. Elabore un programa en Python que calcule el promedio de 5 numeros. Emplee listas. numeros=[10,20,30,40,50] #promedio de lña lista de numeros suma=0 for numero in numeros: suma+=numero #la suma de todos los numeros de la lista promedio=suma /len(numeros) print(suma) print(promedio)