blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a612118878a2c7c3a5ea5f26cb6ab025fdceb804
Sirdan247/A_to_Z_ML
/Templates/KMeans.py
1,472
3.640625
4
# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing dataset with pandas dataset = pd.read_csv('Mall_Customers.csv') dataset.head() X = dataset.iloc[:,[3,4]].values # Using the elbow method to find the optimal number of clusters from sklearn.cluster import KMean...
c9621d3f5799b82458b3d9f5fe32d4419f2def7f
Bunty-Bot/Codechef-Problems-
/HelpingChef.py
1,171
4.21875
4
Question: Write a program, which takes an integer N and if the number is less than 10 then display "Thanks for helping Chef!" otherwise print "-1". Input: The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N. Output: For each test case, output...
8d8385f84f3ce45173e7b283ead06db8e9f8e08e
TechKrowd/sesion1python_03062020
/cadenas/04.py
245
4.03125
4
""" Pedir dos cadenas por teclado y comprobar si la primera es subcadena de la segunda. """ cad1 = input("Introduce la primera cadena: ") cad2 = input("Introduce la segunda cadena: ") print("Cadena encontrada: {}".format(cad2.find(cad1)!=-1))
8bf9c69cd6128261cc38ca2f7634438466bd1a78
jeankyj/dsp-assignment3
/src/data.py
2,391
3.734375
4
# To be filled by students import streamlit as st from dataclasses import dataclass import pandas as pd @dataclass class Dataset: name: str df: pd.DataFrame def get_name(self): """ Return filename of loaded dataset """ return self.name def get_n_rows(self): """ Return number of r...
2b6b39f1b8c5b033dcc9b2422acdc8eadcb660ba
ariser/Innopolis
/y3s1/DSA/bucket_sort/countingsort.py
635
3.703125
4
def _sort(source, min_v, max_v): if source is None or len(source) == 0: return if min_v > max_v: raise ValueError("min can't be bigger than max") counter = [0 for i in range(min_v, max_v + 1)] for item in source: counter[item - min_v] += 1 write_index = 0 for i in ran...
db3605d03f3172e362d920326cb38597c8aaa59e
olawalejuwonm/Capstone-Projects
/Monsuru Lawal - Hotel Management System.py
7,802
3.75
4
from datetime import datetime import string import random import time from pprint import pprint from sys import exit name,number,mail,address,Night,code,details,database,price,Atm,Price,pincode,Roomcode,My_select,rum= "Admin","08162210489","","No 17, Surulere. Soka, Ibadan","","",{},{"Admin" : {"Name" : "Monsuru", "Nu...
9e9b5339a7e55399b95fa88f7763f74877497db7
bogwien/mipt_labs
/3_turtle/1_for_odd_or_even.py
448
4.25
4
# Для каждого положительного числа, меньшего n, напечатайте odd, # если число является нечётным, и even, если оно является чётным print('Input number:') inputData = input() number = int(inputData) if inputData != '' else 0 if number > 1: for val in range(1, number): print(val, 'even' if val % 2 == 0 else...
6f290bfe7481d2f66dda847868ce59eb64cd5adc
arpitiiitv/maximl
/maximl_test.py
559
3.65625
4
def count_distinct(s): return len(set(s)) def maximl(s): dist = count_distinct(s) minm = dist maxm = len(s) for i in range(len(s)): if dist == count_distinct(s[i:]): temp = s[i:] else: break ss = temp[::-1] for i in range(len(ss)): ...
efa3dfd86f5e8831a573f49773df49e6fe6a7b9b
ko-tech/pythone-dev
/Chapter 8 pt 2/cars.py
429
3.953125
4
#8-14: Cars - def car_profile(manufacturer, model, **car_info): """Build a dictionary containing information about car.""" information = {} information['manufacturer'] = manufacturer information['model'] = model for key, value in car_info.items(): information[key] = value return informat...
a91ef80491f2bb3b5f76f90db79a68d72f22299c
jihoonyou/problem-solving
/leetcode/copy-list-with-random-pointer.py
818
3.703125
4
''' https://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/585/week-2-february-8th-february-14th/3635/ ''' """ # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random =...
749658e20e47a3e1ac68c20e642f71de16214314
adrianurdar/100DaysOfCode-Bootcamp
/Day-032/main.py
1,489
3.578125
4
# Birthday Wisher (Extra-hard) import datetime as dt import smtplib import pandas import random # 1. Update the birthdays.csv # Name,Email,YYYY,MM,DD # 2. Check if today matches a birthday in the birthdays.csv now = dt.datetime.now() birthday_df = pandas.read_csv("birthdays.csv") birthday_dict = birthday_df.set_inde...
9638cd2079c8e05126e2bc2107feeddb4ee86d9a
KBabic/MY-PROJECTS
/avg_ratings.py
1,778
3.875
4
# The input file contains three columns: id - a unique identifier for each row, year - the year and quarter of the rating, and rating - the approval rating. # Write output to a new CSV with three columns: # year will contain whole years (i.e., 1975 but no information about specific quarters), # mean will have the m...
f91919d4d690431abb1be1fb6b840bb3a8bde352
hyeri2565/python-_algorithm
/1655.py
491
3.609375
4
from bisect import bisect_left N=input() num_list=[] num_list.append(int(input())) print(num_list[0]) for i in range(int(N)-1): num = int(input()) # 숫자가 삽입 될 인덱스 찾기 index = bisect_left(num_list, num) # 숫자 삽입, array 길이 1 증가 num_list.insert(index, num) if len(num_list)%2==1: ...
6d9d81d45698e6e76fc0003158cda46db3cef802
13834319675/python
/02 高级语法系列/cp 爬虫/基础/v26.py
219
3.65625
4
""" findall """ import re pattern = re.compile(r'\d+') s = pattern.findall("i am 18 yes old and 185 high") print(s) s = pattern.finditer("i am 18 yes old and 185 high") print(s) print(type(s)) for i in s: print(i)
038ae2d15b9006c595455008e882636c97fb9f6f
math4tots-misc/keep_talking_and_nobody_explodes
/word.py
485
3.5
4
from sys import argv poss = argv[1:] words = [ 'about', 'after', 'again', 'below', 'could', 'every', 'first', 'found', 'great', 'house', 'large', 'learn', 'never', 'other', 'place', 'plant', 'point', 'right', 'small', 'sound', 'spell', 'still', 'study', 'their', 'there', 'these', 'thing', 'think', 'three'...
cf77c42a2240369b19e7af1dd1c1a8fb93104d8b
achowDMA/Machine-Learning
/AI and Machine Learning/PyCharm/Calculator.py
229
3.625
4
import sys print(2 + 2) command = sys.argv[1] if command == "add": x = int(sys.argv[2]) y = int(sys.argv[3]) print(x + y) if command == "countto": x = int(sys.argv[2]) for i in range(x): print(i)
a634c0fd3783b41c8f366a1a204cd07512500e79
Shao-junliang/Python
/day01/04-认识数据类型.py
301
3.828125
4
""" --检测数据类型-- type(数据) """ num1 = 1 num2 = 1.1 a = 'hello world' b = True print(type(num1)) print(type(num2)) print(type(a)) print(type(b)) c = [10, 20, 30] d = (10, 20, 30) e = {10, 20, 30} f = {'name': 'Tom', 'age': 18} print(type(c)) print(type(d)) print(type(e)) print(type(f))
412c7876b1636aae8ca500a3479b56ba8756c552
love-adela/algorithm-ps
/acmicpc/1213/1213.py
205
3.640625
4
from itertools import permutations, combinations def is_palin(name:str)->bool: name for e in lst: if e == e[::-1]: return True return False s = input() print(is_palin(s))
635f323da217bdc09c2d6d5c8dd72c2e728e58a5
k-schmidt/Coding_Problems
/HackerRank/easy/implementation/mini_max_sum.py
1,120
3.8125
4
""" Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Input Format A single line of five space-separated integers. Constraint...
dea13070ebc37161642c930c4862f0559d6b8218
handdole/PYTHON
/파이썬강의(함수부르기등)/mega/가위바위보.py
1,915
3.59375
4
import random list1 = ['가위!', '바위!', '보!'] while True: print('가위 바위 보 게임 시작.') print("------------------------------") print("종료는 9 번을 눌러주세요") my = int(input('가위 0 바위 1 보 2 ! >> ')) if my not in (0,1,2,9): print("제대로 입력해주세요.") cum = random.randint(0, 2) if my == 0: ...
1eb4edd352a9177ee0b757e919a3e49a4824fcc2
sm171190/problems
/python1_Solutions.py
3,578
4.28125
4
#P1.Given the variables: planet = "Earth" diameter = 12742 # use the .format() to print the following string: The diameter of Earth is 12742 kilometers. # Solution1 #print('The diameter of {0} is {1} kilometers.'.format(planet,diameter)) #Strings are essentially a list of characters. So we should be able to extrac...
2dc5384c4172c93f88c10c575bd165aa232fb2b3
JayTheriault/pkrbot
/advanced_strategy_bot_tory_v1/player.py
12,285
3.515625
4
''' Simple example pokerbot, written in Python. ''' from skeleton.actions import FoldAction, CallAction, CheckAction, RaiseAction from skeleton.states import GameState, TerminalState, RoundState from skeleton.states import NUM_ROUNDS, STARTING_STACK, BIG_BLIND, SMALL_BLIND from skeleton.bot import Bot from skeleton.run...
842938b66f413e4a260395823d59a0a589bbdecf
newkstime/PythonLabs
/Lab03 - Selection Control Structures/Lab03P2.py
824
4.21875
4
secondsSinceMidnight = int(input("Please enter the number of seconds since midnight:")) seconds = '{:02}'.format(secondsSinceMidnight % 60) minutesSinceMidnight = secondsSinceMidnight // 60 minutes = '{:02}'.format(minutesSinceMidnight % 60) hoursSinceMidnight = minutesSinceMidnight // 60 if hoursSinceMidnight < 24 and...
819d738bfb211ac2e843e9fe11e498b3198f03be
jpgrennier/pylot_ng
/app/controllers/Play.py
2,145
3.84375
4
""" Sample Controller File A Controller should be in charge of responding to a request. Load models to interact with the database and load views to render them to the client. Create a controller using this template """ from system.core.controller import * from datetime import datetime import random c...
8afa2351afec30f516a710b054fb5b95776238fa
JamesTeachingAccount/PythonDemos
/selectiondemo.py
1,976
4.46875
4
import random #I am an example of selection") #The program will choose which statements to execute based on conditions #A simple 'if' statement will do an instruction if a condition is met firstRan = random.randint(1,10) if (firstRan==10): #notice the colon at the end of this line and the indentation (one tab or...
eb7b463c9bfc7bd9862f0814fa3c6b99737fb362
lf-pereiram/MisionTIC-2022
/Ciclo 1/python/Actividades/Promedio.py
213
3.625
4
a = float(input("numero 1: ")) b = float(input("numero 2: ")) c = float(input("numero 3: ")) d = float(input("numero 4: ")) e = float(input("numero 5: ")) prom = (a+b+c+d+e)/5 #print(prom) print(-75.943>-75.877)
6ff2866d5025a3a594634bb92787768a2ab89eb8
otseobande/keywords
/positional_tf_idf.py
2,121
4.25
4
import math def get_tf(term, document): """Calculates the frequency of a term in a document Args: term (str): The term (word) to find the frequency of. document (str): The document to search for the term in. Returns: float: The term frequency (tf) """ term_list = [term.lower() for term in docu...
ce8ee6b43dc1c967e2e1417ac7224f8c06d6a9d0
chiragcj96/Algorithm-Implementation
/Dynamic Programming/Pascal's Triangle/solution.py
1,081
3.8125
4
''' Dynamic Programming - matrix[i][j] = matrix[i-1][j] + matrix[i][j-1] Using a list[list[]] is used to build a [numRows x numRows] matrix, initialized with all 1's We then calculate each value for the pascal triangle by adding -> matrix[i][j] = matrix[i-1][j] + matrix[i][j-1] This populates the whole matrix with co...
2679589e3ff39400eb0a5b81596df762e4090f32
adriellison/UFC
/1-Semestre/Curso extra de python/aula 05/parametroPadrao.py
233
3.75
4
def insira(n = 1): return n * 2 def parametros(msg = "VALOR DEFAULT"): return msg print(insira()) msg = input("Digite uma frase") if(msg == ""): print(parametros())#se deixar vazio chama o default else: print(parametros(msg))
03ae595dac34fec2880915279f8fb8ccad9708cc
nettercm/timing
/t.py
2,731
3.890625
4
import time from time import monotonic as now from time import sleep import sys print(sys.argv) interval = float(int(sys.argv[1])) / 1000000.0 offset = float(int(sys.argv[2])) / 1000000.0 def jitter_test(iterations): for j in range(0,iterations): min=99999.0 max=0.0 avg=0.0 sum=0.0...
f9b472888ffb3cd08f873027efb7a817cca7f352
lamsnakesgit/42bootcamppython
/day00/ex04/operations.py
1,096
4.09375
4
import sys import string def usage(): print("Usage: python operations.py <number1> <number2>\nExample:\n" + " python operations.py 10 3") def operations(): if len(sys.argv) < 3: print("InputError: two arguments needed") # optional usage() elif len(sys.argv) == 3: try: ...
b4cfd3df53a04f368b15ac04783943d1a194deb8
doplab/act-tp
/2022/week07_conso1/solutions/overlap.py
209
3.875
4
def overlap(list1,list2): res=[] for elm in list1: if elm in list2: if not(elm in res): res.append(elm) return res print(overlap([1, 2, 3, 4], [9, 4, 3, 7, 1]))
cc4b8a2b8caa1f53554e4630c1a0088f60de5c7e
harerakalex/code-wars-kata
/python/fold_array.py
1,542
4.46875
4
''' In this kata you have to write a method that folds a given array of integers by the middle x-times. An example says more than thousand words: Fold 1-times: [1,2,3,4,5] -> [6,6,3] A little visualization (NOT for the algorithm but for the idea of folding): Step 1 Step 2 Step 3 Step 4 S...
984ccba7696d30aae3ca574dec139266285000a1
dbracewell/pyHermes
/hermes/util/timer.py
1,152
3.734375
4
from datetime import datetime class Timer: def __init__(self, started=False): self._elapsed = 0 self._start = None if not started else datetime.now() def running(self): return self._start is not None def start(self): if self._start: raise Exception("Already st...
167e8b39b63c82e117f46f1e8723e12982166ebe
quintelabm/PrmFitting
/venv/Lib/site-packages/numpoly/array_function/where.py
1,759
4.03125
4
"""Return elements chosen from `x` or `y` depending on `condition`.""" import numpy import numpoly from ..dispatch import implements @implements(numpy.where) def where(condition, *args): """ Return elements chosen from `x` or `y` depending on `condition`. .. note:: When only `condition` is provi...
41f32c34e8b054dee321e0faf91c9062b0a912ad
Zaargh/exercism
/python/anagram/anagram.py
208
3.546875
4
from collections import Counter def detect_anagrams(word, candidates): return [c for c in candidates if Counter(c.lower()) == Counter(word.lower()) if c.lower() != word.lower()]
682e7b4863cc218fc563976cf4fa515072043a3f
JoshuaW1990/algorithm016
/Week_03/permute.py
671
3.671875
4
class Solution: # def permute(self, nums: List[int]) -> List[List[int]]: def permute(self, nums): """ 依然是迭代做路径枚举 :param nums: :return: """ result = [] nums.sort() def dfs(path, remain_nums): if len(path) == len(nums): re...
4e197aef602d076d30e487dd29f4b1e47e24cdc5
saalim-mohammed/python
/flowcontrols/dicisionmaking/student.py
332
3.984375
4
m1=int(input("mark of s1:")) m2=int(input("mark of s2:")) m3=int(input("mark of s3:")) total=m1+m2+m3 print("total is",total) if(total>145): print("A+") elif((total>=140)&(total<=145)): print("A") elif((total>=135) & (total<=140)): print("B+") elif((total>=130) & (total<=135)): print("B") else: prin...
a1f37e8e109d34c971ffcafc697c35e65cab9177
omryry/wog
/guess_game.py
821
3.890625
4
import random def generate_number(difficulty): secret_number = random.randint(1, difficulty) return secret_number def get_guess_from_user(difficulty): user_guess = 0 while user_guess < 1 or user_guess > difficulty: user_guess = input("Please choose a number between 1 and " + str(difficulty) ...
1532985082648ee9250a114dabf827f33f4bb37d
Mespn520/400B_Klein
/Homeworks/Homework7/GalaxyMass.py
4,488
3.53125
4
# This is a program that will return the total mass of any desired galaxy component import numpy as np import astropy.units as u from ReadFile import read # Function for the Component Mass of the specified galaxies def ComponentMass(filename, par_type): # Inputs: # filename, this designates the file from which...
2c9706eb213b39cc5ddcf52b9d6f345ccce6ae44
TreidynA/CP1404_Practicals
/Prac_01/loops.py
514
4.1875
4
for i in range(1, 21, 2): print(i, end=' ') print() #a count in 10s from 0 to 100 for i in range(0, 110, 10): print(i, end=" ") print() #b count down from 20 1 for i in range(20, 0, -1): print(i, end=" ") print() #c print n stars. Ask the user for a number, then print that many stars (*), all on one line nu...
1f7c3e0412843767513052346ef0a5a364095281
wwtang/code02
/lcsrecursive.py
556
3.96875
4
def lcs(xs, ys): '''Return a longest common subsequence of xs and ys. Example >>> lcs("HUMAN", "CHIMPANZEE") ['H', 'M', 'A', 'N'] ''' if xs and ys: xb = xs[:-1] xe = xs[-1] yb = ys[:-1] ye = ys[-1] #*xb, xe = xs #*yb, ye = ys if xe == ...
a22e15570aef88449b98c3da9b2ef47aad1c2fb5
june0313/programmers-python
/level2/소수찾기/number_of_prime.py
338
3.765625
4
def numberOfPrime(n): # 1부터 n사이의 소수는 몇 개인가요? return len(list(filter(isPrime, range(1, n + 1)))) def isPrime(n): return list(filter(lambda i: n % i is 0, range(1, n + 1))) == [1, n] # 아래는 테스트로 출력해 보기 위한 코드입니다. print(numberOfPrime(10)) print(numberOfPrime(5))
6ce5dec51ac0ee53f3675c5515c4520e657ce0a1
Rochan01/B1ackPyramid
/rock paper scissors.py
1,052
4.09375
4
# Rock Paper Scissors import random options = ["r", "p", "s"] player_wins = 0 comp_wins = 0 no_of_games = 5 rounds_left = 5 print(f'Rounds left = {rounds_left}') while no_of_games > 0: comp = random.choice(options) player = input("enter your choice: r for rock,p for paper and s for scissors: ")....
75a2e414e491199c72391b6ffbc8e2d5027fed4c
UULIN/automation_test
/unit6_unittest_sample/more/test_skip.py
997
3.96875
4
""" 测试跳过某些测试用例 unittest.skip(reason) 无条件的跳过装饰器的测试,需要标明跳过的原因 unittest.skipIF(condition, reason) 如果条件为真,则跳过装饰器的测试 unittest.skipUnless(condition, reason) 当条件为真时,执行装饰器的测试 unittest.expectedFailure() 不管执行是否失败,都将测试标记为失败 """ import unittest class My_test(unittest.TestCase): @unittest.skip("测试无条件跳过测试用例") def test_skip...
9aaf6bcee9b912d44d65f61b0a130f19e2201bc2
kadey001/puzzle_solver
/utility.py
497
4.125
4
position_dict = {} goal_state = [] def set_position_dict(n = 3): """ Creates a dict for each value's correct position and builds a goal state for goal checking """ value = 1 for i in range(n): row = [] for j in range(n): if (i + 1) * (j + 1) >= n**2: position_dict[0] ...
f850ddd956a5deccd7b24230f029d7c2ee0de354
PacktPublishing/Mastering-OpenCV-4-with-Python
/Chapter05/01-chapter-content/saturation_arithmetic.py
649
4.0625
4
""" Example to show how saturation arithmetic work in OpenCV """ import numpy as np import cv2 # There is a difference between OpenCV addition and Numpy addition. # OpenCV addition is a saturated operation while Numpy addition is a modulo operation. x = np.uint8([250]) y = np.uint8([50]) # OpenCV addition: values ar...
c37337aa2470f570ab08f350b94f74f6022bbc6c
sssmrd/pythonassignment
/7.py
111
4.21875
4
#program to calculate length of string str=input("Enter a string="); print("Length of ", str, "is", len(str))
bc4295dd17c71962d4a5c0544b2a1a0e226b6874
RodrigoZea/Miniproyecto4
/ai_player.py
3,307
3.734375
4
import utils import random import hashlib import copy random.seed(69) def apply_move(board, move, p1_turn, scores): board = copy.deepcopy(board) stones = board[move] board[move] = 0 move_index = (move + 1) % 12 repeat_turn = False last_move_index = -1 while stones > 0: # jugador 1...
74dce1645dcca1992095c3b4dcf8d809fc6cfa80
mat-green/stealth-co
/stealthco/models.py
2,715
4
4
''' Created on 24 Jan 2016 @author: Matthew Green @copyright: 2016 New Edge Engineering Ltd. All rights reserved. @license: MIT ''' class Graph(object): ''' Object that plots vectors as lines and render to ascii characters. ''' def __init__(self, width, height): ''' Construc...
d89db8638265803ee88083527e864d886644ec47
adityabettadapura/TicTacToe-game
/main.py
1,427
3.546875
4
import random from board import Board from randomai import RandomAI from pseudorandomai import PseudoRandomAI from humanai import HumanAI from tictactoe import TicTacToe if __name__ == "__main__": while True: board = Board() ttt = TicTacToe() print "Choose the match-up:" print "Typ...
3f1a4882b6869c9d181d632d20f4aafebdd90014
Pavan-443/Python-Crash-course-Practice-Files
/chapter 3&4 - lists/chap_4_lists/cubes_4-8.py
147
4.125
4
cubes = [] numbers = list(range(1,11)) for num in numbers: cube = f'Cube of {num} is {num**3}' cubes.append(cube) for cube in cubes: print(cube)
9a7c3fdaff845673cac16ebc3926419b24c027cb
vipin-t/py-samples
/listings.py
1,058
4.28125
4
# print ("to work on lists") a_list = [7,1,5,8,4,2,6] b_list = ['f', 'g', 'a', 'd', 'b', 'e', 'c'] c_list = [a_list, b_list] b_list. ## list commands # a_list.sort() # a_list.reverse() # b_list.sort() print ( a_list ) print(b_list) print ('\n') print ( c_list ) #print ( b_list.pop(2) ) # prin...
1fc653ac58a75e91199d0f726edd90c3e0caf11a
kylemaa/Hackerrank
/LeetCode/find-first-and-last-position-of-element-in-sorted-array.py
1,674
3.921875
4
# Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. # Because the array is already sorted, we can use binary search tree for solve for logarithmic time. class Solution: # returns leftmost (or rightmost) index at which `target` should be ins...
bc37dad623ce7e411d1ddbb12e0b504891c28c5a
vitalyvj/python
/HW3_3.py
278
3.859375
4
def my_func(a, b, c): d = min(a, b, c) return a + b + c - d a = float(input('Введите первое число: ')) b = float(input('Введите второе число: ')) c = float(input('Введите третье число: ')) print(my_func(a, b, c))
f409dd577aaf6baf462ee31c5cde435570831cd8
yinchuandong/python_algorithm
/leetcode/add_two_numbers.py
1,250
3.890625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ head = rlist...
81e1c7ffebfcd8feacae0a3d63457ebfadeb07b0
alexkorep/udacity-deep-learning
/softmax.py
381
3.53125
4
import numpy as np def softmax(input): sum = np.sum(np.exp(input), 0) if not sum.any(): return input return np.exp(input)/sum scores = [1.0, 2.0, 3.0] print softmax(scores) scores = [100.0, 101.0, 102.0] print softmax(scores) """ scores = np.array([[1, 2, 3, 6], [2, 4, 5, 6],...
d3019d9627a03af5aeef2d44102053b35f9a5f53
wandsen/PythonNotes
/JavaClasses/Abstract_Class_2.py
497
3.984375
4
from abc import ABCMeta, abstractmethod import abc class AbstractOperation(object): __metaclass__ = abc.ABCMeta def __init__(self, operand_a, operand_b): self.operand_a = operand_a self.operand_b = operand_b super(AbstractOperation, self).__init__ #This is an explicit declaration. If n...
b768c36a0857d704bc90a8b19bed0d48c3563a6b
supragub/python-codecool
/18-Pairprogramming/Fizzbuzz/fizzbuzz_module.py
353
3.765625
4
def fizzbuzz(number): text = number if int(number) % 15 == 0: text = "FizzBuzz" elif int(number) % 3 == 0: text = "Fizz" elif int(number) % 5 == 0: text = "Buzz" return text def main(): for i in range(1, 101): print(fizzbuzz(i)) fizzbuzz(i) return if _...
bb82660c60a1ac8bf2ae9f7dba5306b325f3dfa0
sagar8080/Algorithms
/Search/Interpolation_Search.py
774
4.03125
4
# Implement interpolation search def interpolation_search(input_sequence, key): start = 0 end = len(input_sequence) - 1 while input_sequence[end] != input_sequence[start] and key >= input_sequence[start] and key <= input_sequence[end]: mid = int( start + ((key - input_sequence[start]) * ...
9963c2ba41bf2eaafac35445565557c7889feec6
wwd605075811/CS5014_MachineLearning
/P1_logistic_regression/practise/bc.py
940
3.6875
4
#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt def one_bezier_curve(a, b, t): return (1 - t) * a + t * b # xs表示原始数据 # n表示阶数 # k表示索引 def n_bezier_curve(xs, n, k, t): if n == 1: return one_bezier_curve(xs[k], xs[k + 1], t) else: return (1 - t) * n_bezier_curve(xs,...
3a877aca5369408bbd17c0d4838a9c537e0d751d
zbarton88/Python-Physics-Euler-Problems
/Euler 49.py
720
3.703125
4
def sieve(n): answer = [] notprimes = [] primes = [] for i in range(2,10000): if i not in notprimes: primes.append(i) for k in range(i**2,10000,i): notprimes.append(k) for i in range(3,len(primes)): n1 = primes[i] n2 = primes...
f45532bdc3d09be187c77ae63a85200aa75a0875
Invalid-coder/Data-Structures-and-algorithms
/Graphs/Unweighted_graphs/Tasks/eolymp(2401).py
863
3.625
4
#https://www.e-olymp.com/uk/submissions/7692873 class Graph: def __init__(self, matrix): self.adjacentMatrix = matrix def wave(self, start, end): queue = [start] distances = {start:0} while len(queue) > 0: current = queue.pop(0) if current == end: ...
330c7adb265619579a7977d492cc955e93a49d33
0siris7/vjcet-python
/program42.py
169
4.03125
4
list1=input("enter list:") minimum=list1[0] for i in range(1,len(list1)): if(list1[i]<minimum): minimum=list1[i] print "the minimum is:",minimum
95f34a50d7e799de0cde93ebf7306f6622ad1f04
Joey-Hu/pythonbasic
/100day&Project/train_project/geekcomputers/koch curve/koch curve.py
954
3.5625
4
#!/usr/bin/env python # encoding: utf-8 # @author: huhao # @Software : PyCharm # @file: koch curve.py # @time: 2019/6/28 15:04 # @Ducument:https://www.python.org/doc/ # @desc: from turtle import * def snowflake(lengthSide,levels): if levels == 0: forward(lengthSide) #向右绘制 ret...
85977cdd81750694446d29c0de981b5ab982e107
sandeepkabir/python-project
/assingment2.py
326
3.796875
4
#Q1 print("my name is sandeep") #Q2 print("sandeep" +"kabir") #Q3 x=input("enter any number") y=input("enter any number") z=input("enter any number") print(x,y,z) #Q4 print("let\'s get started") #Q5 s="acadview" course="python" fees=5000 print("%s %s %d" %(s,course,fees)) print (s + " " + course + " " + str(...
6233cc7838eca4c21fd29f495106beef40795f43
Darioxa20/Toapanta
/semana2/import math.py
192
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 26 12:40:21 2019 @author: 1-26-PB-L2-13 """ from math import pi,radians,degrees,sin,cos,tan,asin ad=90 ar=radians(ad) print(ar)
fe9c910ccf39ba6cd2b15e0847ea18cd5bace87a
ttungl/Coding-Interview-Challenge
/source-code/Positions of Large Groups 830.py
1,491
3.796875
4
# 830. Positions of Large Groups # In a string S of lowercase letters, these letters form consecutive groups of the same character. # For example, a string like S = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z" and "yy". # Call a group large if it has 3 or more characters. We would like the starting and ending...
1253792585fdf668d346671ca672e190706495f2
rishavhack/Data-Structure-in-Python
/String/String Template.py
289
3.609375
4
from string import Template #Create template that has placeholder for value of x t = Template('x is $x') print t.substitute({'x':1}) student=[('Rishav',88),('Ankit',78),('Bob',92)] t = Template('Hi $name,you got $marks marks') for i in student: print t.substitute(name = i[0],marks=i[1])
124d75fb8167d9c709b64f757b846a805a59675f
MaximKuba/python_labs
/lab5/lab5.1.py
356
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 19 21:47:33 2018 @author: maximkuba """ import numpy as np M = 208 N = 12 array = np.zeros((M,N)) array.size a = np.array([1, 2, 3]) key = int(input('Enter key:')) print(key) def find_nearest(z, A): id = (np.abs(A-z)).argmin() return...
0711bf826050419d69c4c78f2c19b3ccd2e5252d
HeywoodKing/mytest
/MyPractice/fib3.py
308
3.59375
4
# -*- coding utf-8 -*- L = ['adam', 'LISA', 'barT'] def normalize(name): return name.capitalize() res = list(map(normalize, L)) print(res) L1 = [1,2,3,4,5] from functools import reduce def multi(x, y): return x * y def prod(l): return reduce(multi,l) print(prod(L1))
84be8ce106db4d9c3d97cc7d07ea06734f0f8f04
sudhanvalalit/Koonin-Problems
/Koonin/Chapter1/Exercises/chap1c.py
669
3.78125
4
""" The following FORTRAN program finds the positive root of the function ..math:: f(x) = x^2 - 5, x_0 = 5^{1/2} = 2.236068 to a tolerance of 10^{-6} using x = 1 as an initial guess and an initial step size of 0.5: """ import numpy as np # tolerance tolx = 1e-6 def func(x): return x*x - 5.0 def mai...
61b170a04191b0de444bed073640f63dab941bfb
cjetter/practicefiles
/Coursera/Python for Everyone/PythonCode/Ch8Ex5.py
792
3.84375
4
'''Ch10Ex1: Revise a previous program as follows: Read and parse the “From” lines and pull out the addresses from the line. Count the number of messages from each person using a dictionary. After all the data has been read, print the person with the most commits by creating a list of (count, email) tuples from the dic...
9bf9bd16ac955622202eac70d66f40b9658c8715
Erin-hua/python-study
/three_chapter/list_3_8.py
294
3.8125
4
places=["Yunlan","Beijing","Xinjiang","Qinghai","Xian","Nanjing"] print(places) print(sorted(places)) print(places) print(sorted(places,reverse=True)) print(places) places.reverse() print(places) places.reverse() print(places) places.sort() print(places) places.sort(reverse=True) print(places)
d90a7b450e6ba6a3b1da578577bfb90c095ecc8c
saurabhsharma21/PythonTraining
/Task 1/Task1.py
1,583
3.859375
4
#Code #>>> a = 1; b = 3.3; c = 'String' #>>> c #'String' #>>> b #3.3 #>>> a #1 ######################## #>>> x = 1 + 2j #>>> a = 3 #>>> a = x #>>> a #(1+2j) ######################### #>>> a = 2 #>>> b = 3 #>>> result = a #>>> a = b #>>> b = result #>>> a #3 #>>> b #2 #>>> a = 5 #>>> b = 7 #>>> a, b = b, a #>>> a...
4b27099442e351a591145e9e400c8cce3561b7d9
brendonericlucas/project-euler
/archive-problems/problem7/problem7a.py
740
3.71875
4
import math from itertools import compress def sieve_of_eratosthenes(n): """ implements the sieve_of eratosthenes; compare the time complexity of this function to the function using trial division in sol 3a """ is_prime = [True]*(n + 1) is_prime[0] = False is_...
19a0b25920b206ea008ee041405eec09dbe4f2dc
Araym51/DZ_Algoritm
/Ostroumov_DZ_5/Ostroumov_DZ_5-2.py
3,497
4.03125
4
""" 2. Написать программу сложения и умножения двух шестнадцатеричных чисел. При этом каждое число представляется как массив, элементы которого это цифры числа. Например, пользователь ввёл A2 и C4F. Сохранить их как [‘A’, ‘2’] и [‘C’, ‘4’, ‘F’] соответственно. Сумма чисел из примера: [‘C’, ‘F’, ‘1’], произведение - [‘7...
353046578d02f9bb00200c28cb23599a84fb3884
destructor0/destructor0
/is_primenumber.py
484
4.21875
4
while True: a = int(input("Enter a number you want to check is prime number or not: \n")) def is_prime(a): if a%a==0 and a<10 and a/4!=1 and a/6!=1 and a/9!=1 and a/8!=1: print(f"{a} is a prime number") elif a%a==0 and a%2!=0 and a%3!=0 and a%4!=0 and a%5!=0 and a%6!=0 and a%7!=...
24119635301ba517509b11b9f8320b6ce6c37694
gksheethalkumar/Python_Practice
/beersong.py
366
3.953125
4
word = "bottles" for num in range(99,0,-1): print(num, word, "of beer on the wall") print(num, word, "of beer") print("take one down") print("pass it worund") if num == 1: print("no more bottles") else: num -= 1 if num == 1: word = "bottle" print(n...
ace6e8569c9636fc12f49423a8746cc11b7e3036
2324593236/MyPython
/练习项目/逢7拍桌子.py
780
4.28125
4
# _*_ coding utf-8 _*_ # 开发团队:HS黄舍 # 开发人员:Administrator # 开发项目:Python Study # 开发时间:日期:2020/11/27 时间:19:48 # 文件名称:逢7拍桌子.py # 开发工具:PyCharm i = range(1,100)#建立1-99数字 count = 0 for x in i : if x%7 == 0:#遍历到7的倍数时 print("啪") count +=1#拍桌子次数加一 continue#跳出本次小循环,进入下一次循环 elif str(x)....
d146faf4ec2432c8b9db0e814ba6407a440b22db
AnastasioNieves/Python-
/Cursos/Mastermind/Cualestuedad.py
395
3.75
4
edad = int(input("¿ Que edad tiene? ")) tipo_carnet = input("digame su tipo de carnet (E para estudiante / P pensionista / F familia numerosa / N para ninguno) " ) if (edad <= 35 and edad >= 25 and tipo_carnet == "E") or edad < 10 or (edad > 65 and tipo_carnet == "P") or (tipo_carnet == "F"): print("se te ha a...
fcae6eab4a894859eb4fb987f69f3bfbc35c8f1b
bottleling/scratches
/IsTreeSymmetric.py
3,024
3.71875
4
class Tree(object): def __init__(self, x): self.value = x self.left = None self.right = None def buildtree(treedict): if treedict is None: return None keys = treedict.keys() tree = Tree(treedict["value"]) tree.left = None tree.right = None if "left" in keys: tree.l...
4452dae5d2de7395735227d9515de3b45ff09654
MorhaliukOL/python_workout
/ex_1.py
938
4.125
4
import random def get_int_input() -> int: """ Take input from user and convert it to integer. If user input cannot be converted to int, ask user to try again """ # Fix 'int '-like inputs (with trailing spaces) !!! num_str = input('>') try: num = int(num_str) return num ...
06cfeba0d268f8408d7475bb135dd98143871c15
IsseW/Python-Problem-Losning
/Uppgifter/3/3.15.py
772
4.21875
4
""" Övning 3.15 - Omvänd uppslagning Skriv en funktion reverse_lookup(dictionary, value) som tar in en dictionary och ett värde som argument och returnerar en sorterad lista med alla nycklar som är associerade med det värdet. Funktionen ska returnera en tom lista om man inte får någon träff. >>> reverse_lookup({'a':1...
9189af8da8a59718f850591c46559b3d06ad5208
rahdirs11/Geekster
/Contests/28Feb/goodPairs6.py
675
3.671875
4
''' Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i < j. Find the number of good pairs. Input Format first line contain N, no of elements in nums arrays. Second line contain Array elements Constraints 1<=N<=1000 1<=Ai<=1000 Output Format Print desired output Sample Inpu...
7aa00b18bbb5d693187b09532cd35aec6aa692c2
Amazinggggg/-
/性格分析.py
8,735
3.78125
4
# /usr/bin/python # coding: utf-8 from tkinter import * import math # 按键返回函数 def call(num): global content2 if num == 'A型': content = display.get() + num content2 = content2 + '+3' display.set(content) elif num == 'B型': content = display.get() + num ...
d52d53973e9d61efbf4b2939cd7f3c3f7e081a67
VioletZhdanova/backend_python
/task2.py
471
3.9375
4
import re #Регулярное выражение pattern = r"[АВЕКМНОРСТУХ]\d{3}[АВЕКМНОРСТУХ]{2}\d{2,3}" #Пример для теста (Важно, что перечислены русские буквы) numbers = ["А123АА11", "А222АА123", "А12АА123", "А123СС1234", "АА123А12","О123ОО59","а123аа59"] answer = list() for i in numbers: if re.fullmatch(pattern, i): ...
c60e305dce1f7659a7037a686120e8af58d03fc8
TUdayKiranReddy/Voice_Controlled_bot
/data_set/codes/rename.py
392
3.71875
4
# Pythono3 code to rename multiple # files in a directory or folder # importing os module import os # Function to rename multiple files path = '/media/solomon/Apps/AI and ML/Audio_Dataset/right' files = os.listdir(path) print(enumerate(files)) for index, file in enumerate(files): os.rename(os.path.join(pat...
12cfb12e447c948514226443fd6c0fafb238e6ed
shubhamagrawal7/ViolentPython
/UnixPasswordCracker.py
1,690
3.609375
4
import argparse import crypt class UnixPwdCrack: def __init__(self): # Parsing Shadow file open_shadow = open('shadow.txt', 'r') self.shadow_file = {} for line in open_shadow: comps = line.split(":") self.shadow_file[comps[0]] = comps[1] def parse_passw...
301c421ef05c3554b6934fb7fee0fcbc3cd98a8c
tina8860035/yzu_python
/Lesson02/case08.py
113
4.0625
4
# -*- coding:UTF-8 -*- n = int(input("請輸入數字")) odd = n % 2 ==0 print('%d是偶數嗎? %s' % (n, odd))
d23a1e54efcb3fdb1f47c55d83ba5bcdaccd264a
mestre204os/Python-Curso_em_video
/LIções/010.py
847
3.703125
4
from random import randint import time itens = ('Pedra', 'Papel', 'Tesoura') jogador = int(input('''Qual é a sua jogada? [0] Pedra [1] Papel [2] Tesoura ''')) time.sleep(1) print('JO') time.sleep(1) print('KEN') time.sleep(1) print('PÕ') computador = randint(0,2) print('-=-' * 11) print('Computador escolheu {}'.format(...
d596a10eb0d923153348bc3bf318ce21d1ed41bf
yooseungju/TIL
/Algorithm_class02/IM/sort.py
1,847
3.609375
4
import sys sys.stdin =open('input.txt') # 버블정렬: n**2시간 복잡도, 원하는 갯수만큼 정렬하고 싶다면 회전수를 정하면됨 def bubbleSort(x): #정렬할 대상과 회전수 for i in range(len(x)-1): #비교 대상들 for j in range(i+1, len(x)): if x[i] > x[j]: x[i], x[j] = x[i] , x[j] # #이차정렬일 경우 안에다가 하나 넣어주면됨 ...
0551d706c9ce7ffbd7393a32ffd344241b9796dd
maguas01/hackerRank
/pStuff/SortingBubbleSort.py
1,057
4.1875
4
#!/bin/python ''' Given an n element array A = a0, a1,...,a(n-1) fo distint elements, sort array A in ascending order using the Bubble Sort algorithm above. Once sorted, print the following three line: 1. Arrays is sorted in numSwaps swaps, where numSwaps is the number of swaps that took place 2. First Element: fi...
e1e4520e7a382c4c4d244a19274f9216ed32c430
cloud0606/summer_semester
/Cloud/LearnPython/test/hello.py
1,012
4.28125
4
print('hello,world') print('hello','python') print("waht\'s your name?") # 这是第一个python程序的注释 print('打印一个浮点:') a = 6.6e6 print(a) print("打印字符串:") a = "穿着长衫"+","+"站着喝酒"+'。' print(a) print(r'他说"要一碟茴香豆"') print(r''' 今天天气不错啊! 你看起来像一条"小鱼" 谢谢!^-^''') print("2017 + 0x11 = ",2017 + 0x11) print('\nlist的使用:') friend = [1,'wzy',2...
5069af05ee55a5f14ba74370bf09fbdb71a8aebd
kecarrillo/monopoly
/Monopoly/Pawn.py
15,855
3.796875
4
import random from Monopoly.Auction import Auction from Monopoly.Owner import Owner class Pawn(Owner): """ This class represents the avatar of the players. """ def __init__(self, name, money): """This method is the constructor of the class. :param form: Form of the pawn. :ty...
883d99978fe304f98203f1d0a633127cfe7bdd21
iknowed/units-convert
/node.py
1,303
4.09375
4
class Node(object): """ This module implements the Node class as a container for edges to neighbor nodes. """ def __init__(self, name): """ initialize node and set name """ self.name = name self._edges = [] def _set_name(self, name): self.name = name ...
bc4011ac60e86b1dd19772eca0793dcc723415a2
EJChavez/challenges
/Exercises/SuperList.py
273
3.96875
4
class SuperList(list): # this is how you use inheritance to get all the stuff from the object class def __len__(self): return 1000 super_list1 = SuperList() print(len(super_list1)) super_list1.append(5) print(super_list1[0]) print(issubclass(SuperList, list))
cb4afefeba1f69736a6c1e3b7f6bbafbb2d43e9c
tawrahim/Taaye_Kahinde
/Kahinde/chp5/repython/additionprogram.py
353
3.9375
4
print"I will ask you to type in 2 numbers so I can add them together for you." addend=int(raw_input("What is your first addend?")) second=int(raw_input("What is your second addend?")) print "You entered,",addend,"for your first addend." print "And you entered,",second,"for your second addend." answer=addend+second...
ef7868cf2ce1f3dbb22bfa65b2e5454bd94daa25
berlyncast/python3
/ejercicios_progra/ejer8.py
837
3.578125
4
#escriba un algoritmo que dada la cantidad de monedas de 5-10-12-,5-25-50 cent #y bolivar, dega la cantidad de dinero que se tiene en total monedas1 = 0 monedas2 = 0 monedas3 = 0 monedas4 = 0 monedas5 = 0 monedas6 = 0 tot1 = 0 tot2 = 0 tot3 = 0 tot4 = 0 tot5 = 0 tot6 = 0 total = 0 monedas1 = int(input("ingrese moned...
9101dbb722c7dcfacc2dfe3103ac052074484ed9
swcide/algorithm
/week_1/01_01_find_max_num.py
731
4
4
input = [3, 5, 2, 3, 4, 6, 1, 2, 4] def find_max_num(array): a = max(array) for i in array: for j in array: ''' i의 값이 j보다 작다면 break j의 값이 더 크다면 계속해 반복. for else. if 문 안의 값이 break가 아닐 시 else를 출력함. ''' if i < j: ...