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
c6b7b9de260949fbf77a4440d6ea2bc8b1582c89
wabain/tact
/src/tact/agent/__init__.py
843
3.8125
4
"""Support for agents which handle the gameplay of a given player""" from __future__ import annotations from abc import ABC, abstractmethod from typing import Optional from ..game_model import GameModel, Move __author__ = "William Bain" __copyright__ = "William Bain" __license__ = "mit" class AbstractAgent(ABC): ...
d066b5f153c401f14ec6c7a8ee2e18922831b76d
josiegit/untitled1-
/testing/test_yield.py
190
3.640625
4
# -*- coding:utf-8 -*- #yield+函数==生成器 def provider(): for i in range(5): yield i #生成器:return i + 暂停 p=provider() print(next(p)) print(next(p)) print(next(p))
4df75339e297a06764078b076354d165b5c48af2
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/etwum/lesson02/series.py
3,258
4.40625
4
def fibonacci(n): # this function finds the nth integer in the fibonacci series # fibonacci series ....0, 1, 1, 2, 3, 5, 8, 13 # the next integer is determined by summing the previous two # starting two numbers of the fibonacci series (0 and 1) x = 0 y = 1 # adds the starting two numbers ...
a2c6576ad8fde1230432eee02146f142ec2a4b85
MarioViamonte/Curso_Python
/exercicio/exercicio1.py
925
4.3125
4
""" faça um programa que peça ao usuário para digitar um número inteiro, informe se este número é par ou ímpar. Caso o usuário não digite um número inteiro, informe que não é número inteiro. """ numero_inteiro = input('digite um numero inteiro: ') if numero_inteiro.isdigit(): # checar se pode converter a string para ...
11a847f35b6f8b035907c5725667013bb975e067
reveo/TKOM
/Python/POS/for.py
98
3.796875
4
For I in range(0,10): a = 5; a = "abc"; b = a; print(b); for J in range(2): print("Hello");
9f8d32d49274367e6d6177a47581dad6a6e9c6a4
hbyyy/TIL
/study/python_100quiz/quiz52.py
1,648
3.84375
4
# def qsort(num_list): # num_list_len = len(num_list) # if num_list_len <= 1: # return num_list # pivot = num_list.pop(num_list_len // 2) # num_list_front = [] # num_list_back = [] # # for i in range(num_list_len - 1): # if num_list[i] < pivot: # num_list_front.appen...
933046baeeeb0122a68c290202beb29b197d36cb
MadSkittles/leetcode
/318.py
540
3.5
4
class Solution: def maxProduct(self, words): w = {} for word in words: w[word] = set(word) max_product = 0 for i in range(len(words) - 1): for j in range(i + 1, len(words)): if not w[words[i]].intersection(w[words[j]]): max_...
d3d3b33b40cb1b3cbff98e1562e2a9538ca9919e
tachajet/IS211_Assignment7
/pig_game.py
3,192
4.0625
4
from random import randint,seed import argparse seed(0) class Dice: """ This program unfortunately does not work as I'd hoped, but at least I think I can explain why """ @staticmethod def roll(): return randint(1, 6) class Player: """ Dice and Player classes are OK, I think ""...
48a04a8770191c3f3c51c5899eeaa1bc10f8bf1d
vamshiderdasari/5363-CRYPTOGRAPHY-vamshiderdasari
/Vamshider.Dasari.Elliptical/elliptical.py
1,537
4.40625
4
############################################### # Name: Vamshider Reddy,Dasari # Class: CMPS 5363 Cryptography # Date: 04 August 2015 # Program 3 - Elliptical Curve. ############################################### ##including header files import string import argparse import random import sys from pprint import pprint ...
e02f9db4512aab24cd8b6dbed60025e944154ee8
a87150/learnpy
/starred_expression.py
1,439
3.9375
4
def one(a,*b): # a是一个普通传入参数,*b是一个非关键字星号参数 print(b) one(1,2,3,4,5,6) #-------- def two(a=1,**b): # a是一个普通关键字参数,**b是一个关键字双星号参数 print(b) two(a=1,b=2,c=3,d=4,e=5,f=6) def three(*x): # 输出传入的第一个参数 print(x[0]) lst={"a","b","c","d"} stri="www.pythontab.com" three(stri,lst) three(lst) three(*stri) d...
b89e13baef9e8e357181ba1c2c146e4b55d8fc50
rafaelperazzo/programacao-web
/moodledata/vpl_data/129/usersdata/149/44333/submittedfiles/al7.py
193
3.71875
4
# -*- coding: utf-8 -*- n=int(input('digite o valor de n:')) i=0 soma=0 for i in range(1,n,1): if n%i==0: j=n//i+i print(i) soma=soma+i if j==n: print(PERFEITO)
45a620b302549c9a3dc494794b0fb91107eb01d6
trigodeepak/Programming
/Recursively_remove_duplicates.py
332
3.53125
4
#Program to recursively remove all the same arrays a = 'geeksforgeeg' a = list(a) l = len(a) i = 0 while(i<l-1): if a[i] == a[i+1]: s = i a.pop(i+1) l-=1 while(i+1<l and a[i]==a[i+1]): a.pop(i+1) l-=1 a.pop(i) l-=1 i-=2 i+=1 print ...
e3d7fd79863b8438f5aaef3fcbda61641c80ca37
zuxinlin/leetcode
/leetcode/268.MissingNumber.py
939
4.09375
4
#! /usr/bin/env python # coding: utf-8 ''' Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Input: [3,0,1] Output: 2 Example 2: Input: [9,6,4,2,3,5,7,0,1] Output: 8 连续整数数组,其中丢失一个数字,求丢失的数字 1. 求和 2. 异或 ''' class Solution(object): ...
a3b578691ab55d88165cb522ba6e873c8931de35
RyoWakabayashi/hello-worlds
/python/scripts/hello_branch.py
265
3.53125
4
""" Say hello. """ __author__ = "RyoWakabayashi <gfdmkm573@gmail.com>" __version__ = "1.0.0" __date__ = "2021/04/20" HELLO_WORLD = "Hello, world!" if HELLO_WORLD == "Good morning": print("morning") elif "Hello" in HELLO_WORLD: print("noon") else: print("night")
68df6a2a5cbb0980afb6ddff3df84a6a292804a3
Gabriel-ino/python_basics
/adivinhação.py
356
3.90625
4
from random import randint from time import sleep b = randint(0, 5) a = int(input('Vou pensar em um número inteiro entre 0 e 5, tente adivinhar qual é!\nDigite:')) print('Vamos ver...') sleep(2.0) if a == b: print('Você acertou! Eu pensei exatamente {}!'.format(b)) else: print('Que pena! Você errou, o número em...
f9e19a575fea26dd85ec24fc800f922bbbb3f8f1
messaoudi-mounir/orientation_tool
/lib/mlModel.py
2,913
3.5625
4
# coding=utf-8 import numpy as np import scipy as sp import pandas as pd from abc import ABC, abstractmethod class AbstractMLOperator(ABC): """Python ABC class""" def __init__(self,dt): self.dt = dt self.nchannel=None self.ntStep=None # super.__init__(self) @abstractmethod...
ac33fd47a31c45afcc32a02a39cc1a2063714ad5
haavardsjef/NTNU
/TDT4110 - Informasjonsteknologi, grunnkurs/Oving2/Betingelser.py
1,051
4.03125
4
#Generelt om betingelser av Håvard Hjelmeseth , Øving 2 ITGK x = float(input("Skriv inn ditt første tall: ")) #Første tallvaribel, input av bruker y = float(input("Skriv inn ditt andre tall: ")) #Andre tallvariabel sum = x + y #Summerer første og andre tallvariabel og lagrer i en variabel sum prod = x * y #Tar ...
fb37930b7e0ceebc5fb1b364d88765f3c77409dd
w8833531/mypython
/other/function/dict.py
224
4
4
#!/usr/bin/env python # -*- coding utf-8 -*- d = {'Michael': 95, 'Bob': 75, 'Tracy': 85} print d['Bob'] c = {'Larry': 95, 'Abe': 97, 'Lee': 99} print c['Lee'] c['Lee'] = 97 print c['Lee'] a = d d.pop('Bob') print d print a
ba2dd51b3e9b73bd712571684f651519956fff82
guangyw/algo
/mergeIntervals.py
647
4
4
""" Definition of Interval. class Interval(object): def __init__(self, start, end): self.start = start self.end = end """ class Solution: """ @param intervals: interval list. @return: A new interval list. """ def merge(self, a): # write your code here a.sort(key ...
609ed1e7ef4f87bb82c1a0845eba530f5bb52e7e
gaurapanasenko/unilab
/06/ZI_Lab2/vigener.py
1,935
3.921875
4
#!/usr/bin/python import sys ALPHABET = ([chr(ord('а') + i) for i in range(0, 32)] + [chr(ord('a') + i) for i in range(0, 26)] + [" "]) ENCRYPT = 2 DECRYPT = 4 def main(): """Main function.""" dothing = 0 for arg in sys.argv[1:]: if arg == "--encrypt": dothing = dothing ...
05e563150e8bf14d300cea41eda4fc71c69c14d8
VinayHaryan/String
/q13.py
1,602
4.375
4
''' PRINT THE INITIALS OF A NAME WITH LAST NAME IN FULL given a name, print the initials of a name(uppercase) with last name(with first alphabet in uppercase) written in full separated by dots Examples: Input : geeks for geeks Output : G.F.Geeks Input : mohandas karamchand gandhi Output : M.K.Gandhi ...
55cb6274444d63ea3b7724784685fafc4bc9597f
Acova/Medieval_Construction_Manager
/building_level.py
1,420
3.5625
4
class BuildingLevel: """All the data in a building level""" def __init__(self, name, settlementType, buildingConditions, convert_to, buildingCost, upgrades, capabilities): self.name = name self.settlementType = settlementType self.buildingConditions = buildingConditions self.con...
07100da452d2c0fb249d1255b426bc9951b71043
zzz136454872/leetcode
/isRectangleCover.py
1,615
3.703125
4
from typing import List class Solution: def isRectangleCover(self, rectangles: List[List[int]]) -> bool: def area(rec): return (rec[3] - rec[1]) * (rec[2] - rec[0]) nodes = {} totalArea = 0 for rec in rectangles: nodes[(rec[0], rec[1])] = nodes.get((rec[0]...
ecade0666baa69442fbf9f6ba238c416fe894d70
evaristrust/Courses-Learning
/DSFIRST/PANDAS/Dataframe.py
621
3.65625
4
import numpy as np import pandas as pd from pandas import Series, DataFrame data = pd.read_clipboard() print(data) print(data.columns) new_names = ['date', 'expenses', 'amount', 'iou', 'receipt', 'paid'] new_data = data.set_axis(new_names, axis='columns') print(new_data) print(new_data['expenses']) analysis = new_dat...
f337d07d74a97c032ce8883c4a7d1740a023744a
sue0805/Algorithm_BJ_Python
/SWExpertAcademy/desertCafe.py
1,676
3.5625
4
import sys cafes = list() result = -1 def cafe_tour(x, y, cnt, visited, home, size, direction): global result if x == home[0] and y == home[1] and len(visited) != 0: result = max(result, cnt) return if cafes[x][y] in visited: return if y != home[1] and x == home[0]: re...
6437d3b6dab4ae399a6d513471d602ee305e0ff4
kwonseongjae/p1_201611055
/w7main_3.py
937
3.5
4
def saveTracks(): import turtle wn=turtle.Screen() t1=turtle.Turtle() t1.speed(1) t1.pu() mytracks=list() t1.goto(-370,370) t1.rt(90) t1.pd() mytracks.append(t1.pos()) t1.pencolor("Red") t1.fd(300) t1.lt(90) mytracks.append(t1.pos()) t1.fd(400) t1.lt...
c46f2d79056ad4493fb7420954c1f5142936c91f
junthbasnet/Project-Euler
/ProjectEuler #2[Even Fibonacci Numbers].py
405
3.859375
4
#!/usr/bim/python #Author@ Junth Basnet #Mathematics(Fibonacci numbers) #Time Complexity:O(28*T) #Formula:f(n)=f(n-1)+f(n-2) #Even Numbers:E(n)=4E(n-1)+E(n-2) import sys def fibonacci(max=4*10**16): a,b=0,1 while(a<max): yield a a,b=b,a+b fib=[] for i in fibonacci(): if i%2==0: fib.append(i) for i in ran...
7c756475384bf25924ced95045ef06c202188f51
mkvenkatesh/Random-Programming-Exercises
/contiguous_subarray_count_start_end_index.py
1,809
3.875
4
""" Contiguous Subarrays You are given an array arr of N integers. For each index i, you are required to determine the number of contiguous subarrays that fulfills the following conditions: The value at index i must be the maximum element in the contiguous subarrays, and These contiguous subarrays must either ...
49e4f2a8780e922fea900fc7ea102e49d57e6849
iulidev/code
/ternary.py
323
3.78125
4
# Ternary if-else operator # value_true if condition else value_false numar = 6 paritate = 'par' if numar %2 == 0 else 'impar' print('Numarul', numar, 'este ', paritate) pret_maxim_de_achizitie = 30 pret_actual = 40 print('Achizitia este aprobata' if pret_actual<=pret_maxim_de_achizitie else 'Achizitia este suspendat...
34dc5c73629cc005bd3276b74876509c0c9e6ff0
tzxyz/leetcode
/problems/0009-palindrome-number.py
1,218
3.65625
4
class Solution: """ 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 示例 3: 输入: 10 输出: false 解释: 从右向左读, 为 01 。因此它不是一个回文数。 进阶: 你...
d467529bdb8f32a0c038d9ecd3c916f8f6c2e9d7
33percent/python-DSA
/problems/leet_code_8.py
1,293
4.125
4
""" Given two arrays of integers nums and index. Your task is to create target array under the following rules: Initially target array is empty. From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array. Repeat the previous step until there are no elements to read in n...
ebba0ce712495e0c6072fe021c2f69bbf826b36a
pavelkang/pomodoro
/draw.py
951
3.734375
4
# This is used to draw the vector map of GHC7 using GHC7_vector.txt # Author: Kai Kang import matplotlib.pyplot as plt fig = plt.figure(figsize=(5,4)) ax = fig.add_subplot(1,1,1) def getVectors(filename="GHC7_vector.txt"): start_points = [] end_points = [] with open(filename, 'r') as f: for li...
93a15537b29d73d9ec01ccc6989d5bfa7d3e9f8b
eastglow-zz/kky2413
/과제2 2번.py
150
3.671875
4
def int_sum(arg1): b=0 for i in arg1: if i.isdigit(): b=b+int(i) return int(b) c=int_sum('sh452 ?sf56d') print(c)
6f02cb6349f29842a7b541b115191f15d1bd72be
Cperbony/intensivo-python
/cap4/exercise_4.py
597
4.15625
4
for value in range (1, 20): print(value) one_million = list(range(1, 10000)) print(one_million) print(min(one_million)) print(max(one_million)) print(sum(one_million)) odd_numbers = list(range(1, 20, 2)) print(odd_numbers) multiple_of_threes = list(range(3, 31, 3)) print() print("List of multiples of 3") for nu...
9c4cf2192c5eec5854dc1eeca9cde409b7590529
Barathnatrayan/Barath-Repository
/calculator.py
1,169
4.1875
4
def add(num1,num2): """Adddition funcction""" return num1+num2 def sub(num1,num2): """Substractoin funcction""" return num1-num2 def mul(num1,num2): """Multiplication funcction""" return num1*num2 def div(num1,num2): """Division funcction""" return num1/num2 """Displa...
09819c86e4f3b4e31bc89e514268faff6cb355ed
eldss-classwork/nlp-sandwich-shop
/sandwich.py
2,289
4.125
4
import sandwichlib as sl def main(): '''Gets an order from a customer, records the order, and confirms it is correct.''' # Init the shop shop = sl.SandwichShop("Evan's Sandwich Shop") # Greet the customer shop.greeting() while True: # Ask if they want to see a menu affirmati...
6d7fee281b5d47521b1f77e108e49efc4efdb882
PeterTheOne/epu-accounting
/functions_db.py
2,684
3.921875
4
import sqlite3 from sqlite3 import Error def create_connection(db_file): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object or None """ try: conn = sqlite3.connect(db_file) return conn ex...
22b2039a358fba167b4796652c355868985d3865
brandonhong/Cryptopals-Challenge
/Set 1/s1c6.py
4,683
3.859375
4
# -*- coding: utf-8 -*- """ Created on Sat Jun 9 11:34:31 2018 @author: Brandon Set 1 Challenge 6 Set 1 challenges available on https://cryptopals.com/sets/1 The goal of this challenge is to decipher the ciphertext given in a text file format. The file is based 64'd AFTER being encrypted by some repeating...
de63233ccfa4316b7016111a6d83d3e9e284d0ec
Sookmyung-Algos/2021algos
/algos_assignment/2nd_grade/김가영_kijh30123/week3/1920.py
450
3.734375
4
import sys def binary_search(num): left=0 right=len(arr) while left<right: mid=(left+right)//2 if arr[mid]<num: left=mid+1 elif arr[mid]==num: return 1 else: right=mid return 0 N=int(input()) arr=list(map(int,sys.stdin.readline().spli...
4d51b0449ec3feebdf05210f151bf99be95c8f15
tanajis/python
/problems/dutchNationalFlagProblemAlgorithm.py
2,783
3.8125
4
############################################################################## # This problem was asked by Google. # Given an array of strictly the characters 'R', 'G', and 'B', # segregate the values of the array so that all the Rs come first, the Gs come second, and the Bs come last. # You can only swap elements of...
f2393231b3b843b9624bb09160ae4201ce8ecd5c
CerzBbz/daily-programmer
/closest_string/closest_string.py
1,048
3.59375
4
# /r/DailyProgrammer # [2018-03-05] Challenge #353 [Easy] Closest String # https://www.reddit.com/r/dailyprogrammer/comments/826coe/20180305_challenge_353_easy_closest_string/ # Author: CerzBbz def get_input(): with open('inputs.txt', 'r') as file: data = [line.strip() for line in file.readlines()] ...
0c63ccdee5dd9d10eec6f4972dafd53f21439f42
MobyDick69/python_work
/test_vscode_5.py
2,797
3.6875
4
############################ Reading a txt file ############################### file = 'C:\\Users\\andre\\Documents\\python_work\\files\\py_digits.txt' with open(file) as file_obj: for line in file_obj: print(line.rstrip()) ############################################################################### ###...
f645fbdf69d33c5130e8dab0327c3055c32244e2
dungruoc/GeeksforGeeks
/DynamicProgramming/longest_common_substr.py
1,232
3.75
4
#!/bin/env python import sys # Returns length of longest common # substring of X[0..m-1] and Y[0..n-1] def LCSubStr(X, Y): m = len(X) n = len(Y) # Create a table to store lengths of # longest common suffixes of substrings. # Note that LCSuff[i][j] contains the # length of longest common suffix o...
d4fecfd9aa79660a4008880962653fe15ab72fa9
ben-nathanson/miscellaneous
/pacer.py
746
3.90625
4
from time import sleep def format(d) -> str: return str(int(d)).zfill(2) time_in_minutes = int(input("How many minutes long is your exam?\n")) number_of_questions = int(input("How many questions are on the exam?")) if number_of_questions <= 0: exit() if time_in_minutes <= 0: exit() pace = time_in_minute...
f3f5ad10e1b6ea39dac1d0f2a5a009e4301c40c1
BrotherB1/343-Zork
/Bar.py
370
3.65625
4
import random """Class for Chocolate Bar. Uses basic getters. Created by Luke Bassett Fall 2017""" class Bar: def __init__(self): self.use = 4 self.mult = 0 def used(self): self.use = self.use - 1 def getMult(self): self.mult = random.uniform(2.0, 2.4) return self.mult def getUse(self): return s...
20cb5a6781b564b50af55ada697248a5c515c372
liyangjie110/weiboProject
/test03.py
876
3.71875
4
# -*- coding: utf-8 -*- import random print "hello,test!" #random 方法生成0-1之间的浮点数 print random.random() #uniform(1,10) 指定范围内的随机浮点数 random.uniform(1,10); #randint(1,10)指定范围内的随机整数 random.randint(1,10) li=["苹果","柚子","香蕉"] li[random.randint(1,2)] num = 20 i=0 while i<3: b = input("请输入数字:") if b == num: p...
5b54d69790c6d524c1b253b8bec1c32ad83c4bf8
LoktevM/Skillbox-Python-Homework
/lesson_011/01_shapes.py
1,505
4.25
4
# -*- coding: utf-8 -*- # На основе вашего кода из решения lesson_004/01_shapes.py сделать функцию-фабрику, # которая возвращает функции рисования треугольника, четырехугольника, пятиугольника и т.д. # # Функция рисования должна принимать параметры # - точка начала рисования # - угол наклона # - длина стороны ...
8a4f0fb95d0cc2660d18dd66dcf3db3e3d7da704
SuperYIP/PythonCode
/极客晨星/part1/py0232函数的四种类型.py
527
3.578125
4
#coding=utf-8 ''' 课件 ''' # def calculateNum(num): # result = 0 # for i in range(1, num+1): # result += i # return result # # print(calculateNum(50)) # def testB(): # print('----testB start----') # print('此时执行testB') # print('----testB end----') # def testA(): # print('----testA sta...
b7ead8c14c8217fb24333ff5b88d41f11a77d2c4
itsrbpandit/fuck-coding-interviews
/problems/tests/test_camel_case.py
471
3.625
4
# coding: utf-8 import unittest from problems.camel_case import camelcase class TestCase(unittest.TestCase): def test(self): test_data = [ {'input': 'saveChangesInTheEditor', 'expected': 5}, ] for data in test_data: s = data['input'] expected = data['ex...
9653cda2df6106e6205251c7df63c19f9f7e1fb4
asihacker/python3_bookmark
/python笔记/aaa基础内置/类相关/property.py
719
3.953125
4
class Apple: """ debug """ def __init__(self): self._age = None @property def age(self): """ :return: """ return self._age @age.getter def age(self): """ :return: """ print('我被调用了getter') # return f'{sel...
e59be7bf1909ff36c8bc35b1725b433f4751cb1a
nikhilvkn/python
/PythonPrograms:Basic-Advanced/password-manager.py
2,807
3.796875
4
import pyperclip import shelve import sys pwdList = shelve.open('UserPwd') if len(sys.argv) == 2 and sys.argv[1].lower() == '--help': print('Usage: ./passwordSafer.py [-l | -a | -d | -m]') print('-l : to list the entire accounts in database\n-a : to add a new account to database\n-d : to delete an existing account\...
5acaae9d5574c13c3dac229506fe623ba169c2ce
prodahouse/trading.ml
/2016Code/PiazzaCode/#MC1/HWK1/stdev_code.py
759
3.796875
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 20 03:15:00 2016 @author: Owen """ import math as m # calculate the population standard deviation def stdev_p(data): datamean=m.fsum(data)/len(data) result = 0 for i in test: result+=m.pow(i-datamean, 2) result = m.sqrt(result/len(data)) ...
99684d3f327cd662d85f4f4239c882ef3b130bf5
eshthakkar/coding_challenges
/closing_paran_index.py
2,161
4.0625
4
def get_closing_paran_index(sentence, open_paran_index): """ Problem : Return the closing paranthesis index from the input string Complexity Analysis: O(n) time and O(1) space Tests: >>> sentence = "Sometimes (when I nest them (my parentheticals) too much (like this (and this))) they get c...
53eb3207428d63bd3126405e5766142af75bce29
suyeon0610/python
/Module/module_basic01.py
553
3.640625
4
''' * 모듈 임포트 - 모듈은 파이썬 코드를 작성해 놓은 스크립트 파일이며 모듈 안에는 변수, 함수, 클래스 등이 정의되어 있음 - 파이썬에서는 주요 기능들을 표준 모듈로 구성하여 표준 라이브러리로 제공 - 표준 모듈이나 외부 모듈을 현재 모듈로 불러서 사용할 때는 import 사용 ''' import math # pi = 3.14 print(5 * 5 * math.pi) print(math.sqrt(3)) # 제곱근 print(math.factorial(6)) # 6! print(math.log10(2)) print(math.log(3, 4)) pr...
42fca238a25992b2a1e68f8927469716c9dc09a1
PPGY0711/viscourse
/draw_density.py
4,902
3.625
4
# -*- coding:utf-8 -*- """ Created on 2020/11/29 @Author: ppgy0711 @Contact: pgy20@mails.tsinghua.edu.cn @Function: Implement the density Map of Visualization based on MNIST DataSet """ import numpy as np import matplotlib.pyplot as plt from sklearn.manifold import TSNE import scipy.stats as st def pre_handle_images(...
077301af7fe2815de79649f4f28d0b888a8e7902
harman666666/Algorithms-Data-Structures-and-Design
/Other Practice/Crack the Coding Interview Algorithms/Graphs/DirectedGraphs/RouteBetweenNodes.py
3,397
3.859375
4
'''Given a directed graph, design an algorithm to find out whether there is a route between 2 nodes:''' '''This is a directed graph''' A = { 0: [1], 1: [2], 2: [0,3], 3: [2], 4: [6], 5: [4], 6: [5] } CS241Example = { "a": ["b", "c", "d"], "b": ["d"], "d": ["a", "c", "f","e"], ...
9568babdcf2c4bd62a291cc453b39968844bb410
connectheshelf/connectheshelf
/reader/extrafunctions.py
301
3.859375
4
def encrypt(message): message=message.upper() newmess="" for i in message: if(i>='A' and i<='Z'): newmess+=chr(ord('A')+ord('z')-ord(i)) elif(i>='0' and i<='9'): newmess+=str(9-int(i)) else: newmess+=i return newmess.upper()
b73ad5322ac5090651102c3e8ccc0aaabd72ed09
ChenBaiYii/DataStructure
/singleton/singleton.py
368
3.640625
4
#!/usr/bin/python3 # __new__ 实现单例类 class Singleton: def __new__(cls, *args, **kwargs): if not hasattr(cls, "_instance"): orig = super(Singleton, cls) cls._instance = orig.__new__(cls, *args, **kwargs) return cls._instance class MyClass(Singleton): a = 1 a = MyClass(...
078d4c6b8cf633377982d09afc5a4ec3b182f59f
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/rna-transcription/6c9bdc2e91814708b237dcdb97810854.py
329
3.703125
4
class DNA: def __init__(self, seq): self.seq = seq def to_rna(self): rna = '' sequence = list(self.seq) for letter in sequence: if letter == 'A': rna += 'U' elif letter == 'C': rna += 'G' elif letter == 'G': rna += 'C' elif letter == 'T': rna += 'A' else: 'Not valid' retur...
157f329091f074ecd52c62763d3a192cb39d16a5
amrishparmar/Sammy-for-MyAnimeList
/menuinterface/search.py
4,458
3.53125
4
import html import click import requests from bs4 import BeautifulSoup import add def display_entry_details(entry): """Display all the details of a given entry :param entry: an anime or manga entry as a Beautiful Soup Tag object """ for detail in entry.children: # ignore newlines in childre...
46c5c49b6f9c5107b89708b6a4faffeb21006448
AliceDreaming/python_classes
/musicians.py
1,741
3.71875
4
class Musician(object): def __init__(self, sounds): self.sounds = sounds def solo(self, length): for i in range(length): print(self.sounds[i % len(self.sounds)]) # The Musician class is the parent of the Bassist class class Bassist(Musician): def __init__(self): ...
38ba251362f38281ae16948bc13a1e36fa5d3e59
VitaliySid/Geekbrains.Python
/lesson8/task2.py
1,339
4.15625
4
# 2. Создайте собственный класс-исключение, обрабатывающий ситуацию деления на нуль. # Проверьте его работу на данных, вводимых пользователем. # При вводе пользователем нуля в качестве делителя программа должна корректно обработать эту ситуацию # и не завершиться с ошибкой. class ZeroDivisionException(Exception): ...
1974776ae1559db1daba2628f92856ed5303e06b
DNSingh-15/MyProjects
/Email-Collector.pyw
1,024
3.625
4
from tkinter import * import tkinter.messagebox as tmsg import re def collect(): inputValue = text.get("1.0", "end-1c") email = re.findall(r'[\w\.-]+@[\w\.-]+\.\w+', inputValue) for mail in email: print(f"Your email are as follows: {mail}") tmsg.showinfo("Emails", mail) root...
01fcfefc1861b32063c15eed1d0fc752cb90a13c
JustinOliver/ATBS
/2048.py
1,642
3.515625
4
#! python3 # 2048.py - A program to automate the game 2048 from the webpage remotely from selenium import webdriver import time from selenium.webdriver.common.keys import Keys browser = webdriver.Firefox() browser.get('https://gabrielecirulli.github.io/2048/') time.sleep(10) ...
a9ec2f7b017f2e9b26ab325aa7bfd69c0b07565b
mukundajmera/competitiveprogramming
/Circular Linked List/Circular Linked List Insertion At Position.py
1,907
3.890625
4
#User function Template for python3 ''' class Node: def __init__(self, data): self.data = data self.next = None ''' def insertAtPosition(head,pos,data): #code here node = Node(data) if pos == 1 and head == None: node.next = node return node elif pos == 1 and head != ...
d35a2becbe1cfe364da351179d1c3bcc96dee08f
wfgiles/P3FE
/Week 12 Chapter 10/CH 10 slides2.py
1,065
3.90625
4
##counts = {'chuck' : 1, 'annie' : 42, 'jan' : 100} ##lst = counts.keys() ##print lst ##lst.sort() ##for key in lst: ## print key, counts[key] ##------------- ##d = {'a':10, 'b':1, 'c':22} ##print d.items() ## ##print sorted(d.items()) ##-------------- ##SORT BY VALUE ##d = {'a':10, 'b':1, 'c':22} ## ##print d.items...
6b2da7154250f58898b1e8f091aa7a7990ac6609
evarenteronieto/Tutorials
/Python/python/codecademy_itirator_dict.py
2,023
4.40625
4
#Create your own Python dictionary, my_dict, in the editor to the right with two or three key/value pairs. #Then, print the result of calling the my_dict.items(). my_dict= { 'Boyfriend':'Dan', 'Age': '41', 'Race': 'other european' } print(my_dict.items()) #Remove your call to .items() and replace it with a ca...
186881d37c7457ede261461b90c8fc8a6cc55d71
juancho1007234717/EJERCICIOS-PROGRAM
/Ejercicio15
481
3.640625
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 12 16:10:39 2021 @author: juanj """ cal1 = int(input("Ingrese calificacion del primer bimestre:")) cal2 = int(input("Ingrese calificacion del primer bimestre:")) cal3 = int(input("Ingrese calificacion del segundo bimestre:")) cal4 = int(input("Ingrese calificac...
60724e2d545c018e061fb14208830fd2ce101429
Aasthaengg/IBMdataset
/Python_codes/p03712/s735974449.py
215
3.5
4
h, w = map(int, input().split()) s = [list(input()) for i in range(h)] s = [["#"] + i + ["#"] for i in s] s = [["#" for i in range(w+2)]] + s + [["#" for i in range(w+2)]] for i in range(h+2): print("".join(s[i]))
6f811ec8db75e2f2042a2cf19bb8c035cb8a0129
ruanchaves/Zero-Shot-Entity-Linking
/src/toy.py
346
3.625
4
class A(object): def __init__(self, a, b, c): self.a = a self.b = b self.c = c class B(A): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) class C(A): def __init__(self, *args): print(args) super().__init__(*args) c = C(3,4,5) prin...
ecc5cb4b42b6bbe9bb98a7efbff439e0f59a1d42
IvamFSouza/ExerciciosPython
/Exercicio-18.py
733
4.28125
4
# Crie um programa que leia o nome completo de uma pessoa e mostre: # · O nome com todas as letras maiúsculas; # · O nome com todas as letras minúsculas; # · Quantas letras ao todo (sem considerar espaços); # · Quantas letras tem o primeiro nome. nome = str(input('\nDigite seu nome completo: ')).strip() print('+'*22) ...
d8afee215b71970a86e759475dba3ec1d706ee11
Hafswa/birthday
/birthday.py
595
3.984375
4
import calendar name=input('ENTER NAME: ') days=['Monday', 'Tuesday','Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] endings=['st','nd','rd']+17*['th']+['st','nd','rd']+7*['th']+['st'] print('Hey '+name+', I can tell the day of your Birthday') D=input('Enter Day(1-31): ') M=input('Enter Month(1-12): ') Y...
ae30a0bacf43318a3238bd3dde9c7077e7cd360e
jingong171/jingong-homework
/孙林轩/第一次作业/第一次作业 金工17-1 2017310392 孙林轩/体重指数.py
173
3.859375
4
h=1.88 w=72.01 m=h*h t=w/m if t<18: print("为低体重") elif t<=25: print("为正常体重") elif t<=27: print("为超重体重") else: print("为肥胖")
1e45dfc42dbb2a1fc359b88194330459575bc4fb
Soooyeon-Kim/Object-Oriented-Programming
/sample.py
444
3.96875
4
# 9주차 2차시 # 산술 연산자 오버로딩 class SampleClass: def __init__ (self, value): self.value =value def __add__(self, another): result = self.value + another.value return SampleClass(result) def __str__(self): return f'value is: {self.value}' if __name__== '__main__': ...
844c60c667287081736d1daeb45e0958b5d7023a
shunz/Python-100-Days_Practice
/PythonExam/北京理工大学Python语言程序设计-Mooc/Chapter5/5.1.4.py
530
3.96875
4
# 计算 n!//m # 定义可选参数,放在必选参数后面 def fact(n, m=1): s = 1 for i in range(1, n+1): s *= i return s//m print(fact(10)) print(fact(10,10)) # 参数传递的两种方式,函数调用时, # 参数可以按照位置或名称传递 print(fact(m=20,n=10)) # 可变参数传递 # 计算 n!乘数 def fact2(n, *b): s = 1 for i in range(1, n+1): s *= i for ite...
e8e3f76d00d8865efde28d35024f0afe05c220a0
rafaelperazzo/programacao-web
/moodledata/vpl_data/1/usersdata/102/142/submittedfiles/formula.py
119
3.59375
4
p=input('valor de p:') n=input('valor de n:') i=input('valor de i:') v=(p*(1+i)**n-1)/i print('resutado de v:%.2f'%v)
788a516d0a949ea12b6b12d7498cae8555a9fd4a
rajatsachdeva/Python_Programming
/Python 3 Essential Training/08 Operators/boolean.py
881
4.375
4
#!/usr/bin/python3 # Boolean Operators def main(): print("Main Starts !") print("7 < 5 = {}".format(7 < 5)) print("5 == 5 = {}".format(5 == 5)) print("type(True) = {}".format(type(True))) print("True and False = {}".format(True and False)) print("True and True = {}".format(Tr...
5ed759e0742d9f4186da7a41fca2faa1aba5c575
liubaoxing/51reboot
/20150418/8.py
99
3.515625
4
a = range(9) b = [] for i in range(len(a)): b.append(a.pop()) # a.insert(i,a.pop()) print b
dfcc63059496191ccc1280cfaf0c32fea88542aa
PhillipHage202/Python_programs
/near.py
361
3.8125
4
def near (string_main, string_sub): list_parent = list(string_main) for letter in string_main: word_with_letter_removed = string_main.replace(letter, "") if word_with_letter_removed == string_sub: return True return False word1= input("Enter first word:") word2= input("Enter f...
58c88e2d1acb817e7a83c34cf9d97d6658ed6f88
JWilson45/cmpt120Wilson
/credentials.py
1,232
4.15625
4
# CMPT 120 Intro to Programming # Lab #4 – Working with Strings and Functions # Author: Jason Wison # Created: 2018-02-20 def FirstandLast(): first,last = input("Enter your first name: "),input("Enter your last name: ") first,last = first.lower(),last.lower() return [first,last] def username(first,last): ...
539371616d7ded4cb5adfdc94c8c2f2b2b4907a4
adwanAK/adwan_python_core
/think_python_solutions/chapter-09/exercise-9.4.py
2,032
4.40625
4
#!/usr/bin/env python # encoding: utf-8 """ exercise-9.4.py Write program with a function that will accept user-entered list of required letters and a word, and return True if the word doesn't use only the required letters, and False if it does. Created by Terry Bates on 2012-09-16. Copyright (c) 2012 http://the-awes...
cff2894eb92fb79764b5b117272322ba741b6f0e
hrishikeshtak/Coding_Practises_Solutions
/hackerrank/si/graph/si-longest-path-in-graph-brute-force.py
1,024
3.671875
4
#!/usr/bin/python3 # BFS with distance array |V|*(|V| + |E|) from collections import defaultdict class Graph: def __init__(self, N, M): self.G = defaultdict(list) self.V = N self.E = M def insert(self, u, v): self.G[u].append(v) self.G[v].append(u) def length_of_...
459a27fe620e442782ee75f434ff5384b34cc262
asferreir/CursoEmVideo
/Exercicios/ex007.py
282
3.90625
4
""" DESENVOLVA UM PROGRAMA QUE LEIA AS DUAS NOTAS DE UM ALUNO E MOSTRE SUA MEDIA. """ nome = input('Nome do Aluno: ') n1 = float(input('Informe Nota 1: ')) n2 = float(input('Informe Nota 2: ')) media = (n1 + n2) / 2 print('A media do Aluno {}, é = {}.'.format( nome, media))
bbec07f472f90c7adcd799a91ae01f2789733bfa
ShawnDong98/Algorithm-Book
/leetcode/python/74.py
1,033
3.75
4
import bisect from typing import List class Solution: def searchMatrix_v20220405(self, matrix: List[List[int]], target: int) -> bool: if not matrix: return False for row in matrix: ret = bisect.bisect_left(row, target) if ret < len(row) and row[ret] == target: ...
89a2a8bb4638493f1af993a622a97962cffbef25
uccser/codewof
/codewof/programming/content/en/prime-numbers/solution.py
378
4.25
4
number = int(input("Enter a positive integer: ")) if number < 2: print('No primes.') else: print(2) for possible_prime in range(3, number + 1): prime = True for divisor in range(2, possible_prime): if (possible_prime % divisor) == 0: prime = False ...
4ab27467f210f24ce2a014df07030b9c3c71550d
angolpow/gbhw
/Python/05/Task3.py
1,398
3.75
4
""" 3. Создать текстовый файл (не программно), построчно записать фамилии сотрудников и величину их окладов (не менее 10 строк). Определить, кто из сотрудников имеет оклад менее 20 тыс., вывести фамилии этих сотрудников. Выполнить подсчет средней величины дохода сотрудников. Пример файла: Иванов 23543.12 Петров 13749....
b59ece29eb816299e950931ecb0432e1c2f98928
sgrade/pytest
/leetcode/design-underground-system.py
1,157
3.59375
4
# 1396. Design Underground System # https://leetcode.com/problems/design-underground-system/ class UndergroundSystem: def __init__(self): self.checkins = {} self.averages = {} def checkIn(self, id: int, stationName: str, t: int) -> None: self.checkins[id] = [stationName, t] def c...
f09e95db9ecad205a682a00d4574c3a2f02e9bf7
egraven14/portfolio
/Euler 1
289
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 16 17:55:32 2019 @author: eric """ result = 0 num = 0 while num < 1000: if num%3 ==0 or num%5 == 0: result = result + num num = num + 1 else: num = num + 1 print (result)
9230fce167659cef98fc8cee08ba06f3239c8fcf
nsunga/CMSI_485_Artificial_Intelligence
/homework-2/MazeClause.py
6,102
3.609375
4
''' AUTHOR: NICK SUNGA MazeClause.py Specifies a Propositional Logic Clause formatted specifically for Grid Maze Pathfinding problems. Clauses are a disjunction of GridPropositions (2-tuples of (symbol, location)) mapped to their negated status in the sentence. ''' import unittest class MazeClause: ...
95d521b8ea1adee8a0012d1d4109c9ffcc35227e
JerryHDev/Functional-Programming
/Chapter 8/8_9.py
1,038
4.0625
4
#Jerry Huang #Period 4 def main(): print("This program computes the fuel efficiency of a multi-leg journey.") print("Exit the program by pressing the <Enter> key.") odometer = eval(input("Enter the starting odometer reading: ")) x = 1 gas = 0 total_gas = 0 user_input = input("Enter the curr...
a7844f2f3d095e4d84b212d28332d3de20ff69a7
Saradippity26/Beginning-Python
/lists.py
1,095
4.1875
4
""" Learn about lists: regular python does not have arrays it has lists. reason hard to explain an array to non coders. List is easier to explain. performance wise arrays do better than lists because the size is set and you are not constructing and destructing objects all the time. Unlike lists, lists are mutable (can ...
edf78ee62578bd56ba859b869e49873c3dd49b90
HugoPorto/PythonCodes
/PythonZumbis/lista2/questao07.py
223
3.6875
4
area_pintar = input("Tamanho da area a ser pintada: ") litros = area_pintar / 3.0 if (litros / 18) > 0: latas = int((litros / 18) + 1) else: latas = int((litros / 18)) print "Total de latas necessarias: ", latas
e353075bf68189741316043c309e36a98deac6f8
rostun/ittyBitty
/intro/intro101.py
6,105
4.25
4
""" Using Python 3.4.0 """ #python intro101.py print("Hello") my_int = 7 my_float = 1.23 my_bool = True my_int = 3 print (my_int) #function def spam(): eggs = 12 return eggs print (spam()) #adding count_to = 100 + 10 print (count_to) #exponent eggs = 10 ** 2 print (eggs) #modulo spam = 101%100 print (s...
451b9fc012e61d7d5f37d5223fc3d01c1c7abb1f
Rika321/Snake
/model/board.py
520
3.703125
4
from random import randint class Board: UP = ( 0, -1) DOWN = ( 0, 1) LEFT = (-1, 0) RIGHT = ( 1, 0) def __init__(self, height, width): self.width = width self.height = height self.food = [2, 2] def new_food(self, cells): new_food = [randint(1, self....
96f96ab222284dc1c5ce6e51465037d487699af1
LeonGrund/EPX-JAM-2017-Demo
/hackerrank/trees.py
1,006
3.6875
4
#import treeOperations class Tree: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def __str__(self): return (str(self.data)) class Operations: def preOrder(root): pre = '' if (root is None): ...
7e5e63931b402bbeef9c1b038cf4be69263f237f
pbhandaru/Hacker_Rank_Programming_Exercises
/lists.py
449
3.75
4
#!/usr/bin/python ################ N = int(raw_input()) i = 0 L = [] while i <= N: F=raw_input().split() i += 1 if F[0] == 'insert': L.insert(int(F[1]), int(F[2])) elif F[0] == 'append': L.append(int(F[1])) elif F[0] == 'print': print L elif F[0] == 'remove': L.remove(int(F[1])) elif F[0...
837f6e6d2610fb529e3ab6470bc39f9bcb90796f
abhishekshanbhag/Design-By-Software-HW-Files
/Week_4/w4_polynomial.py
5,371
3.765625
4
# AUTHOR Abhishek Shanbhag anshan@bu.edu # AUTHOR Ziteng Xu zxu83@bu.edu class Polynomial(): def __init__(self, sequence = []): self.sequence = dict({}) for i in range(len(sequence)): if(sequence[i] != 0): self.sequence.update({len(sequence) - 1 - i:sequence[i]}) #self.max = len(sequence) - 1 #self.min ...
ea6a68681509029b162146b208acba28a39948ad
msGenDev/bioinformatics_algorithms
/approximate_pattern_matching_problem.py
740
3.90625
4
## Python function to find all starting positions where Pattern appears as a substring of Text with at most d mismatches ## given strings Pattern and Text along with an integer d. def find_pattern(p, q, d): count = 0 for x, y in zip(p,q): if x != y: count = count + 1 if count > d: ...
a822556316b285d494e26bb89c3149e82935d3b9
Schrodingfa/PY3_TRAINING
/day3/for_demo/ex12.py
453
3.59375
4
# 累加1 -- 100 之间 能被3整除的整数和 # count = 0 # for i in range(100): # if not ( i + 1 ) % 3 : # count += ( i + 1 ) # else: # continue # print(count) # count = 0 # for i in range(1, 100): # # 如果满足条件则累加 # if not i % 3 : # count += i # print(count) count = 0 for i in range(1, 100): #...
434813f98c2b1ad3f21a33fbc044b845d7503b00
elise-baumgartner/Python-Sleuth
/src/timer.py
3,202
3.53125
4
import time from logger import Logger from globals import Globals class Error(Exception): pass class TimeError(Exception): def __init__(self, message): self.message = message class Timer: def __init__(self, name): self.name = name self.start_time = 0.0 self.stop_time = ...