blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ed5b9a4432de26637ecbfc6e2fd3fdecc4ce7617
MjrLandWhale/StatisticsCalc
/range_test.py
1,006
3.71875
4
import unittest from range import RangeCalc # test for range with list of numbers class RangeTest(unittest.TestCase): def test_range_list(self): range_num = RangeCalc() number_list = [10, 6, 4, 2, 4, 7] # list of numbers for test expected_output = 8 # expected output for number_list ...
0de66b65d8d8e7731542c613d35eae6f98704a37
cryjun215/c9-python-getting-started
/python-for-beginners/08 - Handling conditions/add_else.py
479
3.859375
4
price = input('how much did you pay? ') price = float(price) if price >= 1.00: # $1.00 이상의 비용은 모두 7%의 세금이 부과됩니다. # 들여 쓰기(indent)된 모든 구문은 price >= 1.00 인 경우에만 실행됩니다. tax = .07 print('Tax rate is: ' + str(tax)) else: # 그 외에는 세금을 부과하지 않습니다. # 들여 쓰기된 모든 구문은 가격이 $1 미만인 경우에 실행됩니다. tax = 0 print('Tax rate is: ' + str...
353c8a980f132f1c58edde0bc9805648fe3225d2
sangloo/Data-Science-Learning-Path
/Dataquest Learning/python-programming-intermediate/Challenge_ Modules, Classes, Error Handling, and List Comprehensions-186.py
1,210
3.90625
4
## 2. Introduction to the Data ## import csv data = csv.reader(open("nfl_suspensions_data.csv")) nfl_suspensions = list(data) nfl_suspensions = nfl_suspensions[1:] years = {} for item in nfl_suspensions: year = item[5] if year in years: years[year] += 1 else: years[year] = 1 print(years)...
c51a98098abc77ddb7aaedec0bc163b7c2ad1879
PrVrSs/tng
/projects/py_projects/pvs/pvs/errors.py
1,266
3.828125
4
"""Custom Exception""" class ItemAlreadyStored(Exception): pass class ItemNotStored(Exception): pass class CutterException(Exception): """General Cutter exception occurred.""" class CMDException(Exception): """General Cmd exception occurred.""" class ArgumentValidationError(ValueError): ""...
60dba71446796ccb51a43adffdb82d0dbb034816
mrob95/MR-caster
/caster/lib/latex/book_citation_generator.py
4,807
3.5625
4
# -*- coding: utf-8 -*- try: from bs4 import BeautifulSoup except: pass from urllib2 import Request, urlopen, quote from caster.lib.dfplus.actions import Key, Text from caster.lib.dfplus.clipboard import Clipboard import re # takes URL, returns beautiful soup def request_page(url): header = {'User-Agent': ...
9bbd83a4689c875ee5a6dce967abbc61e133eeb9
salvador-dali/algorithms_general
/interview_bits/level_6/06_greedy/03_bulbs.py
317
3.75
4
# https://www.interviewbit.com/problems/bulbs/ def bulb(arr): if not len(arr): return 0 prev, arr2 = -1, [] for i in arr: if i != prev: arr2.append(i) prev = i if arr2[0] == 1: return len(arr2) - 1 return len(arr2) print bulb([1, 1, 1, 0, 1, 1])
6d6f9092a91ac220daf0c4ef0a67b04ed4fc76c4
Jill1627/lc-notes
/isComplete.py
1,336
4.125
4
""" 问题: 问一棵树是否完全 思路:使用队列 Queue装入所有TreeNode,pop掉所有尾端的None,然后逐个检查,一旦中间有None,false 1. 将root装进queue 2. 用指针index,记录queue中的元素 3. 当index未达到队列长度时,意味着队列中还有实际的元素,就先测试该元素的左右儿子是否存在,然后加入队列 4. 加入完毕后,将靠后的None元素全部pop掉,会停止在一个实际元素的位置 5. for所有当前队列中的元素,任何是否出现空,都false,其他true。因为现在出现的None元素,就是树中间的,而不是尾后的 """ """ Definition of TreeNode: clas...
760c87e0819c71c4679e9a35bfc3e3ab6c117aac
djanlm/Curso-Em-V-deo---Python
/Mundo 2/ex058_JogoDaAdivinhacao2.py
486
3.609375
4
from random import randint comp = randint(0, 10) print('\033[1;33m=-'*20) print('\033[1;32m{:^40}'.format('JOGO DA ADIVINHAÇÃO')) print('\033[1;33m=-'*20+'\033[m') guess = int(input("Qual número entre 0 e 10 eu pensei? ")) tentativas = 1 while guess != comp: print("\033[1;34mO número que pensei não foi esse, tente ...
d77a4d51d56dda9fbd7337872ed3e8374ecbc33d
apatelCSE/pyprojects
/buzzfeedquiz.py
1,080
4.0625
4
while True: print("Tell Us Which of These Movies Made You Cry and We'll Guess Your Favorite Food") counter = 0 titanic = input("Did you cry during Titanic?") print(titanic) if "y" in titanic: counter += 1 up = input("Did Up make you cry?") print(up) if "y" in up: counter += 1 notebook = input(...
da5b82a6ba953974d1f1c7bf2b7fe0602a8f9b35
salvador-dali/algorithms_general
/training/02_implementation/the_grid_search.py
1,074
3.71875
4
# https://www.hackerrank.com/challenges/the-grid-search def find_all(a_str, sub): arr, start = [], 0 while True: start = a_str.find(sub, start) if start == -1: break arr.append(start) start += len(sub) return arr def tryPattern(positions, M, sM, line): l = l...
63131207928d367b6bd0b2656aa4b3a8b6c135ee
lasya02/comp110-21ss1-workspace
/lessons/quiz01.py
517
3.6875
4
def main() -> None: b: list[str] = a print(b) f(a) print(b) print("6") g() print(b) print("4") print(b[0]) return None def f(c: list[str]) -> None: c[0] = "p" print(c) c = ['m','j'] print(c) print("0") return None def g() -> None: global a a...
89ec863c50a51ab2df25d938f689096f88e402a2
knunura/TCP-Client-Server-Centralized-Network
/client/client.py
2,874
3.5625
4
####################################################################### # File: client.py # Author: Kevin Nunura and Jose Ortiz # Purpose: CSC645 Assigment #1 TCP socket programming # Description: Template client class. You are free to modify this # file to meet you...
c9f734a2a56e30d8449a84d211d48c7cd4938fab
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/khstsa004/question1.py
161
4.03125
4
x=eval(input("Enter a year:\n")) if x%400==0 or x%4==0 and x%100!=0 : print(x, "is a leap year.") else: print(x, "is not a leap year.")
5c22038c133b8f3c714c3b2644bcbb8bf1e94f51
ryanriccio1/prog-fund-i-repo
/main/labs/lab3/ryan_riccio_lab3b.py
8,403
3.765625
4
# this program will calculate the gross pay for a given employee and return # it as a pay stub # declare constants BASE_SALARY = 2000 MAX_VACATION_DAYS = 3 MAX_VACATION_DEDUCTION = 200 BONUS_THRESH = 3 BONUS_0 = 0.0 BONUS_1 = 0.0 BONUS_2 = 1000.0 BONUS_3 = 5000.0 GREATER_3_BONUS = 100000.0 LONG_TIME_MONTH = 60 LONG_TI...
9b6962477e16fe96e6f7dde2b572dec31458e865
CreateCodeLearn/data-science-track
/Workshop_Coding/temperature_module.py
507
4
4
def kelvin_to_celsius(temperature_K): ''' Function to compute Celsius from Kelvin ''' rv = temperature_K - 273.15 return rv def fahrenheit_to_celsius(temperature_F): ''' Function to compite Celsius from Fahrenheit ''' temp_K = fahrenheit_to_kelvin(temperature_F) temp_C = kelvin...
b1f81701c48a5d3efdcfd5712f9911c77e9033ae
cvitanovich/course_projects
/CIS313/assignment2/cvitanovich/problem2-1.py
895
3.734375
4
# Dictionaries for A and B Tiers A_tier = {} B_tier = {} # Read Text File And Store Each Address In Correct Dictionary import sys data = (line.rstrip('\n') for line in open(sys.argv[1])) nAddresses = int(next(data)) for lineNo in range(0,nAddresses): line = next(data).split(' ') # split line by whitespace if(line[1]...
6d64a565735cb69cc39417777fa468e9c960c331
Stewie4848/CP1404_Practicals
/prac_05/word_occurrences.py
353
3.96875
4
text = input("Text: ") words = text.split(" ") words.sort() word_count = {} for word in words: if word in word_count: word_count[word] += 1 else: word_count[word] = 1 max_length = max((len(word) for word in words)) for word in sorted(list(word_count.keys())): print("{:{}} = {}".format(word...
56f75189a3546b846f2a27434cfdcc0bb2fbb7b0
Foroozani/rasta
/rasta/process_geo_data.py
1,468
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Holds some static method which can be used to process GPS data. @author: ikespand """ import math class ProcessGeoData: """Some methods to post process geospatial data""" @staticmethod def get_distance_from_df(data): """Returns the distance for...
e2eb64ac37273b26c96c061717179f45abee9fc6
zois-tasoulas/algoExpert
/easy/palindromeCheck.py
642
4.28125
4
def is_palindrome(string): if string is None: raise Exception("Empty string passed to function is_palindrome") end_index = len(string) - 1 # For odd length strings, the middle letter will not be checked for index in range(0, len(string) // 2): if string[index] != string[end_index - ind...
113f8ca21b3a9aaaba6e49bb2cae403e2daf8a42
JMCSci/Introduction-to-Programming-Using-Python
/Chapter 13/13.4/readwrite/ReadWrite.py
1,128
3.828125
4
''' Chapter 13.4 ''' import random, os.path def main(): filename = input("Enter a filename: ") pathExists = os.path.exists(filename) # check if file exists if(pathExists == False): fileOutput = open(filename, "a") for i in range(0, 100): value = random.randint(0, 200) ...
7640c6d480b18748a83c8b73c401ea800e7abb89
alferovyuriy/geekbrains
/Python(Basic)/home_work_5/task3.py
673
3.640625
4
""" Определяет, кто из сотрудников имеет оклад менее 20 тыс., выводит фамилии этих сотрудников. Выполняет подсчет средней величины дохода сотрудников. """ try: with open('employees.txt', 'r') as file: sum_salery = 0 counter = 0 for i, employee in enumerate(file.readlines(), 1): surname, salary = employee.spl...
092fc50a686e9712d05f3de8b7db099b28ed5e0a
christy951/programming-lab
/c01/co1 q5.py
183
3.640625
4
lit=[] n= int(input("Enter the number")) for i in range(0,n): ele= int(input()) if(ele<100): lit.append(ele) else: lit.append("over"); print(lit)
8ba6f57a90e12ae912a83a00f15183850036767b
plelukas/TK
/zad4/AST.py
4,060
3.625
4
#!/usr/bin/python class Node(object): def accept(self, visitor): return visitor.visit(self) def __init__(self): self.children = () class BinExpr(Node): def __init__(self, op, left, right, line): self.line = line self.op = op self.left = left self.right = ...
1a4a19808a4b00b8465cc2b88d0c9659bf1ac04a
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc241_diff_ways_to_add_parenthesis.py
1,363
3.546875
4
# https://leetcode.com/problems/different-ways-to-add-parentheses/ class Solution: def __init__(self): self.eval = { '+' : lambda a,b: a+b, '-' : lambda a,b: a-b, '*' : lambda a,b: a*b } self.m = {} def diffWaysToCompute(self, input: str) -> [...
5ecb23519722924a031f0bd491bec60cebee024d
jrpfaff/PythonNetworkFlows
/main.py
6,934
3.703125
4
from math import inf from collections import deque ''' Ford-Fulkerson implementation and general network flow solver base class. Implemented based on William Fiset youtube video: https://www.youtube.com/watch?v=LdOnanfc5TM&list=PLDV1Zeh2NRsDj3NzHbbFIC58etjZhiGcG&index=1 ''' class Edge: def __init__(self, start: in...
6f0f67cf205923a88e4af0ab47ba00307e894198
juanall/Informatica
/TP2.py/2.1.py
545
4.03125
4
#INTRO. A PYTHON PARTE 2: #Ejercicio 1 #Creá un programa que lea una cadena por teclado y compruebe si la primer letra es mayúscula o minúscula. def mayus (cadena): if (cadena[0]).isupper() == True: print ("la primer letra esmayuscula") else: print("la primer letra es minuscula") print(mayus("c...
ba445e0fcbf182279a43330a86752602eeca1cb0
tonydelanuez/python-ds-algos
/probs/merge-integer-ranges.py
958
3.671875
4
def merge_ranges(input_range_list): #check for null or 1 list if (len(input_range_list) <= 1 or input_range_list == None): return input_range_list output = [] i = 1 previous = input_range_list[0] while i < len(input_range_list): current = input_range_list[i] #overlap exists if(previous.upper_bound >= curr...
48494013345d258fb17e1ba214f143b778a1f3bb
PNeekeetah/Leetcode_Problems
/Reverse_Words_in_a_String.py
683
3.609375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 29 22:17:09 2021 @author: Nikita """ """ Took me less than 10 minutes to code this. It beats 42% in terms of runtime and 0% in terms of memory. 4th time submission sucessful. The fact that I could have multiple white spaces tripped me. """ class Solution: def re...
b4058abfb2cc246e722d17fdd6b0c17863528b76
hrawson79/Algorithms
/Trees/binary_search_tree.py
3,063
4.03125
4
# BinarySearchTree Class from Trees.tree_node import TreeNode class BinarySearchTree(object): # Constructor def __init__(self): self.root = None # Method to insert a new item into the tree def insert(self, item): self.root = self._subtree_insert(self.root, item) # Helper method to...
be5fee8ef69cbdd12312868d07b9e0e134a26252
sairam-py/CodeForces-1
/EvenOdds.py
541
3.765625
4
__author__ = 'Devesh Bajpai' ''' http://codeforces.com/problemset/problem/318/A Algorithm: Find the half of the limit number. Check if it lies on the left of the half of it. If so, print the kth odd number. Check if it lies on the right of the half of it. If so, print the kth even number. ''' def solve(n,k): if(n...
c767bc5afd8548ab91cc53ec8003be6d09281ad5
Fahmad920/CSE
/Blackjack.py
338
3.75
4
import random def draw_hit(): return random.randint(1, 10) def total_value(): return card1 = draw_hit() card2 = draw_hit() print(card1 + card2) print("Your cards are %s" % card1, card2) turn = input("Do you want to hit or stay? ") if "hit": print("You got %s." % draw_hit()) print("Your total is n...
428a709fcf92f5045413648f16869b12534f33bb
dtliao/Starting-Out-With-Python
/chap.5/25 p.231 ex.15.py
1,188
4.09375
4
def calc_average(): average=(firstScore + secondScore + thirdScore + fourthScore + fifthScore)/5 return average def determine_grade(x): if x>=90 and x<=100: return 'A' elif x>=80: return 'B' elif x>=70: return 'C' elif x>=60: return 'D' else: return 'F...
452c8102267ccf119f35b22b06a6455f9ebb770d
AbdullahEsha/Python
/basics/BIDIRECTIONAL.py
1,330
3.84375
4
import queue class Node: def __init__(self, value): self.value = value self.neighbors = None self.visited_right = False self.visited_left = False self.parent_right = None self.parent_left = None def bidirectional(s, t): def extract_path(node): node_copy = node ...
e2fb14778e064b003116eb55b510709a3d59f071
edeng/CodeEval
/Easy/FizzBuzz.py
679
3.71875
4
# Eden Ghirmai, 2/18/14, www.codeeval.com # prints out the the pattern generated by such a scenario given the values of # 'A'/'B' and 'N' which are read from an input text file. import sys test_cases = open(sys.argv[1], 'r') for test in test_cases: if test: split = test.split(" ") first = int(split[0]) ...
6e14cbcd144e3de7c1e05d77abdd187e81ddca36
Gaterny/PythonTechnical
/algorithm/冒泡排序
431
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 时间复杂度:O(n^2) # 稳定性:稳定 def bubble_sort(alist): # 遍历次数 for i in range(len(alist)-1): # 每次遍历比较次数呈递减 for j in range(len(alist)-1-i): # 比较前后位置的大小,并交换位置 if alist[j] > alist[j+1]: alist[j], alist[j+1] = alist[j+1],...
b4dcd1486de6280afc20f968f50f42e8e70c3bf0
ZeroxZhang/pylearning
/except.py
248
4.21875
4
#代码报错时,自定义错误输出内容 try: print(10/0) except: print("0 cannot be divided~") #标准的数据 try: print(10/8) print(10+"0") except ArithmeticError as e: print(e) except TypeError as t: print(t)
fe60b86ca377e8697e0bddd0a01bfab487c68154
raymonddtrt/Design-Pattern
/Strategy/2-1.py
711
3.984375
4
#生成cashier類別 class Cashier: #建構式 def __init__(self,price,amount): self.price = price self.amount = amount #用來顯示的方法 def total(self): return Calculator(self.price,self.amount).calculate() #簡麗calculate物件。用來計算,繼承Cashier class Calculator(Cashier): #建構式,繼承Cashier才能把參數傳進來 def ...
aa7647dd4a117b8553569668e23efa58cc8f60e8
rafaelperazzo/programacao-web
/moodledata/vpl_data/49/usersdata/98/17379/submittedfiles/pico.py
358
3.703125
4
# -*- coding: utf-8 -*- from __future__ import division #def pico(lista): #CONTINUE... n = input('Digite a quantidade de elementos da lista: ') #CONTINUE... a=[] for i in range(0,n,1): a.append(input('Digite um valor: ')) posicao=0 for i in range(0,len(a)-1,1): if a[i]>a[i+1]: posicao=...
8f384bceefe2e1758c9697738639b5fb3adee2d3
Armando101/Programaci-n-Concurrente
/17-Eventos.py
1,401
3.546875
4
import time import logging import threading logging.basicConfig(level=logging.DEBUG, format='%(threadName)s : %(message)s') """ Un evento internamente contiene una bandera, verdadero o falso Por default la bandera comienza en falso Una vez la bandera cambia a verdadero se dispara una señal Todos los threads que se en...
6d4502fab466787f0e51ec6bf342719a0ef94692
KaiserSamrat/left-rotation-array-solution
/left-rotation.py
422
3.875
4
def rotateLeft(a, d,n): length = len(a) newArray = [0 for x in a] # Initialize 0 in an array of size 5. for i in range(n): newElement = i-d newArray[newElement]=str(a[i]) result = " ".join(newArray) return result def main(): arr = [1,2,3,4,5] d = 4...
f135bf627f4f64964a4b5c09c7c4147419236f74
IvayloSavov/Programming-basics
/loops_part_2_exercise/vacation_my.py
746
3.828125
4
needed_money = float(input()) available_money = float(input()) days_spend = 0 total_days = 0 spend_5_days = False while available_money < needed_money: type_command = input() money_spend_save = float(input()) total_days += 1 if type_command == "save": days_spend = 0 available_money += m...
4adfd5d86e17b37017f0205ee46898af43d9dd45
Atul-Nambudiri/AIMPS
/cs440_pacman/dfs.py
2,879
3.953125
4
from stack import stack import copy def dfs(maze, start, end, walls): """ This function runs DFS on the maze to find a path from start to end """ m_stack = stack() #Inits a stack to store nodes in visited = copy.deepcopy(walls) prev = copy.deepcopy(maze) #Keeps track of the previous for a particular node ope...
7fbecea1be4d4e5bd272eabdd8442b8a25154264
guyman575/CodeConnectsJacob
/semester2/lesson7/linkedlist.py
740
3.984375
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): temp = self.head while temp != None: print(temp.data) temp = temp.next # here temp is ...
59c975c02cdfd2d9ce0c2fce771afbf8379a5086
xudalin0609/leet-code
/DataStructure/dataStream.py
1,906
3.671875
4
""" 960. 数据流中第一个独特的数 II 中文English 我们需要实现一个叫 DataStream 的数据结构。并且这里有 两 个方法需要实现: void add(number) // 加一个新的数 int firstUnique() // 返回第一个独特的数 样例 例1: 输入: add(1) add(2) firstUnique() add(1) firstUnique() 输出: [1,2] 例2: 输入: add(1) add(2) add(3) add(4) add(5) firstUnique() add(1) firstUnique() add(2) firstUnique() add(3) first...
53367ea1b19756b89e3591b154c37862c84011a6
venkataniharbillakurthi/python-lab
/ex-8.py
245
4.25
4
word=input('Enter the word') status=Flase for i in "aeiouAEIOU": status=True if status==True: print("word contains vowels") else: print("word doesn't contains vowels") #output #Enter the word:why #word contains vowels
a322062a7f59c37313aea7cd4da1975ea7e16cde
lucasdealmeidadev/Python
/Composição/Exemplo - 1/main.py
404
3.546875
4
from classes import Motor, Carro; carro01 = Carro(1, 'Honda Civic', '4 cilindros'); print('\n-------------------MOTOR-------------------\n'); print('Id do motor = ',carro01.getIdMotor()); print('Modelo do motor = ',carro01.getMotor()); print('\n-------------------CARRO-------------------\n'); print('Id ...
9d4e17cacb3b15af3e7e27022e17485bc652e45d
ColorfulCodes/Algo-Grind
/JerAguilon/CoinChange/Coins/__init__.py
387
3.90625
4
def coinChange(coins, amount): need = [0] + [amount + 1] * amount if len(coins) == 0: raise ValueError('Must insert a list of coin types') for c in coins: for a in range(c, amount+1): need[a] = min(need[a], need[a - c] + 1) if need[-1] <= amount: return need[-1] e...
e1669201384c661bd649077dc7cd54ef2c6b178b
aktersabina122/CSI-31-Academic-Project-
/CSI 31 (Introduction of Python)/Project 2 (Average of n integer).py
576
4.03125
4
#CSI 31 Sabina Akter Avg.py #This program calculates the average of n integers def main(): print( "This program computes the average of n integers. ") print() n = eval(input("How many? ")) sum = 0 for i in range(n): a = eval(input("Enter a number? ")) sum = sum + a ...
a7ac77a3056340362cb484e74dcb8c8c5fd8ccfc
mmankt2/CodingDojo
/Python/OOP/users-w-bankaccounts.py
2,150
4.28125
4
#!/usr/bin/python3 class User: # here's what we have so far def __init__(self, name, email): self.name = name self.email = email self.account = BankAccount(int_rate = 0.02,balance =0) # adding the deposit method def make_deposit(self, amount): # takes an argument that is the amount of the deposit ...
25568ea2097de0f9c7e256145c4831a433f2175c
Industrial-Functional-Agent/cs231n
/Assignment1/doogie/numpy_prac/Scipy_prac.py
4,358
3.71875
4
# Scipy # Numpy provides a high-performance multidimensional array and # basic tools to compute with and manipulate these arrays. # Scipy builds on this, and provides a large number of functions # that operate on numpy arrays and are useful for different types # of scientific and engineering applications. # Image oper...
8b134e6c561840709e6fc8e1952cfe8d0f7a63cc
VerstraeteBert/algos-ds
/test/vraag4/src/isbn/15.py
1,699
3.734375
4
def isISBN13(code): if not( isinstance(code, str) and # input moet string zijn len(code) == 13 and # moet lengte 13 hebben code.isdigit() # moet numeriek zijn ): return False # als vorige 3 voorwaarden niet...
dde024fe9258df419e7a7eba953f6f43dd120fa0
SurekshyaSharma/Variables
/ftoc.py
321
3.96875
4
def f2c(fahr): Celsius = (fahr - 32) * 5 / 9 # Fahrenheit = 9.0/5.0 * Celsius + 32 rounded_Celsius = round(Celsius, 2) result = rounded_Celsius return result def main(): value = float(input("Enter the temperature in degree F: ")) print(value, "degree F is",f2c(value),"degree C") main()...
ce0f78e1097e21437c7facc26e30fdd382d23210
orffen/cepheus
/dice.py
1,254
4.09375
4
# dice.py -- Dice class definition and related functions # # Copyright (c) 2020 Steve Simenic <orffen@orffenspace.com> # # This file is part of the Cepheus Engine Toolbox and is licensed # under the MIT license - see LICENSE for details. from typing import List import math import random import sys class Dice(object)...
f1c5cd2927fbad1285ad79bca2cc3994cb7eda7c
Divya-vemula/methodsresponse
/strings/tuplefunction.py
101
3.765625
4
def is_even(n): return n%2==0 num=[1,5,2,8,9,7,6,4] even =list(filter(is_even,num)) print(even)
1163709041df658771b26f1f8a63fdd3013800f8
Avaneesh-tech/Atm
/atm.py
306
3.625
4
class Atm(object): def __init__(self,name,pin,): self.name=name self.pin=pin def info(self): print("Account name is : "+self.name) print("card pin is : "+self.pin) Atm1=Atm("Avaneesh Sawant","2364") Atm2=Atm("Sanjana Sawant","3018") Atm1.info() ...
f470df288a6b4826f56472f6a3a17618e5446851
jessimk/SklearncomPYre
/SklearncomPYre/split.py
2,876
3.625
4
# coding: utf-8 # In[ ]: from sklearn.model_selection import train_test_split import numpy as np import pandas as pd def split(X, y, ptrain, pvalid, ptest): """ The function splits the training input samples X, and target values y (class labels in classification, real numbers in regression) into train,...
e568187a893786a4ecec8c486e58951cc31301ae
loudbrightraj/Chain_reaction_Python_Version_1
/src/core/Game_controller.py
812
3.828125
4
''' Created on Sep 17, 2015 @author: H141517 ''' from Grid import Grid from Player import Player def main(): ''' Controller which starts the game. ''' possible_color = ['red','blue','green','yellow','orange','brown','black'] grid_size = 8 players = [] no_of_players = input("How many play...
5a3de4465748ae156f5eb7b8aa4814d38a1eae20
erik-hasse/pidrive
/pidrive/abstract/car.py
1,064
3.625
4
from abc import ABC class Car(ABC): def __init__(self, drive_motors, turning_motors): self._drive_motors = drive_motors self._turning_motors = turning_motors self.velocity = 0 self.angle = 0 def stop(): self.speed = 0 @property def angle(self): return ...
dec540503746546a5d69fbabd2870c3eaa8d77c9
gtenorio10/Codecademy_DS
/Python/Carly_Clippers.py
814
3.71875
4
hairstyles = ["bouffant", "pixie", "dreadlocks", "crew", "bowl", "bob", "mohawk", "flattop"] prices = [30, 25, 40, 20, 20, 35, 50, 35] last_week = [2, 3, 5, 8, 4, 4, 6, 2] total_price = 0 for cost in prices: total_price+=cost print(total_price) average_price = total_price/len(prices) print("Average Haircut Pric...
c3f4ea1dc2d1a1fc19e553f146c0c8d053d4985f
marajput123/caesar-encryption
/caesar_encryption/password_decoder.py
6,820
4.34375
4
# ///This program will decode the password using the provided key # This is the key list. it will be used to dencode the passcode keyList = ["A","B","C","D","E","F","G","H","I","J",\ "K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] # This function will ask the the user to input the password def in...
360fc692c900021341c9c10e5a975ee6c19be57e
win911/UT_class
/for_pytest/exercises/1/my_math.py
117
3.671875
4
# my_math.py def is_multiples_of_three(num): if num % 3 == 0: return True else: return False
ff0aaee034f8848353b361e6c06514b2b0734726
udayt-7/Python-Assignments
/Assignment_1_Basic_Python/s1p17.py
278
4.25
4
# to count no of vowels in string str1= input("Enter string:") vowels=0 for i in str1: if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'): vowels=vowels+1 print("Number of vowels are:", vowels)
7810cc3bff3d4d7f68148b9e27252dde2166363a
grivanov/python-basics-sept-2021
/IV.11-clever-lilly.py
546
3.5
4
lilly_years = int(input()) wm_price = float(input()) toy_price = int(input()) money_received = int() toys_received = int() even_birthdays = 0 for num in range(1, lilly_years + 1): if num % 2 == 0: money_received += num * 5 even_birthdays += 1 else: toys_received += 1 money_received -...
e91f4e8727e2204b859e074c988835d3bb7eaf04
p4thakur/PythonScripts
/drawCircleUsingRectangle.py
471
3.796875
4
import turtle def drawSquare(some_turtle): for i in range(0,4): some_turtle.forward(100) some_turtle.right(90) def drawRect(): window=turtle.Screen() window.bgcolor("red") brad=turtle.Turtle() brad.shape("turtle") # this mean my drawing tool will lokk like a turtle brad.color("green") brad.speed(2) fo...
328ea03c58336cb6e7241cb9dc109115c0b60e03
aryamangoenka/c-98
/c-98/countingwords.py
261
4.15625
4
def countwords(): test1=input("enter the file name ") words=0 file=open(test1,"r") for line in file: word=line.split() print(word) words=words+len(word) print("no. of words ") print(words) countwords()
5b6337d85519db6267d3e417ace054d8fe831e2a
avrahamm/python-bootcamp-062020
/lesson19/ex4/ex4.py
629
3.796875
4
import sys from collections import defaultdict # Well done - loved it def build_anagrams_dict(): filename = sys.argv[1] # words anagrams_dict = defaultdict(set) with open(filename, "r") as f: for word in f: clean_word = word.strip() key = (''.join(sorted(clean_word))) ...
b1d428cbcae752e7a46db5713c0d58042bda0724
pdxgitit/python_class
/teaching/11.py
332
3.671875
4
# You will be provided with an initial list (the first argument # in the destroyer function), followed by one or more arguments. # Remove all elements from the initial array that are of the same # value as these arguments. def destroyer(first, *argv): return print(destroyer([1, 2, 3, 1, 2, 3], 2, 3)) # should re...
be81acb668da2dc8f26ad6979109153838c7644a
Araym51/Ostroumov_Egor_DZ
/Lesson_2/Task_2_1.py
401
4.09375
4
# Задание 1 # Выяснить тип результата выражений: # 15 * 3 # 15 / 3 # 15 // 2 # 15 ** 2 a = 15 * 3 b = 15 / 3 c = 15 // 2 d = 15 ** 2 print('тип переменной a = 15 * 3', type(a)) print('тип переменной b = 15 / 3', type(b)) print('тип переменной c = 15 // 2', type(c)) print('тип переменной d = 15 ** 2', type(d))
c7cf7bf4c90aded76c7590b217d506c7385637fa
hseritt/idea-sandbox
/using_dicts_switch_case/demo1.py
179
3.75
4
#!/usr/bin/env python def subtract(num1, num2): return num1 - num2 func = { '-': subtract, } if __name__ == '__main__': diff = func['-'](6, 3) print(diff)
0435d7048f2045dff873f0c51e6f06661559289f
tylors1/Leetcode
/Problems/jewels.py
180
3.609375
4
J = "aA" S = "aAAbbbb" def jewels(J, S): count = 0 j_set = set([letter for letter in J]) for char in S: if char in j_set: count += 1 return count print jewels(J, S)
f18a126e62df6b105fb9dcdcbec2936f7c60cf7c
CARLOSC10/T06_LIZA.DAMIAN-ROJAS.CUBAS
/LIZA_DAMIAN_CARLOS/SIMPLES/condicionales_simples07.py
828
3.75
4
#CONDICIONAL SIMPLE QUE CALCULA EL AREA DE TRAPECIO import os Base_mayor,Base_menor,altura=0,0,0 #ARGUMENTOS Base_mayor=int(os.sys.argv[1]) Base_menor=int(os.sys.argv[2]) altura=int(os.sys.argv[3]) #PROCESSING area_trapecio=((Base_mayor+Base_menor)/2*altura) #OUTPUT print("##########################################"...
ec7861c62e3a4c2897aa0d8e5b2f72f585c62251
eLtronicsVilla/Miscellaneous
/Python/fundamental/test3.py
59
3.578125
4
iterable = [1,2,3,4] for item in iterable: print(item)
a525a8871b9a9eb10b27570d79851c83b72d273f
hyro64/Python_growth
/Day 8/Exercises/8-7Album.py
292
3.8125
4
def make_album(artist, album, tracks = ''): """Returns a dictionary of albums""" completed_album = {"Artist: ": artist, "Album: ": album} if tracks: completed_album['tracks'] = tracks return completed_album completed = make_album("jimi","Voodoo Child", tracks = 12) print(completed)
d217bac5f6d7f1e31f3b7a74f18c1f3e8cc1560a
KevinPautonnier/MachineLearning
/cours5.1.py
1,112
3.53125
4
""" Premier exercice de notre cinquième cours de machine learning. Le but était d'utiliser surprise pour prédire la note que donnerai un utilisateur spécifique pour un film en fonction de ses notes sur d'autres films. Surprise nous fournis les données nécessaires. """ from surprise import SVD from surp...
966fffddd0fb7a3a660c209198e707e5fe3bd621
JoseEscudero07/Archivos-Python
/ejercicio_6.py
153
3.671875
4
peso = float(input("Digite su peso en [kg]: ")); Estatura = float(input("Digite su Estatura en [cm]: ")); imc = peso/pow(Estatura,2); print("IMC: ",imc)
adf5e47ef4d4049b55a035be8569b7389f016392
ranafge/all-documnent-projects
/scrapy_file/python_re_details.py
595
3.546875
4
# You may use a Negative Lookahead (?!...) to ensure that content following the # digit is not a letter you set # # Here an example where all digits followed by any of there char GJK are not concerned by the suppression import re sentenc = "On 11 December 2008, India entered the 3G arena 1A 3J 5K" print(re.sub(r"\d(?!...
ddc2dd587144bb2c53824011368091552efd5c3f
anusha4999/anusha
/python/tasks/loops/l1.py
159
3.671875
4
num=int(input('enter a number')) sum=0 n=num while n>0: rem=n%10 sum=sum+rem*rem*rem #n//=10 n=n//10 if num==sum: print('ams') else: print('not a ams')
b24a38e00ddf62eb3ed1f7129197857d299e2f43
Jmwas/Hangman
/Hangman.py
1,219
3.984375
4
""" Word guessing game based on hangman. You get seven tries to guess a letter. """ import random from dictionary import dict while True: question = input("Do you want to continue? Y/N: ") question.lower() if question not in ('y', 'n'): print("Please select y or n") continue elif que...
e1db1e1c7bc20877b6f396fd89236880828b08ea
MBras/AOC2020
/15/part2.py
1,750
3.828125
4
def playgame(inp): if len(inp) % 10000 == 0: print "size: " + str(len(inp)) #print "input: " + str(inp) last = inp.pop() search = 1 searchinp = inp[::-1] #print "looking for " + str(last) + " in " + str(searchinp) inp.append(last) try: search = searchinp.index(l...
5761e4389371f1291bf97aed3501a669beeb5376
zaarabuy0950/assignm_2
/datatypes/33.py
253
4.125
4
"""33. Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are square of keys""" n = int(input("Enter the end of list: ")) dict1 = {} for i in range(1,n): dict1[i]=i**2 print(dict1)
94e4cf21536e44dca8b72e43e762c910450a2939
effyhuihui/leetcode
/RectangleCircleProccess/spiralMatrix.py
1,793
4.1875
4
__author__ = 'effy' # -*- coding: utf-8 ''' Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] 有一种方法哦,就是每次打印矩形的外面一圈,然后再打印里面一圈,一点点打印到最里面(一圈表示四边) ''' class Solution: # @param...
c1e2eba9b3bedfb19991033d2deea033fbe3ce05
MartinWan/ACM-ICPC-Practice
/metaprogramming.py
761
3.703125
4
from fileinput import input namespace = dict() for line in input(): tokens = line.split() if tokens[0] == 'define': value = int(tokens[1]) symbol = tokens[2] namespace[symbol] = value else: # tokens[0] == 'eval' symbol1 = tokens[1] op = tokens[2] symbol2 = tokens[3] ...
4704b19bfbfcd30cb7c21b38f74a76c538210998
lerozhao/pythontest
/0401.py
1,756
3.609375
4
# list1=[1,2,3,4,5,6,7,8,9] # print(list1[1]) # print(list1[0:-1]) # print(list1[1::2]) # list2=["tab","tas"] # list1.extend(list2) # for i in list1: # list2.append(i) # list1.count() # list1.sort() # list1.remove() # i=0 # j=1 # while j<21: # print(j) # i,j=j,i+j # list1=[1,2,4,7] # for i in list1: # ...
2ca0e8e0120c9e2e4bfbef8f2710f66aec4f1fb1
hailey1003/Projects
/AVLTree.py
15,158
3.765625
4
import random as r class Node: # DO NOT MODIFY THIS CLASS # __slots__ = 'value', 'parent', 'left', 'right', 'height' def __init__(self, value, parent=None, left=None, right=None): """ Initialization of a node :param value: value stored at the node :param parent: the parent...
a67f85b7a39f706c05f234e0622d884a0deaca0c
nsbradford/HorizonCV
/horizoncv/horizon.py
7,571
3.59375
4
""" horizon.py Nicholas S. Bradford """ import cv2 import numpy as np import math DEBUG_VERBOSE = False def printV(text): """ Wrapper allowing for verbosity flag. """ if DEBUG_VERBOSE: print(text) def convert_m_b_to_pitch_bank(m, b, sigma_below): """ Method from original paper: ...
369ade678d1d640d0dd86dfb1cabd79e946ffb92
ayman-shah/Python-CA
/Python 1/21.3.py
297
4.03125
4
print("-------- Loop 1 -------") for i in range(0, 7): print(i) print("-------- Loop 2 -------") for i in range(1, 11): print(i) print("-------- Loop 3 -------") for i in range(20, 28): print(i) print("-------- Your loop -------") for i in range(5, 18): print(i)
52842707ba3e154a43fae090445ef8717dbac930
yoriaantje-dev/AutoKitten
/AutoKittenTerminal.py
3,388
3.515625
4
import ctypes import datetime import os import shutil import time import urllib.error import urllib.request def select_option(options): _opt = -1 flag2 = True while flag2: print("\nWhat would you like to do?") for num, _opt in options.items(): print(f"{num}. {_opt}") t...
acedb0c143b0fc7a237f21926dfc972f0d005e78
GustavoR0dr1gu3z/Full_Python
/SentenciaIF_Python/sentencia_if_else.py
486
3.984375
4
condicion = 10 if condicion == True: print("La condicion es verdadera") elif condicion == False: print("La condicion es falsa") else: print("xd") numero = int(input("Digite un numero entre 1 y 3: ")) if numero == 1: numeroTexto = "Numero Uno" elif numero == 2: numeroTexto = "Numero Do...
9967dc201c936cf35947edd66c88532098e9a0b4
Mehr2008/summer-of-qode
/Python/2021/Class 2/Student Code/Daksh Leekha/ass5.py
177
4.1875
4
age = int(input("Enter age: ")) if age >= 18: print("Eligible to drive") elif age <= 0: print("You are not born yet!") else: print("Not eligible to drive")
852d5bdf9fac7614f2092ac8febde976b0c1fef1
narasimha7854/qazi
/LambdaEx1.py
298
4.34375
4
#program to find smaller of two numbers using lambda def small(a,b): if(a<b): return a else: return b sum = lambda x,y : x+y diff = lambda x,y : x-y #pass lambda function as argument to regular function print('Smaller of two numbers',small(sum(-3,-2),diff(-1,2)))
9a0ef705b424c9ea4b6a1f1fb9d3a539e4846120
telegrace/Python3
/Ex_5_Day_2_a.py
546
4.34375
4
my_name = "Grace" my_age = 45 # yes it is a lie my_weight = 60 # kg my_height = 165 # cm my_eyes = "brown" my_teeth = "tanned" print(f"Lets talk about {my_namee}.") print(f"She's {my_age} old.") print("But we all know that's a lie.") print(f"She weighs {my_weight} kg.") print(f"She is {my_height} cm tall.") print(f"Sh...
7bbf8eb3f5779e6b2b9cc7f0f15d6a55c24862f9
Linar468/ProjectForJob
/28. Python (Introduction)/ClassesAndObjects.py
504
3.671875
4
class Person(): def __init__(self, name, surname, age, salary): self.name = name self.surname = surname self.age = age self.salary = salary def getInfo(self): info = "Name: " + self.name + ", surname: " + self.surname + ", age: " + str(self.age) + ", salary " + str(self....
0197d4ff4d60baee9987d93b55de0429c93b7454
kaustav19pgpm025/Python-for-Everybody-EdX
/typefunction.py
208
4.0625
4
# type() in Python str = raw_input("Enter a string: ") print type(str) n = int(raw_input("Enter an integer: ")) print type(n) f = float(raw_input("Enter a floating point value: ")) print type(f)
072e810842987339e30e9e3e851503548d8c9c72
pawarspeaks/Hacktoberfest-2021
/Python/quicksort.py
700
3.625
4
def partition (a, s, e): i = (s - 1) pivot = a[e] for j in range(s, e): if (a[j] <= pivot): i = i + 1 a[i], a[j] = a[j], a[i] a[i+1], a[e] = a[e], a[i+1] return (i + 1) def quick(a, s, end): if (s < end): p = par...
1584d333cd37f925eb7da1f037c3690e17d196c7
gschen/where2go-python-test
/1906101059王曦/11月/day20191111/11.3.py
327
3.75
4
#3. 使用“冒泡排序”的方法对列表里面的元素由大到小进行排序,ls=[10,9,13,5,25,70,2] def wxsort(ls): for n in range(len(ls)-1): for i in range(len(ls)-n-1): if ls[i]>ls[i+1]: ls[i],ls[i+1]=ls[i+1],ls[i] return ls ls = [10,9,13,5,25,70,2] print(wxsort(ls))
0fdcb34f5d7c6087a32e0e9da36cefaa85fc2d15
AmeyVanjare/PythonAssignments
/Assignmentq5.py
332
3.828125
4
print("*"*10,"Q5","*"*10) num=int(input("Enter length of list : ")) lst1=[] lst2=[] for i in range(0,num): ele=input("Enter list elements") lst1.append(ele) for j in range(0,len(lst1)+1): lst2.append(-1) for position,data in enumerate(lst1): lst2.insert(int(data),position) print...
e585a889078bb786bfb9299c5262d987322321be
obetsa/python_basic_hw
/hw8/hw8/practice/reverse_brackets.py
1,318
3.96875
4
""" Реверс подстроки в () Таким образом, чтоб: [in] "(bar)" [out] "rab" [in] "foo(bar)baz" [out] "foorabbaz" [in] "foo(bar)baz(blim)" [out] "foorabbazmilb" [in] "foo(bar(baz))blim" [out] "foobazrabblim" так как "foo(bar(baz))blim" -> "foo(barzab)blim" ...
53bfb78a397709d76217a88035f6179d50ece64d
YarikGn/YaroslavGnatenkoA2
/main.py
9,517
4.09375
4
""" Name: Yaroslav Gnatenko Date: 29 September Brief Project Description: This project is the modified version on the Assignment 1 that is implemented on the app.kv file. In terms of how the program works, the "Required Books" shows the buttons for the Required Books list and when the button on the required book ...
b81b7a528800e0e625c5d632347d1bb23aea1db2
H33l6ey/python
/Learning/list.py
189
3.75
4
my_list = [ 100, 2, 10, 150, 20, 175, 5, 10, 6, 25 ] total = 0 for ele in range(0, len(my_list)): total = total + my_list[ele] print("The sum of all numbers in this list are ", total)
af93406d971b356ece79171d076316212e6405ed
rubenmejiac/CS101
/Module5Homework1.py
1,700
4.03125
4
# Module5Homework1: Functions # Collect information from the user hoursworked = int(input("Please enter your work hours: ")) hourlyrate = int(input("Please enter your hourly rate: ")) state = input("Please enter your state of resident: ") maritalstatus = input("Please enter your marital status: ") def calcula...