blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
65a65098dd270deac773c7a30002197e02ba1189
eduardojordan/Practicas-Python
/KC_EJ05.py
222
4.09375
4
mes = input("Escribe el Mes:") año = input("Escribe el Año:") mesDos = input("Escribe otro Mes:") añoDos = input("Escribe otro Año:") if mes != mesDos or año != añoDos: print ("False") else: print ("True")
6224a5adabe1b796d293ccf35b0adedc5f9bac69
FossMec/Code-a-pookalam
/Malavika_S_Menon/Malavika_pookalam.py
1,389
3.90625
4
import turtle my_window = turtle.Screen() my_window.bgcolor("black") # creates a graphics window my_pen = turtle.Turtle() my_pen.speed() my_pen.up() my_pen.goto(0,-250) my_pen.down() my_pen.color('darkgreen') my_pen.begin_fill() my_pen.circle(250) my_pen.end_fill() my_pen.goto(0,-220) my_pen...
da489ff3d3767dafa2f7edaf12f4e1d7038ec935
mortontaj/Python_9
/Part 9/timezone_challenge.py
1,679
4.3125
4
# create a program that allows a user to choose one of # up to 9 time zones from a menu. You can choose any # zones you want from the all_timezones list # # The program will then display the time in that timezone, # as well as local time and UTC time. # # Entering 0 as a choice will quit the program. # # Display the da...
e6ebe1c40435126ca25592cb7b558f86d0732c43
chriscarter3377/ASSIGNMENTS
/osimport.py
530
3.65625
4
import os filepath = input("Enter path for file: ") filename = input("Enter name of file: ") if not os.path.exists(filepath): os.makedirs(filepath) fullname = os.path.join(filepath,filename + ".csv") name = input("Enter full name: ") address = input("Enter Address: ") phone = input("Enter ...
547fbf27509a9ebabbceecf4e3334220f09cad70
Nicolas5425/WWW
/Hola.py
1,216
4.03125
4
print "Elija Opcion 1.Calculadora, 2.Impar o Par" sel1=int(raw_input("Que Opcion Desea Elegir?")) if sel1==1: op=(raw_input("Que Opcion Desea Elegir (+, -, *, /")) if op=="+": val1=int(raw_input("Ingresa Primer Dato")) val2=int(raw_input("Ingresa Segundo Dato")) print "Suma", val1 + val2...
c79387cb43043b472739790b14f16236cd884c90
gwaxG/pypatterns
/structural/facade/facade.py
1,070
3.5625
4
#!/usr/bin/env python3 # coding: utf-8 from abc import ABC, abstractmethod ''' Facade proposes a simple interface for a complex system. ''' class Computer: def power_suply(self): print('Power suply') def post(self): print('Power-on self-test') def show_loading_screen(self): pri...
02d3a50e1834ece511b82c51937761f027419ebb
raviarrow88/Python-coding
/algorithms/sequential_search.py
324
3.828125
4
#Write a Python program for sequential search. def seq_search(l,target): found = False pos = 0 while pos<len(l) and not found: if l[pos] == target: found = True else: pos = pos+1 return found, pos print(seq_search([11, 23, 58, 31, 56, 77, 43, 12, 65, 19], 3...
e381307d78620c19c0e9f6a279b774937b5fcef6
Oscarpingping/Python_code
/01-Python基础阶段代码/04-Python文件操作/Python文件操作.py
2,069
3.625
4
# 1. 打开文件 # 相对路径, 相对于哪一个目录下面的指定文件 # f = open("a.txt", "r+") # # # 2. 读写操作 # content = f.read() # print(content) # # # f.write("88888") # # # # 3. 关闭文件 # f.close() # 1. 打开xx.jpg文件, 取出内容, 获取内容的前面半部分 # 1.1 打开文件 # fromFile = open("xx.jpg", "rb") # # # 1.2 读取文件内容 # fromContent = fromFile.read() # print(fromContent)...
264e2c62ad8315183ea1629a01db026952c30101
amz049/IS-Programming-samples
/IS code examples/Unit 7/koch.py
552
4.21875
4
import turtle def drawFractalLine(width, height, size, level): if level > 0: for d in [60, -120, 60, 0]: drawFractalLine(width, height, size / 3, level-1) # t.forward(size / 3) turtle.left(d) # t.setheading(d) else: turtle.fo...
cc1ca821cf31b9ae4fbd07cb73f49892f59718b7
tarnowski-git/Python_Algoritms
/modular_inverse.py
932
4.0625
4
#!/usr/bin/python3 """ Multiplicative Inverse of `a` under modulo `m`. a * x ≡ 1 (mod m) The value of x should be in {0, 1, 2, … m-1} The multiplicative inverse of `a modulo m` exists if and only if a and m are relatively prime (i.e., if gcd(a, m) = 1). e.g m = 7, a = 4, x = 2 4 * 2 = 8 mod 7 = 1 m = 11, a = 8,...
dfb8eb585181f6d4104b573d55e709878deec55f
VeriitoQD/Cursos
/HackerRank_Python/powerModpower.py
317
3.765625
4
def calculatepow2(x,y): return pow(x,y) def calculatepow3(x,y,z): return pow(x,y,z) if __name__=='__main__': a=int(input()) b=int(input()) m=int(input()) if 1<=a<=10 and 1<=b<=10 and 2<=m<1000: print(calculatepow2(a,b)) print(calculatepow3(a,b,m)) else: exit()
7be835039d09d1111d93208a09dadd70db8d9f83
actcheng/leetcode-solutions
/1261_Find_Elements_in_a_Contaminated_Binary_Tree.py
1,377
3.84375
4
# Problem 1261 # Date completed: 2019/11/21 # 132 ms (11%) # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class FindElements: def __init__(self, root: TreeNode): root.val = 0 ...
4403ac491e381ec22878981173df5903ff7fcc9f
mauro-20/The_python_workbook
/chap2/ex56.py
598
4.53125
5
# Frequency to Name frequency = float(input('enter a frequency(hz): ')) name = '' if frequency < 3e9: name = 'radio waves' elif 3e9 <= frequency < 3e12: name = 'microwaves' elif 3e12 <= frequency < 4.3e14: name = 'infrared light' elif 4.3e14 <= frequency < 7.5e14: name = 'visible light' e...
2bda9e7c78630644f681f8c054597c0c2b0c587a
N-bred/100-days-of-code
/Day_029/passwordManagerGUI/main.py
3,864
3.796875
4
import tkinter as tk from tkinter import messagebox import math from passwordGenerator import create_random_password import pyperclip WIDTH, HEIGHT = 200, 200 # ---------------------------- PASSWORD GENERATOR ------------------------------- # def generate_password(): random_password = create_random_password(n_o...
b7ea0d6141067119b39163ae70e1d56f153021af
faliona6/PythonWork
/OOP/characters.py
615
3.59375
4
class Character: def __init__(self, health, name): self.health = health self.name = name def __str__(self): healthInfo = " Health: " + str(self.health) nameInfo = "Name: " + self.name return nameInfo + healthInfo def changeName(self, newName): self.name = newN...
b629beeba3e2cd27857b32e54dc5d920b9257aef
EmeraldHaze/QFTSOM
/api/node.py
3,454
3.953125
4
from collections import OrderedDict from api import Abstract class Node(Abstract): net = False class AbstractNode(Node): """An abstract node used for conversations and other logical networks""" def __init__(self, name, links=[], does=[], exit_=False, data=None): self.name = name self.li...
bfd3e0c5583b9c358205181554c731890584f714
wagnersistemalima/Exercicios-Python-URI-Online-Judge-Problems---Contests
/Pacote Dawload/Projeto progamas Python/ex1144 Sequencia logica.py
338
4
4
numero = int(input()) for c in range(1, numero + 1): # EX: A sequencia é de 1 a 5, porem ela se repete print('{} {} {}'.format(c, c**2, c**3)) # na primeira repetição o contador**2 contador**3 print('{} {} {}'.format(c, c**2 + 1, c**3 + 1)) # na segunda repetção o contador**2 +1 c...
3b97456fe81956df35480e2fe58f99d651aab90a
GabrielSlima/Adivinhe-o-numero
/TakeGuess.py
785
4.0625
4
import random numeroSecreto = random.randint(1,20) print('O numero que estou pensando esta entre 1 e 20') #Dando ao usuario 6 oportunidades for tentativa in range (1,7): print('Tente adivinhar:') entrada = input() if entrada == '': while True: print('Tente adivinhar') entrada = input() if entrada !=...
422767c53169505c64a05ff346991117dbd11cc4
chibitofu/Coding-Challenges
/date_conversion.py
451
4
4
# Given a date formatted as 9/23/2019 convert it to 092319 # All single digit numbers should be prepended with a 0 def date_convert(date_input): split_date = date_input.split("/") if int(split_date[0]) < 10: split_date[0] = "0" + split_date[0] if int(split_date[1]) < 10: split_date[1] ...
10323b90495a7a0a649114c28464d1724ef9451e
G-itch/Projetos
/backup/Ignorância Zero-backup/Ignorância Zero/026Exercício1.py
115
3.953125
4
lista = [] for i in range(1,6): n =int(input("Digite o número %i de 5:" %i)) lista.append(n) print(lista)
feca03fa52ff6d9977412402a6345fb6b6461829
Zuce124/Algorithm_Learning
/test_recursion.py
405
3.890625
4
def countdown(x): if x == 0: print(x,"...\ndone!") return else: print(x,"...") countdown(x-1) def factorial(x): if x == 0: return 1 else: return x*factorial(x-1) def exponent(x,y): if y == 0: return 1 else: r...
1f195a45050270f4608b722356b481899767a809
ARAV0411/HackerRank-Solutions-in-Python
/Collections Most Common Moderate Problem.py
421
3.890625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from collections import * s= raw_input() string= [i for i in s] counter= Counter(string) string= sorted(set(string)) for i in range(3): for j in string: if counter[j]== max(counter.values()): print j+" "+ str(max(coun...
104b8f058ab98f16471c5c9bed4178d07b453d1b
kmckinl/PacMan_Learner
/game/cell.py
1,598
3.53125
4
from coin import * class CellMap: def __init__(self): self.map: Cell = self.getCells() def getCells(self): cells: Cell = [] lineCount = 0 rowCount = 0 walls = open("db/walls.txt", "r") for line in walls: if lineCount == 28: lineCount...
08603d03adb586deba6809e06eecb634c9a91ce6
ferranpons/ccc_pumptrack_attack
/player.py
3,212
3.5
4
#!/usr/bin/env python import pygame from pygame.rect import Rect class Player(pygame.sprite.Sprite): max_speed = 8 speed = 8 boost = 2 acceleration = .1 screen_rect = Rect(0, 0, 1280, 768) lap = 0 buffer = [] max_buffer_count = 3 start_ticks = 0 time_in_seconds = 0 previou...
09190e727d3e75ae20f3cac3a067b2923140b030
Aditi-Billore/leetcode_may_challenge
/Week2/straightLineCheck.py
844
3.84375
4
# You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. # Check if these points make a straight line in the XY plane. # (x2 - x1)(y3 - y1) - (x3 - x1) (y2- y1) import numpy as np def main(): coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] # coordina...
651f8268095c0440f5fce2cd46ea7900017b70e8
yangyu823/PythonPractice
/01/hello.py
1,715
3.6875
4
import random import sys import os print("Hello world") ''' Mulitilineafhsdjvkhakd ''' name='Derek' print(name) # Number print("5 + 2 = ",5+2) print("5 - 2 = ",5-2) print("5 * 2 = ",5*2) print("5 / 2 = ",5/2) print("5 % 2 = ",5%2) print("5 ** 2 = ",5**2) print("5 // 2 = ",5//2) # String quote ="\" Always remember...
fdb5341e41edb0edbead0b274920586d12ce6ad6
LyricLy/python-snippets
/properties/recursive.py
372
3.890625
4
#!/usr/bin/env python3 # encoding: ascii class Factorial: def __init__(self, n): if n < 0: raise ValueError self.n = n @property def value(self): if self.n == 0: return 1 old_n = self.n self.n -= 1 result = (self.n+1) * self.value self.n = old_n return result if __name__ == '__main__': im...
42e3aa09879dd849113a9289bf8baaa600ac21d0
joshwestbury/Digital_Crafts
/python_exercises/py_part3_ex/turtle_ex/shapes.py
924
4.1875
4
#Extract all the code for the shapes in exercise 1 into functions. Move them all into a single file called shapes.py. Write a new .py program that imports the shapes module and use its functions to draw all the available shapes onto the screen. from turtle import * def triangle(): for i in range (3): forwa...
74eddb734cfb7332258e72b1747ff4b93d14535c
ramona-2020/Python-OOP
/04. Inheritance/Lab_ 4. Mixin Inheritance.py
687
3.53125
4
import math from statistics import mean class CalculateAverageMixin: def get_average(self, data): return math.floor(mean(data)) class Student(CalculateAverageMixin): def __init__(self, name, age, grades=[]): self.name = name self.age = age self.grades = grades class Employee(C...
2d3caac051ebe17ce5967c1e184c839dada0b163
Aguu21/Python
/Ejercicio6.py
951
3.796875
4
def mayorProducto (primero, segundo, tercero, cuarto): '''Encuentra el mayor producto entre dos numeros, dados cuatro numeros.''' resultado = primero * segundo resultadosegundo = primero * tercero resultadotercero = primero * cuarto if (resultado > resultadosegundo): if (resultado ...
650cc67cc2d813032cb81fafc01059e27f0c09c8
LiaoTingChun/python_turtle
/turtle_q2.py
1,362
4
4
# !/usr/bin/env python # coding: utf-8 # Q2: Plot stars with user requirements via turtle import turtle as t import random # 2-(1) 用戶輸入7種顏色 color_check = ['red', 'orange', 'yellow', 'green', 'blue', 'skyblue', 'purple'] color_list = [] for i in range(7): color = input("輸入7種顏色: ") while color not in color_c...
2282287a82c58f48e9adf88d1ac14f15feb6abfd
guzmanchris/SnakeAI
/main.py
2,940
3.828125
4
import sys from agents import * from environment import SnakeEnvironment def run_benchmarks(n): result = '' agents = [ShortestPathSnakeAgent, HamCycleSnakeAgent, HamCycleWithShortcutsSnakeAgent] for agent in agents: result += f'{agent.verbose_name()}\n' result += '%s %12s %22s %27s %22s\n'...
c0977490789fd3291fda075b9675d7a5ecb8aa54
BingyuSong/my_practice
/sum.py
699
3.75
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): carry = 0 root = n =ListNode(0) while l1 or l2 or carry: v1 = v2 = 0 if l1: v1 = l1.val l1 = l1.next if l2: v2 = l2.val l2 = l2.next carry, val =...
150c698eaec7a88a887a3992e1e3e43e99522057
DashaChis/second
/hw1/hangman.py
3,099
3.78125
4
import random hangmans = [''' +---+ | | | | | | =========''',''' +---+ | | O | | | | =========''',''' +---+ | | O | | | | | =========''',''' +---+ | | O | /| | | | =========''',''' +---+ | | O | /|\ ...
61e3447944b42639d5ff4cdb4d2c6a4be8577561
r3corp/Detect-Faces-OpenCV
/faces_from_camera.py
1,642
3.84375
4
# This is a demo of running face recognition on a Raspberry Pi. # This program will print out the names of anyone it recognizes to the console. # To run this, you need a Raspberry Pi 2 (or greater) with face_recognition and # the picamera[array] module installed. # You can follow this installation instructions to get ...
f27ab9504d9691ce870a1746f0aa31eb60e1eaa7
hwanyhee/mlearn_8
/tensorflow2/cnn_mnist.py
2,636
3.59375
4
import tensorflow as tf from tensorflow import keras #https://www.tensorflow.org/tutorials/images/cnn class CnnMnist: def __init__(self): (self.train_images, self.train_labels), (self.test_images, self.test_labels) = tf.keras.datasets.mnist.load_data() self.train_images = self.train_images.reshape...
3843350bbe966f487566fde98252d9df92196bc6
dbkaiser/EulerKaiser
/python/42.py
320
3.796875
4
#!/usr/bin/python # though this is useless def readfile(): f=file('../test.txt'); while True: str = f.readline(); print ord(str[len(str)-1]); if len(str)==0 : break; f.close(); def isPrime(num): for x in range (1,num/2): if num%x==0: return False; return True; print(isPrime(33))
914145bd5ab6f6d404b83ef91ca7f1a9c3e15f75
santakd/PyEng
/Image_Video/edge_detect.py
505
3.5625
4
import cv2 import sys # The first argument is the image image = cv2.imread(sys.argv[1]) #conver to grayscale gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) #blur it blurred_image = cv2.GaussianBlur(gray_image, (7,7), 0) cv2.imshow("Orignal Image", image) # Use low thresholds canny = cv2.Canny(blurred_image, ...
3d50bfd5a4fdfe9009bf470768daf96c283036bf
chenjunyuan1996/Java-Practice
/day30/greedAlgorithm/lastStoneWeight.py
1,250
3.71875
4
''' 有一堆石头,每块石头的重量都是正整数。 每一回合,从中选出两块 最重的 石头,然后将它们一起粉碎。假设石头的重量分别为 x 和 y,且 x <= y。那么粉碎的可能结果如下: 如果 x == y,那么两块石头都会被完全粉碎; 如果 x != y,那么重量为 x 的石头将会完全粉碎,而重量为 y 的石头新重量为 y-x。 最后,最多只会剩下一块石头。返回此石头的重量。如果没有石头剩下,就返回 0。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/last-stone-weight ''' import heapq class Solution: def la...
72b2c8e75e101cd113c4a58f8754a9138bccbd6c
lizprogrammer/python_samples
/list_duplicates.py
318
3.59375
4
import random a = [random.randrange(0, 3)] count = random.randrange(0,40) i = 1 while i < count: a.append( random.randrange(0, 10)) i += 1 print(a) def get_set(a_list): my_set = set(a_list) return my_set my_new_set = get_set(a) print(sorted(my_new_set)) #def defaultArg( name, msg = "Hello!"):
e508afae8126b676e0b83fae4394f7a24a5d8fb6
hayesall/i427-SearchInformatics
/Assignments/assignment1/problem1.py
533
3.734375
4
#!/bin/python import sys import os def lastLetter(word): lastletter = word[-1:] lasttwo = word[-2:] #not elegant, but it works. secondtolast = lasttwo[:1] return lastletter + " " + secondtolast print(lastLetter("APPLE")) #should print: E L print(lastLetter("EMACSRULES")) #should print: S E print(la...
1509e944246ce5e76bdc44d81f173f89f65de1b4
roselller/myTkinterApplication
/main.py
8,560
4.3125
4
# Applications using Tkinter # 1. Import tkinter from tkinter import * '''------------------------ Functions --------------------------''' # function to compute and display Multiplcation Table def multiplication_table(): txtTable_MT.delete("1.0", END) try: n = int(entNumber_MT.get()) ...
b9367f2ad890b6548fe6043d92642b17292c0261
AnthonyRChao/Scripts-and-Implementations
/test.py
208
3.75
4
# x = 1 # y = x # x = x + 1 # print(x) # print(y) # x = [1, 2, 3] # y = x # x[0] = 4 # print(x) # print(y) x = ['foo', [1, 2, 3], 10.4] y = list(x) # or x[:] y[0] = 'foooooo' y[1][0] = 4 print(x) print(y)
a1b453399083ed740c5b64daf400388bcf559685
laucavv/holbertonschool-machine_learning
/math/0x02-calculus/10-matisse.py
462
4.15625
4
#!/usr/bin/env python3 """ calculates the derivative of a polynomial """ def poly_derivative(poly): """ calculates the derivative of a polynomial """ if type(poly) is list and len(poly) > 0: if len(poly) == 1: return [0] derivative = [0 for a in range(len(poly) - 1)] f...
6f9c705a3f0b9ea47b6ab0cd4c7a51909e3e8f1f
kamaliselvarajk/aspire
/Python/30-Jun-2021(if,while&functions)/for_shell.py
1,108
3.71875
4
a=[[1,2,3], ['Kamali', 'Dharshu', 'Papu'], 'Aspire'] for i in a: print(i, len(i)) print('------------------------------------------') sum = 0 for i in range(11): sum = sum + i print('Sum of first 10 numbers is: ', sum) print('------------------------------------------') sum = 0 for i in range(11): if(i%2 ==...
0317be7f56d8112fbd94290c56369947035baecb
PythonZero/sklearn-dataschool
/06_linear_regression.py
1,693
3.609375
4
import numpy as np import pandas as pd from sklearn import metrics from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split def print_linear_regression_formula(model): print( f"y =", " + ".join( [f"({m:.3f} * {col})" for col, m in zip(featu...
6e83533281dad63146b92dbc8a7e43f7841b225e
AltenArcade/ArcadeProject
/Emulator/Games/Tetris/Figure.py
4,297
3.515625
4
import pygame from Games.Tetris.Block import Block from random import randint BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) PINK = (255, 0, 142) PURPLE = (182, 0, 251) YELLOW = (251, 247, 5) class Figure(pygame.sprite.Sprite): def __init__(self, struct, width, height, block, pr...
964c04bc27edee7dd4587fdf1a55f7d9d6eea319
JiahengHu/Turtle-Run
/Turtle.py
7,155
3.84375
4
# Liwei Jiang, Yin Li, Kebing Li # CS269 JP17 # Computer Game Design # Turtle.py # Jan. 15th 2017 import pygame class Turtle: '''the class of turtle''' def __init__(self, screen, position = (0,0), color = 0, scale = 1, grid = -1): self.screen = screen self.position = position self.colo...
492f53608a989edf505c149ba04bf3a99e022e2b
adk7/cs-review
/quick_sort.py
943
3.71875
4
def quick_sort(items): return quick_sort_(items, 0, len(items) - 1) def quick_sort_(items, low, high): if(low < high): p = partition(items, low, high) quick_sort_(items, low, p - 1) quick_sort_(items, p + 1, high) def get_pivot(A, low, hi): mid = (hi + low) /...
edc6fa200bd33992ddb127cee544891480797c24
cbrianhill/adventofcode
/2021/day4.py
2,656
3.515625
4
import re def make_board(lines, start): grid = [] for i in range(0, 5): gridline = [] fileline = re.split(r'\s+', lines[start+i].strip()) for j in range(0, 5): gridline.append(int(fileline[j])) grid.append(gridline) return grid def print_board(board): templat...
bab811386c28977e798fa08ef503e767699d9e61
LiRamos/Kpop-Listening
/kpop_mood.py
2,275
4.375
4
user_sad = input("Are you sad? Please type 'yes' or 'no'.\n") food_sadness = input("Are you sad because you are hungry? Please type 'yes' or 'no'.\n") current_project = input("Do you have a project you should be doing for school Please type 'yes' or 'no'.\n") work_rough = input("Was today a rough day at work for you? ...
27e569cf7783e836dc70c6f661945c94db0eb201
MajetyPrashanth/My-Coding-Practice
/Stack.py
670
3.75
4
# class A(object): # def __init__(self,ID,name): # self.ID = ID # self.name = name # def display(self): # return self.ID, self.name # a = A(1,"Ram") # print(a.display()) class Stack: def __init__(self): self.stack = [] pass def push(self,item): self.stack....
c803db11e4b3394db04feeac7d01ffee61507cfb
tatsuya999/Gakky_classwork
/Gakky.py
379
3.71875
4
n=input('正の整数を入力してください:') x=int(n) while x<=0: n=input('正の整数を入力してください:') x=int(n) divisor="" count = 0 for i in range(1,x+1): if x%i==0: divisor = divisor + " " + str(i) count += 1 else: pass print(x,'の約数は',divisor,'です。') print('全部で', count,'個あります')
d84a9d909e5523a765467ca4c4eb0c34f76503ba
HeathLoganCampbell/UoA-CS-320
/AssignmentOne/gen.py
559
3.890625
4
''' THIS PROGRAM WILL GENERATE A RANDOM INPUT FOR THE QUESTION OF ASSIGNMENT ONE. YOU CAN RUN THE FILE WITH, WHICH WILL OUTPUT THE FILE TO ./test/sample-answer.txt RUN: Python ./gen.py > ./test/sample-answer.txt Height Width (0,0) (0,1) (0,2) .. (0, width) (1,0) (1,1) (1,2) .. (1, width) ... (height,0) (height,1) (h...
17e89673f56b7ae9b42144458d1c888e88ed4a8d
316112840/Programacion
/Tareas/Tarea07/Ejercicio1.py
652
3.84375
4
# -*- coding: utf-8 -*- # Mariana Yasmin Martinez Garcia # Correo: mariana_yasmin@ciencias.unam.mx # Ejercicio 7.1: Practica con sets def InterseccionConjuntos(lista): a = lista[0] for i in range( len(lista) ): a = a.intersection( lista[i] ) return a # PRUEBAS: a = set(...
1fb9cf4c005151481a074914c75dda6ad105a63c
vineetpathak/Python-Project2
/initialize.py
683
4.1875
4
# -*- coding: UTF-8 -*- # Program to initialize linked list import linked_list as ll # Initialize the following linked listaz # 4 -> 5 -> 13 -> 6 -> 9 -> 41 -> 8 -> 27 -> 33 def initialize_linked_list(): lList = ll.LinkedList() lList.insert(4) lList.insert(5) lList.insert(13) lList.insert(6) lList....
244f628540c82cf24245d1859103243ef4bd57d8
Ligthert/4xMUD
/old/login.py
505
3.65625
4
#!/usr/bin/python from getpass import getpass user_id = 0 print "Login with your username and password. If you are new and wish to create a new account. Login with user 'create'"; while user_id == 0: username = raw_input("Username:") if username == "create": print "Fun!\n" user_id = 1 password = "*****" el...
fbb3974dd83f0882f27e0098e50d27b50f987392
luismasuelli/mistra
/mistra/core/intervals.py
3,553
3.84375
4
from enum import IntEnum class Interval(IntEnum): """ These values can be used as intervals for source (original data) or digested data. They can also constrain/truncate a timestamp to be relevant for the interval being considered. """ SECOND = 1 MINUTE = 60*SECOND MINUTE5 = 5*MINUTE ...
687a678c13129f05b136eb770abde72a014824d5
ChenCMadmin/study
/object/day2/super的使用.py
1,683
3.75
4
# 自定义类 class Master(object): # 实例方法,方法 def make_cake(self): print("按照 [古法] 制作了一份煎饼果子...") # 父类是 Master类 class School(Master): # 实例方法,方法 def make_cake(self): print("按照 [现代] 制作了一份煎饼果子...") # 执行父类的实例方法 super().make_cake() # 父类是 School 和 Master # 多继承,继承了多个父类 class Prent...
363ca8016f7c45d74305dccf463cc427ae24d49c
tzyl/algorithms-python
/algorithms/dynamicprogramming/longest_palindrome_substring.py
530
3.71875
4
# O(n^2) DP solution. def longest_palindrome_substring(s): longest = "" # P[i][j] is True if the substring s[i:j+1] is a palindrome. P = [[False] * len(s) for _ in range(len(s))] for i in range(len(s)): P[i][i] = True for l in range(2, len(s) + 1): for i in range(len(s) + 1 -...
3fd31d6c5df189d06d76aae96be127f8645b899a
hbishnoi/SSW-810
/HW07_Himanshu.py
1,931
4.15625
4
'''wroking with different type of methods to use dictionaries, tuples, list and set''' from collections import defaultdict, Counter from typing import DefaultDict, Counter, List, Tuple def anagrams_lst(str1: str, str2: str) -> bool: '''checking if two given strings are anagrams or not''' return sor...
91525fd00852b57c89915cb99815b5a838596d3e
jayendra-ram/columbia_hw
/e4040-2021fall-assign1-jcr2211/utils/classifiers/softmax.py
4,035
3.8125
4
import numpy as np from random import shuffle def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) This adjusts the weights to minimize loss. Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inpu...
a02411c22d8ba287dd4b0dc678cc97010cf29193
AnacondaSL/Own-tiny-project
/phonebook.py
992
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Filename: phonebook.py # Author: SHUANG LUO import os path = os.path.expanduser(r"~/Desktop/myphonebook.txt") phonebook_content = open(path).read() c = phonebook_content.split('\n') print (c) # this line is used to print out the context of myphonebook.text which can be r...
b2b1a2906b87726310da8df55a3b1a5a7db8afd8
BolajiOlajide/python_learning
/beyond_basics/decorators.py
460
4.125
4
""" Decorators are a way to modify or enhance functions w/o changing their definition. """ # functions as decorators def escape_unicode(f): def wrap(*args, **kwargs): x = f(*args, **kwargs) return ascii(x) return wrap @escape_unicode def vegetable(): return "blomkåi" @escape_unicode d...
9ec4431f8fa8b33436f0edecb985236c60923ef2
tsuganoki/project_euler
/014.py
589
4
4
"""n → n/2 (n is even) n → 3n + 1 (n is odd)""" def get_longest_seq(starting_num): longest_seq = 0 ans = 0 for i in range(starting_num,1,-1): seq = 0 result = i print("i is: ", i) while result > 1: if result % 2 == 0: result = int(result/2) ...
c735184ae91c85b051485e379e600f8dec358a90
Meph1sto/Text_Problems
/pig_latin.py
566
3.984375
4
''' Pig Latin - Pig Latin is a game of alterations played on the English language game. To create the Pig Latin form of an English word the initial consonant sound is transposed to the end of the word and an ay is affixed (Ex.: "sloppy" would yield loppy-say). ''' def pig_latin(word): vowels = ['a','e','i','o','u'...
4e2c09068d42bc86ecdaf52708fb8ddc05416cda
sky-dream/LeetCodeProblemsStudy
/[0035][Easy][Search_Insert_Position][BinarySearch]/Search_Insert_Position.py
496
3.84375
4
# Time Complexity: O(logN) # Space Complexity: O(1) # solution 1, binary search class Solution: def searchInsert(self, nums: List[int], target: int) -> int: if not nums: return 0 start,end = 0,len(nums)-1 while(start<=end): mid = start + (end-start)//2 if...
3028bf1fee341282434508fb1bf5a8225c80ee0d
Josh551/Kamikaze
/cobra2.py
172
4.375
4
#Program to check if number is negative or positive a=int(input("Enter a no")) if a>0: print("the number is positive") else: print("the number is negative")
0b4cc7f6c6b7f676144caed7c668fd1880c55c38
cszatmary/machine-learning-exercises
/Part 8 - Deep Learning/Section 40 - Convolutional Neural Networks (CNN)/cnn.py
1,902
3.6875
4
# Convolutional Neural Network # Part 1 - Building the CNN # Importing the Keras libraries and packages from keras.models import Sequential from keras.layers import Convolution2D, MaxPooling2D, Flatten, Dense from keras.preprocessing.image import ImageDataGenerator # Steps: Convolution -> Max Pooling -> Flattening -...
aaa77b1da87339f2ede526dd10f9622ba52c0754
HeDefine/LeetCodePractice
/Q705.设计哈希集合.py
1,483
4
4
#!/usr/bin/env python3 # https://leetcode-cn.com/problems/design-hashset # 不使用任何内建的哈希表库设计一个哈希集合 # 具体地说,你的设计应该包含以下的功能 # add(value):向哈希集合中插入一个值。 # contains(value) :返回哈希集合中是否存在这个值。 # remove(value):将给定值从哈希集合中删除。如果哈希集合中没有这个值,什么也不做。 # # 示例: # MyHashSet hashSet = new MyHashSet(); # hashSet.add(1);         # hashSet.add(2);  ...
c5b7cac2173d0a767ec340e86ba30f12ed62a2f2
ARXZ-soft/idea-board
/idea_board_jp.py
787
3.5625
4
# coding:utf-8 import tkinter as tk import tkinter.messagebox as tmsg import random # ボタンがクリックされたときの処理 def ButtonClick(): tmsg.showinfo("ヘルプ", "一時的にドキュメントを保存するアプリです。終了すると同時に保存してあるドキュメントは削除されるのでご注意ください。    ") # メインのプログラム root = tk.Tk() root.geometry("650x565") root.title("アイディアボード Ver.0.1.2") # 履歴表示のテキストボックスを作る r...
94268fd83330470506552e3439a23c35a1c7d1d1
usmanchaudhri/azeeri
/sort_array_of_0_1_and_2/sort_array_of_0_1_and_2.py
2,562
4.09375
4
""" Given balls of these three colors (Red, Green and Blue) arranged randomly in a line (the actual. 8/18 number of balls does not matter), the task is to arrange them such that all balls of the same color are together and their collective color groups are in the correct order (Red first, Green next and Blue last). The...
1a8d49ede10973475e59a34d9c34113f5892630d
alexanderraj478/TSH01
/TSHTDM/DataNode1D.py
1,414
3.609375
4
class DataNode1D: def __init__(self): self.m_DataNode1D = [] @property def NoneNode(self): return self.__NoneNode @NoneNode.setter def NoneNode(self, NoneNode): self.__NoneNode = NoneNode def AddDataNode(self, DataNode): self....
ffaefb5dbb07772e2271f0886dc3e4480272a44a
cromox1/KodPerang_kata
/4kyu_next_smaller_number_same_digits_2.py
2,235
3.671875
4
def next_smaller(n): print(n) chars = list(str(n)) print(chars) print(sorted(chars)) print(sorted(chars, reverse=True)) uniq = list(set(chars)) print(uniq) limit = int(''.join(sorted(chars))) - 1 for i in range(n - 1, limit, -1): if sorted(list(str(i))) == sorted(chars) and i...
3db5aa67b9dee910d5ce5a47fad35813ad723c93
r3k4t/Python-Practice.github.io
/conditional-statement.py
634
4.25
4
# Conditional statement # if # elif(else if) # else # when if true and answer ==> ok,hello. print('Condtional Statement: 1') if 3>2: print('ok') elif 2<4: print('hmm') else: print('1+1') print('hello') # When if false and answer ==> hmm,hello. print('Condtional Statement: 2 ==>Example:Robot') if...
11394f3928f8f2e005476ae15246b3bd5fa7a49b
cg-dv/project_euler
/46.py
490
3.59375
4
#!/usr/bin/env python import sieve def is_goldbach(n): for prime in primes: for square in squares: if n == (prime + (2 * square)): return True return False odds = set([(2 * i + 1) for i in range(100000)]) primes = set(sieve.eratosthenes(100000)) squares = set([i ** 2 for i...
29c17bf2b044a349ce48555b1f3f2079419ec58a
rohinisyed/GuessTheNumber
/main.py
471
3.84375
4
from random import randint play_game=True random_number = randint(1,100) while play_game: player_guess = int(input("Guess the number: ")) if player_guess > random_number: print ("Too High, Try again!") elif player_guess < random_number: print ("Too low, Try Again!") else: play_again = input ("...
252dd5a270dcd877885c4016b2981f3a76129c7d
zerynth/core-zerynth-stdlib
/examples/Serial_Port_Read-Write_Basics/main.py
599
3.515625
4
################################################################################ # Serial Port Basics # # Created by Zerynth Team 2015 CC # Authors: G. Baldi, D. Mazzei ################################################################################ import streams # creates a serial port and name it "s" s=streams.seri...
04713dff54915945494ae5438ed4a0b0cdb95c01
RenegaDe1288/pythonProject
/lesson30/mission1.py
342
3.65625
4
from functools import reduce floats = [12.3554, 4.02, 5.777, 2.12, 3.13, 2, 11.0001] names = ["Vanes", "Alen", "Jana", "William", "Richards", "Joy"] numbers = [22, 33, 10, 6894, 11, 2, 1] print(list(map(lambda x: round((x ** 3), 3), floats))) print(list(filter(lambda x: len(x) > 4, names))) print(reduce(lambda x...
a6d01340ec8f516b4eff483a8c5a9526633907c6
hatttruong/machine-learning-from-scratch
/util/helper.py
212
3.5
4
def extract_words(document): """Summary Args: document (str): document instance Returns: list: list of words """ words = document.lower().strip().split(' ') return words
6e5180cdeac9e948734601c391442be97579e7ab
Leigan0/python_challenges
/fibonacci/app/fib_checker.py
164
3.53125
4
from fibonacci import FibonacciChecker import argparse i = input('Please enter a number ') fib_checker = FibonacciChecker(i) print('sum =') print(fib_checker.sum())
2a04d196e19ae05e33286694314106e64d25812d
ritishadhikari/pandas
/pandas_merge.py
1,897
3.734375
4
import pandas as pd df1 = pd.DataFrame({ "city": ["new york","chicago","orlando"], "temperature": [21,14,35], },index=[0,1,2]) df2 = pd.DataFrame({ "city": ["chicago","new york","orlando"], "humidity": [65,68,75], },index=[1,0,2]) df3 = pd.concat([df1,df2],axis=1) print("The Concatenat...
bf589df2e1b01a9bfe7a2943a60ae98323eebf41
kasia-basia/advent-of-code
/02.py
675
3.609375
4
"""https://adventofcode.com/2020/day/2""" with open(r'02.txt') as data: passwords = [row.split(' ') for row in data.read().splitlines()] def check_passwords1(): i = 0 for [times, letter, password] in passwords: min, max = times.split('-') if password.count(letter[0]) in range(int(min), i...
2d9c8d0200dc8f2eeba12abc764601b6fbf2bbd4
jvugar/Intelligent-Atropos-Player
/jvugarPlayer.py
4,985
3.515625
4
#Vugar Javadov #U66070335 #jvugar@bu.edu #CS440: PA3 import sys # print to stderr for debugging purposes # remove all debugging statements before submitting your code msg = "Given board " + sys.argv[1] + "\n"; sys.stderr.write(msg); #parse the input string, i.e., argv[1] s = sys.argv[1] #s ="[13][302][1003][30002][...
f2e4b6baed6c4317f5df5b95fc73ae8ee3c2dfda
twopiharris/230-Examples
/python/oop3/accessMethods.py
372
3.703125
4
""" accessMethods.py demonstrates getters and setters """ class Critter(object): def __init__(self, name = "Anonymous"): self.name = name def getName(self): return self.name def setName(self, name): self.name = name def main(): c = Critter() c.setName("Marge") print(c.getNa...
790cfbc5d6536879b9650d38f8df5ca6aa74bd9d
EmperoR1127/algorithms_and_data_structures
/PriorityQueue/MaxHeapPriorityQueue.py
1,632
3.578125
4
from HeapPriorityQueue import HeapPriorityQueue class MaxHeapPriorityQueue(HeapPriorityQueue): """A max-oriented priority queue extends with a min-oriented priority queue""" # -------- nonpublic utilities -------- def _upheap(self, i): while i > 0: idx_parent = self._parent(i) ...
d78b7ef93cdd315e512294ebc3387aafbeb98a19
Meet57/programming
/Basic Python/Tkinter/43_filedialog_box.py
438
3.78125
4
from tkinter import * from tkinter import filedialog def openfile(): result = filedialog.askopenfile(title="My file",filetype=(("text file",".txt"),("all files",".*"))) print(result) text.delete(1.0,END) for c in result: text.insert(INSERT,c) root = Tk() button = Button(root, text='open file...
ceba9d34a00337eafec9a71a3e353de90c563186
jjason/RayTracerChallenge
/ray_tracer/patterns/checker_board.py
1,737
4.34375
4
import math from patterns.pattern import Pattern class CheckerBoard(Pattern): """ The checker board pattern. A checker board pattern has two colors and changes in all three dimensions such that no two adjacent cubes are the same color. The color is determined by: +- color_a if...
e37741f8c0297ff2e2b75284869d3a89dbdcf930
HamzaRatrout/my_project
/python/square.py
181
3.90625
4
import turtle turtle.shape("turtle") for x in range(10): for x in range(4): turtle.forward(100) turtle.left(90) turtle.left(36) turtle.hideturtle() turtle.exitonclick()
6a11225f0f6646e70d86db7ca057260953afe5a0
japarker02446/BUProjects
/CS521 Data Structures with Python/Homework3/japarker_hw_3_1.py
1,998
4.0625
4
# -*- coding: utf-8 -*- """ japarker_hw_3_1.py Jefferson Parker Class: CS 521 - Spring 1 Date: February 3, 2022 Loop through the integers 2 - 130, inclusive Count and report how many are: Even Odd Squares Cubes For evens and odds, report the range. For squares and cubes, report the list o...
43f65417df793810d673e87d36aea7fb4aae1e84
dlavareda/Inteligencia-Artificial
/Ficha 1/5.py
1,436
4.25
4
""" A biblioteca numpy é muito útil para processamento matemático de dados (tipo matlab). Para a podermos usar devemos fazer o seguinte import: import numpy as np Agora podemos criar, por exemplo, um array 7x3 (7 linhas e 3 colunas) inicializado a zero com: a = np.zeros([7,3]) Escreva um programa um programa que peça a...
70b402256e784e540a30eaa337cbb3c77f206484
jonathanchiu/python-gpacalc
/gpa_calc.py
1,387
4.03125
4
class Course: """Contains information regarding a course Parameters: grade -- String representing letter grade received credits -- Integer representing number of credits course has name -- String representing the name of the course (optional) """ def __init__(self, grade, credits, name = "N/A"): ...
5204fd16933d40e6b4881193f4b1960857741995
george-hcc/py-euler
/044_pentagon_numbers.py
578
3.5
4
#!/usr/bin/python3 def main(upper_limit): #return alt() pentagon_list = [n*(3*n-1)//2 for n in range(1, upper_limit)] pentagon_set = set(pentagon_list) solution = 0 found = False for idx, pj in enumerate(pentagon_list): for pk in pentagon_list[idx+1:]: if (pk+pj in pent...
6ace7e4ba422fed937a2bdfe30fbc90bcf2a8777
eebmagic/algos_hw
/05/py_tests/three/script.py
2,000
3.53125
4
import matplotlib.pyplot as plt class Line: # y = mx + b def __init__(self, m, b, name='line'): self.m = m self.b = b self.name = name def f(self, x): return (self.m * x) + self.b def solution(a, b): ''' find solution of two lines ''' try: slopes =...
af03b870e655e3dd855e77f638af1032a31b61a6
Ash515/LeetCode-Solutions
/Arrays/Difficulty-Easy/PascalTriangle1.py
658
3.890625
4
''' 118. Pascal's Triangle Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown ''' class Solution: def generate(self, numRows): pas_tri = [[] for i in range(numRows)] for i in rang...
c1468d5e32cd23adf86084120e1d3eecceddd55c
frimmy/LPTHW-exs
/ex14.py
644
3.9375
4
from sys import argv script, user_name, user_ht = argv what_say = '> ' print "Hi %s of %s, I'm the %s script." % (user_name, user_ht, script) print " I'd like to ask you a few questions." print "Do you like me %s of %s?" % (user_name, user_ht) likes = raw_input(what_say) print "Where do you live %s" % user_name liv...
f10c7c0742b6d9d971b1f62453faff84fd656636
Phongwind002/baikiemtra
/bai3.py
528
3.5
4
def tinhgiaithua(n): giaithua = 1; if (n == 0 or n == 1): return giaithua; else: for i in range(2, n + 1): giaithua = giaithua * i; return giaithua; n = int(input("Nhập số nguyên dương n = ")); if (n<0): print("Yêu cầu nhập lại số nguyên dương") ...
fde6812d58c67a262948a43cd4f7e57975dd49cb
Szoul/Automate-The-Boring-Stuff
/Chapter 10/Organizing files.py
2,947
3.640625
4
import shutil, os from pathlib import Path dir1_path = Path("C:/Users/Acer PC/Desktop/Python/Automate-The-Boring-Stuff/Chapter 10/dir1") dir2_path = Path("C:/Users/Acer PC/Desktop/Python/Automate-The-Boring-Stuff/Chapter 10/dir2") filename = "a_moving_file_title.txt" # shutil.copy(source, destination) copies a file (...
96d6cf3bc9777bb930d66426515b3acd487a815e
djangoearnhardt/Exercism
/luhn.py
2,167
3.78125
4
# Given a number, determine whether or not it is valid per Luhn formula # Need at least two numbers, doubles every other digit from the right # adds the two numbers of the double together to make new single digit import numpy as np print("Please enter a valid 16 digit CC#") array = input() counter = 0 max = 4 while ar...
4e2ff85783c0c909b58e8e43a793700e4e3a9273
FabioGUB/ExerciciosCursoEmVIdeo
/Ex040.py
356
3.828125
4
n1 = float(input('Nota da primeira prova: ')) n2 = float(input('Nota da segunda prova: ')) m = (n1 + n2) / 2 if m >= 7.0: print('Parabéns você foi aprovado e já pode entrar de férias.') elif m < 5.0: print('Infelizmente você foi reprovado, estude mais.') else: print('Você está de recuperação, se esf...