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
0fcac24e1728b2be332b04a8d6726863e868b9cf
damingus/CMPUT174
/class_Example1.py
2,887
3.921875
4
class Rectangle: #capitalize the first letter of a class def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height self.top_left = (self.x, self.y) self.bottom_right = (self.x + self.width, self.y + self.height) de...
5def4ffc1d4aa1f09363d0a3d3e86661085c23b0
damingus/CMPUT174
/weather1.py
407
4.4375
4
#This program sees whether 2 inputted temperatures are equal or not #assign 'a' to the first temperature we ask for and 'b' for the next a = input("What is the first temperature? ") b = input("What is the second temperature? ") #we convert 'a' into a string from an integer a = str(a) b = str(b) if a == b: print...
81e2d58511ee405fd453a4865d97c13f3805739b
damingus/CMPUT174
/Color Matching Game/color_match_final.py
6,523
3.875
4
# Pre-Poke Framework # Implements a general game template for games with animation # You must use this template for all your graphical lab assignments # and you are only allowed to inlclude additional modules that are part of # the Python Standard Library; no other modules are allowed import pygame, random, time # U...
161780dc9580ea787ae5219a71f5d96ac9e67658
BrassMic/Silprog
/Excel.py
485
3.5
4
import pandas as pd import os path = os.chdir(input("Ścieżka folderu: ")) list = os.listdir(path) print(list) files = list df = pd.DataFrame() kol = input("wybierz kolumny: ") for f in files: data = pd.read_excel(f, usecols=kol, index_col=None) df = df.append(data) print(df) x = input("Nazwa pliku: ") sheet_...
915f7f30d13db757d714eca308304cf07424b4b9
alexismorison95/Algoritmos_y_estructuras_de_datos_2017
/Semáforo/TDAColaDinamica.py
945
3.65625
4
# -*- coding: utf-8 -*- class T_Dato(): id,tiempoverde,color = None,None,"rojo" class NodoCola(): info, sig = T_Dato, None class cola(): def __init__ (self): self.frente = None self.final = None self.tam = 0 def crearcola (q): q.frente = None q.final = None q.tam = 0 ...
db523f5943689c49c667d4c61bad26605f050117
joeytman/one-line-palindrome-finder
/palindrome_one_line_expanded.py
2,556
3.5625
4
import argparse def p(s, v=False): return [s[i_j_pair[0]:i_j_pair[1] + 1] for i_j_pair in [ [ [ item for seeking_palindrome_of_size in range(1, len(s) + 1) for item in [ (i_j_pair[0],i_j_pair[1]) for i_j_pair in [ (i, i + seeking_palindrome_of_size - 1) ...
3bb05110f4e61837f3033087526ee6f96e418f8d
andrew1236/python
/organism population calculator.py
864
4.1875
4
#ask user for number of intital organisms, the average increases of organisms, and how many days to calcualte def calculate_organism_population(): organisms=int(input('Enter number of organisms:')) average_increase =int(input('Enter average daily increase:')) days=int(input('Enter number of days to multiply...
766b63291ec5c848a28f6ac413fe47556e87f842
duongdidom/DDDsecond
/machine_learning_neural_network.py
18,842
3.921875
4
""" NEURAL NETWORK deep neural network when there is more than 1 hidden layer All machine learning above are good at classification, not logic. Neural network is good at logic TensorFlow is not pure python code, they've only basically created a nice pretty Python wrapper to make our lives easier. TensorFlow inherentl...
e2eb787d892e1f9a0a2004a058a30c9a84be549e
underfilho/Workspace
/arrow.py
1,117
3.953125
4
from tkinter import LAST from workspace import * class Main(Workspace): def __init__(self): self.position = Vector(10, 10) # Posição da flecha self.velocity = Vector(2, 2) # Velocidade em pixels por frame super().__init__() def config(self): self.set_title("Arrow") ...
85dac24696162aa06c9989af1a76c9a9cb8e26b1
ivyivory/learningpython
/leetcodeOJ.py
5,085
3.65625
4
''' Created on Nov 26, 2013 @author: Ivy ''' ''' result=[] def combine(n, k): if n<k: print "n is smaller than k" return #elif n==k: #for i in range(1,n): print i,"," #print n #result.append(range(1,n+1)) #return result if k==1: ...
63c36e6c87df626016cc31959bca58959ec52a9c
Alexerson/adventofcode
/y2018/day9.py
835
3.59375
4
from collections import deque from utils import data_import def add_marble(number, circle): if number % 23 == 0: circle.rotate(7) score = number + circle.pop() circle.rotate(-1) else: score = 0 circle.rotate(-1) circle.append(number) return circle, score...
e9e340ba4f30fb1fc00bc7c8bd284cb389c1d299
Alexerson/adventofcode
/y2021/day2.py
1,756
3.5
4
from enum import Enum from typing import NamedTuple from utils import data_import class Position: x: int = 0 y: int = 0 aim: int = 0 def apply(self, action: 'Action', with_aim: bool = False) -> 'Position': action.apply(self, with_aim) class Verb(Enum): FORWARD = 'forward' DOWN = 'd...
693f3437f5df18466f3183dd45d5eb2ed3f213fa
Alexerson/adventofcode
/y2018/day3.py
1,490
3.59375
4
import collections from utils import data_import # We need to convert the input in something we can work with def convert_data(data): out = [] for item in data: pk, _, position, size = item.split(" ") pk = pk[1:] x, y = position[:-1].split(',') w, h = size.split('x') o...
eb3ac8fd16ffe209128adafed365d61dbe59fc2e
Alexerson/adventofcode
/y2020/day6.py
935
3.671875
4
from typing import List, Set def data_import(filename: str) -> List[List[Set[str]]]: data = [] with open(filename) as file: line = file.readline() group: List[Set[str]] = [] while line: line = line.strip() if line == '': data.append(group) ...
4a3e9712840f42d378d66efa0c5915ca19336d5c
CIPPUS-SSS/RegularMeetingCodes
/cppElementary/objectOriented/example2.py
482
3.546875
4
#coding: utf-8 class animal(): def run(self): print 'Animal is running.' class dog(animal): def run(self): print 'Dog is running.' def eat(): print 'Eating dog food.' class cat(animal): def run(self): print 'Cat is running.' def main_2(obj): # obj.run() i...
f8a9fdf12f1d324353b1c7f7bfcc4c3ecc6df3d7
cernyc/the-parking-problem
/CarDetectionExamples/matplotlibOpenCV.py
569
3.515625
4
import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('watch.jpg',cv2.IMREAD_GRAYSCALE) plt.imshow(img, cmap = 'gray', interpolation = 'bicubic') plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis plt.plot([200,300,400],[100,200,300],'c', linewidth=5) plt.show() """ M...
e03234ead130d80f81f623ad279e8a1987578390
Muhammadtawil/Python-Lessons
/set-part1.py
822
4.3125
4
# ----------------------------- # -- Set -- # --------- # [1] Set Items Are Enclosed in Curly Braces # [2] Set Items Are Not Ordered And Not Indexed # [3] Set Indexing and Slicing Cant Be Done # [4] Set Has Only Immutable Data Types (Numbers, Strings, Tuples) List and Dict Are Not # [5] Set Items Is Unique # --...
f5aa7ba07b63b836c71d5bd08a76b65d78813878
sgandavarapu/Data_Structures
/ch2p1.py
1,352
3.71875
4
import math def interleave(text1,text2): out=[] n = len(text1) for i in range(0,n): out.append(text1[i]+text2[i]) return ''.join(out) def scramble(text,num): n=len(text) curr_num = num if n==curr_num: return interleave(str(text[:n/2]),str(text[n/2:])) else: return scramble(text[:n/2],cu...
2f9b3ee9e458ca2e53599ca5a3a1befd90d04268
dshipman/devtest
/part_2_6.py
621
4.25
4
""" Write a short docstring for the function below, so that other people reading this code can quickly understand what this function does. You may also rename the functions if you can think of clearer names. """ def create_step_function(start_time, end_time, value): """ Create a step function that takes a si...
79ad5f03e779657dcba2084af7e62e732b6be464
Brensterfrenster/Lesson-9
/problem3.py
283
4.09375
4
print('-'*60) print('Alien Greeter Bot:') print() planet = input("What planet are you from? ") if planet == 'Mars' or 'mars': print("Welcome to Earth, please do not kill us!" ) else: print("Welcome to Earth! Don't know why you picked this planet among the others? ") print('-'*60)
e1d8a85edcd4598ead1ca3578c75310452f80fb5
gibranmfw/edf_raspi
/scripts/utils/safety.py
1,341
3.53125
4
""" This file contains rocket safety features """ #! /usr/bin/env python import rospy from servo import ServoHandler class SafetyHandler: """ This class contains functions to ensure the safety of the rocket """ def __init__(self, sh): """ __init__ method of SafetyHandler class :sh: Actuat...
a8d3ef77167eac0dd71d4473835a3cc32ef866d1
ZPlin1030/password
/password.py
421
3.859375
4
# 密碼重試程式 # password = 'a123456' # 讓使用者重複輸入密碼 # 最多輸入3次 # 如果正確就印出 "登入成功!" # 如果不正確就印出 "密碼錯誤! 還有__次機會!" password = 'a123456' i = 3 #剩餘次數 while i > 0: pwd = input('請輸入密碼: ') if pwd == password: print('登入成功!') break else: i = i - 1 print('密碼錯誤!,還有', i, '次機會!')
439d5dc0ea49976b5904d34787fcca4ee456b2c6
mhrsavci/OkuDeneOgren
/OkuDeneOgren_10.py
3,325
3.71875
4
# Python p110 #### 10.KARAKTER DİZİLERİNİ BİÇİMLENDİRMEK #### ## s Anahtar Harfi parola=input("Parola Giriniz: ") # Kullanıcıdan parola bilgisi alındı. print("Girilen Parola: %s" %parola) # Parola bilgisi ekrana string format yapısı ile yazdırıldı. Burada yer alan 's' anahtar harfi string degerleri ifade...
d91fc95f364e491f76c5c341aa5d777caa2c1911
AmirMoshfeghi/university_python_programming
/Functions/wine_house.py
1,549
4.46875
4
# Working with Functions # Making a house wine project # Wine Temperature must be closely controlled at least most of the time. # The program reads the temperature measurements of the wine container # during the fermentation process and tells whether the wine is ruined or not. def main(): # Get number of measure...
29ecb07768924e1803d45d5bd367358e1355c197
nivethasathiya/nivetha7
/nivetha7.py
294
3.90625
4
int = 407 if int > 1: # check for factors for i in range(2,int): if (int % i) == 0: print(int,"is not a prime number") print(i,"times",int/i,"is",int) break else: print(int,"is a prime number") else: print(int,"is not a prime number")
a37b2dfb1c6a3e8b2d9fcdd3145b533d9a1a0b2b
DMNK20888/InvestmentCalculator
/CompoundMath.py
336
3.78125
4
def CompInterest(principal, years, percent): #basic compund interest calculator principal = float(principal) years = float(years) percent = float(percent) money = principal*((percent*0.01)+1.00)**years money = round(money, 2) print("Your balance after", int(years), "years will be: $", money, ...
7e329a1ec41dcb002ef530c673ce66b1d6c85400
HanHyunsoo/Baekjoon_Algorithm
/Python/1977.py
1,032
3.625
4
from math import sqrt # math 모듈에 sqrt함수(제곱근함수)를 불러온다. def checkInt(n): """ n이 sqrt로 구한 값이면 반환값이 float형이기때문에 뒤에 소수점이 무조건 붙는다. 그런데 딱 나누어 떨어지게 된다면 뒤에있는 소수가 0밖에없기 때문에 n을 문자열로 바꾼다음 뒤에 '.0'이면 int형으로 간주하여 True를 반환하고 아니면 False를 반환한다. """ if str(n)[-2:] == ".0": return True else: ret...
ae1867b4a3b45f8dff6b231cd3594b0c4ff7267d
HanHyunsoo/Baekjoon_Algorithm
/Python/1009.py
944
3.53125
4
def checkComputer(a, b): """ 반복문으로 a의 제곱 순열(1~ 똑같은 숫자가 있을때까지) 구하는 함수. int(caseNum[-1])은 해당하는 숫자의 첫째자리이다. 첫째자리가 numArr에 또 있으면 그 순열은 반복하는 것이므로 리스트에 추가하지 말고 반복을 멈춘다. result는 b에 순열의 길이(0부터 시작하므로 1을 뺀다.)를 나눈 나머지값. result가 0이면 나누어 떨어지는 것이므로 10으로 반환. """ numArr = [] i = 1 while True...
d96f6860eb0816cafc7ae15eee83c013fcd7d454
HanHyunsoo/Baekjoon_Algorithm
/Python/11656.py
126
3.9375
4
word = input() result = [] for i in range(len(word)): result.append(word[i:]) result.sort() for j in result: print(j)
b9fe42cda86e67e2df337dcb40f4462ad9fdab64
HanHyunsoo/Baekjoon_Algorithm
/Python/5597.py
115
3.53125
4
students = list(range(1, 31)) for i in range(28): students.remove(int(input())) for j in students: print(j)
451d25c85b3a4ce4efcf194b236cd9303e269ef0
HanHyunsoo/Baekjoon_Algorithm
/Python/2753.py
119
3.78125
4
year=int(input()) if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: year = 1 else: year = 0 print(year)
0283d8961c5c9938efa8a89a9f147f33b0d4569f
HanHyunsoo/Baekjoon_Algorithm
/Python/5026.py
193
3.59375
4
for i in range(int(input())): result = input() if result == "P=NP": print("skipped") else: result = result.split("+") print(int(result[0]) + int(result[1]))
8b620f22314dfb1d21c4cb447964c90ff3002db8
HanHyunsoo/Baekjoon_Algorithm
/Python/1934.py
168
3.640625
4
from fractions import gcd def lcm(a, b): return int(a * b / gcd(a , b)) for i in range(int(input())): a, b = map(int, input().split()) print(lcm(a, b))
7e6395fb6525681515679781355a02bfa813b64b
HanHyunsoo/Baekjoon_Algorithm
/Python/2720.py
202
3.5
4
money = [25, 10, 5, 1] for i in range(int(input())): c = int(input()) result = [] for j in money: result.append(c // j) c %= j for p in result: print(p, end=' ')
aefd2aa0db6a70d3fd22198b764a0da2f0527d77
HanHyunsoo/Baekjoon_Algorithm
/Python/1546.py
183
3.5625
4
number=int(input()) score=list(map(float,input().split())) score.sort(reverse=1) result=0 for i in range(number): result += score[i]/score[0]*100 print("%0.2f" % (result/number))
c73a52cd3a55b227463e692f551df8786f359452
HanHyunsoo/Baekjoon_Algorithm
/Python/2292.py
126
3.703125
4
n = int(input()) plus = 6 result = 1 count = 1 while result < n: result += plus plus += 6 count += 1 print(count)
7275131a6715be0eea89ca0b26380ca61d0519a7
liquidlx/tcp-socket-python
/TCPServer.py
1,353
3.65625
4
#importa o modulo de socket nativo do python import socket serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serv.bind(('0.0.0.0', 8080)) #Deixa o servidor escutando por novas conexoes no socket. #O parametro define a quantidade de conexoes que podem estar na fila. serv.listen(5) while True: #accept() - ace...
8d65fb87d9ce3043d37059ad11e560b1d7447979
naits3/Exercises
/Exercise1/helloworld_python.py
531
3.75
4
# Python 3.3.3 and 2.7.6 # python helloworld_python.py from threading import Thread i = 0 def someThreadFunction(): global i for j in range(1,1000000): i = i + 1 def someAnotherThreadFunction(): global i for j in range(1,1000000): i = i - 1 def main(): someThread = Thread(target = someThreadFunction, ...
28235cd4e587f723fa3516e37f7aeea1d0b0faa2
vnl2k/funkpy
/funkpy/Monads.py
4,135
3.625
4
class Functor: """ A container with a map interface. """ # Prevents the class from creating a dictionary with 'val' key, # which helps save on memory usage. There is a test for this. __slots__ = ['val'] def __init__(self, value=None): self.val = value def __eq__(self, other): if isinstance(other,...
0d93c157e002a995e152822a3cce28a022f3fec6
Gustavoarrod/Loop
/ex23.py
493
3.78125
4
#Codigo e quantidade print(''' Código Especificação Preço 1 Cachorro Quente R$4.00 2 X-Salada R$4.50 3 X-Bacon R$5.00 4 Torrada simples R$2.00 5 Refrigerante R$1.50 ''') cod = int(in...
44b0b251bb6c392716a45048769305e21374716c
ptapasu/budget
/read_input.py
4,282
3.796875
4
import os import csv import sqlite3 import datetime import logging '''This reads csv files in the input folder named "mastercard"," bnz" and "visa". Then...''' def logger(): """A tool for logging events in the program to alter the log reporting change the level: logging.INFO, logging.DEBUG, logging.ERROR""" ...
a447ed47414f5b2467f74cbf0b62f134ad049a38
itismesam/Courses-1
/Courses/Swedish Courses/Datastrukturer Python Umeå Universitet/Implementerad Datastrukturer/PrioQueueDirectedList.py
3,524
3.5625
4
# -*- coding: latin-1 -*- #Written by Lena Kallin Westin <kallin@cs.umu.se>. Modified by Johan Eliasson #May be used in the course Datastrukturer och Algoritmer (Python) at Ume University. #Usage exept those listed above requires permission by the author. """ Datatypen Prioritetsk enligt definitionen p sidan 293 i La...
6c36fdba837de0171b09ad0b7a1efe47d5f22600
itismesam/Courses-1
/Courses/Swedish Courses/Datastrukturer Python Umeå Universitet/Implementerad Datastrukturer/HashTable.py
4,508
3.59375
4
# -*- coding: latin-1 -*- #Written by Lena Kallin Westin <kallin@cs.umu.se>. #May be used in the course Datastrukturer och Algoritmer (Python) at Ume University. #Usage exept those listed above requires permission by the author. """ Datatypen HashTabell Variabler och funktioner som inleds med ett enkelt underscore ...
a7cccc385ee163c3a071ca30878ea7e6985a2b5b
Artem7898/Python_Cheat_Sheet
/Cheat Sheet/myPython.py
5,577
4.25
4
# The Walrus operator # Разрешить присваивание и возрать значения в одном вырожении from timeit import timeit import random import statistics import math from importlib import metadata inputs = list() while (current := input("Написать что-то: ")) != "выход": inputs.append(current) # Как указать только пазиционные...
f6e66580b128af7d4d0f757ec2a1062eb40001c0
baha312/chapter4_task7
/task7.py
735
4.1875
4
# Implement Students room using OOP: # Steve = Student("Steven Schultz", 23, "English") # Johnny = Student("Jonathan Rosenberg", 24, "Biology") # Penny = Student("Penelope Meramveliotakis", 21, "Physics") # print(Steve) # <name: Steven Schultz, age: 23, major: English> # print(Johnny) # <name: Jonathan Rosenberg, age...
9a766a51894b2255e55bbf945cd9e9ae015cd24a
hrvojka/wd1-lesson_13
/homework_13.1.py
2,190
3.890625
4
class Player: def __init__(self, first_name, last_name, height, weight): self.first_name = first_name self.last_name = last_name self.height = height self.weight = weight class FootballPlayer(Player): def __init__(self, first_name, last_name, height, weight, goals, yellow_card...
7fd2ed27b7956cf58308ab4832b503f4668fc8f3
brunopurper/Python-Curso-em-Video
/ex022.py
728
4.125
4
#Exercício Python 22: Crie um programa que leia o nome completo de uma pessoa e mostre: # – O nome com todas as letras maiúsculas e minúsculas. # # – Quantas letras ao todo (sem considerar espaços). # # – Quantas letras tem o primeiro nome. nome = str(input("Digite seu nome: ")).strip() nomeup= nome.upper() nomelow= ...
7b9d3c51c3cdbaef9bd3fdc0c9b6177b8462c2a2
brunopurper/Python-Curso-em-Video
/ex011.py
626
4.0625
4
#Exercício Python 11: Faça um programa que leia a largura e a altura de uma parede em metros, calcule a sua área e a quantidade de tinta necessária para pintá-la, sabendo que cada litro de tinta pinta uma área de 2 metros quadrados. base_parede = float(input("Digite a largura da parede a ser pintada: ")) altura_pared...
c04223829974466b65da43116a84e3dedfa09973
birkett0011/SimPy
/simple_queuing_system.py
1,638
3.71875
4
# tutorial https://www.youtube.com/watch?v=oJyf8Q0KLRY&list=PL2Wg3oyN-jmMD39JFqejZAzi06BWo_uJa&index=3 import numpy as np class Simulation: def __init__(self): self.num_in_system = 0 self.clock = 0.0 self.t_arrival = self.generate_interarrival() self.t_depart = float('inf') ...
e75aaddd1169af6a4e268e81d4c2745f7dc22c7c
deannah/6270krotus
/RRT.py
2,472
3.5625
4
""" RRT - Rapidly Exploring Random Tree This is how a lot of the robot's global planning will occur. Heavily based upon sample RRT code provided by Ariel Wexler """ from random import random from math import sqrt class TreeNode: def __init__(self): self.x = 0.0 self.y = 0.0 self.parent = None def toString(se...
7834d52d4eea94dff50949181b63eb74252fbbef
lgminh/Challenges
/Python/Medium/labyrinth2.py
7,283
3.65625
4
def unvisited_position(marked): for row in marked: for i in row: for j in i: if j[0] == ' ': return True return False def possible_move(positions, labyrinth, marked): directions = {'U': (-1, 0), 'R': (0, 1), 'D': (1, 0), 'L': (0, -1)} moves = [] ...
a43fb800a6e4a1bc6374e368154a0f834ee2821a
lgminh/Challenges
/Python/Hard/labyrinth.py
9,406
3.609375
4
import numpy as np from fractions import gcd def maze(labyrinth, start, dest): direction = { 'U':(-1,0), 'R':(0,1), 'D':(1,0), 'L':(0,-1) } solution = [] def move(labyrinth, dest, steps, current_position): if (current_position['x'] > len(labyrinth) - 1 or curren...
fa4466a428aaef30b7dec2e5c35c13fd525173d7
stuharley8/CS2911-Labs
/lab6.py
9,364
3.8125
4
""" - CS2911 - 021 - Fall 2019 - Lab 6 - Names: - Stuart Harley - Shanthosh Reddy A simple HTTP server """ import socket import re import threading import os import mimetypes import datetime def main(): """ Start the server """ http_server_setup(8080) def http_server_setup(port...
3c41b7e9e3484dcc1e3d27e705a8317064185216
TheoKanning/GridworldRlDemo
/environment.py
3,018
4.3125
4
"""This class represents a python Gridworld environment. Actions sent to this class will update the state of the environment and return a reward""" AGENT='A' OPEN=' ' OBSTACLE='#' GOAL='G' ACTIONS=[ (0, -1), # up (0, 1), # down (-1, 0), # left (1, 0) # right ] class...
5dde7e024c76e0e8b213103e0d8c43df1558a73b
zhpg/python1805
/day03/fibs.py
264
4.03125
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- """数列""" list = [0,1] len = int(input('length:')) for i in range(len - 2): #num1 = list[-1] #num2 = list[-2] #sum = num1 + num2 #list.append(sum) list.append(list[-1] + list[-2]) print(list)
2a8b4176ce27bca263396aa38373630c561f116a
zhpg/python1805
/day05/my_sort.py
108
3.9375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- alist = ['bob','alice','tom'] list = sorted(alist) print(list)
abd7000ccff2ded52d32938bc1420c3941056117
zhpg/python1805
/day09/quick_sort.py
682
3.859375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- from random import randint def qsort(data): if len(data) < 2: #如果列表中的元素只有一个或者是0个就返回 return data middle = data[0] #取列表中的第一个值当做中间值 smaller = [] larger = [] for i in data[1:]: #从列表中的第二个元素以次取出 if i < middle: smaller.append(i) ...
13aba9119f3d6076ab304e5dd699f45ee62c36b6
zhpg/python1805
/day11/test.py
150
3.546875
4
class TheThing(): def __init__(self): self.name = str(self) #此处想获得赋值对象的名称 print(self.name) a = TheThing()
3164e574eacac3e9dfdf88fe40002a78c4e104a0
zhpg/python1805
/day08/newargs.py
271
3.796875
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- def add(x,y): print(x +y) if __name__ == '__main__': nums = [100,200] add(*nums) #*nums表示把nums拆开 ndict = {'x':100,'y':200} add(**ndict) #**拆成x=100,y=200, 注意实参和形参要一至
ac139d1bdeeceb79a0afc92049740eedf1e8dcac
benjaminleon/EulerProject
/20.py
128
3.6875
4
import math number = str(math.factorial(100)) print number ans = 0 for digit in number: ans += int(digit) print ans
ae430661d281a65275da7d7230c35096d68c593e
Jayu8/Python3
/assert.py
636
4.125
4
""" It tests the invariants in a code The goal of using assertions is to let developers find the likely root cause of a bug more quickly. An assertion error should never be raised unless there’s a bug in your program. assert is equivalent to: if __debug__: if not <expression>: raise AssertionError """ # Asserts a...
09ad5fd637753c86b388e834963afd93628a69c0
Jayu8/Python3
/D_Intro_to_FunctionalProgramming/Function_returning_functions.py
685
3.875
4
# program to calculate polynomials def polynomial_creator(*coefficients): # variable arguements """ coefficients are in the form a_0, a_1, ... a_n """ def polynomial(x): res = 0 for index, coeff in enumerate(coefficients): res += coeff * x** index return res return ...
cca3af68f10727cdbba541b57dec1bb9ce419211
imharshith/pandas
/pandas operation/columnheader/changingcolheader.py
296
3.671875
4
#changing column header import pandas as pd import numpy as np print("ISE DEPARTMENT") df=pd.DataFrame({'YEAR':[2015,2016,2017,2018], 'ISE_OFFERS':[59,np.nan,42,47], 'ISE_ELIGIBLE':[43,49,39,39], 'ISE_PLACED':[43,46,35,33]}) print(df) dfc=df.rename(columns={'YEAR':'OUTPUT_YEAR'}) print(dfc)
b9caac5aa84570cda354762a0fc8b02223e113cb
mamerida/python-poo-curse
/Interfaz.py
450
3.75
4
class Interfaz: def solicitar_un_numero_rel(self,titulo): variable = input(titulo) try: var= float(variable) #float real o int entero except ValueError as error: print("El dato ingresado no es un numero") var = 0 return var def solicitar_numero_entero(self,titulo): variable = input(titulo) t...
17337f031948e2332462ffc17874a97c03db5489
dennishy/hackerrank_scripts
/triangle.py
124
3.78125
4
import math ab = int(input()) bc = int(input()) out = math.degrees(math.atan2(ab, bc)) print('{}°'.format(round(out)))
b2d675b96a26428a9bd8695a2425a1d0f09dfe59
netteNz/Python-Programming-A-Concise-Introduction
/problem2_5.py
1,296
4.21875
4
'''Problem 2_5: Let's do a small simulation. Suppose that you rolled a die repeatedly. Each time that you roll the die you get a integer from 1 to 6, the number of pips on the die. Use random.randint(a,b) to simulate rolling a die 10 times and printout the 10 outcomes. The function random.randint(a,b) will generate an ...
359711c64ad6b35be6eac00883d02089c0e45e2b
netteNz/Python-Programming-A-Concise-Introduction
/problem1_2.py
363
4.0625
4
""" Test run. Note that the grader program will use different numbers: problem1_2(3,5) 8 15 """ def problem1_2(x,y): """ Problem 1_2: Write a function problem1_2(x,y) that prints the sum and product of the numbers x and y on separate lines, the sum printing first. """ print(str(x + y)) ...
f3e57dfec92ca096d20b528e27c175e28d72332b
kmichnicki/word_analysis
/most_common_words.py
1,990
3.796875
4
##In command line navigate to the folder with this script and the text file you want to analyze. ## ##for windows: ##type alice.txt | python most_common_words.py import sys from collections import Counter from matplotlib import pyplot as plt num_words=10 #this the number of words that shows up in the bar graph. all_wo...
6b3b084cc5a1f52b73edf3f6d6f373d6358487f4
python-practice-b02-927/vernovskaya
/lab2/task6.py
183
3.796875
4
import turtle t = turtle.Turtle() t.shape('turtle') n = int(input()) for i in range(n): t.forward(100) t.stamp() t.right(180) t.forward(100) t.right(180 - 360/n) input()
b2effbf42732e7f894304a6574d11edaa5397340
python-practice-b02-927/vernovskaya
/lab2/task9.py
361
4.0625
4
import turtle import math t = turtle.Turtle() t.shape('turtle') def angle(i,r): t.left(90 + 180/i) for k in range(i): t.forward(2*r*math.sin(math.pi/i)) t.left(360/i) t.right(90 + 180/i) t.penup() t.forward(20) t.pendown() r = 20 for i in range(3, 13): angle(i,...
31e06742c4f5b32294e05562d380297438d6c5fe
python-practice-b02-927/vernovskaya
/lab2/task8.py
121
3.703125
4
import turtle t = turtle.Turtle() t.shape('turtle') for i in range(30): t.forward(10 + i*5) t.right(90) input()
cf145f782ac24c8a9740c99d5a8c2c2b96641ab6
akash-sr/Machine-Learning-basics
/Linear_Regression/test.py
1,891
3.609375
4
import pandas as pd import numpy as np import sklearn from sklearn import linear_model from sklearn.utils import shuffle import matplotlib.pyplot as pp from matplotlib import style import pickle # load data data = pd.read_csv("student-data.csv", sep=",") # clean data data = data[["GS","TS","Uni_rat","SOP",...
b388b6b156bb2f8b78a8ae47bf27cabc65103de2
Rashine/pythonpractice
/dictionary_practice.py
1,225
3.859375
4
#shoping cart cart = { "item":"hamberger", "price":"2.0", "quantity": 10 } artist = { "first": "Neil", "last": "Young", } # DON'T TOUCH PLEASE! donations = dict(sam=25.0, lena=88.99, chuck=13.0, linus=99.5, stan=150.0, lisa=50.25, harrison=10.0) # DON'T TOUCH PLEASE! # Use a loop to add together...
2e8e524ba02c0a7ce32f8e54e90787448e74e8f4
Guinsooss/HomeGrownGill
/HGG_adding_to_menu.py
3,190
4.40625
4
menu = { # item categories 'fruits': { # items inside each category 'apples': { # the price of the item 'price': 3 }, 'oranges': { 'price': 3 }, 'watermelon': { 'price': 1.50 } }, 've...
dd248098db811b6309039853a3a62c78afd400aa
diegoami/hackerrank-exercises
/data_structures/tree/inorder.py
296
3.734375
4
""" Node is defined as self.left (the left child of the node) self.right (the right child of the node) self.data (the value of the node) """ def scan(node): return scan(node.left) + [str(node.data)] + scan(node.right) if node else [] def inOrder(root): print(" ".join(scan(root)))
3d347fba4bf20cda9864cbfe6fba64c3515b0c32
diegoami/hackerrank-exercises
/artificial_intelligence/bot_building/bot_clean_2.py
2,638
3.609375
4
#!/usr/bin/python inputarray = [ "0 0", "5 5", "b---d", "-d--d", "--dd-", "--d--", "----d" ] from tools import input, initArrayInputter initArrayInputter(inputarray) # Head ends here def next_move_sub(posy, posx, dimy, dimx, board): csdy, csdx = None, None for bi, by in enumerate(board): for bj, bx...
dee2536eb02e13f4cecccf0979fcfd6b9d16560a
diegoami/hackerrank-exercises
/algorithms/chocolate.py
560
3.890625
4
#!/bin/python3 inputarray1 = [ "5", "1 2 1 3 2", "3 2", ] inputarray2 = [ "6", "1 1 1 1 1 1", "3 2", ] inputarray3 = [ "1", "4", "4 1", ] from tools import input, initArrayInputter initArrayInputter(inputarray3) import sys import sys def getWays(squares, d, m): w = 0 for i, s in enumerate(squares): ...
a52d6f64dedcc90fd56b423d4d4d5b6d54f4ea95
diegoami/hackerrank-exercises
/artificial_intelligence/bot_building/bot_clean.py
2,608
3.6875
4
#!/usr/bin/python inputarray = [ "0 0", "b---d", "-d--d", "--dd-", "--d--", "----d" ] inputarray2 = [ "0 0", "b---d", "----d", "-----", "-----", "ddd--" ] inputarray3 = [ "1 2", "-----", "--b--", "-----", "-----", "ddd--" ] from tools import input, initArrayInputter initArrayInputter(inputarray) # Head ends here...
56bfba46f2d21deb66fe71c8acf3a100388a6964
diegoami/hackerrank-exercises
/sort/inssort_1.py
954
3.75
4
inputarray = [ "5", "2 4 6 8 3" ] from tools import input, initArrayInputter initArrayInputter(inputarray) def insertion_sort(m): e = m[-1] l = m[:-1] index = len(l)-1 while l[index] > e and index >= 0: l = (m[:index]+[m[index],m[index]]+m[index+1:])[:len(m)] print(" ".join(map(...
026966a59af606980fc6c6e32ce589ddcd8a64fe
stwins60/Python-Class
/Assignment4.py
3,523
4.09375
4
#ASSIGNMENT #4: YOU HAVE BEEN HIRED FINALLY BY THE 21 Century as a Senior Programmer and you've been tasked to help #in revamping their credit rating system and loan issuing system. Just remember, your job is to make things happen. #As a Sr. Developer in Python Programming, all the lights and attention are turned tow...
ebec75172e3811de38ae1e2b3bd54ec9d2f5c2ae
cqz3000cs/chaoSSS
/test2.py
137
3.875
4
# -*- coding: utf-8 -*- import calendar from datetime import date mydate = date.today() print(calendar.month(mydate.year, mydate.month))
d515ba03c551f0a79971a7e223dc6228a711b081
prathgan/COASTL
/coastl/stl_toolkit/stl_node.py
4,802
3.71875
4
class Node(object): def __init__(self, parent, child1, child2, type, logic, vars, range_start, range_end, string_rep): """ Constructs node to be used in tree representing expression of signal temporal logical. Parameters ---------- parent: pointer to the object of parent of this node child1:...
8e7ef357f2ba4ce482381e6381e4d346ace4f69a
prathgan/COASTL
/coastl/stl_toolkit/stl_parsing_helpers.py
2,772
4
4
def round_parens(string, start=0): """ Return indices of opening and closing parentheses of expression, starting from right side of expression """ count = 0 itr_index = start first_not_found = 1 end = 0 while itr_index<len(string): if string[itr_index]=='(': if first_not_found==1: start = itr_index ...
ac4457954cabb98bb4b331bab41a40003c245386
pbellon/gist
/lib/decorators.py
5,184
3.703125
4
import argparse import sys import json from .utils import as_obj def command_arg(*args, **kwargs): """ Small tweak to build argparse.add_argument() arguments through a command declaration (see `command` decorator and `Command.add_arguments` method) """ class CommandArg: def __init__(self, ...
d1ba3599a7b16b7a65acd2b77a2b7af0c0f80d9a
zinef/CircuitChallenge
/Solution.py
1,752
3.8125
4
#A solution for the "circuit" challenge by Zine-eddine fodil #P.S: I used "windows-1252" encoding since most of the other #encoding I tried gave errors and to use bytearrays def getKthBit(given_num,k): return (given_num & (1 << k)) >>k def encrypter(char,key): """ literally the given circuit "bitwise OP maping"...
9aacc5316cc72f391e2b58690087a89528b4d855
sonampaul/beggainner
/alphabet.py
145
3.609375
4
int main() char c print("emter a character") if(c>="a"&&c<="z")||(c>="a"&&c<="z") print c is an alphabet else print c is not an alphabet
98492e84fe7deeaddce87f21ce0ba8bfdfe78ae4
harshabandaru/Grocio
/app.py
4,189
3.671875
4
""" Grocio: Twilio app for maintaining lists between friends like groceries Help: 1. Adding items into your list add <list name> <item1> <item2> 2. List items in your list list <list name> 3. Delete items in your list using indexes in the list remove <list name> <index_item1> <index_item2> Also persists data i...
f3db3ba1af9a34c6b223dd1d4d0e55c99e1319fe
prudhvireddym/CS5590-Python
/Source/Python/ICP 2/Stack Queue.py
852
4.15625
4
print("Enter Elements of stack: ") stack = [int(x) for x in input().split()] con ="yes" while con[0]=="y": ans = input("Enter 0 for push\n1 for pop\n2 to print stack\n3 for Top most element : ") while ans == "0": a = int(input("Enter the element to append")) stack.append(a) print(stack) ...
649dac1c71975a65f87626abfe509d9dc128a333
codewithmodi/Python_Projects
/P0003.py
295
4.09375
4
num = input("Enter a number less than 10 ") if int(num) <= 5: print("please guess higher than 5") num = input() if int(num) >= 5: print("Well done") else: print("Your are still short of no") else: print("Your chosen number is " + num) print("Well done")
5dbacdbecdff023d6a5b3e221a0040aab73fc95e
ksenialearn/HackRank
/weekofcode-cookie_party.py
623
3.625
4
You're having a cookie party tonight! You're expecting m guests and you've already made n cookies. You want to distribute all the cookies evenly between your guests in such a way that each guest receives the same number of whole cookies. If there are not enough cookies to give everyone the same amount, you must make s...
3a0f29f2d3ff5180b65313c25ef5c8b51aa2469e
jp-git1986/pythonnumadd
/numadd.py
162
3.75
4
#!/usr/bin/python import sys sum = 0 num1=int(sys.argv[1]) num2=int(sys.argv[2]) sum = num1 + num2 print('The sum of {0} and {1} is {2}'.format(num1, num2, sum))
c37da23937471ee4332a24ca62f2763b7c9b3588
th28/easyflow
/graphs.py
430
3.6875
4
import numpy as np class DirectedGraph: """Simple data structure to model a directed graph""" def __init__(self, nodes={}, edges={}): self.nodes = nodes self.edges = edges def __str__(self): return str(self.edges) def add_node(self, name, value): self.nodes[name] = v...
513f822ef30237e322ce5ffcc8ee9424b70efce3
AnanduR32/data-structures
/Dynamic Programming/HowSum/solution.py
581
3.609375
4
def howSumMemo(target, values,memo = {}): if(target<0): return(None) if(target==0): return([]) if(target in memo): return(memo[target]) for val in values: new_target = target-val res = howSumMemo(new_target,values,memo) if(res!=None): ...
15b0e4f4c1dc1827a9e581c3e414aaf2f181c3ed
nedervold/visibly-happy
/GenCode.py
2,124
3.53125
4
#!/usr/local/bin/python3 from typing import List # MONAD = "Reader" MONAD = "State" PARAM = MONAD[0] def generic(i: int) -> str: return chr(i + ord("A")) def arg(i: int) -> str: return chr(i + ord("a")) def arg2(i: int) -> str: return arg(i) + "2" def generics(i: int) -> List[str]: return [gene...
24435ee8502fc7adf677803e29eb0b22cee9ca57
YChaoZ/python
/venv/bin/__my__.py
597
3.6875
4
#参数类型 普通参数 关键字参数 默认参数 收集参数 #收集参数 def tel(*args): print("自我介绍:") print(type(args)) for item in args: print(item) #args为list数组,不能使用关键字参数 tel("liuying", 18, "北京大通州区", "wangxiaojing", "single") #普通参数 tel()#默认参数 #收集参数 def my(**kwargs): print("自我介绍:") print(type(kwargs)) for k,v in kwargs.i...
3bacebb48434e79c9334b4e85de40f6686f6acbc
aligol1/beetroot111
/lesson24.py
2,204
4.09375
4
#Lesson 24 task 2 Implement a stack using a singly linked list. class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.head = None def isempty(self): if self.head == None: return True else: ...
2853c45cb2b7883d73a62a288916aa026c6db2be
aligol1/beetroot111
/lesson37.py
1,421
4.59375
5
"""Task 1 Create a table Create a table of your choice inside the sample SQLite database, rename it, and add a new column. Insert a couple rows inside your table. Also, perform UPDATE and DELETE statements on inserted rows. As a solution to this task, create a file named: task1.sql, with all the SQL statements you h...
69eaa079f4ad20db8c19efa7af08adcdcf174e1a
aligol1/beetroot111
/lesson14.py
2,240
4.65625
5
"""Lesson 14 Task 1 Write a decorator that prints a function with arguments passed to it. NOTE! It should print the function, not the result of its execution! For example: "add called with 4, 5" def logger(func): pass @logger def add(x, y): return x + y @logger def square_all(*args): return [arg ** 2 fo...
72a5b84b6f409f3987a9c5e2b6c2ab189c913684
Gwinew/To-Lern-Python-Beginner
/Tutorial_from_Flynerd/Lesson_6_conditionalstatement/adult_if.py
229
4.09375
4
age = int(input('How old are You?')) if(age>100): print("This is realy your age?") if(age>=18): print("You are adult") else: print("You have a bit of legal age\nExactly you have {} years to be adult".format(18-age))
dee27fd688a682c9b84d9e7b98035d3c8584de6d
Gwinew/To-Lern-Python-Beginner
/Pluralsight/Beginner/Core_Python_Getting_started/Module_9/6_Iteration_tools.py
1,543
4.09375
4
# Iteration Tools # # ################# # itertools.islice() # # - Perform lazy slicing of any iterator. # - from itertools import islice # islice(all_primes, 1000) ################# # itertools.count() # # - An unbounded arithmetic sequence of integers. # from math import sqrt def is_prime(x): if x < 2: ...