blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
be01f32ed478acf37072f7a5c4da10fe668dad64
MidDevOps/DevOps_Online_Summer_Program_2020
/m7/task7.1/count_vowels_unittest.py
1,001
3.84375
4
import count_vowels import unittest class FizzBuzzTest(unittest.TestCase): def test_fizz(self): string = "aeiou" only_unique_letters = set(string) result = count_vowels.get_vowels(string) self.assertEqual(result[0], 5) for vowel in only_unique_letters: self.asse...
0c4982d9184fd467e581a23cfdf8779a89543608
nayomipoligami/repeat
/5.bölümödevler/deneme.py
277
3.71875
4
print(""" **************** mükemmel sayı **************** """) sayı = int(input("Lütfen bir sayı giriniz: ")) liste = list() for i in range(1, sayı): if sayı % i == 0: liste.append(i) if sum(liste) == sayı: print("Mükemmel sayı")
153dc6c60d2afc0a73f41c5db62a954e94c34035
samuelfranca7l/PythonExercises
/exercicios/PythonExercicios_Desafio086.py
291
3.875
4
matrix = [[], [], []] for i in range(0, len(matrix)): for n in range(0, 3): matrix[i].append(int(input(f'Digite um valor para [{i},{n}]: '))) print('=-' * 30) for i in range(0, len(matrix)): for n in range(0, 3): print(f'[ {matrix[i][n]:^5} ]', end='') print('')
5e2bff807d76575253fe5c31ab381f89577dbbaa
leosty/sort_python
/sort_test.py
2,436
3.90625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # Time: 2018/10/15 15:27 # # # 1. 插入排序 # def insert_sort(ilist): # for i in range(0, len(ilist)): # for j in range(i): # if ilist[i] < ilist[j]: # ilist.insert(j, ilist.pop(i)) # return ilist # # ilist = insert_sort([2, 3, 4, 7, 9, ...
538ecce26a2b78b8a9294e9f29674ecb4e906b59
illagrenan/block-timer
/block_timer/timer.py
2,256
3.890625
4
# -*- encoding: utf-8 -*- # ! python3 import sys import time from contextlib import ContextDecorator from typing import Optional __all__ = ["Timer"] class Timer(ContextDecorator): """ Timer class that can be used both as a context manager and function/method decorator. Usage: >>> import math >...
26653cab8f92eb296cac98b55ec3c3567e9bbcbb
Luisa158/LaboratorioContAcumRemote
/primosB.py
245
3.75
4
a= int(input("Por favor, ingrese un número ")) i = 1 cont=0 while i<=a: if a % i == 0: print("divisor:", i) cont=cont+1 i=i+1 if cont> 2: print("El número no es primo") else: print("El número es primo")
116101cf222972a1f08f4246e8d2f789e26c46cf
sophmintaii/tic-tac-toe
/btree.py
1,897
3.609375
4
""" Contains Linked Binary Tree implementation. """ class LinkedBinaryTree: """ Linked Binary Tree representation. """ def __init__(self, root): """ Creates a new LinkedBinaryTree onject. """ self.key = root self.left_child = None self.rig...
07d46e4bd33ed1d68bbe38cfbac883f5c44d78c7
priyansh210/Airline_Reservation_and_Management_System-python
/user/payment.py
1,127
3.734375
4
import menu.usermenu as usermenu import sql mycursor=sql.mycursor mydb=sql.mydb def make_booking(udft): l=len(udft) for i in range(l): mycursor.execute("INSERT INTO BOOKING VALUES"+str(tuple(udft.loc[i,:]))) mydb.commit() print("YOUR FLIGHT HAS BEEN BOOKED !") input("> ") us...
75f4b60f10d387655676ca32a6d0076b0b0df082
0xJayShen/arithmetic
/有序列表合并.py
1,296
3.75
4
# -*- coding: utf8 -*- # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # def mergeTwoLists(l1, l2): # l = head = ListNode(0) # while l1 and l2: # if l1.val <= l2.val: # l.next, l1 = l1, l1.next # else: # l.next, l2 ...
5ff07adc2ffa1c0612854183174b9a5bcefbde58
cesarbhering/30-days-of-code-HackerRank
/20-Sorting.py
268
3.59375
4
numSwaps = 0 while a != sorted(a): for i in range(n-1): if a[i] > a[i+1]: a[i], a[i+1] = a[i+1], a[i] numSwaps += 1 print(f'Array is sorted in {numSwaps} swaps.') print(f'First Element: {(a)[0]}') print(f'Last Element: {(a)[-1]}')
a1dccee3850a0edb931b2ea592f89be302d6bd0c
steffenerickson/humanitiesTutorial
/17_nltk3_textobject1.py
892
4.03125
4
# NLTK comes with a Text object that has many useful methods # that facilitate many common tasks import nltk # Same prep as before textfile = open("holmes.txt","r",encoding="utf8") holmesstring = textfile.read() textfile.close() startpoint = holmesstring.find('*** START OF THIS PROJECT GUTENBERG EBOOK') endpoint = h...
594092f9d32f046abe6a09a7773d3c49dedae817
Miszion/Connect4
/InputController.py
1,651
3.875
4
class InputController: @staticmethod def getValidColumn(board, player, turnNumber): col = int(input("Turn " + str(turnNumber) +": " + player.name + " (" + player.color + "), choose your move: ")) while ((col > board.columns) or (col <= 0)): print("Invalid move, outside board, try a...
52a3768352a4379ce691d785475d5d2b3b9764ee
zrzka/blackmamba
/blackmamba/lib/rope/refactor/occurrences.py
12,841
4.15625
4
"""Find occurrences of a name in a project. This module consists of a `Finder` that finds all occurrences of a name in a project. The `Finder.find_occurrences()` method is a generator that yields `Occurrence` instances for each occurrence of the name. To create a `Finder` object, use the `create_finder()` function: ...
6921b246a0d2babdb6b25b433fb2f1d2d8a9bf90
mattpmartin/DataStructuresSeries
/Insertion Sort/Final.py
582
4.0625
4
import random # creating array of random ints numbers = [int(random.random() * 20) for _ in range(100)] # printing array so we know what were looking at print(numbers) # insertion sort def insertionSort(numbers): for index in range(1, len(numbers)): currentValue = numbers[index] position = index ...
f01cb78c48ff83fe3fa5af56f9e658f6c0dbeac0
BioAlex1978/automateboringstuffpythonpractice
/guessTheNumber.py
1,913
4.34375
4
# A short program to guess the number, from "Automate the Boring Stuff With Python, 2nd Edition" import random # The following commented block of code is what I came up with before look at the book, # based entirely in the book's example output, and without knowing the full features. # This version allows infinite gu...
102f2a7ec7b8f0dc47c8f5c2b1751f11f9c062f9
shi-kejian/nyu
/csuy-1122/homework/1/test.py
5,303
3.5
4
import time import random from selection import selectionSort from quicksort import quickSort from insertion import insertionSort import matplotlib.pyplot as plt import matplotlib.patches as mpatches import matplotlib.ticker as mticks import numpy as np import sys sys.setrecursionlimit(1000000) def generate_list(len...
3c2c806f32ff729fb235e8df850c4a7f5724e888
Salazar769/Ciclo-1-python
/cadenas y variables.py
339
3.515625
4
val1 = 5 val2 = 2 suma = val1 + val2 print(suma) resta = val2 - val1 print(resta) promedio = (val1+val2)/2 print(promedio) producto = ((val1-val2)/2)*365 print(producto) centroamerica = ("Guatemala, Belice, El salvador, Honduras, Nicaragua, Costa Rica, Panamá") print(len(centroamerica)) print(ce...
56d1a2a479004686a5d35dbe6546746aec391843
hdgogo/lccspop
/ch1/onetimepad.py
837
3.5
4
#!/bin/python3 # -*- coding: utf-8 -*- """ FileName : onetimepad.py Author : hongda """ from secrets import token_bytes def random_key(length): # 生成指定长度的随机密钥 tb = token_bytes(length) return int.from_bytes(tb, "big") def encrypt(original): """通过XOR运算进行加密""" original_bytes = original.encode() ...
2a0bf86b5473f6c30150c553afc931a0afdbc927
tabish606/python
/fromkeys_get_clear_in_dict.py
944
3.921875
4
#fromkeys method gives same values to each keys #it gives individually a,b and c to unknown user_info = dict.fromkeys("abc",'unknown') print(user_info) #using list #it gives each keys to unknown(we can use tuple also) user_info1 = dict.fromkeys(['name','age','state'],'unknown') print(user_info1) #get method...
c68ce83ee8cbbb5c73181b5d9c4be40799febd6d
roctubre/data-structures-algorithms
/algorithmic-toolbox/week2_algorithmic_warmup/2_fibonacci_last_digit.py
819
3.84375
4
# Uses python3 import sys import random def get_fibonacci_last_digit_naive(n): if n <= 1: return n previous = 0 current = 1 for _ in range(n - 1): previous, current = current, previous + current return current % 10 def get_fibonacci_last_digit(n): a = 0 b = 1 ...
9446404583ffdbdd77f74fd57fc2bef1ee72f365
devolopez88/PythonPrro
/hangman.py
1,894
4
4
import random import os # It picks a work from the list returned by the file def pickword(file): word = "" ln = random.randrange(0, len(file)) word = file[ln] return word # It prints the spot for each letter def printSpace(word): print("You have " + str( len(word)) + " opportunities to WIN. let...
e73f24e319c0134c2021b97ddac9bfb62d030d1e
mohammedEshtayah/simulation
/lab4.py
561
3.609375
4
import math ; import matplotlib.pyplot as plt import numpy as np; if __name__ == "__main__": t=[] pt=[] elem=2*325*1000 # نسبة الاسبرين h=22 k=-math.log(0.5)/h pv=3000 # البلازمه dt=0.01 #تغير بالزمن tt=24 #ساعة q=1 d=0.12*q for i in range(int(tt/dt)): elem= k*e...
e47983a86615394ae14cd8ff9b13c88a164b45cf
Sanchitgupta910/MCA-python-programming
/password.py
1,647
4.1875
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 7 17:40:12 2021 @author: SANCHIT """ # Lambda function to check if a given vaue is from 10 to 20. import random test = lambda x : False and print("weak password") if((len(x) < 8 or len(x) > 20) or not any(char.isdigit() for char in x) or not any(char.isuppe...
8fa4cd96e7c0745d02cf9c0482227dc5bdf2abe0
emma-metodieva/SoftUni_Python_Advanced_202106
/01. Lists as Stacks and Queues/01-02-09. Key Revolver.py
828
3.546875
4
# 01-02. Lists as Stacks and Queues - Exercise # 09. Key Revolver from collections import deque price = int(input()) barrel = int(input()) bullets = deque(map(int, input().split())) locks = deque(map(int, input().split())) intelligence = int(input()) count = 0 while bullets and locks: for shot in range(1, barre...
2bfc8bb9b1e90b03366378e1c80611749229625c
agrima13/PythonCoding
/Strings/Reverse_String-II.py
252
3.765625
4
class Solution: def reverseStr(s: str, k: int): a = list(s) for i in range(0, len(a),2*k): a[i:i + k] = reversed(a[i:i + k]) return "".join(a) if __name__ == '__main__': print(reverseStr("abcdef",2))
771305622d798a19254257bd5cf6fa2314284f08
yiyuli/Automatic-Minesweeper-Solver
/rank.py
821
3.984375
4
class Rank(object): ''' Rank object storing top three records ''' def __init__(self): ''' Constructor for Rank object ''' self.first = 'No record' self.second = 'No record' self.third = 'No record' def update(self, time): ''' Update ra...
e4a0fdfaf7d2c30c42a1066f01c7d1f94a41b488
khush-01/Python-codes
/Codechef/FLOW010.py
136
4
4
a = {'b': "BattleShip", 'c': "Cruiser", 'd': "Destroyer", 'f': "Frigate"} for _ in range(int(input())): print(a[input().lower()])
f6bf3f040544e8639cf0636dfc67b5ec100415eb
madanmeena/python_hackerrank
/set/py-set-union.py
407
4.09375
4
#https://www.hackerrank.com/challenges/py-set-union/problem # Enter your code here. Read input from STDIN. Print output to STDOUT n = int(input()) first_integer_list = map(int, input().split()) m = int(input()) second_integer_list = map(int, input().split()) first_set=set(first_integer_list) second_set=set(secon...
18a10ea55bbcbcd0e0ec53f87c480f37996abf66
DryTuna/codeeval
/longest_common_subsequence.py
1,631
3.8125
4
""" DESCRIPTION: You are given two sequences. Write a program to determine the longest common subsequence between the two strings (each string can have a maximum length of 50 characters). NOTE: This subsequence need not be contiguous. The input file may contain empty lines, these need to be ignored. INPUT: The first a...
19c2572210edbc792d25d537effffa6a5162abd8
drwpeng/shiny-meme
/装饰器/decorator_1.py
2,337
3.984375
4
import time # 装饰器 # 让其他函数在不需要做任何代码变动的前提下增加额外功能 # 经常用于有切面需求的场景,比如:插入日志、性能测试、事务处理、缓存、权限校验等场景 # 不带参数的装饰器 def decorator1(func): def wrapper(): start_time = time.time() func() end_time = time.time() print("不带参数的装饰器: " + str(end_time - start_time)) return wrapper # 带参数的装饰器 def ...
400c69aacd8490c2cc73db8b7d2c57805bb2967a
RadBoris/cardinality
/cardinality.py
1,246
3.984375
4
def main(): combined = 1 g = [] r = str (input ("Enter numbers separated by a space for each column: ")) w = r.split(" ") for x in w: if x: x = int(x) return w def searchTable(g): result = {} combined_cardinality = [] with open('cardinality.sql', 'r') as f: lines = f.readlines() for line in lines:...
263890c5d42c22154293a970541f368c3f18f1c2
suku19/python-associate-example
/controlflow/for_statement.py
1,349
4.40625
4
words = ['cat', 'window', 'defenestrate'] # Measure some strings: for w in words: print(w + ' length is: ', len(w)) # Loop over a slice copy of the entire list. for w in words[:]: if len(w) > 6: words.insert(0, 'test') print(words) # The range function for i in range(5): print('ra...
c1fccbaa5e41b2d1b60b0efe28d6cc981fac7804
jasminjahanpuspo/All_Lab_Code
/AI/untitled3.py
325
3.671875
4
#lst=[] # #n=eval(input("input: ")) # #for x in range(0,n): # ele=eval(input()) # lst.append(ele) #print(lst) lst=[] n=eval(input()) for x in range(0,n): elmt=eval(input()) lst.append(ele) print(lst) p=lst.sort() print(lst[-1]) print(max(lst)) ...
22a0ed12e0b5d5f52be2858339efddf3bcbc663a
zomblzum/DailyCoding
/task_1/test.py
478
3.59375
4
import unittest import sum_searcher as ss class TestSearch(unittest.TestCase): def test_search(self): some_array = [10, 15, 3, 7] some_result = 17 self.assertTrue(ss.list_contain_equal_sum(some_array, some_result)) def test_search_with_duplicates(self): some_array = [10, 15, 3...
f1ffa09d1b8c859106496dba51709ed3d1c036b4
mkholodnyak/Documents
/SummerPractice/2014/src/python/task2/vector.py
652
3.625
4
# -*- coding: utf8 -*- __author__ = 'kholodnyak' from geom.shape import Point from geom.shape import Shape class Vector(Shape): def __init__(self, start, end): self.start = start self.end = end def __iadd__(self, other): self.end.x += other.end.x - other.start.x self.end.y +=...
cf6020e0e68a9e81e8eb4717f79d04a14637ff07
tayalebedeva/hackaton_2021
/LSH3.py
4,319
4.25
4
class Bird: name = '' height = 0 weight = 0 def __init__(self,name,height,weight): self.name = name self.height = height self.weight = weight def printInfo(self): print('Info: ', self.name, self.height, self.weight) def breathing(): print('Im br...
268f06a7b4322320f5abc3e2ba71923562d2e06f
frozen007/algo-study
/Challenge/lcof/lcof-06.py
1,022
3.890625
4
""" 剑指 Offer(第 2 版) https://leetcode-cn.com/problemset/lcof/ 剑指 Offer 06. 从尾到头打印链表 https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/ """ # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(o...
cb5d8e22c90ed5d0866c889ad330cf1abf88dc71
100rabhsrivastava/python_by_100rabh
/pp9.py
89
3.515625
4
n = int(input()) for i in range(1, 11): result = n*i print( n,"x",i ,"=", result)
ea24f3ceea8f2db74d407b6238805a2527a033f6
Amansinghtech/iant-python-classes
/exercise2.py
548
3.609375
4
# multiple inheritence class A: def __init__(self) -> None: print("class A init is called") def feature1(self): print("this is feature 1") class B: def __init__(self) -> None: print("class B init is called") def feature2(self): print('this is feature 2') class C (...
d5fa393de8f6a4ad061ef8ed8618ccc163c8a184
keivanipchihagh/Competitions
/Quera/مسابقه/تیم کشی.py
157
3.671875
4
a1 = int(input()) b1 = int(input()) a2 = int(input()) b2 = int(input()) a3 = int(input()) b3 = int(input()) print(min(a1, b1) + min(a2, b2) + min(a3, b3))
633fa1948b30b789fde6de8352c4dec3501227f6
Apaisley/python01
/assignment 8.5 AdamPaisley.py
269
3.71875
4
fname = raw_input('File name') if len(fname) < 0: fname ='mbox-short.txt' try: fh = open(fname) except: print" not a file bruh" for line in fh: if not line.startswith('From'): continue words_list = line.split() email = words_list[1] count += 1 print email
287854c9cb24e721341dc18f6e34bc903613afcb
AnandMurugan/Python
/ifelseblock.py
338
3.5625
4
#!/usr/bin/env python user = { 'admin': False, 'active': False, 'name': 'Kevin'} if user['admin'] and user['active']: print ("ACTIVE - (ADMIN) %s " % (user['name'])) elif user['admin']: print ("(ADMIN) %s " % (user['name'])) elif user['active']: print ("ACTIVE %s " % (user['name'])) else: print ("%s" ...
8cb1fc7c90e0201635b0c8fad6cf18beea0f9b28
NamelessKing/Python-Exercises
/Es13.py
533
4.25
4
# coding=utf-8 ''' The function max() from exercise 1) and the function max_of_three() from exercise 2) will only work for two and three numbers, respectively. But suppose we have a much larger number of numbers, or suppose we cannot tell in advance how many they are? Write a function max_in_list() that takes a list o...
8aebc65c73775b76fc2b7e5940d50134d312dc58
iss760/algorithm
/algorism_interview/01.valid_palindrome.py
641
3.53125
4
import re def is_valid_palindrome(s): # 전처리: 문자만 추출, 소문자로 변환(대소문자 구분 x 이므로) s = [_s.lower() for _s in s if _s.isalnum()] # 회문 판별 for i in range(len(s)//2): if s[i] != s[len(s) - 1 - i]: return False return True def is_valid_palindrome2(s): # 전처리 s = s.lower() # 소...
1500e032c3fd8836ac8f2a0236176c27f7b03983
TatianaPan/JavaScript-Exercises_new
/Week3/day1/10_split_bill.py
315
3.609375
4
def split_the_bill(obj): sum = 0 for key in obj: sum += obj[key] amount = sum // len(obj) for key in obj: obj[key] = amount - obj[key] return obj group = { 'Amy': 20, 'Bill': 15, 'Chris': 10 } print(split_the_bill(group)) # { 'Amy': -5, 'Bill': 0, 'Chris': 5 }
822c33cdc95988000c925afc22493269ebae6c5e
r-bergundy/practice
/bin/account.py
1,249
3.921875
4
""" This is a test Account class """ import logging import sys class Account: def __init__(self, name, email, balance): self.balance = balance self.name = name self.email = email def get_name(self): logging.info("Retrieving Account Name....") logging.inf...
c4a4b5e230874f56ecce147e7dd07d3ab3277980
siily15/school
/Hangman.py
336
3.953125
4
used_letters =() word = "Ametikool" guessed_word =["_,_,_,_,_,_,_,_,"] letters = list(word) while True: print(guessed_word) print("used letters" + str(used_letters)) letter = input("Type a letter: ") used_letters.append(letter) if letter.lower in word.lower(): letter == word ...
5501fccb6c9362822f75752274cfc41173180032
martinhuprich/teamprojekt
/mx_teamprojekt.py
2,299
3.859375
4
import urllib.request import json from random import shuffle class Quiz(): def __init__(self, name, url): self.name = name self.url = url # def get_info(self): # print(self.name) # print(self.url) def get_question_and_answers(self): #retrie...
8087240d9b774be478f17a77e14fe9406968022c
esparig/Group-14
/daniela997/assignment-1/anagramchecker.py
1,072
4.21875
4
"""This module defines an Anagram checker implementation.""" from collections import Counter class AnagramChecker(object): """Anagram checker with basic functionality. Assumes that character case does not matter, and inputs should be single words made up of alphabetical characters. """ def __...
88ec53865bd0f588e259986bba253f09aba29d7a
KindoIssouf/DataWareHousingScripts
/gradient_example.py
2,302
4.3125
4
import numpy """Gradient descent for linear regression. We will try to learn this linear regression model: w_0 1 + w_1 x = y where we want to predict the value of y, from the value of x. We want to learn the values of the weights w_0 and w_1 from the training data (x,y). """ # we shall simulate data (x,y) with...
4a2f30241b986b64e998c459cd984a45744c9657
kenic1121/Daniel-Pythoon
/Unit2CLab/Unit2CLab.py
614
3.921875
4
print ('My List:') numlist = [1,2,3,4,5,6,7,8,9,10] print (numlist) print ('Counts all thenumbers and adds them up:') print (len(numlist)) print ('Get first 5 numbers:') sublist = numlist[0:5] print (sublist) print ('Insert 3 into list:') sublist.insert (0 , 3) print (sublist) print ('Inserts a nummber:') subl...
b976d0512d6932a56ab590325bf9d63b32eb869a
amerus/python_basic_11_05_20
/homework/lesson3/prob5.py
1,694
3.640625
4
''' Программа запрашивает у пользователя строку чисел, разделенных пробелом. При нажатии Enter должна выводиться сумма чисел. Пользователь может продолжить ввод чисел, разделенных пробелом и снова нажать Enter. Сумма вновь введенных чисел будет добавляться к уже подсчитанной сумме. Но если вместо числа вводится специал...
244db56653add66390af6642d97d93441ea6b2be
iamvee/python-course-2021
/oop/property_definition.py
420
3.765625
4
class Square: def __init__(self, side): self.side = side @property def area(self): return self.side ** 2 @area.setter def area(self, value): ratio = (value / self.area) ** 0.5 self.side = self.side * ratio if __name__ == '__main__': s = Square(6) print(s.s...
13fdd47c11575ed5f0633c3a6d94a9b3b8903e40
Maxim-Kazliakouski/Python_tasks
/My_first_calc.py
743
4.125
4
a = float(input("Введите первое число: ")) b = float(input("Введите второе число: ")) operation = input("Введите операцию: ") vibor = operation #sum = "+" #sub = "-" #div = "/" #mul = "*" #od = "%" #pow = "**" if vibor == "+": print("Результат", a+b) elif vibor == "-": print("Результат", a-b) elif vibor == "*":...
8f8d933e91546b1347f2bb6a59e469603142508c
Nishant-nehra/twitter_data_python
/project.py
1,684
3.5
4
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] def strip_punctuation(s): for i in s: if i in punctuation_chars: s=s.replace(i,'') return(s) # lists of words to use positive_words = [] with open("positive_words.txt") as pos_f: for lin in pos_f: i...
d8198b9a360f1b63d5c7f32fe23d19d0b28ce879
s1881079/weather-info-plotting
/task1_plenty.py
2,057
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 9 15:44:05 2018 This is a program for reading file plenty.data as float and do some data mapping @author: Ananomous """ from matplotlib import pyplot import os def readPlenty(file_dir): '''read plenty.data and convert to float''' data =...
b1acb74615230a15ac903d05020c366b7790d1c0
pannkotsky/lutz_demo
/demo/models.py
532
3.59375
4
class Person: def __init__(self, name, age, pay=0, job=None): self.name = name self.age = age self.pay = pay self.job = job def __str__(self): return "{class_} {name}, {age}. {job} paid {pay}".format( class_=self.__class__.__name__, name=self.name...
d1652a3fc54f45acad689f30dc09e24516108d0f
asperaa/back_to_grind
/Binary_Search/1060. Missing Element in Sorted Array_Clean.py
475
3.734375
4
"""We are the captains of our ships, and we stay 'till the end. We see our stories through. """ """1060. Missing Element in Sorted Array [Clean] """ class Solution: def missingElement(self, nums, k): left, right = 0, len(nums) while left < right: mid = left + (right - left) // 2 ...
ff37dc96aaface7771a822fd40fae7e8ef1b5e2b
youkx1123/hogwarts_ykx
/python_practice/class_python/bicycle/bicycle_practice.py
632
3.9375
4
""" 写一个Bicycle(自行车)类,有run(骑行)方法, 调用时显示骑行里程km(骑行里程为传入的数字): 再写一个电动自行车类EBicycle继承自Bicycle,添加电池电量valume属性通过参数传入, 同时有两个方法: 1. fill_charge(vol) 用来充电, vol 为电量 2. run(km) 方法用于骑行,每骑行10km消耗电量1度,当电量消耗尽时调用Bicycle的run方法骑行, 通过传入的骑行里程数,显示骑行结果 """ class Bicycle: def run(self,km): print(f"骑行了{km}公里") class EBicycle(Bicycle...
da695b152900a852f578253eb667952387a77cd9
arvindkarir/python-pandas-code
/Py exercises/My code/CSS exercises/05_03_alternate.py
1,275
3.53125
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 5 20:44:43 2018 @author: User """ def phone_bill(plan, minute, new_user, student): monthly_fees = {'A':40.00, 'B':50.00, 'C':100.00} free_minutes = {'A':150, 'B':250, 'C':10000} per_minute = {'A':0.50, 'B':0.25, 'C':0} # cap_of_minute_charges =...
bd3e6cecbf66f957c09d25bacd02a96111f0e51f
HB-Kim0106/HAN
/totalsum.py
149
4.03125
4
#!/usr/bin/python3 import sys num1 = sys.argv[1] num = float(num1) def totalsum(num): ans = (num * (num+1))/2 print(round(ans)) totalsum(num)
82de5edcef6ca2301d895185a4ce505d3eb187ea
satoshi6380/RegexEngine
/Problems/Recursive summation/main.py
93
3.5
4
def rec_sum(n): # write the insides here! return n + rec_sum(n - 1) if n > 0 else 0
d26bd99cb98051b1dd8cfffb66a4b4a439ce580f
DeadSoul-Zh/LeetCode
/258-AddDigits.py
384
3.65625
4
class Solution(object): def addDigits(self, num): """ :type num: int :rtype: int """ n = 0 while num >= 0: n += (num % 10) num /= 10 if num == 0 : break; if n == 0 : return 0 elif n % 9 !=...
963db86acfc6897399ec4576cd4786c041d92639
rajan3010/leetcode
/best_time_to_sell_buy.py
252
3.9375
4
def maxProfit(prices): minPrice=float('inf') max_profit=0 for price in prices: minPrice=min(price, minPrice) max_profit=max(max_profit,price-minPrice) return max_profit prices = [7,1,5,3,6,4] print(maxProfit(prices))
15a3926177637cf7b542459adc368c7bc99568ca
vpc20/python-misc
/HashFunctions.py
278
3.546875
4
import hashlib print(hashlib.algorithms_available) filename = input("Enter the input file name: ") sha256 = hashlib.sha256() with open(filename, "rb") as f: for byte_block in iter(lambda: f.read(4096), b""): sha256.update(byte_block) print(sha256.hexdigest())
b2d2cdbd083e6f406f96a4918f475cca570090bd
ishantk/GW2019PA1
/venv/Session20A.py
493
4.09375
4
import pandas as pd nums1 = [10, 20, 30, 40, 50] nums2 = [11, 22, 33, 44, 55] emp1 = {"eid":101, "name":"John", "age":20} emp2 = {"eid":201, "name":"Fionna", "age":22} emp3 = {"eid":301, "name":"Kia", "age":24} df1 = pd.DataFrame([nums1, nums2]) df2 = pd.DataFrame([emp1, emp2, emp3]) print(df1) print() print(df2) ...
df267152c84dab82ec46efcf4918e537ae80f9bf
rkatipally/python-advanced
/src/raj_numpy/numpy_exercise.py
560
4.09375
4
import numpy as np # Create an array of 10 zeros print(np.zeros(10)) # Create an array of 10 ones print(np.ones(10)) # Create an array of 10 fives print(np.ones(10)*5) # Create an array of the integers from 10 to 50 print(np.arange(10, 50)) # Create an array of all the even integers from 10 to 50 print(np.arang...
1f20a6980648ec445ee1ca40ea6153f917b04a43
Ducky3283/Beginner-Python
/randomnumgen.py
676
4.15625
4
#import the random module import random import time #generate random number method ranumber = random.randint(1, 20) #program introduces itself print("Hello, Im a random number generator.") time.sleep(5) #add a time delay of 5 seconds print("Right now, i am thinking of a number between 1 and 20. I bet you ca...
0908363a9e00ca389452d8709f6560deef25affb
chowdhurykaushiki/python-exercise
/insertionSortList.py
411
3.84375
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 18 15:50:23 2018 @author: 212634012 """ print('outside fun',__name__) def fun(): print('inside fun',__name__) num=[4,3,2,1,5] length=len(num) for i in range(length): minIdx=i for j in range(i+1,length): if num[j]<num[minIdx]: ...
518c84e1ba49d931ce15627cd4a962be68b7f4da
MelvinCC10/Python_Carsh_Course
/Ch11 - Testing Code/test_code_example.py
572
3.65625
4
import unittest from sampleFunction import get_formatted_name class NamesTestCase(unittest.TestCase): """Test for ;get_formatted_name' function.""" def test_first_last_name(self): """Do names like 'Janis Joplin' work?""" formatted_name = get_formatted_name('janis','joplin') self.assert...
b1d0ccfe0fc7c5d146e525cdecf7477f4ea4cdcf
komal-navale/PythonBasicLearning
/Python Variables, Data Types & Casting/Variables.py
1,816
4.6875
5
# 1. A variable is created the moment you first assign a value to it. x = 5 y = "User" print(x) print(y) # 2. Variables do not need to be declared with any particular type, and can even change type after they have been set. a = 10 a = "Admin" print(a) # This will show last assigned value to same variable. In this c...
63e2eba2a161aa90e2329a5bf6bad44e041edbb6
kira-ll/python-learn
/hello.py
466
4.03125
4
#!usr/bin/env python3 # -*- coding: utf-8 -*- name = input('please enter your name:') print('hello',name) height = 1.75 weight = 80.5 bmi = weight / (height*height) if bmi < 18.5: print("过轻") elif bmi >= 18.5 and bmi < 25: print("正常") elif bmi >= 25 and bmi < 32: print("过重") else: print("肥胖") names = ['a','b','...
10b3cbe761c667b948d0bd9f3b9d416bc414ed7a
KarlaDiass/AulaEntra21_Karla
/atividadesPY/While_Introdução/exercicio1.py
1,483
4.15625
4
"""Exercício 1 (não usar o continue ou o break) Crie um programa que mostre um memu com as seguites opções: 1) Soma 2) Subtração 3) Multiplicação S) Para sair! Para número 1: Peça 2 números e mostre a soma deles Para número 2: Peça 2 númeors e mostre a subtração deles Para númeor 3: Peça 2 números e mostre a multip...
2f0b7e2238b6f22326fe6e75a60d6ed0a0cf520f
odormond/adventofcode
/2022/9/nine.py
2,722
3.546875
4
#! /usr/bin/env python import advent_of_code as adv test_data = """\ R 4 U 4 L 3 D 1 R 4 D 1 L 5 R 2 """ def to_motions(data): return [ (move, int(distance)) for line in data.splitlines() for move, distance in [line.split()] ] DX = {'R': 1, 'U': 0, 'L': -1, 'D': 0} DY = {'R': 0, 'U': 1, 'L': 0, 'D...
c7a01905abccd90f3ebb92753d03fb8c85138b83
tushgup/python-basics
/solutions.py
2,266
4.125
4
# 1. Count no of letters and digits countL = 0; countD = 0; for c in "Test123": if (c.isalpha()): countL = countL + 1; else : countD = countD + 1; print("No of letters: ", countL); print("No of digits: ", countD); # 2. Remove punctuation import string s = "It's a good day" for c in s: if c ...
725f87280f21a42a5bb65e553007c4ccf9b19811
dmheisel/FortyBelow
/players.py
1,281
4.09375
4
class Player: def __init__(self, name, hand): self.name = name self.hand = hand def __repr__(self): return self.name ###################################################################### class Hand: """ Player's hand consists of six cards in three columns of t...
f337995e94f98602a3665b2116a90e8992cb0fec
Vipexi/python_course
/time.py
379
3.890625
4
#! /usr/bin/python3 import time start_time = time.time() print(start_time) for x in range(1000): for y in range(1000): xy = x+y print(xy, end=" ") end_time = time.time() print(end_time) print(" ") print(end_time - start_time) for y in range(10): print(str(y) + " ", end="") time.sleep(1) ...
83dfc00c65680431f065067ce998f9489d452a83
shalini2503/learn_py
/Assign2-2_Singh.py
1,560
4.3125
4
# This assignment asks to write a program in which # total travel distance is calculated using a loop structure. class DistanceTraveled: speed = 0 # speed is in miles per hours time = 0 # time is in hour distance = 0 # distance is in miles # constructor function def __init__(self, sp...
67f59e5f6ef15ca5389f1a163d02bfae6c35bbef
paramita2302/algorithms
/iv/Arrays/wave_array.py
382
3.765625
4
class Wave(): def wave_array(self, A): A.sort() for i in range(0, len(A) - 1, 2): temp = A[i] A[i] = A[i + 1] A[i + 1] = temp return A def main(): A = [3, 2, 1, 3] # A = [-1, 0, -1] # A = [6, 7, 5] # A = [-6, -1, 4] a = Wave() pr...
2dafd13cba08e61cf3c09867b6ea1bf41e18b331
umluizlima/testing-101
/intro/test_sum.py
529
3.90625
4
def test_sum_passes(): """Assert if the sum of 1, 2 and 3 equals 6. As the asserted result is correct, this will pass. """ assert sum([1, 2, 3]) == 6, "Should be 6" def test_sum_fails(): """Assert if the sum of 1, 1 and 1 equals 6. As the asserted result is incorrect, this will fail with an ...
6c7d3e6595a1cb779125d71178578466c946e950
hamzaMahdi/rec2017
/REC2017Programming/OnymousApp/onymous.py
1,552
3.640625
4
#the following program is supposed to interact with the JSON object #currently, the program reaches the local host and is able to import the data from it #however there is an error in converting the JSON to an object that python can interact with #this lead us to create onymous_static.py which gets data statically and ...
e27a088bbbc5c484a61e1f2a7e601d83fefd3529
udwivedi394/LinkedList
/palindromeList.py
1,195
4.1875
4
class Node: def __init__(self,data): self.data = data self.next = None def palindromeList(root): count = 0 temp = root while temp: count += 1 temp = temp.next temp = root i = 0 while i < count/2: temp = temp.next i += 1 back = reverseLis...
f4942d0589627101ebc341b060c9dbeba966b2bf
Sakthiumamaheshwari97/multipeoffive
/mult.py
66
3.828125
4
numss=int(input()) for x in range(1,6): print(x*numss,end=" ")
04ff4e8bb6e48e265c329b8719f3152a4921adc2
DongGunYoon/Algo_DS
/mar_26th/circularLinkedList.py
967
4.09375
4
class Node: def __init__(self, value, next): self.value = value self.next = next class CircularLinkedList: def __init__(self): self.head = None def append(self, value): if self.head is None: node = Node(value, None) self.head = node node....
7c2378b06734db998778f404ef4a3c0ce7b49f65
pankypan/DataStructureAndAlgo
/leetcode/basicDS08_heap/b04_lc253_min_meeting_rooms.py
1,036
3.5
4
import heapq from typing import List class Solution: def minMeetingRooms(self, intervals: List[List[int]]) -> int: # 按会议开始时间进行排序 intervals.sort(key=lambda item: item[0]) priority_queue = list() heapq.heappush(priority_queue, intervals[0][1]) for i in range(1, len(interval...
3d7da9faeee321fc3d63a703ee8bee35134b355c
Bill2462/AX3003P
/examples/testProtection.py
3,522
3.625
4
""" Example that demonstrates the overcurrent protection (OVP) and overvoltage protection (OVC). This script sets the OVP level to 5V and OCP to 0.3A. Then slowely increases the voltage until the OVP trips. Next the OVP is reseted and the same procedure is repeated with the OCP. """ # This file is part of AX3003P libr...
7128cd1ae9a1b803409d1c9973fbc9560ee3a870
Helloworld616/algorithm
/SWEA/응용/5186_이진수2/sol1.py
885
3.625
4
import sys sys.stdin = open('sample_input.txt') # 이진수 변환 함수 def to_binary(N): # 이진수 결과 초기화 binary = '' # N이 0 이하가 될 때까지 반복문 실행 while N > 0: # N을 2배 더한 값을 변수 double에 할당 double = N*2 # double의 정수 부분만 추출해서 binary에 합산 binary += str(int(double)) # binary의 길이가 12를 넘어...
9881aa187cb706cf2c7b7785a78fb175afb1a3d4
akhandsingh17/assignments
/topics/BinarySearch/CapacityToShipPacakges.py
2,030
4.34375
4
""" A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity ...
474e049cf6d0f3849bb4df33df87784469174c5e
pperorin/Data-Struct
/3.2 Parenthesis Matching.py
1,535
3.65625
4
class Stack: def __init__(self,lst = None): self.lst = lst if lst is not None else [] def push(self,item): self.lst.append(item) def pop(self): self.lst.pop() def peek(self): return self.lst[-1] def size(self): return len(self.lst) def isEmpty(self): ...
0335714468f25c9ee4f4bb2c02f7cb1d2440c3de
nlpjoe/fullstack-nanodegree-vm
/vagrant/tournament/tournament.py
4,503
3.5625
4
#!/usr/bin/env python # # tournament.py -- implementation of a Swiss-system tournament # import psycopg2 def connect(database_name="tournament"): """Connect to the PostgreSQL database. Returns a database connection.""" try: db = psycopg2.connect("dbname={}".format(database_name)) cursor = db...
ab6c06de37bf84a28d04d0b673f791dd7adc7447
42Inc/MIP
/Sem-2/Lab-1/src/readWrite_v2.py
1,941
3.734375
4
#!/usr/bin/env python3 experiment = 50 # Amount of tries in one experiment measuring = 1000 # Amount of measurings in one try alphabet = 26 # Length of the given alphabet (Default: Eng - 26 letters) def genRnd(): readersData = [[0 for cnt in range(experiment)] for cnt in range(2)] for attempt in range(1,...
a7ea53e96c428ca41356a28e86bf93b663197f72
ParadoxPD/Random-Projects
/NCode/OCT/4.py
133
3.765625
4
def number_sum(n): return sum([int(x) for x in str(n)]) N = int(input()) R = int(input()) print(number_sum(R*number_sum(N)))
7cfdead1e1789d68ba58a23dc93cf1f467fb7687
stevenraybon/Python
/Imputation/Imputation_Methods.py
8,314
3.578125
4
###Comparing Imputation Methods ###10/10/2017 ''' Goal of code: Want to compare "prediction errors" of different imputation methods. Will compare Scikit-Learn Imputation methods (mean, median, mode) and a method using OLS to predict missing values. Going forward, a better way to isolate predictive power is to divi...
c501b1aabf12bc966c3d4a118332c58bd2000dac
jgomez07/Election_Analysis
/Resources/If-elif-else.py
640
4.3125
4
# What is the score? score = int(input("What is your test score? ")) # Determine the grade. if score >= 90: print('Your grade is an A.') elif score >= 80: print('Your grade is a B.') elif score >= 70: print('Your grade is a C.') elif score >= 60: print('Your grade is a D.') else: print('Your grade ...
df910e98dd3c2f00c00aaf3ff7c6aa7b9e8ccd3e
ndri/challenges
/old/40.py
201
4.09375
4
#!/usr/bin/env python # 40 - Find the largest number in an array, and print its position from random import randint array = [randint(0,99) for i in range(20)] print array print array.index(max(array))
29144eca28894e2704c27acafc639ab5dd98469b
jmyao17/Learning_Vocabulary
/lec01/YourName.py
1,291
4.40625
4
# ********************************************************** ## lecture01: first python code # ********************************************************** ## - practice with the input() function ## - concept of variables: string and integer number ## - proactice with print() function print("R2D2: Welcome to ...
bf36cc412c903cdd1a46109d436c6afdf187aa2c
5l1v3r1/kinematics_py_calculator
/Calc.py
787
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): print("V") print("D") print("T") choice = input ("Please make a choice: ") if choice == "V": print("V = D / T") D = float( input ("D = ") ) T = float( input ("T = ") ) print("V = "), print(D/T) el...
4837e8769ab408661c6c502d7e88c51be2c6b9d1
gfike19/machineLearning
/work/students-10-12.py
1,763
3.875
4
import pandas as pd import numpy as np studentData = pd.read_excel("C:/Users/aerot/coding/machineLearning/Week3/Assignments/students.xlsx") studentDf = pd.DataFrame(studentData) # Filter class 1 and class 2 students - COMPLETE # print("Class 1\n") # print(studentData[(studentData["class"] == 1)],"\n") # print("Class ...
8ccbbe72bf43b591ef783aea08dde2b5af7650d4
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/kndsit001/question1.py
620
4.125
4
"""Program to Determine Palindrome Sithasibanzi Kondleka 9 May 2014""" words = input("Enter a string:\n") def palindrome(string): if string == "": #a message that contains nothing is technically a palindrome return "Palindrome!" if len(string) == 1: return "Palindrome!" #a message th...
a8d3dd1b28f4d1ec27544eb9ad418a7f87407008
Seorimii/PythonStudy2019
/mar_24/0324_54.py
193
3.609375
4
class Add: def add(self,n1,n2): return n1+n2 class Calculator(Add): def sub(self,n1,n2): return n1-n2 obj= Calculator() print(obj.add(1,2)) print(obj.sub(1,2))