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
770c7743de09cf81a7967ca61caa4a0d3feba12a
manojitballav/charts_python
/apollo/luminosity.py
375
3.578125
4
from PIL import Image import colorsys svep = 0 # Traversing through all the pixels for x in range(0,a): for y in range(0,b): # Getting the RGB values of each pixels R,G,B = img.getpixel((x,y)) # Getting the brightness of each pixel avep = (R + G + B)/3 svep += avep # Getting the average brightness print "Th...
08716f2a67ce5e050276fac71ec24103d79825f6
vero11602/guessnum
/guessnum.py
453
3.75
4
import random count = 0 low = input ('請決定數值最小範圍:') low = int (low) high = input ('請決定數值最大範圍:') high = int (high) r = random.randint (low , high) while True : count+=1 #count = count + 1 num = input ('請輸入數字:') num = int (num) if num == r : print ('終於猜對了') print ('總共猜了' ,count , '次') break elif num < r : pr...
bcfbb2aeb996835a5d1d567c331b5a926b2c4fd9
AllanRPereira/Simple-Color-Terminal
/cursor.py
2,803
4.15625
4
""" Função: Definir funções para realização de operações com o cursor, usando o terminal Autor: Állan Rocha """ import sys ANSI = "\033[" def cursor_move(direction="UP", lines=1): """ Move o cursor de acordo com a direção e quantidade de linhas/colunas desejadas """ directions = {"UP":"A", "DOWN":...
63738ee1388108a73fe99abc4956c3b89e73827c
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 2/ex045 - Pedra, Papel e Tesoura.py
2,597
4.0625
4
""" Crie um programa que faça o computador Jokenpô com você. """ from random import choice from time import sleep print("-=-" * 15) print("VAMOS JOGAR JOKENPÔ?!") print("-=-" * 15) sleep(1) print("No final do Jokenpô você digita se vai jogar Pedra, Papel ou Tesoura.") sleep(2.5) print("Jo", end="") sleep(0.5) print("...
3223ced97083d48d879451264165dc100c62d7d2
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 2/ex071 - Simulador de Caixa Eletrônico.py
1,137
4.21875
4
''' Crie um programa que simule o funcionamento de um caixa eletrônico. No início, pergunte ao usuário qual será o valor a ser sacado (número inteiro) e o programa vai informar quantas cédulas de cada valor serão entregues. OBS. Considere que o caixa possuí cédulas de R$50, R$20, R$10 e R$1. ''' print('=' * 30) pri...
cde7d764af164f70efe5d973930a62c343678d72
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 1/ex032.py
575
4.09375
4
# Faça um programa que leia um ano qualquer e mostre se ele é BISSEXTO. from datetime import date from time import sleep print("-=-" * 15) print("Lhe direi se o ano é Bissexto ou não.") print("-=-" * 15) sleep(1) print("Se deseja saber se o ano atual é bissexto, digite 0") ano = int(input("Digite o ano que você desej...
f56bed31802fc4ed597a609204b2e35aef85e426
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 2/ex051 - Progressão Aritmética.py
656
3.984375
4
""" Desenvolva um programa que leia o primeiro termo e a razão de uma PA. No final, mostre os 10 primeiros termos dessa progressão. """ print("-=-" * 13) print(" 10 PRIMEIROS TERMOS DE UMA PA") print("-=-" * 13) primeiro = int(input("Digite o primeiro termo: ")) razao = int(input("Digite a razão: ")) n = primeiro...
599934e1928f735bab8f421cc0cf2cfda1f4ddf2
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 1/ex013.py
348
3.765625
4
# Faça um algoritmo que leia o salário de um funcionário e mostre seu novo salário, com 15% de aumento. salario = float(input("Qual o valor do salário do funcionário? R$")) aumento = salario * 0.15 salario_aumento = salario + aumento print("O novo salário desse funcionário, com 15% de aumento, será: R${:.2f} ".format...
d0773128c4e95c086f4c21eb0e93bda36083cbac
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 2/ex036 - Aprovando Empréstimo.py
1,447
4.1875
4
""" Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. O programa vai perguntar o valor da casa, o salário do comprador e em quantos anos ele vai pagar. Calcule o valor da prestação mensal, sabendo que ela não pode exceder 30% do salário ou então o empréstimo será negado. """ from time...
c0c7f5440c3b9ca7a783ae2b21c479ae022d9b2b
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 1/ex028.py
695
4.1875
4
# Escreva um programa que faça o computador "pensar" em um número inteiro entre 0 e 5 e peça para o usuário tentar desco #brir qual foi o número escolhido pelo computador. # O programa deverá escrever na tela se o usuário venceu ou perdeu. from time import sleep from random import randrange random = randrange(6) prin...
eff03e7cc17166c357cce773fcbd775d3eec297d
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 1/ex019.py
513
3.984375
4
# Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, # lendo o nome deles e escrevendo o nome de escolhido. from random import choice aluno1 = input("Digite o nome do primeiro aluno: ") aluno2 = input("Digite o nome do segundo aluno: ") aluno3 = input("Digite o no...
7c0b5be8f0ce378dbb771c4b21aaaa71025cea6b
Hugocorreaa/Python
/Curso em Vídeo/Desafios/Mundo 1/ex018.py
454
4
4
# Faça um programa que leia um ângulo qualquer e mostre na tela o valor do seno, cosseno e tangente desse ângulo. from math import sin, cos, tan, radians angulo = float(input("Digite o valor do ângulo para saber seu seno, cosseno e tangente: ")) seno = sin(radians(angulo)) cosseno = cos(radians(angulo)) tangente = tan...
8c0e2f4562c5a2b460706c070a486202963cd1ca
akifkartal03/CSE321-Introduction-to-Algorithm-Design
/Take Home Midterm/source/171044098_Q3.py
1,269
3.859375
4
# 171044098 # Akif Kartal # Q3 Real Code import random def main(): arr = [random.randint(1, 1000) for _ in range(100)] #create random array with size 100 print("-----------------------------------------------------------------------") print("Array before sorting: ", arr) quicksort_improved(arr, 0, len...
bcae633046863f15c31ebafa81dc2e2fe2aba0bc
prbsh9/News-Scraper
/nepnews_soup_json.py
2,691
3.5625
4
from bs4 import BeautifulSoup import requests import csv def onlineKhabarNews(x=15): '''Gives fresh onlineKhabarNews from internet while parameter x is in which you get to chose how many small headlines you want. It will get you a main main headline with summery, link to news and other headlines with link...
d19c2337d4c51da317336258e21448bc245b8d42
swglamsk/SI-GeneticAlg
/City.py
580
3.578125
4
import geopy.distance as gp import math class City: x: float y: float def __init__(self, name, x, y, weight_type): self.name = name self.x = x self.y = y self.weightType = weight_type def __str__(self): return "Name:{0}\tx:{1}\ty:{2}".format(self.name, self.x,...
1e8f15e12488f15ded6ccc35152401b85173cda5
seven320/AtCoder
/94/C.py
306
3.640625
4
# encoding:utf-8 import copy import numpy as np import random n = int(input()) x = [int(i) for i in input().split()] x_sorted = sorted(x) middle = n//2 middle_num = x_sorted[middle] for i in range(n): if x[i] < middle_num: print(x_sorted[middle]) else: print(x_sorted[middle-1])
e679cb54e7ac7e7f9f6d0e4e9d2962dee1e1c8b0
seven320/AtCoder
/79/C.py
780
3.5625
4
# encoding:utf-8 import copy import numpy as np import random nums = list(input()) nums = [int(i) for i in nums] def make2digits(n): digits = [] for i in range(3): if n % 2 == 1: digits.append(1) else: digits.append(0) n = n//2 return digits for i in range(...
5aac77559a8528a4bb8caac04de288eb88b2820e
seven320/AtCoder
/module/heapq.py
344
3.53125
4
import heapq """ 優先度付きキュー 大小関係を保ちつつ,キューを使える. 最小値をO(logN)で取り出す 要素をO(logN)で挿入できる 通常O(N) """ a = [] for i in reversed(range(10)): heapq.heappush(a, i) # 挿入, for i in range(len(a)): print(heapq.heappop(a)) # 最小の値から取り出す
73731704ecf461b46705cc593ee1a593a57bd92a
seven320/AtCoder
/67/A.py
310
3.59375
4
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math A,B = map(int,input().split()) if A%3==0 or B%3==0 or (A+B)%3==0: print("Possible") else: print("Impossible")
db407fb805ae231ad020f47febaef1c1dcdc9e60
manas1015/Python_Selenium_practice
/Practice_1/Class_Demo/Class_Mob.py
771
3.671875
4
class Mobile: Brand = "" Model = "" Size = 0.0 Color = "" def run(self): print (self.Brand + " Is a good Phone") Mob = Mobile() Mob.Brand = "Samsung" Mob.Model = "M30" Mob.Size = "6.2" Mob.Color = "White" Mob.run() print(Mob.Brand,Mob.Model,Mob.Size, Mob.Color) # class Mobile: # Bran...
ed601a349b3998212b48262b55989bc3cdd0a08a
manas1015/Python_Selenium_practice
/office_practice/assignmnet 3.py
2,622
4.09375
4
#####Create a function to separate numbers from given integers # txt='12345 manas 12 54 dash' # for x in txt.split(): # if x.isdigit(): # print(x) # print(y) #####Create a func to determine the percentage of lower case and upper case letters in a given string # def count_by_case(string): # upper = sum...
1bb6513431258d1908c9f87b5a84d1c21a0b0d7e
manas1015/Python_Selenium_practice
/Practice_1/p1.py
958
3.546875
4
# x=10 # y=5+3j # z=x+y # print(z) # x = y = z = "Orange" # print(x) # print(y) # print(z) # x = 1 # y = 35656222554887711 # z = -3255522 # print(type(x)) # print("hello") # # a='hello' # print(a) # a=" HEllo,world" # print(a) # print(a[2:5]) # print(a.strip()) # print(len(a)) # print(a.lower()) # print(a.upper()) ...
a9d5e5f2ef58faf8e335e3d2f5f5c0ea036f033d
FaizIkhwan/30DaysOfCode
/30DaysOfCode/Day 2 Operators/Solution.py
343
3.9375
4
#!/bin/python3 import sys if __name__ == "__main__": meal_cost = float(input().strip()) tip_percent = int(input().strip()) tax_percent = int(input().strip()) tip = meal_cost*tip_percent/100.00 tax = meal_cost*tax_percent/100.00 total = meal_cost+tip+tax + 0.5 print('The total meal cost is'...
5c133a38fdca5f32432dbe164820ed62e249615c
cosmos-sajal/python_design_patterns
/creational/factory_pattern.py
1,035
4.21875
4
# https://dzone.com/articles/strategy-vs-factory-design-pattern-in-java # https://stackoverflow.com/questions/616796/what-is-the-difference-between-factory-and-strategy-patterns # https://stackoverflow.com/questions/2386125/real-world-examples-of-factory-method-pattern from abc import ABCMeta, abstractmethod class D...
a5d87e6f514d6d86d791d0c2a2744deda93dbf06
bezhang-su/projectGroup15
/RateMyProfessor.py
1,395
3.703125
4
import requests import json import math schoolNumber = input("Please input your school ID: ") page = requests.get( "https://www.ratemyprofessors.com/filter/professor/?&page=1&filter=teacherlastname_sort_s+asc&query=*%3A*&queryoption=TEACHER&queryBy=schoolId&sid=" + str( schoolNum...
6ff2fa70612b744a1287f0069fee2103c9d50065
SoySoy4444/Pirate-Game-Server
/Constants.py
6,696
3.625
4
import pygame, sys WHITE = (255, 255, 255) BLACK = (0, 0, 0) BLUE = (0, 0, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) SEA = (59, 111, 226) colours = {"white":WHITE, "black":BLACK, "blue":BLUE, "red":RED, "green":GREEN, "sea": SEA} class Button(): #width and height will only be passed in for buttons with no text ...
b0bc6547398d5e199a3d871cebb6671eb7c3e597
saumitraaditya/RandomCode
/heap.py
1,973
4.0625
4
#!/usr/bin/env python class Heap: def __init__(self): self.list = [] self.list.append(None) self.size = 0 def swap(self,index1,index2): temp = self.list[index1] self.list[index1] = self.list[index2] self.list[index2] = temp def check(self,index): if ...
def37d307f212c850b767899511727cef0b08ffb
mnaufal121/Dictionary
/try.py
1,084
3.53125
4
Dict = [{'barang': 'komputer', 'jumlah': 50, 'harga': 1200}, {'barang': 'mouse', 'jumlah': 20, 'harga': 3400}, {'barang': 'keyboard', 'jumlah': 30, 'harga': 2400}] # for x in range(len(Dict)): # for k, v in Dict[x].items(): # # print(Dict[x][k]) # if Dict[x][k] == '': # ...
a2e21d7f85ba4b2b6c2f78d3aeb740a2829df752
erpambudi/Pemrograman-GUI
/Pertemuan2_GUI/user_input.py
168
3.578125
4
masukan= input("masukan nama anda : ") bilangan= input("masukan angka : ") pecahan = float(input("masukan angka : ")) print(bilangan) print(masukan) print(pecahan)
3f512c705a02897b44f7293d3bc7242b5eb6f417
joshfalter/titanic
/titanic.py
4,881
3.78125
4
# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd ''' Let's import the dataset and take a look. We have the following variables: Passenger Class, Sex, Age, Fare, and whether or not they survived. Let's make our indepedent, X, and dependent, y, vectors. With...
1921b6af6c4f2d31e9d9913f595830d49357e7b5
Bennett1234/Leetcode
/Maximum Subarray.py
448
3.953125
4
def maxSubArray(nums): maximum = running_sum = nums[0] if len(nums) == 1: return(nums[0]) for n in nums[1:]: running_sum = max(running_sum+n,n) maximum = max(running_sum, maximum) return maximum #Maintain a running_total of the array seen so far. #If the current value is greater ...
cc75d51f51081d8f1594e0a3566ad5e4ae14ba2e
aestrell/Gallons-of-Gas
/Estrella_Han_Gasoline_2.py
1,174
4
4
""" File: jayawant_gasoline.py Author: Pallavi Jayawant Description: Prints the pounds of carbon dioxide produced by a given number of gallons of gasoline Prints the amount of crude oil required to produce given number of gallons of gasoline Prints the price of gallons of gasoline """ #ask user to input num...
bd1c09464e71deef999b669fccc3cd52b46ec8f1
danielacevedo20/introprogramacion
/Clases/clase2.py
826
4.03125
4
#Ingresamos variables edad = 18 estatura = 1.8 peso = 75 NOMBRE = "Jose Daniel Acevedo Restrepo" #Aprendimos a usar funciones de lógica buleana "bool" isMayorEdad = edad >= 18 #Comparamos el valor de las variables print ("#"*15,"¿Es mayor de edad?", "#"*15) #Mostramos en pantalla true o false con la función print como ...
27b71f7813aa29c92c607bb98d4e25d3dd35851c
danielacevedo20/introprogramacion
/ExamenClasesHerencia/Quiz3.py
3,576
3.59375
4
# Jose Daniel Acevedo Restrepo # Verónica Obando Builes class ElementosDigitales (): def __init__ (self, nombreEntrada, creadorEntrada, fechaEntrada): self.nombre = nombreEntrada self.creador = creadorEntrada self.fecha = fechaEntrada def mostrarAtributos (self): print (f'...
dd5600b48a73fcc8118a305826d704766463260d
danielacevedo20/introprogramacion
/Clases/Excepciones/ejemplo.py
1,029
4.15625
4
isCorrectInfo = False while(isCorrectInfo == False): try: edad = int (input("Ingrese su edad: ")) isCorrectInfo = True except ValueError: print("Ingresaste un dato erroneo") nombreArchivo = input("Ingrese el nombre del archivo que desdea encontrar: ") try: archivo = open (nombreArc...
48c5d9c85ea33712f4298c1c998c6fa65d79ca30
danielacevedo20/introprogramacion
/Clases/inputsclase3.py
397
3.734375
4
#-----Constantes-----# PREGUNTA_NOMBRE = "¿Cómo te llamas? : " PREGUNTE_EDAD = "¿Cuántos años tienes?: " MENSAJE_SALUDO = "Un gusto conocerte" PREGUNTA_ESTATURA = "¿Cuál es tu estatura?: " Altura = "Eres muy alto" #Entradas del código nombre = input (PREGUNTA_NOMBRE) print (MENSAJE_SALUDO,nombre) edad = int(input(PRE...
b8c2e0e1e4a275334647740c96e94202d44a3dd9
thunguy/hackbright-lab-dicts-word-count
/wordcount.py
1,343
3.75
4
import sys from collections import Counter def word_count(fnames): files = [open(fname) for fname in fnames] all_words = [] for file in files: for line in file: line = line.rstrip() words = line.split(" ") words = [word.strip("'\",.!/?-#$%^&();:_").lower(...
8419672c85e4e61d21a5bfa3dbd4f361e5e11255
stavsta/tpzgraphml
/graph.py
6,748
3.703125
4
# -*- coding: utf-8 -*- from __future__ import unicode_literals from __future__ import division from __future__ import absolute_import from __future__ import print_function from . import Node from . import Edge from collections import deque class Graph: """ Main class which represent a Graph :param nam...
cc2162df92415beb59fe0bc70d403e0d972e377d
hoanglechanhtu/BTLGame_3
/Camera.py
3,028
3.515625
4
import pygame from Setup import * from params import * class Camera: def __init__(self, x, y): self.x = x self.y = SCREEN_HEIGHT - y self.startx = x self.starty = y self.deltax= 0 self.deltay= LVL_HEIGHT - SCREEN_HEIGHT self.leftBorder = 50 self.righ...
92d46625f1bb1bfe6e6a2a359af18f50770d540b
potnik/sea_code_club
/code/python/rock-paper-scissors/rock-paper-scissors-commented.py
2,585
4.5
4
#!/bin/python3 # The previous line looks like a comment, but is known as a shebang # it must be the first line of the file. It tells the computer that # this is a python script and to use python3 found in the /bin folder from random import randint # From the python module called random, import the function randint #...
186c8313a1a792c27ead9388504bb2d2681a46f3
amozalev/parentheses-count
/discount.py
1,965
3.765625
4
class Discount(object): def __init__(self, name, time_start, time_end, **kwargs): self.time_start = time_start self.time_end = time_end self.name = name self.discounts = kwargs self.discount_single_product = 0 self.discount_brand = 0 self.discount_group = 0 ...
d32fb8b9f88697a06d9a1f58186a5b3cb87f62a0
ismailuddin/bioinformatics
/Codon repeat visualisation/codon_repeats.py
4,285
3.53125
4
# Successive Codon rpteat Visualisation Tool # A novel tool to allow the graphical visualisation of # successive codon rpteats with a DNA sequence # (C) 2014, Ismail Uddin, ismail.sameeuddin@gmail.com # www.scienceexposure.com import sys def parse_FASTA(filename): """Parse all entries in FASTA file into a diction...
9df01f7d6fd777a5957df03bfb7891a7b3bc9bc8
ES2Spring2019-ComputinginEngineering/project-one-lily-keiderling
/Project Accelerometer.py
1,130
3.65625
4
#Pendulum Acceleromter #Names: Tookie Wilson and Lily Keiderling #Collecting Real World Data on Microbit from microbit import * import random display.show(Image.BUTTERFLY) #display Butterfly when program is ready to begin a= str(random.randint(1,999)) filename= "pendulum_data_" + a + ".txt" #assorted number in name l...
af908716f27a9ff46e623c883300cdcd7464d994
pranaychandekar/dsa
/src/basic_maths/prime_or_no_prime.py
1,199
4.3125
4
import time class PrimeOrNot: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=7VPA-HjjUmU :Authors: pranaychandekar """ @staticmethod def is_prime(number: int): """ This method tells whethe...
db56d84911eac1cae9be782fd2ebb047c625fce2
pranaychandekar/dsa
/src/sorting/bubble_sort.py
1,488
4.46875
4
import time class BubbleSort: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=Jdtq5uKz-w4 :Authors: pranaychandekar """ @staticmethod def bubble_sort(unsorted_list: list): """ This method s...
7e2f82c44c8df1de42f1026dcc52ecef804d9506
pranaychandekar/dsa
/src/basic_maths/prime_factors.py
1,324
4.25
4
import time class PrimeFactors: """ This class is a python implementation of the problem discussed in this video by mycodeschool - https://www.youtube.com/watch?v=6PDtgHhpCHo :Authors: pranaychandekar """ @staticmethod def get_all_prime_factors(number: int): """ This meth...
2b7a70c760a5b804bc1a2bc7ae1e3605bc15fdb7
CantaTronic/EulerPro
/01-09/prob05.py
808
3.828125
4
''' Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? link: https://projecteuler.net/problem=5 ''' from __future__ import print_function impor...
ca8d3b021147036302555491bebaf3006821881a
fichtitious/pygameTest
/pygameTest.py
2,022
3.828125
4
#! /usr/bin/python #Use this area for testing small pieces of code #raw_input ('Press Enter key to exit.') #exit () import sys, pygame #Remember: sudo apt-get install python-pygame pygame.init() #Create a window. size = width, height = 600, 400 manWidth = 95 manHeight = 161 screen = pygame.display.set_mode(size) c...
0fe66932c1ef42ebd7444c6d197e10f6a8c4b244
8103713/autotesting
/pystudying/day-01/test013.py
769
3.859375
4
#coding:utf-8 """break和continue""" i = 0 j = 0 s = 0 n = 0 while(i<100): s += i i += 1 if(i > 10): print("用break退出时,变量i的值为: %d" % i) break print("测试i的值为:%d" % i) print("当i大于10时,s的值为:%d" % s) #使用continue要注意计数器的位置 while(j<10): j += 1 if (j == 5): print("5这个数跳过,如果成功最后和应该为50...
16d13a12c68a3f273c4c559695c24dcf3d4349c2
Olya14/cs50
/python/dragon.py
946
3.984375
4
import random import time def displayIntro(): print(' Hello dear Player! You have to choose a cave. The first one is filled with gold. But in other one, a very hungry dragon will eat you. ') print() def chooseCave(): cave = '' while cave != '1' and cave != '2': print(' In wich cave you want to...
4b4cfa4ddd3fe140e4ae374a8ba79b7a98151130
anastasia1002/practise1
/lab51.py
202
4.0625
4
# cosx+cos^2x+...cos^nx import math n = int(input("натуральне число:")) x = float(input("дійсне число:")) sum = 0 for i in range(1,n+1): sum+=math.cos(x) ** i print(sum)
a241a2db9e5561e428bfe0aa090059da338da4b9
anastasia1002/practise1
/21.py
252
4.125
4
#cosx+cos^2x+...cos^nx import math n = int(input("натуральне число")) x = float(input("дійсне число")) sum = 0 i = math.cos(x) while i <= math.cos(x) ** n: sum = i + math.cos(x) else: sum = math.cos(x) ** n print(sum)
f6e7af2a50b60bd1cd07e7a696386d41cc2ed5c8
yshzz/starnavi-treasure-hunt
/treasure_hunt/oop_implementation/treasure_hunt.py
1,339
3.765625
4
class TreasureHunt: """Treasure Hunt class. Args: treasure_map (:obj:`list` of :obj:`int`): Map to explore for a treasure. start_row_col (:obj:`tuple` of :obj:`int`): Starting point in the search. """ def __init__(self, treasure_map, start_row_col=(1, 1)): self.treasure_map = t...
1c8d15a45f684e33d070b14116b072685252eda1
reidevries/codecoach
/test/51.py
595
3.625
4
class Rect(object): "A simple rect object for building rooms, constructing trigger areas, etc." def __init__(self, x, y, width, height): self.x1 = x self.y1 = y self.x2 = x + width self.y2 = y + height self.width = width self.height = height def center(self): ...
56c83c940d343023ed7d7bcfe5137e3b655a14ec
reidevries/codecoach
/test/42.py
591
3.5
4
#! /usr/bin/env python2.6 import re import sys import os argv = len(sys.argv) if argv != 2: print "usage: ipfun.py <filename>" sys.exit(1) argo = sys.argv[1] if (os.access(argo, os.R_OK) == 0): print argo, "is not readable" sys.exit(2) InFile = open(argo, "r") for line in InFile: funct = re.match(functionl...
f431e54882495142407c5ac2dc68059ddd8496f0
reidevries/codecoach
/test/39.py
673
4.0625
4
#! /usr/bin/env python2.6 import sys import os def find_median(list1, list2): list1.extend(list2) length = len(list1) medianPOS = length/2 median = list1[medianPOS] #final = tuple(total) final = (median, list1) return final if __name__ == "__main__": print "Enter the first list of numbers: ", data1 = sys....
8b179f485f67359f8de7f5b35d56ad173cb7fddc
rgenius-ru/Learn-only-python
/lesson56_sets_part2/complite_tasks/Stolpovsky.A_lesson56_sets_part2.py
4,822
3.921875
4
# Урок 56 - Наборы (Множества). Часть 2 # Lesson 56 - Sets. Part 2 # Основные операции над множествами (наборами) # A | В # A.union(В) # Объединение. Возвращает множество, являющееся объединением множеств A и B c = {'красный', 'грузовик', 'двухместный', 'новый'} d = {'красный', 'минивэн', 'трёхместный'} ...
f13763b87e0d25ed9e0eb1a27765eefcfccfbd72
mariuszfjg/SeleniumTraining
/advanced/ScrollingWindow.py
1,237
3.640625
4
from selenium import webdriver import time class ScrollingWindow: def __init__(self): self.url = 'https://letskodeit.teachable.com/p/practice' def test(self): driver = webdriver.Chrome() driver.maximize_window() driver.get(self.url) driver.implicitly_wait(3) ...
785cb421940562344c12f8972440936df6c5472b
SpiritusSancti5/AI-gaming
/DemoClient-Python/bots/reversing_stones_bot.py
1,106
3.875
4
from random import choice import json # These are the only additional libraries available to you. Uncomment them # to use them in your solution. # # import numpy # Base N-dimensional array package # import pandas # Data structures & analysis # ==========================================================...
600df3aaf0a0ee3b4ba711da2e67b19aee75396c
zhuypy/AutoTest_zhuy
/framework/tool/fileUtils.py
1,074
3.65625
4
import os def findFileinDir(file_name,dir): ''' 遍历文件夹及其子文件夹检索文件,检索成功返回文件完整路径,检索失败返回None :param file_name: :param dir: :return: ''' if not os.path.isfile(os.path.join(dir,file_name)): for subFile in os.listdir(dir): if os.path.isdir(os.path.join(dir,subFile)) and findFile...
218f53e94acc47d715a3773b2ac4289f01637bd8
hvncodes/Python_July_21
/W1/D3/02_Lets_Make_A_SuperHero/02_SuperHero.py
3,258
3.8125
4
class SuperHero: has_cape = False # NO CAPES league_of_heroes = [] def __init__(self, name: str, alter_ego: str, super_powers: dict, weaknesses: list, planet_of_origin: str ="Earth", can_fly: bool =False, stamina: int =100): self.name = name self.alter_ego = alter_ego self.super_po...
2de18a457b3d52ed43da1d24c439a3a84253e230
karthikwebdev/oops-infytq-prep
/assess1/sq.py
157
3.578125
4
for i in range(1,6): for j in range(1,6): if(i%j): pass elif(j<i): continue else: print(i*j)
1d4285682063430b56947e0ac4149afaec31ffc1
karthikwebdev/oops-infytq-prep
/31-jan.py
379
3.71875
4
#multiple inheritance class father: def __init__(self): self.acres = 10 def getf(self): return father().acres class mother: def __init__(self): self.acres = 5 def getm(self): return mother().acres class son(mother,father): def __init__(self): self.acres = se...
43e28baca5e62a057c9c811378315536fa5e14d7
karthikwebdev/oops-infytq-prep
/assess1/try.py
217
3.546875
4
def fun(a,b): try: c = int(a) print(c+'a') except TypeError: print('t') finally: print('if') try: fun('c',3) except ValueError: print('v') finally: print('of')
a843f08a25400ee90c86ab250c51ae7d205f1a5b
karthikwebdev/oops-infytq-prep
/pre-suf.py
387
3.953125
4
#take a string as input and print prefix and suffix that are equal #sample inputs -> outputs #asa -> a ,adda -> a , safsa -> sa , asdf -> -1 str = input() answer = -1 if(str[0]==str[-1]): answer = str[0] for i in range(1,len(str)//2): prefix = str[:i+1] suffix = str[len(str)-i-1:] print(prefix,suff...
985ee849a95356776888f8b0ea7f2a69bfcd56be
karthikwebdev/oops-infytq-prep
/queue.py
1,087
4.125
4
class Queue: def __init__(self,size): self.list = [] self.front = -1 self.rear = -1 self.size = size def enque(self,val): if(self.size-1 == self.rear): print("queue is full") elif(self.rear == -1 and self.front == -1): self.list.append(val)...
2910d6bc150cfb5cfc60e5b31f9910d546027eda
karthikwebdev/oops-infytq-prep
/2-feb.py
1,943
4.375
4
#strings # str = "karthi" # print(str[0]) # print(str[-1]) # print(str[-2:-5:-1]) # print(str[-2:-5:-1]+str[1:4]) #str[2] = "p" -- we cannot update string it gives error #del str[2] -- this also gives error we cannot delete string #print("i'm \"karthik\"") --escape sequencing # print("C:\\Python\\Geeks\\") # print(r"I...
f5869aaa4189761e68f83239aa7016ebef0b01b4
Justin696/2020-21-c1-challenge-08
/main.py
800
4.15625
4
print("you can do all chalenges in this challenge") print("Please enter the Chalenge number from 1 to 7") num = int(input("<: ")) if num < 1: print("there are no challenges less than 1") elif num > 7: print("There are no challenges more than 1") elif num == 1: print("You have chosen to play chalenge 1 good ...
99306f4e028e0bf8dae654d5f0caabed2dbaa32c
1immanuel/Python1
/conditionals.py
219
3.921875
4
import random num = int(input("What\'s your favorite numer: ")) number = 87 if num >= 0: print("Thats high.") elif num < 50: print("Think bigger.") else: print(num + number + random.randint(0,100))
48739d3ea033da9a39fd7240cda2ad0b83c86f85
ShehanHD/Python
/polymorphism/users.py
1,212
3.53125
4
from instuments import * class User: def __init__(self): self.users = [] self.name = None self.surname = None self.email = None self.password = None self.repeatPassword = None def fullname(self): return '{} {}'.format(self.name, self.surname) def a...
88bace55725367aa89600de73a9f8f4d22c248ee
F-said/computational-humor
/chumor.py
1,265
3.6875
4
from chumor import infoWeb def main(): ans = 'n' # Get prompt from user prompt = input("Input prompt:") # Pass expectation to function that creates graph of expectations chumor = infoWeb(prompt) chumor.getSubject() # Get help from human to make sure subject matter is correct print("P...
06400c1b669620782a5eddb4bbb8d4b3cc9ecf56
TakenouchiTR/CS3280-Credit-Card-Validator
/utils.py
1,325
4
4
#!/usr/bin/env python3 """ Library file for the first project for CS 3280 Utilities for checking if a credit card number is a valid length, only contains digits, and passes the Luhn algorithm. """ import re __author__ = "Shawn Carter" __version__ = "Fall 2021" __pylint__ = "v1.8.3" def luhn_verified(card_number): ...
27fc71bdff1c31eb07e0e2a817320f5d531f74d1
umakanthpai/Advanced-Python
/venv/files.py
1,889
3.640625
4
class Files: def doReadFile(self): file = open("test.txt") print(file.readline()) print(file.readline()) print(file.readline()) print(file.readline()) file.seek(0) # Use readlines to get a list print("\n******************************") print("Use readlines to get a list") ...
3317a083bce5a4c85a4c611337c41ca5a8bec273
azyl99/pyjs
/test.py
5,267
3.671875
4
x = 1 y = 2 * 3 #if-elif-else语句 x = 4 if x == 1 : x = 11 elif x == 2 : x = 22 elif x == 3 : x = 33 else : x = 44 endif print ( x ) x = 1 while x == 1 : if x == 2 : x = x + 1 endif x = 10 endwhile print ( x ) #for x = 1 for i = 0 ; i < 5 ; i = i + 1 : x = x + 1 endfor print ( x ) #while里面嵌套if x ...
c129f898c71a3c20a6623e28dbf6505d790e2c77
VeritasCurat/Synja
/project/lehre/Example.py
290
3.5
4
''' Created on 22.01.2019 @author: Johannes ''' class Example(object): name = "" problemstellung = "" loesung = "" data = 0 def __init__(self, name, problemstellung, loesung): self.name = name self.problemstellung = problemstellung self.loesung = loesung
631220a4e2ca118fa9a0a501eb89007c7602912b
AnmolArya1/Assignment-Submission
/Day1_Assignment/problem_1.py
228
3.875
4
#Problem_1 : BODMAS a=10 b=20 print((a*b)+(a/b)) #Brackets print(a**b) #Order print(a/b) #Division print(a*b) #Multiplication print(a+b) #Addition print(a-b) #Subtraction
99f6733d1bf23a97d50d5c31680882390d982ff1
Sunshien-CC/permutation
/test.py
664
3.515625
4
from itertools import permutations from solution import permutation2index, index2permutation class TestPermutationSequence(object): def test_permutation2index(self): for n in range(3, 10, 1): sequence = [m for m in range(1, n + 1, 1)] for index, permutation in enumerate(permutation...
402f2e2655ab63c46234777b8e249b0fc496911a
RD345/CS435-Project-1
/question_1_d.py
7,952
4.125
4
# Project 1 Question 1-d - Python # Created by Ryan Doherty # (8 points) (You must submit code for this question! ) Submit an implementation # of the following iterative methods in a Binary Search Tree. You do not need to # submit written answers to the framework from above, but it might be useful for # you to c...
4f33f719a0557b39ec618e941b69b30ec9902f30
terrynie/CNKISpider
/Test.py
643
3.546875
4
# -*- coding: utf-8 -*- import urllib2 print('请输入您要查询的内容:') txt_1_value = input() url = 'http://epub.cnki.net/kns/brief/default_result.aspx?action=44&mark=&NaviCode=*&ua=1.11&PageName=ASP.brief_default_result_aspx&DbPrefix=SCDB&DbCatalog=中国学术文献网络出版总库&ConfigFile=SCDBINDEX.xml&db_opt=CJFQ%2CCJFN%2CCDFD%2CCMFD%2CCPFD%2CI...
9635c800f907d6daf2f440574365bf4be72c753e
SHamblin/MC_IEEE_MM_CONTROLER
/findPath.py
10,555
3.546875
4
def floodfillb(startx, starty, endx, endy, lastx, lasty, vis, n, path, maze): positionx = endx positiony = endy if (positionx != startx or positiony != starty) and (not(vis[positionx][positiony].__eq__('x')) or path[positionx][positiony] > n): path[positionx][positiony] = n vis[posi...
eea91806ffb48158665ff40db3a4f90405bce570
ddinhftieens/Search_8o
/LinearRegression.py
745
3.703125
4
import numpy as np import matplotlib.pyplot as plt def estimate_coef(x,y): n = np.size(x) Xtb = np.mean(x) Ytb = np.mean(y) B1 = (np.sum(x*y)-n*Xtb*Ytb)/(np.sum(x*x)-n*Xtb*Xtb) B0 = Ytb - B1*Xtb return (B0,B1) def plot_regression(x,y,b): plt.scatter(x,y,c="g",label='Point=0') y_ = b[0]...
826a8083ee8b4f494291037988d8d5397dd005d8
MaksStarbucks/lesson-02
/lesson3.py
312
3.9375
4
# Дано выражение, расставить скобки так, чтобы значение х было равно 2 x = 2 + 2 * 2 - 2 / 2 print (x) # 5 # 1 вариант решения x = ((2 + 2 * 2) - 2) / 2 print (x) # 2 # 2 вариант решения x = 2 + 2 * (2 - 2) / 2 print (x) # 2
38ff9fa6d0635606b7db9783bd2013b843bed7ea
philipvig/PythonAskiseis
/1.py
1,326
3.515625
4
import random import numpy as np X= input("Dwste X diastash orthogwniou:") Y= input("Dwste Y diastash orthogwniou:") x=int(X) y=int(Y) array1=[] for i in range(x*y//2): array1.append(1) for j in range(x*y//2,x*y): array1.append(0) random.shuffle(array1) array = np.reshape(array1, (x, y)) print(array) counterh=0...
5ddf6f751545e39b4bc8b25d624ae3e874a9353b
stardreamer/yet-another-lang-performance
/yet-another-lang-performance/python/benchmarks/bad_benchmarks/primes_benchmark.py
1,158
3.6875
4
from benchmarks.benchmark import Benchmark class PrimesBenchmark(Benchmark): primes_number = 10 @staticmethod def __get_primes7(n: int): """ standard optimized sieve algorithm to get a list of prime numbers --- this is the function to compare your functions against! --- "...
093a460774ddc7c9a403642163c5e5d8aa67a2e6
yaphet17/Kattis-Problem-Solutions
/Alpahbet Spam.py
518
3.953125
4
string=input() n=len(string) whitespace=0 lowercase=0 uppercase=0 symbols=0 for i in string: if(i=='_'): whitespace+=1 continue if(i.isalpha()): if(ord(i)>=65 and ord(i)<=90): uppercase+=1 continue if(ord(i)>=97 and ord(i)<=122): lowercase+=1 ...
03d6bdcbcff3df9998f0f7142ea9ae8db49434e9
dwiseee/TA_DKP_Daffa-Maulana-Wisesa_21120120140057_Permainan-Gacha
/GACHA.py
6,496
3.5
4
from tkinter import * from tkinter import ttk from tkinter import messagebox import random class gachasystem(): def daffa(): for n in range (1): bebatuan=['Daffa','besi','batu','intan','perak'] hasil=random.choice(bebatuan) if hasil=='Daffa': pesan='Se...
0e87015c63d4c32bb8e32d7b1752a8cd4dcb5288
cole-rogers/simple-stats-scripts
/histogramFromPercents.py
869
3.5625
4
#!/usr/bin/env python import numpy as np import matplotlib.mlab as mlab import matplotlib.pyplot as plt ## this script was just made to generate a historgram of some data from perecents x = [1] rainPercent = [35,148,187,160,125,82,81,59,44,36,21,9,6,4,2] lenghtnum = 0 count = 0 while (lenghtnum < 14): count =...
0276a9e38709970e631bde2771b2a18c3175275a
Zeroska/SnakeGame
/TestLinkedList.py
1,017
3.796875
4
#Cell = Node, SnakeLinkedList = Linked-list_print #[] -> [] -> [] -> None #Each '->' is point to another Cell # class Cell: def __init__(self, cord=None): self.cord = cord self.next_cell = None class SnakeLinkedList: def __init__(self): self.head_cell = None def list_print(se...
7c51f808b192bc89a7a76092c0b672b29f9eb28a
jbronstein2022/cs152spring2021
/l10-nn-from-scratch/nn-from-scratch.py
4,584
3.609375
4
#!/usr/bin/env python3 import torch from torch import Tensor from typing import Tuple def initialize_parameters( n0: int, n1: int, n2: int, scale: float ) -> Tuple[Tensor, Tensor, Tensor, Tensor]: """Initialize parameters for a 3-layer neural network. Args: n0 (int): Number of input features (ak...
05b2181572dbdb0a1c826ddeb5d85bb2c61edd94
gigliolily/pythonlearn
/pylearn001/py003.py
610
3.96875
4
#-*-coding:utf-8-*- print "I will now count my chickens:" #жټ print "Hens",25+30/6 # print "Roosters", 100-25*3%4 #ĸ print "Now I will count the eggs:" #жٵ print 3+2+1-5+4%2-1/4+6 print "Is it true that 3+2<5-7?" print 3+2<5-7 print "What is 3+2?", 3+2 print "What is 5-7?", 5-7 print "Oh, that's...
24cd787fb713d2e489d59e4f698ec1fd233c8e93
vigoroushui/python_lsy
/8.object_oriented_programming/instanceAndClass.py
566
4.15625
4
#区别,第一个是实例属性、第二个是类属性 def Student(object): def __init__(self, name): self.name = name class Student1(object): name = 'Student' # 在编写程序的时候,千万不要对实例属性和类属性使用相同的名字 # 因为相同名称的实例属性将屏蔽掉类属性, # 但是当你删除实例属性后,再使用相同的名称,访问到的将是类属性。 stu = Student1() print(stu.name) print(Student1.name) stu.name = 'Jack' print(stu.name)...
7775c1ad59a930e635030da4c1e260693ec4b58a
vigoroushui/python_lsy
/4.function/function_hannota.py
185
3.765625
4
def move(n, a, b, c): if 1 == n: print(a, '-->', c) else: move(n-1, a, c, b) print(a, '-->', c) move(n-1, b, a, c) print(move(3, 'A', 'B', 'C'))
8efb1392b8336212d00d1c9cddf1a9ebeb9555aa
vigoroushui/python_lsy
/8.object_oriented_programming/classInstance.py
438
3.96875
4
# 一个简单的学生类,继承Object class Student(object): def __init__(self, name, score): self.name = name self.score = score def get_grade(self): if self.score >= 90: return 'A' elif self.score >= 60: return 'B' else: return 'C' #对象的实例化 Lisa = Stud...
689937d8275e03e20a81441f7047f55e9d981aef
sfatkhutdinov/100DaysOfCode
/CoffeeMachine/main.py
3,463
4.15625
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
268ecf05d5eaae973679fbe3518a98ec5a3912d5
sfatkhutdinov/100DaysOfCode
/quiz-game/quiz_brain.py
2,041
4.09375
4
class QuizBrain: """This class handles all the logic that runs the quiz """ def __init__(self, question_list): """Initializer for the QuizBrain class Args: question_list ([string]): The list of questions that is passed to the class during creation. """ ...
838a72caefea94c1074409bf3e97745b3bffe606
crs2107/crs2107
/object_oriented_program.py
698
3.875
4
class Phone : #when you are defining a class the name should starts with a capital letter def make_call(self): print("Making a call") def play_game(self): print("playing a game") def add_color(self,color): self.color = color def add_cost(self,cost): self.cost = co...
5b21b79e288ffadfaf08224baa9c5c6e3c2d3500
vikzh/python-project-lvl1
/brain_games/cli.py
206
3.578125
4
import prompt def welcome_user(title): print('Welcome to Brain Games!') print(title + '\n') name = prompt.string('May I have your name? ') print('Hello, {}!'.format(name)) return name
74a7fd0ef8f3a968827c3da1830f1f7deffb9315
IESPSUR/Python_practice_AOFI_1718
/canas-vidaller-manuel/Ejercicio_3.py
421
3.859375
4
#Creo e inicializo las variables x = 0 y = 0 z = 0 #Pregunto tres números x = int(input("Dime un número mayor que 0:\n")) if x > 0: y = int(input ("Dime ahora un número mayor que el anterior:\n")) if y > x: z = int(input ("Dime ahora otro número pero que sea menor que 0:\n")) if z < 0: print(x, " + ", y, " + ...
fec00151edc848548120fa4789daec0f2be9066b
schw240/BackJoon
/2920_음계.py
620
3.78125
4
''' 1. 리스트에서 원소를 차례대로 비교 2. 비교할 때 두 원소를 기준으로 오름차순 / 내림차순 여부를 체크 input 1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1 8 1 7 2 6 3 5 4 output ascending descending mixed ''' a = list(map(int , input().split())) ascending = True descending = True for i in range(1, 8): if a[i-1] < a[i]: desce...
9ca7895d44ba127283f289c8c27b145ad918f1bc
KalaiarasanK/CodeKata
/find smallest and largest.py
201
3.734375
4
#Given a number N followed by N numbers.Find the smallest number and largest number and print both the indices(1 based indexing). a=int(input()) b=list(map(int,input().split())) print(min(b),max(b))