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
78ec49439d956378c5f414bf673cc92f3c3bccda
nick-lehmann/SnakeCharmerGuide
/games/pizza.py
687
4.28125
4
""" Mario is eating a pizza. The pizza is so tasty that every time he eats a slice he wants to say "Mhhhhhh". Every time he eats a slice his hunger gets lowered by 1. If he is full, he stops eating and says "I'm full 🤤" When he is finished he says "Mamma mia! Buonissima! 😋" Say if he is still hungry after eating all ...
3f3504dfc2832bad0d96fe89bf3233d58442a9c7
nick-lehmann/SnakeCharmerGuide
/games/map_filter.py
1,215
3.671875
4
# 1 def my_filter(number): return number != 7 # Map & Filter numbers = ['1', '-5', '3', '0', '-2', '-4', '7', '0', '3', '-1', '2', '8'] numbers = map(int, numbers) numbers = map(abs, numbers) numbers = filter(my_filter, numbers) total = sum(numbers) print(total) # Comprehensions numbers = ['1', '-5', '3', '0', '...
f93c3a294a435212eceb18e67c5e7c5f86a7e403
nick-lehmann/SnakeCharmerGuide
/games/rock_paper_scissors.py
1,841
4.40625
4
""" You want to play rock-paper-scissors against the computer. 1. Define a dictionary for each player that stores its name and current score. 2. Ask the player about his or her name and ask how many round should be played. 3. Each round, ask the player for his or her choice. The computer should pick a random choice. 4...
877e277d31c05a525ca170ddc6c484df53c59afa
vivi-coding/Python-self-study
/socket_s.py
671
3.71875
4
#!/usr/bin/python3 # 文件名:server.py # 导入 socket、sys 模块 import socket import sys # 创建 socket 对象 serversocket = socket.socket( socket.AF_INET, socket.SOCK_STREAM) # 获取本地主机名 host = socket.gethostname() port = 9999 # 绑定端口 serversocket.bind((host, port)) # 设置最大连接数,超过后排队 serversocket.lis...
35e80aef09ad859ecaf02f1fc118689e7868d09d
payoto/graphcore_examples
/code_examples/popart/block_sparse/examples/sparse_attention/sparse_attention_utils.py
16,682
3.609375
4
# Copyright (c) 2020 Graphcore Ltd. All rights reserved. import numpy as np from scipy import sparse from matplotlib import pyplot as plt class Convert: """ There are two converters available: - convert from a 2D Numpy array or a Scipy sparse matrix to a popsparse representation - convert fro...
e9d042d0ef37f5cffad7f9bd7c304ed63fc9076f
ennozdd/blackjack
/blackjack.py
2,098
3.640625
4
#!/usr/bin/env python3 #blackjack.py import random import os cards= [ "2","3","4","5","6","7","8","9","10","J","Q","K","A"]*4 dealer_hand=[] your_hand=[] def generator(hands): value=0 k=len(hands) for i in range(k): if hands[i] in "JQK": value+=10 elif hands[i] ...
2204b78203ab6bad70f0a092d1fb3600916930f5
Afifa-Aslam/Pyhthon-Practice
/Ques5Lab1.py
156
3.828125
4
Comprehension=["Afifa","Aqsa","Nimra","Basima","Task"] List=[] for a in Comprehension: if(len(a)>5): List.append(a.upper()) print(List)
032adb805859ba0c27c12d52d0ccf680c2eeb482
txyong/learnPython-01
/calculator0.02.py
3,657
3.890625
4
#!/usr/bin/env python3 import sys try: a = int(float(sys.argv[1])) if len(sys.argv) == 2: #判断参数数量 x = a - 3500           if x <= -3500:          #判断参数是否小于0 print("Parameter Error") else: if x > -3500 and x < 1: b = 0 elif x <= 1500:...
88d46bf4694d95c6f9e62726f88cc21871ccbea6
Greensahil/CS697
/Playground/listAndTuples.py
2,067
4.4375
4
#sequence an object that contains multiple items of data #list is mutable can be changed in place in memory #tuple cannot be modified unless you are reassigining to a different place in memory list = [1,2] print(list) #list is similar to array list in java #list is dynamic and we can change the size #list can be h...
6f10ff6d4cc3a2a9c6e8769e008a195658cd0467
Greensahil/CS697
/Playground/pattern.py
425
4.0625
4
charcater = input("Enter character") count = int(input("Enter the number of times the character needs to repeat")) for i in range(count): print(" " * (count - i), end= '') if i == 0 or i == (count-1): if i == 0: print("*") elif i == (count-1): print("* " * (i+1)) el...
8401ef69843234d30758eecc923f15296cc9b1a3
Greensahil/CS697
/Playground/passwordchecker.py
757
4.3125
4
password = input("Enter a string for password:") validPassword = True #A password must have at least eight characters. if len(password) < 8: validPassword = False #A password consists of only letters and digits if not password.isalnum(): validPassword = False #A password must contain at least two digits #A p...
ff1e0747530f7d4f37d0da2535f5fe20aea6aa34
sudarshanAw/height-weight-prediction
/height_weight_reln.py
1,261
3.84375
4
#importing libraries import pandas as pnd import matplotlib.pyplot as mplot #dataset dataset = pnd.read_csv('weight-height.csv') #dependent and independent variable x = dataset.iloc[:,1].values y = dataset.iloc[:,2].values mplot.scatter(x,y) mplot.xlabel('height') mplot.ylabel('weight') #splittin...
d687aa35ca58427c41bc33043183df022ceec206
maderski/ONList
/ONList.py
1,497
3.6875
4
___author__ = 'Jason Maderski' __date__ = '11/15/2015' import re inputFile1List = [] inputFile2List = [] inputFile1 = "inputFile1.txt" inputFile2 = "inputFile2.txt" class FindDuplicates: duplicatesCounted = 0 # Check to see if inputed item is on inputed List def isItemOnList(self, item, inputList): ...
bdd2e11af4e344d570e79df6386d4c362448b51f
DimitrisMorfos/Askiseis
/Askisi9.py
388
3.640625
4
def maxSequence(lista): lilen=len(lista) max=0 p=0 a=0 for i in range(0,lilen-1): for j in range(i+1,lilen): if sum(lista[i:j])>max: p=i a=j max=sum(lista[i:j]) mlista=lista[p:a] return mlista lista=input("Give ...
caabe38098770bf36b610a29095de48d25883c37
furiousdog/py101_third_week
/word_freq.py
1,857
3.515625
4
""" Программа считает Топ-100 слов для переданного ей текстого файла. Путь до текстового файла передается программе в виде аргумента В выводе не должно быть стоп-слов (междометий, союзов, местоимений и т.д.) Список стоп-слов можно взять из популярного пакета nltk Тебе может понадобится модуль os, модуль argparse, цик...
5a9cae303fbc660ac7566063f5593a78c263dabf
half-rice/daily_programmer
/easy_challenge_1.py
699
4.21875
4
# create a program that will ask the users name, age, and username. have it # tell them the information back, in the format: # your name is (blank), you are (blank) years old, and your username is (blank) # for extra credit, have the program log this information in a file to be # accessed later. file = open("easy_ch...
870430a89fb57bdadf8863b9ee8a43ccd3bff287
NhatNam-Kyoto/Python-learning
/100 Ex practice/ex8.py
375
4.125
4
'''Write a program that accepts a comma separated sequence of words as input and prints the words in a comma-separated sequence after sorting them alphabetically. Suppose the following input is supplied to the program: without,hello,bag,world Then, the output should be: bag,hello,without,world ''' inp = input('Nhap c...
35b00333431c30e1ffec6b84a2ac52a3fbb1d757
NhatNam-Kyoto/Python-learning
/python2.7/Learncode the hard way/ex12/ex12.py
268
3.828125
4
age = raw_input("How old are you?- ") #thay the cho print "How old are you" r moi gan age vao raw_input height = raw_input("how tall are you?- ") weight = raw_input("How much do you weight?- ") print "So, you're %r old, %r tall and %r heavy." %( age, height, weight)
7ed931d3d54fb1d56d10813f58c2de5582664d92
NhatNam-Kyoto/Python-learning
/String-Learning/DemoStr2.py
923
3.859375
4
#Toán tử chuỗi: +, * strA = "Hello" strB = "Nhatnam-Kyoto" strC = 'K' strD = "H" print(strA + " " + strB) print(strA * 5) #============================== #check if strA in strB:> T or F return print(strC in strA) print(strD in strA) #============================== #Index of string: 0 > len(str) - 1; -1>>> print(len(str...
795ee5364e0cf492fe12b202dd3d694224ec102a
ssmakhija/python
/week3/donuts.py
184
4
4
x=eval(input("Enter 1 Number")) if x<1: print("invalid input") elif x<=2: print("too few donuts") elif x<11: print("Number of Donuts "+str(x)) else: print("No of donuts too many")
5dbc0a5968f4d9906edd0942a77a1e682daeab17
ssmakhija/python
/30sept/homework/type.py
195
3.65625
4
l= [] data = '' no=eval(input("Enter Number of items in list")) for i in range(no): data=eval(input("Enter Data for list")) l.append(data) for i in l: print (i, type(i))
0e4f1a90d19907b891b6fb1746f979cbecde61ff
wann31828/leetcode_solve
/python_solution/119.py
993
3.890625
4
''' 119. Pascal's Triangle II Easy Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. Example: Input: 3 Output: [1,3,3,1] Follow up: Could you optimize your algorithm to use only O(k) extra space? ''' class Solution(object): de...
3b45a65cd52fd410feba238d22ac19f0a450230d
wann31828/leetcode_solve
/python_solution/231.py
300
3.921875
4
''' 231. Power of Two Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: pow(2,0)= 1 ''' class Solution: def isPowerOfTwo(self, n: int) -> bool: if n<0 : return False return bin(n).count('1') == 1
68305fa1be50462a0668ae0898dec0937ed2307c
wann31828/leetcode_solve
/python_solution/500.py
880
4
4
''' 500. Keyboard Row Easy Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Example: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"] Note: You may use one character in the keyboard more than onc...
03ad4acf13e40d6eb7be83831f02746ec10db1b3
wann31828/leetcode_solve
/python_solution/56.py
1,111
3.9375
4
''' 56. Merge Intervals Medium Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. Example 1: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] ...
3c27361dad1f4c8086c8887b4c5bc215ec80a518
Wangsherpa/games_in_python
/dice_card/dice_card.py
4,707
4.0625
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 18 11:28:58 2020 @author: Asus """ from random import randint, shuffle rules_and_instruction = """ ** 24 Cards and a Dice ** Rules: 1. Player1 and Player2 name must be different. 2. Player1 plays first and then Player2's turn comes. 3. A is considered as 1. 4. Card deck...
bd2e875e5bfcb8be7ab220292287df850958c3bf
samu9809/sesion7
/ordenamiento por insercion.py
424
3.65625
4
def ordenamientoPorInsercion(unaLista): for indice in range(1,len(unaLista)): valorActual = unaLista[indice] posicion = indice while posicion>0 and unaLista[posicion-1]>valorActual: unaLista[posicion]=unaLista[posicion-1] posicion = posicion-1 unaLista[posicion]=val...
30298cfc319c01125062bf8b04983375f3a2b2fe
Lifefang/python-labs
/CheckersV1.9.py
32,905
3.640625
4
import numpy as np # -------------------SOME WILD FUNCTIONS THAT JUST KEEP GROWING-------------------------------------- def game_board(): # makes the game board print(" 'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H'") board = [ ['-', '-', '-', 'R', '-', '-', '-', '-'], ['-', '-', 'b', '-', 'B', '-', 'B', ...
5c2d762aea5323599a8b3f8ad9736dc1e0c37979
Lifefang/python-labs
/Lab6b_Act.py
2,922
3.5
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Name: Matthew Rodriguez # Section: 537 # Assignment: Lab 6 - row_4 # Date: 10/4/2019 ...
a93dd6d0d3929fb5e0004fc9f86ae9703c0a7a60
Lifefang/python-labs
/CFU07.py
1,880
4.25
4
# By submitting this assignment, I agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Name: Matthew Rodriguez # Section: 537 # Assignment: CFU-#9 # Date: 10/23/2019 # this...
0311d830fd6398fc5056583cfe1ac83e2b1ea5bf
Lifefang/python-labs
/Lab3_Act1_e.py
1,031
4.25
4
# By submitting this assignment, all team members agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Names: Isaac Chang # Matthew Rodriguez # James Phillips # ...
697d6e354785d72d736c49de8d4054ffd6514ac3
Lifefang/python-labs
/Lab3_Act1_c.py
878
4.03125
4
# By submitting this assignment, all team members agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Names: Isaac Chang # Matthew Rodriguez # James Phillips # ...
229224216d37994722981141cc29574ad63e664e
Lifefang/python-labs
/Testnumbertwo.py
4,224
3.734375
4
from math import * # n = 7 # num -1 # for i in range(2, num): # if num % i == 0: # print(num, 'is not prime') # break # else: # print(num, "is prime") # def prime(n): # for i in range(2, n): # if n % i == 0: # return False # else: # return True # # # def lpf...
0e1b7ba647bf813dc211973b5a06720dc2c77eb2
Lifefang/python-labs
/Lab3_Act1_a.py
894
4.125
4
# By submitting this assignment, all team members agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Names: Isaac Chang # Matthew Rodriguez # James Phillips # ...
f13ec97a087aa16c4e340fa00c001a328c5b1f6f
eloybarbosa/Fundamentos-de-programacao-com-Python
/TP3/15.py
1,229
3.859375
4
#15. Usando a biblioteca Pygame, escreva um programa que possui uma função que desenha na tela um estrela de 5 pontas no tamanho que preferir. (código e printscreen) import pygame import math branco = (255,255,255) vermelho = (255,0,0) verde = (0,255,0) azul = (0,0,255) preto = (0, 0, 0) pygame.init() tela = pygame....
60205f30deba5b17cfc51a7a17b5bc14e03b66ae
eloybarbosa/Fundamentos-de-programacao-com-Python
/Assessment/10.a.py
3,429
3.96875
4
#10. Obtenha, usando requests ou urllib, dentro de seu programa em Python, o csv do link: #https://sites.google.com/site/dr2fundamentospython/arquivos/Winter_Olympics_Medals.csv #E: #a - Dentre os seguintes países nórdicos: Suécia, Dinamarca e Noruega, verifique: No século XXI (a partir de 2001), qual foi o maior meda...
26d8f4287c3c379b9f34dc2d7a9e2d0ab11e8847
eloybarbosa/Fundamentos-de-programacao-com-Python
/Assessment/08.py
1,996
4.09375
4
#08. Usando a biblioteca ‘pygame’, escreva um programa que desenha um botão (círculo) com o texto “clique” sobre ele na parte superior da tela. Quando o botão for clicado, ele deve chamar uma função que desenha um retângulo em uma posição aleatória na tela. Caso um retângulo apareça na mesma posição que um já existente...
b408bb03477e3949e571946a04c75bb58a32e149
eloybarbosa/Fundamentos-de-programacao-com-Python
/TP1/Atividade 08.py
1,061
4.125
4
#8. Escreva um programa em Python que receba três valores reais X, Y e Z, guarde esses valores numa tupla e verifique se esses valores podem ser os comprimentos dos lados de um triângulo e, neste caso, retorne qual o tipo de triângulo formado. print('Nessa atividade vamos receber três valores reais (X, Y e Z) guardalo...
fa05d06ca10271b82850f978d5a737e47e1d6adb
eloybarbosa/Fundamentos-de-programacao-com-Python
/TP1/Atividade 18.py
1,371
4.15625
4
#18. ) Em jogos antigos era possível ver que os desenhos eram compostos por vários triângulos. Como uma maneira de treinar isso, a partir do N dado pelo usuário desenhe um polígono de lado N composto somente por triângulos como na figura: import math import turtle #referencia: https://github.com/AllenDowney/ThinkPyth...
3fa6134a2488116dbe43bca9e3cb24676b1bfbae
eloybarbosa/Fundamentos-de-programacao-com-Python
/TP1/Atividade 05.2.py
1,024
4.25
4
#5.2. Dada uma tupla, retorne 2 tuplas onde cada uma representa uma metade da tupla original. print('Nessa atividade vamos criar uma tupla inserindo quanto elemento desejarmos, a tupla e encerrada quando for digitada a palava "sair". ') print('Depois o programa vai nos retornar 2 tuplas onde cada uma representa uma me...
41c89e83236a971c90349a0cef1c89753a191993
lcgarcia05/370-Group5Project
/name/backend_classes/temporary_storage.py
1,293
4.15625
4
from name.backend_classes.playlist import Playlist class TemporaryStorage: """ A class which will handle the temporary storage of a created playlist and store the list of songs in a text file. """ def __init__(self, temp_playlist): """ Initializes the temp_playlist class and converts playl...
e8d047a222f0b1cc4c4c342db35cb184b1ffb86d
Dybowskii/wizualizacja_danych
/5_3.py
1,088
3.796875
4
class Ksztalty: def __init__(self, x, y): self.x=x self.y=y self.opis = "To będzie klasa dla ogólnych kształtów" def pole(self): return self.x * self.y def obwod(self): return 2 * self.x + 2 * self.y def dodaj_opis(self, text): self.opis = text de...
313074fb60f5fc000fa7194145a163a3cf839490
Dybowskii/wizualizacja_danych
/zad4_6.py
2,009
3.546875
4
class slowka: def __init__(self, slowo1, slowo2): self.slowo1=slowo1 self.slowo2=slowo2 def palindrom(self,a): if a==1: dlugosc=len(self.slowo1) x=1 z=0 while (x<=dlugosc/2): if self.slowo1[x]==self.slowo1[dlugosc-x]: ...
d91211bdc2053381dbedd22e8e2dbc362afc60e6
itsseraphii/AdventOfCode2020
/days/day6.py
2,412
3.59375
4
from utils.aoc_utils import AOCDay, day @day(6) class Day6(AOCDay): def common(self): # Opening filestream file = open(self.inputPath, "r") self.inputData = [] # Reading and appending each line to the inputData for line in file: line = line.replace('\n', '') ...
2c926dbbf13d6ea7c31082890d2f5273f1be9f63
KeelerNation/PythonLSC2017
/7.12AE.py
119
3.90625
4
string = str(input('Enter a sentence:\n')).split() for word in string: print(word[1:] + word[0] + 'AY', end = " ")
a688e4ed11e2a7f53208f421a7eb0877d094059b
FreddyJimenez9000/CSE
/Notes 3.py
566
4.03125
4
# defining a function def hello_world(): print("hello world") hello_world() # number = 3 def square_it(number): return number ** 2 print(square_it(3)) def tip_calc(bill): tax_amt = bill * 0.18 total_bill = bill + tax_amt return bill + tax_amt print(" Your bill is $%d" % tip_calc(100)) def ...
8ab4eb8ff957f595e54a17b64552f81134363295
chenchenphoebe/base
/webPro/Data-thought/csv_read.py
114
3.515625
4
#-*- coding:utf-8 -*- import csv date = csv.reader(open("csv_read.csv","r")) for user in date: print(user[1])
6a350be7b75cc55510365c0992478dea32fabef0
apatten001/strings_vars_ints_floats
/strings.py
786
4.3125
4
print('Exercise is a good thing that everyone can benefit from.') var1 = "This is turning a string into a variable" print(var1) # now i'm going to add two strings together print("I know im going to enjoy coding " + ","+ " especially once I've put the time in to learn.") # now lets print to add 2 blank lines in be...
7dc85fbcaaeef78eb17a677e6a0178e05eb0c383
HarshGarg1201/Tkinter
/buttons.py
549
3.546875
4
import tkinter window = tkinter.Tk() window.title("My first GUI") top_frame= tkinter.Frame(window).pack() bottom_frame= tkinter.Frame(window).pack(side = "bottom") btn1 = tkinter.Button(bottom_frame, text = "Button 1", fg = "red").pack(side= "left") btn2 = tkinter.Button(top_frame, text = "button 2", fg = "...
fba26dd48b55e24ace8a0e73a27fdee1a9fa8269
Lu-Bell/Sub-Cipher
/attack.py
576
3.796875
4
from collections import Counter print("YOUR ENCRYPTION SCHEME IS BEING COMPROMISED!") print("\nLETTER FREQUENCY: \n") boolean = True q = 1 with open("encrypt.txt", "r+") as e: words = e.read().lower() x = Counter(words) #checks how often a letter appears in the encrypted file count = 0 sort_orders = sorte...
316c6c4a81ed8b224d2ef8af334dd6d27287dc75
CaseyNord-inc/treehouse
/Dates and Times in Python/timestrings.py
287
3.671875
4
import datetime ## Examples # to_string(datetime_object) => "24 September 2012" # from_string("09/24/12 18:30", "%m/%d/%y %H:%M") => datetime def to_string(datetime_object): return datetime.datetime.strftime(datetime_object, '%d %B %Y') to_string("24 January 2016")
51c1c178ed7af2a9842d3f0e459fde9112894311
CaseyNord-inc/treehouse
/Python Collections/shopping_list_collections.py
3,196
4.03125
4
import os shopping_list = [] def clear_screen(): os.system("cls" if os.name == "nt" else "clear") def add_to_list(new_item): show_help() if len(shopping_list): position = input("Where should I add {}?\n" "Press ENTER to add to the end of the list\n" ...
d2ad7cfbd2bb9c727dc6e60d38da40a323b3105d
CaseyNord-inc/treehouse
/Write Better Python/docstrings.py
457
4.3125
4
# From Docstrings video in Writing Better Python course. def does_something(arg): """Takes one argument and does something based on type. If arg is a string, returns arg * 3; If arg is an int or float, returns arg + 10 """ if isinstance(arg, (int, float)): return arg + 10 elif ...
57b56467b8396acceeb83a2783c770698d1ad177
gitter-badger/stylo
/stylo/motion.py
15,736
3.5625
4
from math import floor import numpy as np import matplotlib.pyplot as plt import scipy.integrate as I class Driver: """ A Driver is typically used to control a certain parameter over time for example - the thickness of a line etc. In certain respects it's very similar to a Motion object but I think ...
e3047a53dc5dff4ec33e574f2700cdb152581bde
mdebayu/AdventOfCode
/Day_1/solve_pt1.py
244
3.71875
4
running_sum = 0; with open("input.txt",'r') as fr: for line in fr.readlines(): running_sum += (int(line)) print("Value: {} Current_Sum = {}".format(int(line),running_sum)) print("\n\n\nTotal sum: {}\n".format(running_sum))
72991159727aabd92588d5546b455de5a074ffb7
AranAyyanar/Python
/print_*.py
202
3.625
4
N=int(input()) list1=[" " for i in range(0,N)] sum1="" for i in range(len(list1)-1,-1,-1): for j in range(i,i-1,-1): list1[j]="*" for k in list1: sum1=sum1+k print(sum1) sum1=''
7784b20a54d415207f980dd5fff00a4a9e45a9ce
Arturok/TEC
/Intrucción y Taller de Programación/II Proyecto/Segundo Proyecto Programado/DIOS AYUDAME.py
9,249
3.75
4
#clase Banco class Banco(): def __init__(self,numjuego,juego,baraja,monto,dado): self.numjuego = numjuego self.juego = juego self.baraja = baraja self.monto = monto self.dado = dado def iniciarJuego(self): pass def cargaBaraja(self): pass ...
1cc16eb9f4be897a1776c0ec37b382643f79901b
Arturok/TEC
/Intrucción y Taller de Programación/Progras en Clase/Insert_d_Ver1.0.py
382
3.71875
4
def insert_d(ref, ele, lista): if lista != []: return insert_d_aux(ref, ele, lista) else: return "Error" def insert_d_aux(ref, ele, lista): if lista == []: return [] elif lista[0]==ref: return [lista[0]]+[ele]+insert_d_aux(ref, ele, lista[1:]) else: ...
1e62d5acf159b10bd5a18167fe833b181dbe1ab5
Arturok/TEC
/Intrucción y Taller de Programación/II Proyecto/Segundo Proyecto Programado/Clases.py
1,461
3.640625
4
#Clase Nodo class Nodo(object): def __init__(self, elemento): self.__elemento=elemento #Puntero que servira para "unir" a los Nodos cuando se cree la lista self.__pSig = None def getElemento(self): return self.__elemento #Clase Lista Circular Simple class ListaCirc...
08b107a8ae4d388cc924d67c5b6454482028336d
Arturok/TEC
/Intrucción y Taller de Programación/Nueva carpeta/Arturo Chinchilla Sanchez_ QUIZ#2.py
407
3.703125
4
def partir(lista): if lista != []: return partir_aux(lista, [], []) else: return "Error" def partir_aux(lista, sublista, resultado): if lista == []: return resultado elif lista[0] >= 0: return partir_aux(lista[1:], sublista+[lista[0]], [resultado+[sublista]]) ...
c9b4ec541b0b9ab0f390b6792fe553789c2c3302
Rrawla2/cs-guided-project-python-i
/src/demonstration_1.py
1,696
4.375
4
""" Define a function that transforms a given string into a new string where the original string was split into strings of a specified size. For example: If the input string was this: "supercalifragilisticexpialidocious" and the specified size was 3, then the return string would be: "sup erc ali fra gil ist ice xpi...
7f06559eb0394aab1731440f890f1ccb583b89db
fossabot/yt2mp3
/yt2mp3/util.py
8,712
3.703125
4
#!/usr/bin/env python3 """ yt2mp3 A program that simplifies the process of searching, downloading and converting Youtube videos to MP3 files with embedded metadata via the iTunes API. yt2mp3/util.py Brett Stevenson (c) 2018 """ import sys, os, re, youtube_dl, itunespy, urllib, ssl, shutil, cursesmenu, logging, string ...
fd2958044308c991ea843b73987860bb7fc75a3b
Anushree-J-S/Launchpad-Assignments
/problem1.py
412
4.15625
4
#Create a program that asks the user to enter their name and age. #Print out a message addressed to them that tells them the year that they will turn 100 years old print("Code for problem 1") from datetime import datetime name=input("Enter your name:") age=int(input("Enter your age:")) year=int((100-age)...
bbe09110ea33a0858adddf41a59213d66c51ed1f
kmhasan-class/summer2018ip
/bmp-reader/bitmap.py
7,323
3.625
4
import os class Bitmap: def read_file(self, filename): file = open(filename, "rb") try: filesize = os.path.getsize(filename) print("Reading from", filename) print("File size", filesize) self.byte_array = bytearray(file.read(filesize)) self...
aa9a62147d80b1f09bcddbe8166024aaaa93a452
Lobarr/interview-practice
/problems/search2DMatrix.py
1,233
3.9375
4
def search2DMatrix(matrix, target): # uses decrease and conquer to determine potential row def binarySearchRow(_matrix, _target): start = 0 end = len(_matrix) - 1 while start <= end: mid = start + (end - start) // 2 row = _matrix[mid] if row[0] <= _...
6880becc12def9705e9b3919592afb05d6f58215
Lobarr/interview-practice
/ds/dLinkedList.py
4,405
3.546875
4
class DNode: def __init__(self, data): self.data = data self.nextNode = None self.prevNode = None class DLinkedList: def __init__(self): self.count = 0 self.head = None self.tail = None def isEmpty(self): return self.head == None and self.tail == No...
3fc2c027c0d27101895ed2202de5352ffefd3f66
Lobarr/interview-practice
/problems/sortBitArray.py
679
3.609375
4
def sortBitArray(arr): left_pointer, right_pointer = 0, len(arr) - 1 while left_pointer < right_pointer: while arr[left_pointer] == 0: left_pointer += 1 while arr[right_pointer] == 1: right_pointer -= 1 if left_pointer < right_pointer: arr[left_poin...
bc564e1fe962048da171af08073acd47d2b5ec75
Lobarr/interview-practice
/problems/twoSum.py
614
3.6875
4
from collections import Counter def twoSum(nums, target): check = Counter(nums) for num in nums: complement = target - num if complement in check: if complement == num: if check[complement] >= 2: return True return False ...
f22a7431f0db21bcf80ba862ba71eb6c6954ea84
Lobarr/interview-practice
/problems/isUnique.py
437
3.953125
4
def isUniqueMap(string): check = {} for char in string: if char in check: return False check[char] = True return True def isUniqueAscii(string): ASCII_LEN = 128 ascii_map = [False for _ in range(ASCII_LEN)] if len(string) > ASCII_LEN: return False for ...
6a55eeafb4f54487e531f53289662f2a4770d24f
sjs7007/BookRecos
/Old/Final/FinalModule.py
1,594
3.59375
4
#take in isbn number and save xml file for corresponding book import urllib2 from xml.dom import minidom import sys def bookData(ISBN): #ISBN="0441172717" APIKey="G0YLe4KJic94J0Bi0zeBQ" #Enter your own key here url="https://www.goodreads.com/book/isbn?isbn="+ISBN+"&key="+APIKey #PageSource=urllib2.urlopen("https:...
d6a40dcd4e8227b92bb4abbc9da46877a9a938d3
klkael/Ujian_Bank
/Tugas/8.py
1,221
3.9375
4
star = '' for i in range(5): star += '*' print(star) def star(x): star = '' for i in range(x): star += '*' print(star) star(10) def star(x): star = '' for i in range(x): for j in range(x-i): star += '*' star += '\n' print(star) star(10) def rSta...
3941b7f787b9a23e4f64732bfa8215baa7abd7ff
klkael/Ujian_Bank
/PYTHON/0.py
1,416
4.28125
4
print(1+1) nama = "asd" umur = 12 print(nama) print("halo, aku " + nama) print("umurku" + str(umur)) print("umurku", umur) print('saya ' + nama + 'usia ' + str(umur)) print('saya', nama, 'usia', umur) print('saya %s umur %d' %(nama, umur)) print('saya {} usia {}'.format(nama, umur)) print(f'saya {nama} usia {umur}') pr...
3958f708aae56e62d2e72bbecb6403aaeff98794
klkael/Ujian_Bank
/PYTHON/3.py
997
3.578125
4
x = [(1,2,3),(4,5,6)] x[0]='Andi' print(x) x=[(1,['a','b','c'],3),(4,5,6)] x[0][1][2]='Andi' print(x) x[0][1].append('d') print(x) x = [1,2,3,1,2,3] y = (1,2,3,1,2,3) z = {1,2,3,1,2,3} #set/himpunan, tidak bisa indexing(tidak bisa print angkanya satu-satu) print(x) print(y) print(z) #set/himpunan: #1. no indexing #2....
95cbcaa17096fcaedfe3469cb103141e132158fe
bestchanges/hellomoto22
/server/test/limited_list.py
674
3.890625
4
class LimitedList(list): ''' Limit list for no more than LIMIT entries. If number of entries exceed limit, then delete first items until it ok ''' def __init__(self, limit) -> None: self.limit = limit super().__init__() def append(self, object) -> None: super().append(o...
1742762400bf55caae8f17a642670c25bf978c00
wickedkat/codecool-game-reports
/part2/export.py
595
3.53125
4
import csv import reports filename = 'game_stat.txt' year = input("What year do you want me to look for? ") title = input("What title are we looking for? ") myData = [[reports.get_most_played(filename)], [reports.sum_sold(filename)],[reports.get_selling_avg(filename)],[reports.count_longest_title(filename)],[reports...
32b88874675b792ef87fe57af9b7ffd6de4ff0db
theanilbajar/Machine-Learning-Algorithms-with-scikit-learn
/digit_identification.py
910
3.90625
4
# Digits Identification from digits dataset from scikit-learn datasets # import datasets and required matplotlib library to plot images of digits stored in digits dataset. from sklearn import datasets import matplotlib.pyplot as plt # Get digits dataset from scikit-learn datasets digits = datasets.load_digits() # Mak...
c21cc93f647b97cd9682b531cbe95ec77393290b
VESOC/Project-Euler
/Multi3N5.py
709
3.859375
4
#1번 3과 5의 배수 #1000 미만의 3과 5의 배수의 합을 구하는 문제 #Find the sum of the multiples of 3 and 5 below 1000 (<1000) def Multi3N5(): sum3N5 = 0 for i in range(1,1000): #Starts at 1, ends at 999 if i % 3 == 0 or i % 5 == 0: #Check if i is a multiple of 3 or 5 sum3N5 += i #If above statement is True, adds i to sum print(sum...
5eeb25bf53ae5078589644cf03a7830a03803979
EduardoPNK/Atividades_funcoes
/3.py
419
4.1875
4
#Faça um programa, com uma função que necessite de três argumentos, e que forneça a soma desses três argumentos. def soma(n1, n2, n3): resultado = n1 + n2 + n3 return resultado numero1 = int(input('Informe um numero para soma: ')) numero2 = int(input('Informe um numero para soma: ')) numero3 = int(inp...
a4f8fb8e774adaf331b2568ba5c81e1a3d6aa206
Peace-Song/College_materials
/2019-2/SWPP/Labs/Lab10/Observer.py
892
3.53125
4
class Product: def __init__(self, name='', price=0): self.name = name self._price = price self._observers = [] def attach(self, observer): if observer not in self._observers: self._observers.append(observer) def notify(self, modifier=None): for obse...
89489a8e0d49d71c9b9bc19e92dbd1c81e0e7d03
Peace-Song/College_materials
/2019-2/SWPP/Labs/Lab10/Composite.py
639
3.828125
4
class Function: def __call__(self, value): raise NotImplementedError class CompositeFunction(Function): def __init__(self, *functions): self.h = functions[0] self.g = functions[1] self.f = functions[2] def __call__(self, value): return h(g(f(value))) class F(Fu...
31765a44843aa4906d406abe8053816854057b3e
Peace-Song/College_materials
/2019-2/SWPP/Labs/Lab10/Singleton.py
659
3.6875
4
class Singleton: class _Singleton: def __init__(self, value): self.value = value _instance = None @staticmethod def get_instance(): if Singleton._instance is None: Singleton() return Singleton._instance def __getattr__(self, name): return get...
9be894efed0d1951199b7f31af847879a5519deb
ahmadsufian616/Python-STACK
/python_stack/python (the underscore IS IMPORTANT)/python_fundamentals/For Loop Basic II.py
1,833
3.9375
4
#1 Biggie Size def Biggie_Size(list1): for i in range (0,len(list1),1): if list1[i]>0: list1[i]="big" return list1 print(Biggie_Size([-1,-2,3,4,5,-4])) #2 Count Positives def Count_Positives(list1): count=0 for i in range(0,len(list1),1): if list1[i]>0: count+=1...
498958a1dfd0cac797a33d8179ea9f1e343c2a44
ahmadsufian616/Python-STACK
/python_stack/python (the underscore IS IMPORTANT)/OOP/Intro to TDD.py
1,597
3.609375
4
import unittest # def reverseList (list1): # for i in range(int( len(list1)/2)): # list1[i],list1[len(list1)-i-1]=list1[len(list1)-i-1],list1[i] # return list1 # class IsREVERSETests(unittest.TestCase): # def testTwo(self): # self.assertEqual(reverseList ([1,3,5]), [5,3,1]) ...
fc545385f36a169e17a30ea8589a96fdceea7685
ahmadsufian616/Python-STACK
/python_stack/python (the underscore IS IMPORTANT)/python_fundamentals/For Loops Basic I.py
604
3.8125
4
for i in range (151): #Basic - Print all integers from 0 to 150. print(i) for a in range(5,1001,5):#Multiples of Five - Print all the multiples of 5 from 5 to 1,000 print(a) for b in range(1,101,1):#Counting, the Dojo Way if b % 5 == 0: print("Coding") else: print("Coding Dojo") sum ...
decb8c6ff7d913834dddd19e73580c1f2fd34a61
Piyush-Ghotkar/Hackerrank_Practice
/Dynamic Array.py
1,403
3.625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'dynamicArray' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER n # 2. 2D_INTEGER_ARRAY queries # def dynamicArray(n, que): ...
c2650deda0c6b2f0bb92be60955a393f65410901
gujingit/LeeCode
/11.py
671
3.515625
4
#coding=utf-8 class Solution(object): # @return int def maxArea(self, height): size = len(height) maxArea = 0 i = 0; j= size-1 while i<j: #O(n) area = min(height[i],height[j])*(j-i) if area>maxArea: maxArea = area # 如果area2比area1大,则a2的min(heig...
d017fa6ecc1805dbe9000f3df7f9c659e81a2cdb
gujingit/LeeCode
/2.py
902
3.734375
4
#coding=utf-8 class ListNode(object): def __init__(self,x): self.val = x self.next = None def printResult(self): while self: print self.val,' ', self = self.next print ' ' class Solution(object): # @return a ListNode def addTowNumbers(self,l1,l...
b995579634af72d9a893f5e7c2645832397a9e93
Laura32855/logicaprogramacao
/atividade10.py
565
3.59375
4
#inicio def atividade1(): for c in range (0, 100): if c % 5 == 0: print(c, end=" ") #fim #inicio def atividade2(): n = int(input('Digite o tamanho da lista: ')) lista = [0] * n print(lista) #fim #inicio def atividade3(): lista = [1, 10, 6, 8, 2] cont = 0 for c in lista: if c > 5: cont +...
109c26b18b0868baf20947bdbc23142a266ce908
ayushimrigen/ANT
/cubic.py
2,167
3.84375
4
import matplotlib.pyplot as plt import numpy as np def thomas_algorithm(a, b, c, d): """ Solves the Tridiagonal Linear System -- -- -- -- -- -- |b_1 c_1 | |f_1| |d_1| |a_2 b_2 c_2 | | . | | . | | a_3 . . . | | . | = | . | | ...
8463165a2db6d6e5a64b0c183bd2176dd4f303f2
kishan3/leetcode_solutions
/23.py
1,530
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 22 14:40:09 2018 @author: kishan """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def mergeTwoLists(self, l1, l2): """ :type l1:...
e7ee98a46211ca75309d7f648a0589b5b5101715
kishan3/leetcode_solutions
/561.py
1,724
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 22 09:33:07 2018 @author: kishan """ def checkInclusion(s1, s2): if len(s1) > len(s2): return False s1map = [0] * 26 for i in s1: s1map[ord(i) - ord('a')] += 1 print('S1MAP: ', s1map) i = 0 while i <= len(s2...
a53aa7ce081d05e3af927b0ffe960a9a22498cf3
kishan3/leetcode_solutions
/167.py
2,044
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Dec 23 11:22:01 2018 @author: kishan """ class Solution(object): def bsearch(self, nums, key, start): left = start right = len(nums) - 1 while left < right: mid = (left + right) // 2 if nums[mid] < k...
644d999a3834c116b55e3bcb8aeed4b7aba0499c
estherGomezCantarero/practica
/sample/tdd.py
4,796
3.859375
4
import unittest from sample.strings_example import StringsExamples class TestStringsExamples(unittest.TestCase): def test_concat_strings(self): string1 = "hola" string2 = "adios" result = StringsExamples.concat_strings(string1, string2) assert result=="holaadios" de...
b2efabf379ff90a39ac32e8a60ced7c869572338
vinodh1988/python-code-essentials
/day_four/generators.py
629
3.65625
4
import random """ for x in range(1,10): print(round(random.random()*100)) """ def dataEmitter(): while True: temp=round(random.random()*100) if temp==99: break yield temp print('back in function') result=dataEmitter() """ for x in result: print(x) """ """ whi...
2c07ea5764d7173d72c7b85a1d0622a6a7c8e145
vinodh1988/python-code-essentials
/conditional.py
436
4.15625
4
name=input('enter you name >> ') print(len(name)) if(len(name)>=5): print('Valid name it has more than 4 characters') print('We shall store it in the database') elif(len(name)==3 or len(name)==4): print('type confirm to store it into the database >>') if 'confirm'==input(): print('stored in ...
bbee1125bd3dbbdd08bea43fbf1f8b214aaaa8c2
vinodh1988/python-code-essentials
/day_three/oops/system.py
859
3.796875
4
class Shape: def __init__(self,name=None): print('super class constructor called') self.name=name def _display(self): print('Shape is {}'.format(self.name)) class Box: def __init__(self,type=None): self.type=type def _display(self): print('Box is {}'.for...
932f9ebb71a5dc6eb621c48d8f5ad8f8ce446df3
vinodh1988/python-code-essentials
/whileloop.py
497
3.96875
4
for x in range(2,100): if(x%2==0 and x%3==0 and x%9==0): print(x,end=":::") x=1 while x<10: print(x) x+=1 print("--------------------------------------") for x in range(0,20,3): if(x!=0 and x%5==0): break if(x==6): continue print(x) print("---------------------------...
76063f6f6c03d1fbdd0126ec516116926e8cc44e
jayeshrathi6055/Python-modules
/pyautogui_module.py
4,259
3.625
4
from tkinter.constants import X import pyautogui as pg import datetime # General Function-------------------------------------------------> # # Want to know the size of your screen # print(pg.size()) # # Want to know the position of your mouse cursor # print(pg.position()) # # Want to check that x and y...
9fbbc0f624b4d73e88b72a51ed23d50c52d8331d
jaekeon02/Studying-Progress
/python/gui/Calculatortest.py
1,986
4.1875
4
# 계산기를 만들어 보겠습니다. # Entry 2개 -> 숫자 2개를 각각 입력받습니다. # 버튼 5개 #| +, -, *, /, %| # Entry 두개에 값을 채워 넣고 #| +, -, *, /, %|버튼을 누르면 두 엔트리에 들어있던 값을 토대로 # 결과값을 출력해줍니다 # Label 1개 => 결과값을 콘솔창이 아닌 Label에 출력해보세요 from tkinter import * calculator = Tk() calculator.configure(width="75m",height="100m") ##########함수배치부분########### def ADD(...
4391e0e44bfc132f1c720473cce60c1c25caebec
sinomiko/reading
/source/Python/begining python from noviceto professional/2329/Chapter06/search.py
400
3.90625
4
def search(sequence, number, lower, upper=None): if upper is None: upper = len(sequence)-1 if lower == upper: assert number == sequence[upper] return upper else: middle = (lower + upper) // 2 if number > sequence[middle]: return search(sequence, number, middle+1, ...