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 |
|---|---|---|---|---|---|---|
549659b57129e8bb0b85738015f4f4d6d4e7ebc0 | Machine-builder/python-uno | /scripts/game_logic.py | 5,222 | 3.5625 | 4 | from . import card_logic
class UnoPlayer():
def __init__(self):
self.hand = []
class UnoGame():
def __init__(self):
# create a shuffled uno deck
self.deck = card_logic.make_deck()
self.players = []
self.players_turn = 0
self.turn_direction = 1
... |
43f6c58538bb2bef37b90e942489e7075af2807c | ah4d1/anoapycore | /src/anoapycore/data/null/__init__.py | 1,550 | 3.65625 | 4 | import numpy as __np
import pandas as __pd
def count (a_data) :
"""
Count null in dataframe.
You can also use a_data[a_column] or a_data[[a_column1,a_column2,...]]
"""
return a_data.isnull().sum()
def fill (a_data,a_columns,b_fill_with='NA') :
a_data[a_columns] = a_data[a_columns].fillna(b... |
aaa05eaea50ea34481a5a79b59d4350b747579e6 | kdm1171/programmers | /python/programmers/level2/P_땅따먹기.py | 1,138 | 3.78125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/12913
# DP 문제
# 첫번째 리스트와 두번째 리스트를 비교해서 갈 수 있는 가장 큰 값을 찾고, 두 값을 더한 리스트를 반환하여 마지막 리스트에서 가장 큰 값을 찾음
def getNextList(list1, list2):
result = []
for i in range(len(list2)):
e = 0
for j in range(len(list1)):
if i == j:
c... |
79457ef52eb3f8bc1de24b46048bdd915b7e95e9 | kdm1171/programmers | /python/programmers/level2/P_행렬의_곱셈.py | 541 | 3.6875 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/12949
def solution(arr1, arr2):
m = len(arr1) # row
n = len(arr2[0]) # col
l = len(arr1[0])
answer = [[0] * n for _ in range(m)]
for i in range(m):
for j in range(n):
for k in range(l):
answer[i][j] += arr1[... |
034168d792c48d2c2117d1f89e5a914487485ab1 | kdm1171/programmers | /python/programmers/level2/P_뉴스_클러스터링.py | 1,324 | 3.8125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/17677
import re
def solution(str1, str2):
pattern = '[A-Z|a-z]'
multiSet1 = []
multiSet2 = []
for i in range(1, len(str1)):
s = ''.join(str1[i - 1:i + 1]).upper()
if len(re.findall(pattern, s)) == 2:
multiSet1.append(s)
... |
0a74706da29946c50e28d4ffe12a16f25a243d22 | kdm1171/programmers | /python/programmers/level2/P_스킬트리.py | 584 | 3.53125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/49993
def solution(skill, skill_trees):
answer = 0
for skill_tree in skill_trees:
skill_comp = [i for i in skill]
isMatched = False
for s in skill_tree:
if s in skill_comp:
e = skill_comp.pop(0)
... |
8584992389409fee8982a810415847603a5d7728 | kdm1171/programmers | /python/programmers/level2/P_전화번호_목록.py | 502 | 3.65625 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/42577
def solution(phone_book):
l = sorted(phone_book, key=lambda x: len(str(x)))
for i, a in enumerate(l):
for j, b in enumerate(l):
if i == j:
continue
if str(b).startswith(str(a)):
return F... |
07d0e6234ff5ea5faa2b45699616270713889447 | Pride7K/Python | /Listas/lista_exercicio8.py | 261 | 3.71875 | 4 | vetor = []
media = 0;
for i in range(0,4):
vetor.append(int(input("Digite a nota: ")));
print("");
for i in vetor:
media += i
media = media /4
print(f'{vetor[0]} {vetor[1]} {vetor[2]} {vetor[3]} equivale a média = {media}');
|
4918e2a6e919cbaefc031bdf611398a5a085438a | Pride7K/Python | /Exercicios/for.py | 244 | 3.5 | 4 | contador = 0;
for i in range(1,500):
validador = 0;
validador2 = 0;
validador = i % 3;
validador2 = i % 2;
if validador == 0:
if validador2 != 0:
contador = contador + i;
print(contador);
|
0e44d31802705bb1c7082d846f7ae35ff161229c | Pride7K/Python | /Listas/lista_exercicio5.py | 374 | 3.90625 | 4 | contador = 0;
print("Checando se uma expressão é valida através dos parenteses \n");
expressao = input("Digite a expressão: ");
print("");
for i in expressao:
if i == "(" or i == ")":
contador = contador + 1
contador = contador % 2
if contador == 0:
print("Expressão valida !... |
a609dd67af83c1bf8302578ec639d3bdfe6fcb8a | Pride7K/Python | /Dicionario/dicionario_exercicio2.py | 1,069 | 4.09375 | 4 | from datetime import datetime
pessoa = {}
now = datetime.now();
now = now.year
pessoa["nome"] = input("Digite o seu nome: ");
pessoa["ano de nascimento"] = int(input("Digite o seu ano de nascimento: "));
pessoa["cdt"] = int(input("Digite o sua carteira de trabalho(caso nao tenha digite 0): "));
if(pess... |
9ef4f0332e5bdf6d72be3bc23ef5d5dcc7ae8038 | Pride7K/Python | /Listas/lista_exercicio7.py | 148 | 3.90625 | 4 |
vetor = []
for i in range(0,10):
vetor.append(float(input("Digite um numero: ")));
print("");
print(sorted(vetor,reverse=True));
|
f7c61b747436cfcd105a925edd695ac3c8d97279 | ksheetal/python-codes | /hanoi.py | 654 | 4.1875 | 4 |
def hanoi(n,source,spare,target):
'''
objective : To build tower of hanoi using n number of disks and 3 poles
input parameters :
n -> no of disks
source : starting position of disk
spare : auxillary position of the disk
target : end posit... |
1ad945d852351c2fed94dc05e75eade79aff7c48 | austonnn/ucsd_bio_2 | /bio 2 week 4/1.3.4.py | 1,106 | 3.609375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 21 15:23:09 2018
@author: xiangyin
"""
"""
Spectral Convolution Problem: Compute the convolution of a spectrum.
Input: A collection of integers Spectrum.
Output: The list of elements in the convolution of Spectrum. If an element has multi... |
baf66093d37d83826dd906d458484c653e804597 | austonnn/ucsd_bio_2 | /bio 2 week 3/1.5.py | 2,198 | 3.953125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 11:57:07 2018
@author: xiangyin
"""
#Counting Peptides with Given Mass Problem: Compute the number of peptides of given mass.
# Input: An integer m.
# Output: The number of linear peptides having integer mass m.
aminoAcid = ['G', 'A', ... |
c94f35aaf3c6231e4b07cccc6133fb5f5e490566 | psmith586/directory-parsing-python | /filewalker.py | 1,877 | 4.09375 | 4 | #Author: Phillip Smith
#recursive keyword search/directory data display
#using os library to walk the directory
import os
#using matplotlib to create xy graph of data
import matplotlib.pyplot as plt
#init root dir and keyword vars from user
root_dir = input("Please enter directory path: ")
keyword = input(... |
de64db2e733e592558b5459e7fb4fcfd695abd1b | moogzy/MIT-6.00.1x-Files | /w2-pset1-alphabetic-strings.py | 1,220 | 4.125 | 4 | #!/usr/bin/python
"""
Find longest alphabetical order substring in a given string.
Author: Adrian Arumugam (apa@moogzy.net)
Date: 2018-01-27
MIT 6.00.1x
"""
s = 'azcbobobegghakl'
currloc = 0
substr = ''
sublist = []
strend = len(s)
# Process the string while the current slice location is less then the length of t... |
abb1b3042edbbf6dee7201817177000cb9bc7d39 | theworldcitizen/Web-2021 | /cycle3.py | 128 | 3.59375 | 4 | a = int(input())
b = int(input())
for i in range(a, b + 1):
if(i**(1/2) == round(i**(1/2))):
print(i, end=" ") |
5cd4cd9e965fdce1148584357b0fc9e2fc1709df | theworldcitizen/Web-2021 | /cycle11.py | 98 | 3.5 | 4 | ans = 0
n = int(input())
for i in range(n):
a = int(input())
ans = ans + a
print(ans) |
65882ab6d3f039036a778f6763725231dc69458c | jadsonpp/ordenacao | /src/PersonHandler.py | 954 | 3.703125 | 4 | class Person:
def __init__(self,email,gender,uid,birthdate,height,weight):
self.email = email
self.gender = gender
self.uid = uid
self.birthdate = birthdate
self.height = height
self.weight = weight
def showData(self):
print("E-m... |
fda220a40796a2b8dd83b752bc0cf350830b95ea | ishaniMadhuwanthi/Semester-6 | /CO544-Machine Learning and Data Mining/Lab2-Numpy and Pandas/randomWalk.py | 303 | 3.8125 | 4 | #implement basic version of random walk.
import random
import matplotlib.pyplot as plt
xrange = range
position =0
walk = [position]
steps = 500
for i in xrange(steps):
step = 1 if random.randint(0,1) else -1
position += step
walk.append(position)
plt.plot(walk)
plt.show() |
d9b0a9947e1704fda375f2fddda419d3604cd7f9 | iamhemantgauhai/Digital-Hotel-Menu | /digital-menu-code.py | 6,664 | 3.984375 | 4 | print('''
Welcome to Gauhai's Hotel
गौहाई के होटल में आपका स्वागत है''')
a=True
while a==True:
user=int(input('''
1:Breakfast 2:Lunch 3:Snack 4:Dinner
Order Number Please: '''))
if user==1:
user1=int(input('''
1:Tea 2:Dal ka Parat... |
2e23437ffd15f9ca5ec0383f172fba7fcb4f48af | AmirZimhony/University-Projects | /Assignment 4/create_db.py | 3,084 | 3.984375 | 4 | import sqlite3
import os
import sys
def main():
database_name = "schedule.db"
is_database_exists = os.path.isfile(database_name)
if not is_database_exists: # if database does not exists - we're going to create it.
connection_to_database = sqlite3.connect(database_name)
with co... |
97428ffc166ec44c733e2bda85f6421c922540d7 | boris-vasilev/kalah | /kalah/kalahboard.py | 6,177 | 4.15625 | 4 | class KalahBoard:
"""
A implementation of the game Kalah
Example layout for a 6 bin board:
<--- North
------------------------
12 11 10 9 8 7
13 6
0 1 2 3 4 5
... |
4aa122bf3782a63b4d7680c9f24bd5f70ef0a7c2 | MirjahonMirsaidov/interviewPrep | /merge_sort_linked_list.py | 1,754 | 4.09375 | 4 | import random
from linked_list import LinkedList
def merge_sort(linked_list):
if linked_list.size() == 1 or linked_list.head is None:
return linked_list
left_half, right_half = split(linked_list)
left = merge_sort(left_half)
right = merge_sort(right_half)
return merge(left, right)
de... |
dc81b34ba79a23123018f6a0b2c026c47d49e4f4 | makarandmadhavi/intermediate-python-course | /dice_roller.py | 848 | 3.796875 | 4 | import random
def main():
dice_sum = 0
pname = [0,0]
pscore = [0,0]
pname[0] = input('Player 1 what is your name? ')
pname[1] = input('Player 2 what should we call you? ')
dicerolls = int(input('How many dice would you like to roll? '))
dice_size = int(input('How many sides are the dice? '))
for j in ra... |
fdc8270e35fde55df9e9daf93194db8f51ee6b07 | JonathanQu/Testing2 | /2015-2016 Spring Term Homework/list-1.py | 2,048 | 4.03125 | 4 | import random
def merge (firstList, secondList):
OutputList = []
SmallerList = []
smallestListSize = 0
#determine what list is bigger and smaller
if len(firstList) > len(secondList):
OutputList=firstList
SmallerList=secondList
smallestListSize = len(secondList)
elif len(secondList) >= len(firstList):
Out... |
b08dd793de1d6f63d90d5c42b740fc8f57ded57e | rafiud1305/Rafi-ud-Darojat_I0320079_Aditya-Mahendra_Tugas-3 | /I0320079_Exercise 3.6.py | 174 | 4.09375 | 4 | dict = {'Name':'Zara','Age': 7,'Class':'First'}
dict['Age'] = 8;
dict['School'] = "DPS School"
print("dict['Age']:", dict['Age'])
print("dict['School']:", dict['School']) |
27ebcf2e51a5a9184d718ad14097aba5fb714d94 | tanawitpat/python-playground | /zhiwehu_programming_exercise/exercise/Q006.py | 1,421 | 4.28125 | 4 | import unittest
'''
Question 6
Level 2
Question:
Write a program that calculates and prints the value according to the given formula:
Q = Square root of [(2 * C * D)/H]
Following are the fixed values of C and H:
C is 50. H is 30.
D is the variable whose values should be input to your program in a comma-separated sequ... |
ca33cf3f9132ec9aa4d3e4b77a995fabdd67971c | ivafer00/MiniCrypto | /classic/Vigenere.py | 1,300 | 3.578125 | 4 | class Vigenere():
def __init__(self):
self.plaintext = ""
self.ciphertext = ""
self.key = []
def set_plaintext(self, message):
self.plaintext = message
def set_ciphertext(self, cipher):
self.ciphertext = cipher
def set_key(self, k):
self.key = []
... |
9fa5ecf1948273aa4e80924f56b63343a63e37cb | raquelmachado4993/omundodanarrativagit | /python/funcoes_busca_intermediario.py | 2,370 | 3.828125 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import funcoes as fun
def verifica_escola(texto):
result=""
contador=0
substring1 = "escola"
if substring1 in texto:
result+=substring1+" "
contador+=1
return result,contador
def encontra_esportes(texto):
result=""
c... |
3e63333e7ddfc297059762314bc608723cb3b246 | raquelmachado4993/omundodanarrativagit | /python/RASCUNHOS/teste_regex_findall.py | 162 | 3.5625 | 4 | # -*- coding: utf-8 -*-
import re
sentence = "Eu amava amar você"
word = "ama"
for match in re.finditer(word, sentence):
print (match.start(), match.end())
|
4cbc0f8a14c5b9ec8ae6d9c4dc5b4741ad43700c | raquelmachado4993/omundodanarrativagit | /python/dao/mysql_connect.py | 1,636 | 3.609375 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import mysql
from mysql.connector import Error
def connect():
""" Connect to MySQL database """
try:
conn = mysql.connector.connect(host="", # your host, usually localhost
user="", # your username
... |
1503bb3b33f20f77499db340de8b33523043ea56 | digitalMirko/PythonReview | /python_review08_functions.py | 1,175 | 3.78125 | 4 | # Python Programming Review
# file name: python_review08_functions.py
# JetBrains PyCharm 4.5.4 under Python 3.5.0
import random # random number generator
import sys # sys module
import os # operating system
# functions allow us to both re-use and write more readable code
# define a function that adds numbe... |
4a30e4eb36ebcc74d1f0bc0f7a6249ed5b8a0951 | digitalMirko/PythonReview | /python_review14_inheritance.py | 3,567 | 4.21875 | 4 | # Python Programming Review
# file name: python_review14_inheritance.py
# JetBrains PyCharm 4.5.4 under Python 3.5.0
import random # random number generator
import sys # sys module
import os # operating system
class Animal:
__name = ""
__height = 0
__weight = 0
__sound = 0
def __init__(... |
3314f67d5a12e55b836587554f792d7f5653cf1b | easternHong/pythonStudy | /Lesson3/Func.py | 332 | 3.953125 | 4 | # 偏函数的使用
def func():
print(int('2222'))
print(int('2222', base=8))
print(int2('533', 8))
print(int_custom('533'))
def int2(x, base=2):
return int(x, base)
def int_custom(x):
kw = {'base': 8}
return int(x, **kw)
if __name__ == '__main__':
print('''偏函数的使用''')
func()
|
cb3fb384955f9767077db0d80a5b1374c82c1674 | BurnFaithful/KW | /Programming_Practice/Python/Base/Bigdata_day1001/Input05.py | 304 | 4.1875 | 4 | # 문자열은 인덱스 번호가 부여됨
strTemp = input("아무 문자열이나 입력하세요: ")
print("strTemp : ", strTemp)
print("strTemp : {}".format(strTemp))
print("strTemp[0] : {}".format(strTemp[0]))
print("strTemp[1] : {}".format(strTemp[1]))
print("strTemp[2] : {}".format(strTemp[2])) |
dd7a778882684ed3a30f3ae0df1465977d46d51d | BurnFaithful/KW | /Programming_Practice/Python/Base/Bigdata_day1015/FUNCTION11.py | 219 | 3.640625 | 4 | def func3(num):
# 매개변수로 선언된 것도 지역변수
print(f"func3() num: {num}")
def func4(n1, n2, n3):
print(f"func4() n1, n2, n3 -> {n1}, {n2}, {n3}")
num = 0
func3(num)
print("num : ", num) |
3ab7e81a15e1efa8bd293f6ba35cc5bd8e6a7e23 | BurnFaithful/KW | /Programming_Practice/Python/Base/Bigdata_day1011/WINDOW06.py | 241 | 3.671875 | 4 | from tkinter import *
from tkinter import messagebox
def clickLeft(event):
messagebox.showinfo("마우스", "마우스 왼쪽 버튼 클릭됨.")
window = Tk()
button = Button()
window.bind("<Button-1>", clickLeft)
window.mainloop() |
53fa58a6f7b911378a298d8e96e81dec0423f927 | BurnFaithful/KW | /Programming_Practice/Python/Base/Bigdata_day1011/LIST06.py | 384 | 3.78125 | 4 | heros = ["스파이더맨", "헐크", "캡틴마블", "아이언맨", "앤트맨", "토르", "배트맨"]
srhName = input("찾을 영웅 이름: ")
for i in heros:
if i == srhName:
print("찾음")
break
else:
print("없음")
delName = input("삭제할 이름: ")
for i in heros:
if heros.index(delName):
heros.remove(delName)
print(heros) |
d333885fa35681071ef0c8c01efd9163b7244fdf | BurnFaithful/KW | /Programming_Practice/Python/Base/Bigdata_day1008/STRING05.py | 230 | 3.703125 | 4 | # 문자열 반대로 출력
inStr = ""
outStr = ""
count = 0
inStr = input("문자열을 입력하시오: ")
count = len(inStr)
for i in range(0, count):
outStr += inStr[count - (i + 1)]
print(outStr)
# print(inStr[::-1]) |
a9c300955bbfb4d7187b8018d0319a4912c76454 | BurnFaithful/KW | /Programming_Practice/Python/MachineLearning/Keras/keras13_lstm5_ensemble.py | 3,182 | 3.5625 | 4 | # LSTM(Long Short Term Memory) : 연속적인 data. 시(Time)계열.
import numpy as np
from keras.models import Sequential, Model
from keras.layers import Dense, LSTM, Input
#1. 데이터
x = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7],
[6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12],
... |
9a3a6a0f2b2ef12a06cac9ac23f397afba331605 | BurnFaithful/KW | /Programming_Practice/Python/Base/Bigdata_day1011/LIST03.py | 308 | 3.9375 | 4 | # 문자열 길이를 이용한 출력
letter = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']
print(letter)
length = len(letter)
for i in range(length):
print(letter[i], end=' ')
print(' '.join(letter))
shopping = []
shopping.append("두부")
shopping.append("양배추") |
5144e5d9fb45e8de24f2801c7dfeb3f0cb19cb16 | Anuragjain20/Data-structure-and-algo | /Queue/stackusingqueue.py | 922 | 3.9375 | 4 | from queue import Queue
class Stack:
def __init__(self):
self.q1 = Queue()
self.q2 = Queue()
self.curr_size = 0
def push(self, x):
self.curr_size += 1
self.q2.put(x)
while (not self.q1.empty()):
self.q2... |
b5a083008411fb0bef68ebabaee024e39eb3ea28 | Anuragjain20/Data-structure-and-algo | /Linked List/singlylinkedlist.py | 4,071 | 4.09375 | 4 | """
class Node:
def __init__(self,value =None):
self.value = value
self.next = Node
class SLinkedList:
def __init__(self):
self.head = None
self.tail = None
singlyLinkedList = SLinkedList()
node1 = Node(1)
node2 = Node(2)
singlyLinkedList.head = node1
singlyLinkedList.h... |
7211d015be01620d979bd50c16fe4dfc85b97ec1 | Anuragjain20/Data-structure-and-algo | /Queue/queueUsingStack.py | 970 | 3.8125 | 4 | class QueueStack:
def __init__(self):
self.__s1 = []
self.__s2 = []
def enqueue(self,data):
if self.__s1 == []:
self.__s1.append(data)
return
while self.__s1 != []:
r= self.__s1.pop()
self.__s2.append(r)
self.__s1.... |
edeec7a377a1133c62ab763a5f214706d29c0493 | Anuragjain20/Data-structure-and-algo | /Queue/reverseKqueue.py | 508 | 3.796875 | 4 | from queue import Queue
def reverseKqueue(q,k):
if q.empty() == True or k > q.qsize():
return
if k<= 0:
return
stack = []
for i in range(k):
stack.append(q.queue[0])
q.get()
while len(stack) != 0:
q.put(stack[-1])
stack.pop()
for i in r... |
985645ba73baf9e3e4e0e0891124f47843c4214b | Aakash-Rajbhar/Calculator | /Calculator.py | 4,677 | 4.125 | 4 | import tkinter
from tkinter import *
root = Tk()
root.geometry('303x467')
root.title("Aakash's Calculator")
e = Entry(root, width=25,font=("Callibary",15) ,bg="light grey" ,borderwidth=10)
e.grid(row=0, column=0, columnspan=10)
def btn_click(number):
c = e.get()
e.delete(0,END)
e.insert(0,str(... |
a5d8b66c92ada51e44ca70d2596a30f0da6f7482 | jmlippincott/practice_python | /src/16_password_generator.py | 639 | 4.1875 | 4 | # Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main met... |
a1bfb994c2cdf4ec03bb660500a757538d67be1f | jmlippincott/practice_python | /src/12_list_ends.py | 397 | 4.09375 | 4 | # Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function.
from os import system
import random
lst_length = random.randint(1,100)
lst = [random.randint(0,100) for i i... |
58517d054f5f5430f675947ee6f102ca51c42d21 | jmlippincott/practice_python | /src/18_cows_and_bulls.py | 958 | 3.859375 | 4 | import random, string
from os import system
chars = string.digits
def generate(digits):
return list("".join(random.choice(chars) for i in range(digits)))
while True:
num_digits_solution = int(input("Enter puzzle size (0-9): "))
solution = generate(num_digits_solution)
# print(f"Solution: {solution}"... |
9d5dd5789a533ed84d8f11c82331a87b32095d2d | JagadishThalwar/Python3 | /if-else.py | 200 | 3.9375 | 4 | i=20
if(i<15):
print("i is smaller than 15")
print(" i am in if block")
else:
print("i is greater than 15")
print("i am in else block")
print(" i am not in if block and not in else block") |
d1e7712d91d57eb33e693963bd33a3cccda59151 | Oxidiz3/PythonOneOffs | /FinishedProjects/interpreter.py | 3,475 | 4.0625 | 4 | """
Command Comprehender
summary: be able to get a command in a sentence and then understand what
it wants and do something with it
"""
import json
data_dict = {}
word_type_names = ["action", "object", "target", "actor", "ignore"]
command_hint_length = 2
class WordType:
def __init__(self, name, d_saved_wo... |
f6a05a3977cf18e0a5b424eaec8eb0da10188817 | Autonomous-Agent-25/pybits | /sorting/demo/bubble.py | 800 | 4.09375 | 4 | #!/usr/bin/env python
# coding: utf-8
#--------------------
"""
Bubble sort (Exchange sort family)
"""
N = 10
import random
def bubble_sort(x):
print 'Illustrated bubble sort'
num_tests = 0
num_swaps = 0
num_passes = 0
unsorted = True
while unsorted:
num_passes += 1
print 'P... |
549c2e397f3f0b30aeab13e254242faf8a74f4a1 | VYuLinLin/studying-notes | /Python3k/class/dog.py | 543 | 4.03125 | 4 | # 2.7版本呢需要定义object形参
class Dog():
# 一次模拟小狗的简单尝试
def __init__(self, name, age):
self.name = name
self.age = age
def sit(self):
# 模拟小狗命令式蹲下
print(self.name.title() + ' is now sitting.')
def roll_over(self):
# 模拟小狗命名时打滚
print(self.name.title() + ' rolled over!')
my_dog = Dog('willie', 6)... |
98e13a99f5f668d14d16315f689a6cf5b8981fed | VYuLinLin/studying-notes | /Python3k/pythonCase/hello.py | 216 | 4.0625 | 4 | print("hello world,", "my is python3")
name = input('亲,请输入您的姓名,好吗?')
# 单行注释
'''
多行注释
'''
# if name:
# else:
# print('您还没有输入您的姓名哦!')
print(name) |
2f20c8687a9fadfe8589c10b3de7c0df51f5b9c8 | luiszugasti/adventOfcode2020 | /day8/day8.py | 2,022 | 3.671875 | 4 | # day8.py
import copy
from typing import Tuple
from day2.day2 import open_file
def parse_input_to_puzzle_scope(puzzle_input):
parsed_instructions = []
for entry in puzzle_input:
parsed_instructions.append(parse_instruction(entry))
return parsed_instructions
def parse_instruction(input):
act... |
7897a1f57d210d621f6262132a6a1e8968ceb34e | allptics/software | /draw.py | 1,658 | 3.96875 | 4 | """
Description:
Functions used to render visuals
"""
import numpy as np
import matplotlib.pyplot as plt
def draw_paraxial_system(ax, sys):
"""
Draws a paraxial system
ax: plot
sys: system
"""
# plot optical axis
ax.axhline(y=0,color="black",dashes=[5,1,5,1],l... |
fde121bae6e3a8993cd846d8337644a8b8cc3f0e | lizy90/Learn-Project | /Task2.py | 1,682 | 3.546875 | 4 | """
下面的文件将会从csv文件中读取读取短信与电话记录,
你将在以后的课程中了解更多有关读取文件的知识。
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
任务2: 哪个电话号码的通话总时间最长? 不要忘记,用于接听电话的时间也是通话时间的一部分。
输出信息:
"<telephone number>... |
4c15d5aa19f8c081321df60ba1d0fa1e21bf01fc | biof309/03-loop-example-watkinsta | /airdata.py | 632 | 3.65625 | 4 | import numpy as np
import pandas as pd
airdata = pd.read_excel('airdata.xlsx')
#Data are measurements of air pollution levels from thousands of
#regions throughout the world recorded on WHO. This loop will count how many of
#these regions either do or do not meet guidelines - limit is 20
under_count = 0
over_count = 0
... |
9d057f9b4c79e82df90153757e7797f593adb009 | TasosVellis/Zero | /8.Object Oriented Programming/4_OOPHomework.py | 1,425 | 4.21875 | 4 | import math
# Problem 1
#
# Fill in the Line class methods to accept coordinates as a
# pair of tuples and return the slope and distance of the line.
class Line:
"""
coordinate1 = (3,2)
coordinate2 = (8,10)
li = Line(coordinate1,coordinate2)
li.distance() = 9.433981132056603
li.slope() = 1.6
... |
f1b22aa04b5b7dd47063d11989529775142c3f88 | TasosVellis/Zero | /6.Methods_Functions_builtin/3cardmonty.py | 600 | 4.03125 | 4 | #!/usr/bin/env python
from random import shuffle
def shuffle_list(mylist):
shuffle(mylist)
return mylist
def player_guess():
guess = ''
while guess not in ['0', '1', '2']:
guess = input("Pick a number :0, 1 or 2 ")
return int(guess)
def check_guess(mylist, guess):
if mylist[guess] ... |
95728488a63a49f8260cdb346507a16789e42d7a | TasosVellis/Zero | /6.Methods_Functions_builtin/functiopracticeproblems.py | 5,789 | 4.1875 | 4 | # WARMUP SECTION
def lesser_of_two_evens(a, b):
"""
a function that returns the lesser of two given numbers if both numbers are even,
but returns the greater if one or both numbers are odd
:param a: int
:param b: int
:return: int
lesser_of_two_evens(2,4) --> 2
lesser_of_two_evens(2,5) ... |
cabd94e59e8e1dfc0bcb93ca204b7627426279a6 | Reiich/Raquel_Curso | /Ejercicio06_MasterMind/main.py | 2,591 | 3.96875 | 4 | # Ejercicio 2
# Escribe un programa que te permita jugar a una versión simplificada del juego
# Master Mind. El juego consistirá en adivinar una cadena de números distintos.
# Al principio, el programa debe pedir la longitud de la cadena (de 2 a 9 cifras).
# Después el programa debe ir pidiendo que intentes adivina... |
599ee94087dc1f1ecca3f354fbcfdaade4bd02b8 | Reiich/Raquel_Curso | /receta_15_barrasDesplazamiento/main15.py | 2,277 | 3.5 | 4 | '''
uso de la BARRA DE DESPLAZAMIENTO
aquí para obtener el valor de la barra, donde el usuario la ha dejado parada
se usa:
.valueChanged
hay que tener en cuenta, que éste método devuelve el valor, que se optine.
Automáticamente, si tener que programar nada. Por ello, ucnado definamos la función
qu... |
9b5b7c70619cfb3ec1d41bc5288d6a227b7d244d | Reiich/Raquel_Curso | /Ejercicios_ALF_Ficheros/main.py | 3,383 | 3.75 | 4 | '''
Created on 21 mar. 2020
@author: Raquel
EJERCICIOS - FICHEROS
'''
# Ejercicio 1
# Escribir una función que pida un número entero entre 1 y 10 y guarde en un
# fichero con el nombre tabla-n.txt la tabla de multiplicar de ese número,
# done n es el número introducido.
def pideNumero():
n = int... |
f74f2b5d8ec3cc78ed956c9ad432cf6b428646ac | bhishan/FacebookAutomationDoubleDownCasino | /buychips.py | 3,082 | 3.546875 | 4 | '''
Author : Bhishan Bhandari
bbhishan@gmail.com
The program uses following modules
selenium to interact and control the browser
time to create pause in the program to behave like we are human
pyautogui to find the location of buy chips button in the game to click
time is a default module in python which comes... |
162cc8d2c7562d4ca175908fae458dda6b86969c | lmokto/py-designpattern | /singleton/ejemplo-singleton.py | 501 | 3.78125 | 4 | class Singleton (object):
instance = None
def __new__(cls, *args, **kargs):
if cls.instance is None:
cls.instance = object.__new__(cls, *args, **kargs)
return cls.instance
"""definimos el objecto"""
MySingletonUno = Singleton()
MySingletonDos = Singleton()
MySingletonUno.n... |
71fb6615811b40c8877b34456a98cdc34650dc92 | arvimal/DataStructures-and-Algorithms-in-Python | /04-selection_sort-1.py | 2,901 | 4.5 | 4 | #!/usr/bin/env python3
# Selection Sort
# Example 1
# Selection Sort is a sorting algorithm used to sort a data set either in
# incremental or decremental order.
# How does Selection sort work?
# 1. Iterate through the data set one element at a time.
# 2. Find the biggest element in the data set (Append it to anoth... |
06eed5f573e0c33e89a282600aead38f947dd078 | dgkimura/sudoku | /src/solver.py | 2,506 | 3.84375 | 4 | # solver.py
#
# A solver will insert numbers into a grid to solve the puzzle.
class Solver:
def __init__(self, grid):
self._grid = grid
def populate(self, nums):
for i, n in enumerate(nums):
if n is not None:
# print i
self._grid.cells[i].insert(n)
... |
3eea539c849e14f831231c3bdceb2193c6138bdb | evgenyneu/ASP3162 | /10_integration_python/src/exact_solution.py | 1,740 | 3.9375 | 4 | import numpy as np
def exact(x, n):
"""
Calculate exact solution of Lane-Emden equation.
Parameters
----------
x : float or ndarray
Value or values of independent variable
n : integer
Parameter 'n' of the Lane-Emden equation
Returns : float or ndarray
-------
V... |
465d7a23163f564c85cbc09aa09657a310e95393 | evgenyneu/ASP3162 | /07_upwind_wendroff/plotting/create_movies.py | 3,225 | 3.53125 | 4 | # Create movies of solutions of advection equation
import matplotlib.animation as animation
from compare_animated import animate, prepare_for_animation
import matplotlib
import os
from plot_utils import create_dir
matplotlib.use("Agg")
def create_movie(methods, initial_conditions, courant_factor,
mo... |
da6ff2dc49a425b99fde124769ba8fe2567d0b6d | evgenyneu/ASP3162 | /05_advection_equation/parts/02_numerical/plotting/solver.py | 3,346 | 3.5 | 4 | # Solve a heat equation
import subprocess
from plot_utils import create_dir
import numpy as np
import os
import struct
import array
def read_solution_from_file(path_to_data):
"""
Read solution from a binary file. Please refer to README.md
for description of the binary file format used here.
Parameter... |
671a2d1b58e546d9b38a7499d231412d53418de1 | systembase-kikaku/python-learn | /deep_learning1/numpy1.py | 269 | 3.53125 | 4 | import numpy as np
x = np.array([1.0, 2.0, 3.0])
print(x)
v1 = np.array([3, 4, 5])
v2 = np.array([1, 2, 3])
print(v1 + v2)
print(v1 - v2)
print(v1 * v2)
print(v1 / v2)
A = np.array([[1, 2], [3, 4], [5, 6]])
print(A.shape)
print(A.dtype)
print(A + 10)
print(A * 10)
|
48e3534a6cc05a5068103994a6599a20f50c6f39 | davidsekielyk/frro-soporte-2018-07 | /practico-02/ejercicio-01.py | 544 | 3.984375 | 4 | #Ejercicio 1
print("""Ejercicio 1
Escribir una clase llamada rectángulo que contenga una base y una altura, y que contenga un
método que devuelva el área del rectángulo.
""")
class Triangulo():
def __init__(self, base, altura):
self.base = base
self.altura = altura
def area(self):... |
7d53e8a283b5c82d079752eee3465214cbf683da | davidsekielyk/frro-soporte-2018-07 | /practico-01/ejercicio-12.py | 293 | 3.859375 | 4 | #Ejercicio 12
print("Ejercicio 12: Determinar la suma de todos los numeros de 1 a N. N es un número que se ingresa por consola.\n")
a = int(input("ingrese un numero: "))
rdo = 0
for i in range(a):
rdo = rdo + (a - i)
print("La suma de todos los numeros de 1 a",a, "es:",rdo)
|
d528adcaaa0b77ae7adfd71829542fa02eedc1dd | gomgomigom/Exercise_2 | /w_1-2/201210_0.py | 281 | 3.703125 | 4 | i = 1
current = 1
previous = 0
while i <= 10:
print(current)
temp = previous
previous = current
current = current + temp
i += 1
i = 1
current = 1
previous = 0
while i <= 10:
print(current)
previous, current = current, current + previous
i += 1
|
a287c15b12ed3e3194c5aedac6b2fbb8adeb629b | gomgomigom/Exercise_2 | /w_1-2/201210_4.py | 2,013 | 4.125 | 4 | # numbers라는 빈 리스트를 만들고 리스트를 출력한다.
# append를 이용해서 numbers에 1, 7, 3, 6, 5, 2, 13, 14를 순서대로 추가한다. 그 후 리스트를 출력한다.
# numbers 리스트의 원소들 중 홀수는 모두 제거한다. 그 후 다시 리스트를 출력한다.
# numbers 리스트의 인덱스 0 자리에 20이라는 수를 삽입한 후 출력한다.
# numbers 리스트를 정렬한 후 출력한다.
# 빈 리스트 만들기
numbers = []
print(numbers)
numbers.append(1)
numbers.append(7)
numbers... |
7d9ae260ebd619e69325316d76119ad2ce0b010d | gomgomigom/Exercise_2 | /w_1-2/201212_3.py | 519 | 3.65625 | 4 | import random
guess = -1
ANSWER = random.randint(1,20)
NUM_TRIES = 4
tries = 0
while guess != ANSWER and NUM_TRIES > tries:
guess = int(input(f"기회가 {NUM_TRIES - tries}번 남았습니다. 1-20 사이의 숫자를 맞혀 보세요: "))
tries += 1
if ANSWER > guess:
print("Up")
elif ANSWER < guess:
print("Down")
if gues... |
2929a547ca339b6226756026a221d48a7482b5d8 | eriksylvan/PythonChallange | /1/1.py | 430 | 3.578125 | 4 | # http://www.pythonchallenge.com/pc/def/map.html
# print (ord('a'))
# print (ord('.'))
#
# print (ord('A'))
# print (ord('z'))
# print (ord(' '))
#hej
with open("input") as f:
for line in f:
for ch in line:
asciiNo = ord(ch)
if ord('A') <= asciiNo <= ord('z'):
print(ch... |
393888cb2cb65dc22e7c369dc786dd89618d772d | JoseLuisAcv2/Algoritmos-II-Proyecto-II | /listaReproduccion.py | 4,251 | 3.59375 | 4 | #
# ALGORITMOS II - PROYECTO II
#
# REPRODUCTOR DE MUSICA
#
# AUTORES:
# - Jose Acevedo 13-10006
# - Pablo Dario Betancourt 13-10147
# TAD Lista de reproduccion. Implementado con lista circular doblemente enlazada
# Modulo
from cancion import *
# Clase para nodos de la lista enlaada
class nodoLista:
# Co... |
4e3f98f1e05289dc88477754d42d26ec0d7c82ec | DoyKim-20/DoyKim-20.github.io | /Practice02.py | 269 | 3.640625 | 4 | print("2번 과제 시작!")
year = 19
pin = '990329-1083599'
if pin[7]==3 or pin[7]==4 :
year = year + 1
print('김멋사군의 탄생일은 ' + str(year) + str(pin[0:2]) + '년 ' + str(pin[2:4]) + '월 ' + str(pin[4:6]) + '일 입니다')
#60192164 김도영 |
6dd28e4f0b0e2b51deb6a51d4ed0ee636b321616 | kevinkepp/ann | /ann/act.py | 1,279 | 3.609375 | 4 | import numpy as np
import scipy.special
def linear(z):
return z
def d_linear(a):
return 1
def relu(z):
return z * (z > 0)
def d_relu(a):
return a > 0
def tanh(z):
return np.tanh(z)
def d_tanh(a):
return 1 - a ** 2
def sigmoid(z):
return scipy.special.expit(z)
def d_sigmoid(a):
return a * (1 - a)... |
fa8385e10ce82dcce011f7f0c8b3384c4b4e75f9 | Abe27342/project-euler | /src/65.py | 583 | 3.734375 | 4 | import fractions
def get_frac(continued_fraction_list):
x = continued_fraction_list[::-1]
y = fractions.Fraction(x[0])
x.remove(x[0])
while(len(x) > 0):
y = x[0] + 1/y
x.remove(x[0])
return(y)
def get_continued_frac(n, de):
d = fractions.Fraction(n,de)
x = []
while(int(d)... |
581970e71a706fc9c2eefc33ca0f9afe28042361 | Abe27342/project-euler | /src/359.py | 2,443 | 3.71875 | 4 | '''
First, a simulation...
Evidently, floor 1 contains all triangular numbers.
Looking on oeis,...
floor 2 contains numbers 2, 7, 9, 16 and then a(n) = 2a(n-1) - 2a(n-3) + a(n-4)
a(1) = 2
a(2) = 7
a(3) = 9
a(4) = 16
floor 3 contains a(0) = 1 then a(n) = n^2 - a(n-1) for n >= 1.
floor 4 contains blah blah blah
it t... |
2e31593ab0115bab5ac39d77731cef845f299b4c | Abe27342/project-euler | /src/51.py | 1,520 | 3.609375 | 4 | '''
this code sucks
also used this:
from helpers import isPrime
x = sum([isPrime(101010*k+20303) for k in range(1,10)])
print(x)
'''
from helpers import sieve
import itertools
num_set = ['0','1','2','3','4','5','6','7','8','9','*']
primes = sieve(10000000)
print('primes generated')
def triple_digit(n):
n = s... |
5dc34de95e32b2e08f8f504fda056c1febfcc5cb | Abe27342/project-euler | /src/287.py | 2,675 | 3.59375 | 4 | # (0,0) is bottom_left
# Because I'm too lazy to precompute lmao
from helpers import memoize
@memoize
def get_pow_2(n):
return pow(2, n)
def is_top_left(N, bottom_right):
x,y = bottom_right
return x < get_pow_2(N - 1) and y >= get_pow_2(N - 1)
def is_bottom_left(N, top_right):
x,y = top_right
return x < get_po... |
bb1e8d8a320464f802cd28823c3b551f15906dfe | MilletPu/IR-hw | /IR-hw/index.py | 11,196 | 3.53125 | 4 | # -*- encoding: utf8 -*-
from __future__ import absolute_import, division, print_function
import VB
import collections
import functools
import math
DOCUMENT_DOES_NOT_EXIST = 'The specified document does not exist'
TERM_DOES_NOT_EXIST = 'The specified term does not exist'
class HashedIndex(object):
"""
Inver... |
1c1c21233ee084db1004816005357985b6166e39 | lior-ohana/TDD | /test_bubble_sort.py | 877 | 3.734375 | 4 | import unittest
from bubble_sort import *
class testbublesort(unittest.TestCase):
#tests of the function name-bubbleSort(arr)
def test_bubblesort1(self):
arr1=[4,2,1,7]
expected=[1,2,4,7]
bubbleSort(arr1)
self.assertEqual(expected,arr1)
def test_bubblesort2... |
e0f974c5b42c9c4279fb0ddf8f7030860557ce32 | imknott/python_work | /guest_book.py | 441 | 4 | 4 | filename = 'text_files/guestbook.txt'
print("Welcome to the terminal, we ask that you please enter the following: \n")
while True:
name = input("What is your name? ")
with open(filename, 'a') as file_object:
file_object.write(f'{name} \n')
#Find out if someone else would like to take the poll.
... |
7d2fe2f51f6759be77661c2037c7eb4de4326375 | rbrook22/otherOperators.py | /otherOperators.py | 717 | 4.375 | 4 | #File using other built in functions/operators
print('I will be printing the numbers from range 1-11')
for num in range(11):
print(num)
#Printing using range and start position
print("I will be printing the numbers from range 1-11 starting at 4")
for num in range(4,11):
print(num)
#Printing using range, start... |
126fac3a8f4a79d89830c94e722f8f7082e816b5 | Hiurge/reader | /app_scripts/reader_input_helpers.py | 1,225 | 3.59375 | 4 | import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import re
# Reader input helpers:
# - Turns reader input into one string text contents weather its a link contents or a pasted text.
# Main function to import: get_input_text(contents)
# Gets website contents and turns into list of par... |
193df65365239df519e955afc7487f0435628433 | Sjord/matasano | /set2/pkcs.py | 182 | 3.5 | 4 |
def pad(data, length):
pad_length = length - len(data)
return data + pad_length * chr(pad_length)
assert(pad("YELLOW SUBMARINE", 20) == "YELLOW SUBMARINE\x04\x04\x04\x04")
|
71876e59efb677256adbcd6ddd99bc483b3f6e30 | ktemirbekovna/Moduli | /slide_2.2.py | 379 | 3.890625 | 4 | '''Спросите у пользователя 2 значения через input() а затем через модуль sys
проверьте какое из 2-х значений занимает больше памяти.'''
import sys
a = input("Введите данные: ")
b = input("Введите данные: ")
print(sys.getsizeof(a))
print(sys.getsizeof(b))
|
20c9fb839eb1b852be94e76ea437c479b78f0415 | hackett123/chess | /model/FEN.py | 1,922 | 3.75 | 4 | """
https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation
Fen notation: slashes (/) divide rank information. Within each rank, a lowercase letter
denotes black pieces and uppercase denotes white. A number represents a sequence of empty
squares in the board.
The last segment contains the final rank and extra me... |
ee45660537cff37311a6081eee6082209b998ea4 | shukur-alom/Guess_Game | /Guess game.py | 2,180 | 3.953125 | 4 | #Guess Game
print('\n\n --WELCOME TO GUESS GAME-- \n\n')
my_hide=23
l=1
Tring_Time=10
try:
while l<=100:
User_input=int(input("Enter Your Guess: "))
if User_input <=5:
print('Incrise t... |
6db878c7906c9fecbd5f7f9703f2108cbf626976 | nasjp/atcoder | /arc065_a.py | 962 | 3.8125 | 4 | # Me
def check(s):
words = [
'dream',
'dreamer',
'erase',
'eraser',
]
while len(s) != 0:
flag = False
for w in words:
if s[-len(w):] == w:
s = s[:-len(w)]
flag = True
break
... |
b86322bff277a38ee7165c5637c72d781e9f6ee2 | Bbenard/python_assesment | /ceaser/ceaser.py | 678 | 4.34375 | 4 | # Using the Python,
# have the function CaesarCipher(str, num) take the str parameter and perform a Caesar Cipher num on it using the num parameter as the numing number.
# A Caesar Cipher works by numing all letters in the string N places down in the alphabetical order (in this case N will be num).
# Punctuation, space... |
e026278e161656a19b0d93ec074cbb7d8b0c1a11 | hirosato223/Exercism.io-Problems | /python/hangman/hangman.py | 1,372 | 3.65625 | 4 | STATUS_WIN = "win"
STATUS_LOSE = "lose"
STATUS_ONGOING = "ongoing"
class Hangman(object):
def __init__(self, word):
self.remaining_guesses = 9
self.status = STATUS_ONGOING
self.word = word
self.maskedWord = '_' * len(word)
self.previousGuesses = set()
def guess(self, ch... |
ca33de76147ae37ebd77a1f66b4d5bdabf1e94c9 | nicholas-eden/python-algorithms | /sort/selection_sort.py | 393 | 4.0625 | 4 | from typing import List
data = [3, 6, 12, 6, 7, 4, 23, 7, 2, 1, 7, 4, 3, 2, 5, 3, 1]
def selection_sort(arr: List[int]):
low: int
for left in range(len(arr) - 1):
low = left
for right in range(left + 1, len(arr)):
if arr[right] < arr[low]:
low = right
arr[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.