blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6ca38f6e43d112fd6eadf9a054b64ae43eb996f9
gbalabanov/Hack_BG_101
/Week3/1-Bank-Account/BankAccount.py
1,232
3.6875
4
class BankAccount: def __init__(self, name, balance, currency): self.name = name self.balance = balance self.currency = currency self.events=[] self.events.append("Account was created !") def __str__(self): return("Bank account for {} with balance of {} {}".form...
4be38ebf15c7c93dd5a577d3ac205fb0f7e41c28
haradahugo/cursoemvideopython
/ex013.py
250
3.734375
4
## Salário e aumento salario = float(input('Digite o valor do seu salário atual:')) aumento = salario + (salario*0.15) print('O valor do seu salário é de R${:.2f}.\nApós o seu aumento de 15% o valor será de R${:.2f}!!!'.format(salario,aumento))
de35c2d889edce198f6d524c35243c6de56da4b8
Naysla/Machine_Learning
/4_Linear Classifiers in Python_/15_Visualizing multi-class logistic regression.py
1,310
4.09375
4
#Visualizing multi-class logistic regression #In this exercise we'll continue with the two types of multi-class logistic regression, but on a toy 2D data set specifically designed to break the one-vs-rest scheme. # #The data set is loaded into X_train and y_train. The two logistic regression objects,lr_mn and lr_ovr, a...
aafefe9e421d4fcd3eb0a614d4500d6e7cd79a23
rootzc/python
/test.py
309
3.671875
4
#!/usr/bin/env python # -*- coding : utf-8 -*- # this code for testing the pyhon laguage #value = raw_input("enter a number") #if value >= 100: # flag = 1 #flag = 2 #else: # flag = 2 # # #if flag == 1: # print "value bigger than 100" #else: # print "value lower than 100" # #print r'''line1 #line2 #line3'''
7c98a323ab8cdd7de63e3b38a618b6551ff14375
feieryouyiji/subject_share
/my_orm/test_dict.py
926
3.921875
4
# class T(dict): # pass # t = T(a='a') # print(t.__dict__) # print(t['a']) # class A(): # name = 'A' # def __init__(self, name): # self.name = name # class B(A): # name = 'B' # b = B(name="b instance") # class My(dict): # def __init__(self, *args, **kw): # super().__init__(self, *...
534c26d5cb5dc8943819a91b4456ea8bae16451a
jprasanthkumar28/CSPP1
/Python/DupFreq.py
210
4.15625
4
# To give the frequency of every digit in given array. # arr = [2,2,2,3,1,5,1,3] arr = input().split() # print(arr) dup = set(arr) res = {} # print(dup) for i in dup: res = arr.count(i); print(i , ":" , res)
8af40a44a65021d4af6e29ab48efe0c472ae1ef4
PragathiNS/PythonCodes
/sumOfDivisors.py
290
3.859375
4
# Find the sum of all divisors of a given integer # Guaranteed constraints: 1 ≤ n ≤ 15. def sumOfDivisors(n): sum = 0 if n >= 1 and n <= 15: for i in range(1, n+1): if n % i == 0: sum = sum + i return sum print (sumOfDivisors(12))
2b744ec2fddeefd1f5b9515aa13062484f5383bb
pysnow530/leetcode-apl
/73.py
1,606
3.84375
4
import functools def matrixify(func): """transfer scalar function to matrix function, result is a function""" def wrapper(matrix1, matrix2=None): if matrix2 is None: return [[func(item) for item in row] for row in matrix1] else: return [[func(matrix1[row][col], matrix2...
992752a8dc0e259921aa4edbeaf692a614d1a5f2
andresparrab/Python_Learning
/Data_manipulation/data_manipulation01.py
464
3.96875
4
import pandas as pd import numpy as np #df=pd.Series(np.arange(1,51)) df= pd.DataFrame({'a': pd.Series(np.arange(1,51)),'b': pd.Series(np.arange(51,101))}) print(df.values) print(df.ndim) print(df.axes) # heads will give you first five rows, is good if you have hundreds of thousand of rows # then you can print the fir...
1b9203c390d6a9690ce9a54a26f0be5bcb26302d
iamstacey/UNO
/Files/Deck.py
1,788
3.578125
4
from .Cards import Card class UNO_Deck(): def __init__(self): self.characters = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] self.categories = ['Normal', 'Block', 'Reverse', 'Change_color', 'Drag_4', 'Drag_2'] self.colours = ['Red', 'Green', 'Yellow', 'Blue'] self.deck = [] ...
4abbaa2675640afdaf160107a4b740e706dae2de
th0m1/cracking-the-coding-interview-python-solution
/Questions from careercup/min distance subarray.py
389
3.703125
4
#given a long string "s" and short strings t1,t2,t3 #find the shotest string of s that contains t1,t2 and t3 def minsubstr(s,t1,t2,t3): index_t1=s.index(t1) index_t2=s.index(t2) index_t3=s.index(t3) start=min(index_t1,index_t2,index_t3) end =max(index_t1,index_t2,index_t3) last_len=...
3f272f6f1f7a71c1e38aba1209553305dd57a2dd
ProgFuncionalReactivaoct19-feb20/clase04-mrnarvaez3
/ejercicio3.py
310
4.125
4
""" Manejo de colecciones y tuplas Roberto N """ lista = [(100, 2), (20, 4), (30, 1)] lista2 = ["a", "b", "c"] # funcion anonima para pasar a masyuculas resultado = map(lambda x: x.upper(), lista2) # salida de datos e invierto la lista 2 print(list(zip(sorted(lista), sorted(resultado, reverse = True))))
40b95d01ef6a1d7e0b4004cbb417706b16cae45e
hust-lyy/PyCharmFile
/Fishfile/36-Self/L_36_1.py
530
4
4
class Rectangle: x = 5 y = 4 def setrect(self): print('请输入矩形的长和宽:') self.x = int(input('长:')) self.y = int(input('宽:')) def getrect(self): print('矩形的长:%d 宽:%d' % (self.x, self.y)) def getarea(self): a = self.x * self.y return a rect = Rectangle()...
5a8952796b21ab52beccfc25792771a32fd09365
spkanung/neural
/src/src/test/test_softmax.py
1,185
3.578125
4
import unittest import numpy as np from layers.softmax import SoftMaxLayer class TestSoftMax(unittest.TestCase): def setUp(self): self.layer = SoftMaxLayer() def test_forward(self): """ Test the forward function with some values """ x = np.array(((0.5, 0.5, 0.5), ...
d18c8bd6cb56c3021ea6aabcd78deae9644a883c
htnani/PFB2018_problemsets
/problemsets/protein_domains/script1.py
1,391
4.25
4
#!usr/bin/env python3 #this script calculates the score of alingment for two sequences(a,b) a =input('Please provide sequence a:') b = input ('Please provide sequence b:') rc = input('Please specify if \'reverse_complement_both\', \'reverse_complement_a\', \'reverse_complement_b\' or \'not\':') if len(a) != len(b):...
68353c797dbeb20da9c99c3bbb683e8e87eee208
EricNguyen1124/Sudoku-Solver
/sodoku.py
742
3.609375
4
import random as rng grids = {1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], } columns = {1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], } rows = {1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], } while len(grids[1]) != 9: number = rng.randint(0, 9) if nu...
96530acd4fda5531796b1bfe5e8579928c9a66c7
minxilong/cp1404practicals
/Ass 2/moviecollection.py
2,501
3.84375
4
""" Name: Minxi Long URL: https://github.com/JCUS-CP1404/assignment-2---movies-2-minxilong """ # TODO: Create your MovieCollection class in this file import csv from movie import Movie class MovieCollection(Movie): """Get a list of Movie objects""" def __init__(self): """Initialise the...
f2e14c0f6e0f0db72fef2df1bed24c3f22a15506
dostoievskiab/AutomateBoringStuff
/cap5-jogoFantasia.py
651
3.640625
4
#!/usr/bin/python3 teste = {'Espada de Aco': 1, 'Casaco Gelido': 1, 'Moeda de Ouro': 23, 'Moeda de Bronze': 234, 'Maca': 5} loot = ['Maca','Escama de Dragao','Moeda de Ouro','Moeda de Ouro'] def displayInventory(inv): qtdItens = 0 for x,y in inv.items(): ...
0fab1f3137ea0c81923d2d8aed65d79b4781e1eb
chapman-cpsc-230/hw3-dong113
/turtle_poly.py
604
4.71875
5
""" File: turtle_poly.py Copyright (c) 2016 Lisa Dong License: MIT -asks user for number of sides and the length of each side. -this is converted from a string to an int -a turtle is created -using while loops, the turtle is guided to make a polygon using the user's input """ import turtle s = raw_i...
31b42ea5b1a6ee076ccd4d0e4f524ce5fed6fa22
ksoltan/invent_with_python
/frogs.py
765
4.09375
4
# There are thirty lights in a row. Thirty frogs jump across them. # The first frog lands on every single light. The second frog lands on every # other light. The third frog lands on every third light, and so on. When a # frog lands on a light, it turns on if it was off, and off if it was on. If # all the lights are of...
b84b8b1d0403dc41d7b7834dc0cf75d43f664bc4
Arturo0911/py_trix
/tiktak.py
3,574
3.515625
4
import random import time # variables game_matrix =[] user_1 = str turnos = 0 def crate_game(): print("----------------------------------------") print("----- WELCOME TO TIC TAC TOE GAME -----") print("---------------------------------------- \n") for i in range(0,3): list_add = list...
f5787b391518943aa8e25712b9f0d429011d50eb
GrayPete/instagramBot
/main.py
3,031
3.671875
4
# Get the list of people that you follow on instagram but who doesn't follow you back # requirements # 1. install selenium with "pip3 install selenium" # 2. download chromedrive from "https://chromedriver.chromium.org/downloads" from selenium import webdriver from selenium.webdriver.common.keys ...
26608e72233748bbcfd0719c0a58bc56090c408b
vkpriyesh/iLearn
/codeCademy/pyThon/PygLatin.py
262
3.828125
4
pyg = 'ay' original = raw_input('Enter a word:') word = original.lower() first = word[0] new_word = word + first + pyg s = new_word new_word = s[1:len(new_word)] #slicing the word if len(original) > 0 and original.isalpha(): print s else: print 'empty'
fb625f0bb6dd92a72fae7a04e258f3aa0fe951e8
greendom99/Project-Euler
/Project Euler - Problem 20.py
243
3.828125
4
number = 100 def factorial(N): product = 1 for n in range(1, N+1): product = product * n return product sum_digits = 0 for letter in str(factorial(number)): sum_digits += int(letter) print(sum_digits)
460b12788f86d139aca0f22b9c115fc532f0d4d7
Kamigami55/machine-learning-practice
/twitter.py
588
3.5625
4
# Code from Siraj Raval's Youtube Video # Twitter Sentiment Analysis - Learn Python for Data Science #2 # https://youtu.be/o_OZdbCzHUA import tweepy from textblob import TextBlob # Import consumer_key, consumer_secret, access_token, access_token_secret from twitterKey.py from twitterKey import * auth = tweepy.OAuthH...
201fe30f6b51e7b0a637fc60a7b89a783c649502
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/allergies/5c83cd243661467f84520b33180d011a.py
946
4
4
#!/usr/bin/python # Copyright 2014 Jack Chi # # Python Exercism Practice: # Using BitString Representation to match # Integers to Powers of 2 """ Each allergen has a score """ ALLERGENS = [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ] class Allergies: ...
e82f7896c9b4126bff7de01b3c7734a6e6cc2589
KnightsTiger/tratsgnittegnohtypetisnilarulp
/5Dictionaries.py
494
4.375
4
# Dictionaries are store key value paires # Dictionaries are important once JSON values parsing #An empty dictionary dictionary1 = {} #print(dictionary1) dictionary2 = { "Name":"Saman", "Age":33 } #printing the entire dictionary #print(dictionary2) # Pritinging a specific value # print(dictionary2["Name"]) #n...
e6a73454eff77b67692527185f6de1296d8d0674
mag389/holbertonschool-machine_learning
/supervised_learning/0x04-error_analysis/2-precision.py
471
3.59375
4
#!/usr/bin/env python3 """ precision calculation """ import numpy as np def precision(confusion): """ that calculates the precision for each class in a confusion matrix: confusion: np.ndarray confusion matrix (classes, classes) Returns: np.ndarray(classes,) of sensitivities """ classes = c...
a2b2022868406134f85cb3713350c49b74a47272
andrewsnelgrove/Project-Euler
/Problem 7/Prime Counter.py
668
4.0625
4
def primeNumberChecker(numToCheck): isPrimeNumber = True for i in range(2, numToCheck): if numToCheck % i == 0: isPrimeNumber = False if isPrimeNumber == True: return True else: return False def main(): limit = int(input("Enter the number of prime number you wa...
62c00e9b549a0c95bbc8e797896509deed3289aa
yakiris/20191217_Python
/04_dz. Полезные инструменты.py
5,392
3.84375
4
task = int(input('Запустить задачу номер: ')) if task == 1: # 1. Реализовать скрипт, в котором должна быть предусмотрена функция расчета заработной платы сотрудника. # В расчете необходимо использовать формулу: (выработка в часах*ставка в час) + премия. # Для выполнения расчета для конкретных значений необходимо запуск...
55263efa117ba705026a6c4fe3773b2482ba3f39
rprepo/pythonTips
/tips_and_tricks.py
1,644
3.703125
4
#!/usr/bin/env python # coding: utf-8 # # 1. if and else in a line # # In[7]: condition = False x = 1 if condition else 0 x # # 2. reading number or formating # In[34]: num = 10000000000 print(f'{num:,}') # # 3.Enumerate # In[35]: names =['ibm','simp','manipal','yoho'] for index,name in enumerate(names...
e0c534ce6fcf57e808d6526d4911f7b7df85a61f
pmsorhaindo/adventOfCode2019
/day2/day2.py
2,010
3.578125
4
f = open('input.txt') line = f.readline() ADD_OP_CODE = 1 MULT_OP_CODE = 2 def load_program(): return [int(s) for s in line.split(',')] def ammend_program(noun, verb, program_list): program_list[1] = noun program_list[2] = verb return program_list def run_add_operation(program_list, instruction_pointer): ...
caa7154d6c3b589bfc3253eb46e9777850865e28
b72446916/270201062
/lab6/example1.py
360
3.984375
4
email = input("Please enter an email address:") ref_mail = "ceng113@example.com" if "@" in email: email = email.lower() part_1 = email.split("@")[0] part_1 = part_1.replace(".", "") part_2 = email.split("@")[1] email = part_1 + "@" + part_2 print(email) if email == ref_mail: print("Equal") else: ...
5ee3f67d8ce7d8856e28eb886a4fd2a1a5d44ffd
obeardly/hello_world
/chap8/loop4.py
120
3.96875
4
#!/usr/bin/env python #Exercise 8.4 in Hello World for looper in range (1,5): print looper, "times 8 =", looper * 8
6560ef425e4a21a32d750cd327fbc994b9b98735
jfitz02/DM-solver
/CODE/TSP.py
2,561
3.53125
4
import sys #Used to make the largest possible integer from Matrix import Matrix #Personally made class representing the Matrix datatype from MST import MST #Used to find a minimum spanning tree of a subgraph (To solve Lower bound) class TSP(Matrix): def __init__(self, matrix): ...
ff624fb14bf014faf8f40d44b1c7429636f79d88
alu-rwa-dsa/week-3---dynamic-array-jules
/.github/Q3.py
807
3.5
4
def MergelinkedList(list): ls = [] for l in ls: ls.extend(l) r= set(ls) l = list(r) return l if __name__ == "__main__": a = [[2, 4, 9, 2, 1, 6], [9, 5, 22, 1, 0, 56, 8, 5]] print(MergelinkedList(a)) import ctypes import gc from q2 import DynamicArray, Array class D...
b39a7ca713ff4c9ef4b7d662799742632097aac8
SR2k/leetcode
/third-round/328.奇偶链表.py
1,701
3.8125
4
# # @lc app=leetcode.cn id=328 lang=python3 # # [328] 奇偶链表 # # https://leetcode-cn.com/problems/odd-even-linked-list/description/ # # algorithms # Medium (65.47%) # Likes: 544 # Dislikes: 0 # Total Accepted: 147K # Total Submissions: 224.6K # Testcase Example: '[1,2,3,4,5]' # # 给定单链表的头节点 head ,将所有索引为奇数的节点和索引为偶数的...
1aa4ec0c818b45f980189c5b108f5fb9acbd7f16
kalsotra2001/practice
/hackerrank/mathematics/number-theory/equations.py
652
3.640625
4
def find_primes(n): sieve = [False, False] + [True] * (n - 1) zeroes = [False] * (len(sieve) / 2) for i in xrange(2, int(len(sieve) ** 0.5) + 1): if sieve[i]: sieve[i * i::i] = zeroes[:((len(sieve) - 1) / i) - i + 1] return [index for index, i in enumerate(sieve) if i] def find_powe...
a0d02e4fd45639b9afd37510591feda99da0a6ea
sjogleka/General_codes
/primeornot.py
244
3.765625
4
def prime(x): if x<=2: return False for i in range(2,x): if x%i==0: return False return True if __name__ == '__main__': print(prime(10)) print(prime(2)) print(prime(5)) print(prime(3))
2783bd881ae80ec39685a908514cb494de260999
momchilantonov/SoftUni-Python-Advanced-January-2021
/File-Handling/File-Handling-Exercise/03_file_manipulator.py
1,945
3.796875
4
import os """Using this while debugging""" # def read_file(path): # if os.path.exists(path): # with open(path, "r") as file: # open_file = file.readlines() # return open_file # return "Can't find the f..... file!" def create_file(file_name): with open(file_name, "w") as ...
d170ccbd71089105741de7a2f50cb89476fb7644
dlkorea/piro
/lecture/Python/ex/ex3.py
379
3.65625
4
user_input = int(input('별을 몇개까지? : ')) if user_input % 2 == 0: user_input -= 1 row_count = (user_input + 1) // 2 for i in range(row_count): blank = row_count - (i+1) star = 2*(i+1) - 1 print(' ' * blank + '*' * star) for i in range(row_count - 2, -1, -1): blank = row_count - (i+1) star = 2*...
62589a439add2b3ac6a8ab060a7ba0d2391aa3f4
Wench98/pythonProject
/chapter02/demo02.py
801
4.21875
4
# 数据类型 # 整数类型 # 可以表示 正数、负数、0 n1 = 90 n2 = -79 n3 = 0 print(n1, type(n1)) print(n2, type(n2)) print(n3, type(n3)) # 整数可以表示为 二进制、十进制、八进制、十六进制 print('十进制', 118) print('二进制', 0b10101111) # 二进制以 0b 开头 print('八进制', 0o176) # 八进制以 0o 开头 print('十六进制', 0x1EAF) # 浮点类型 a = 3.14159 print(a, type(a)) num1 = 1.1 num2 = 2.2 print...
f396ba6e6b5a321b6eba30afc43acb42207ed489
haridenton/MatPlotLibGeneticTravellingSalesPersonFramework
/geneticSolutionTSP.py
5,573
3.625
4
import math import random import matplotlib.pyplot as plt from matplotlib.widgets import Button # No of Cities and number of individuals must be even NO_OF_CITIES = 40 NO_OF_INDIVIDUALS = 100 RANDOM_ROUTE_LENGTH = 0 SHORTEST_ROUTE = 0 GENERATION = 1 def getRandomPath(no_of_cities): random_path = [item for item i...
6a70a601a9e44d68419f50436493bd5d2e154d45
yangrencong/web_spiders
/DT/thredtext.py
383
4
4
import _thread import time from time import sleep,ctime #为该线程定义一个函数 def print_time(threadName ,delay): count = 0 while count < 3: time.sleep(delay) count += 1 print(threadName ,time.ctime()) _thread.start_new_thread(print_time ,("Thread_1" ,1)) _thread.start_new_thread(print_time ,("Thr...
2cc1d57cc9fda8f1a68664d52dde93de0608ba53
vishalbelsare/estimagic
/estimagic/visualization/derivative_plot.py
6,120
4.03125
4
"""Visualize and compare derivative estimates.""" import itertools import matplotlib.pyplot as plt import numpy as np def derivative_plot( derivative_result, ): """Plot evaluations and derivative estimates. The resulting grid plot displays function evaluations and derivatives. The derivatives are vi...
19ff714842ae69ecbbb6f276714d9ce965ebcf5a
dero24/task_manager
/TaskManager/read.py
1,347
3.703125
4
from users import Users class Read: def __init__(self, shared, cur_user): self.shared = shared self.user_tasks = self.shared.user_tasks self.save_config = self.shared.save_config self.cur_user = cur_user def task_exist_for_user(self): for name,tasks in self.us...
64682184a44e4875b30d75d617f429ed24efe4d1
gbravo5/m-dulo_1
/anagrama/anagrama_3.py
702
3.609375
4
def strtodict(s): dict = {} for i in s: if i in dict: dict[i] += 1 else: dict[i] = 1 return dict def isAnagram(p1, p2): if len(p1) != len(p2): return False result = [] dictp1 = strtodict(p1) dictp2 = strtodict(p2) ...
8ca5c33c6566b473abfdc537c4fffb3b0545c338
Song2017/Leetcode_python
/Leetcode/33.search.py
1,628
3.5625
4
class Solution: ''' 假设按照升序排序的数组在预先未知的某个点上进行了旋转。 ( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。 搜索一个给定的目标值,如果数组中存在这个目标值,则返回它的索引,否则返回 -1 。 你可以假设数组中不存在重复的元素。 你的算法时间复杂度必须是 O(log n) 级别。 示例 1: 输入: nums = [4,5,6,7,0,1,2], target = 0 输出: 4 ''' def search0(self, nums, target: int) -...
8046d11e059a4fa0eeada034bd21a5ef50762ecb
Anoosha-Shetty/Learn-Python
/Comprehensions.py
498
3.984375
4
#Comprehensions squares = [] for i in range(10): squares.append(i**2) print(squares) squares1 = [i**2 for i in range(10)] print(squares1) squares2 = [i**2 for i in range(10) if i%3 == 0] print(squares2) squares_dict = {i: i**2 for i in range (10) if i%3 == 0} print(squares_dict) print...
775b7db6b71af2de4b27b6aa7a5a191159558bd1
Jacken-Wu/CQU-python-2021
/CQU-python-题库题参考答案/题库练习:字符串/编程题/6.py
390
3.53125
4
def zips(s): c_last = s[0] n = 0 out = '' for c in s: if c == c_last: n += 1 elif n == 1: out += c_last c_last = c n = 1 else: out += c_last + str(n) c_last = c n = 1 return out def run(): ...
c3ed296778a031d22ce442c25c0fbce27eae702b
SunnySaha/python
/Pilling Up.py
231
3.59375
4
from collections import deque for _ in range(int(input())): input() check = deque(map(int, input().strip().split())) result = "Yes" if max(check) not in (check[0],check[-1]): result = "No" print(result)
bae88ee0cbaf7f96b4885b961833629fca306803
tanvipenumudy/Competitive-Programming-Solutions
/HackerRank/Python/set_union().py
810
3.65625
4
# >>> s = set("Hacker") # >>> print s.union("Rank") # set(['a', 'R', 'c', 'r', 'e', 'H', 'k', 'n']) # >>> print s.union(set(['R', 'a', 'n', 'k'])) # set(['a', 'R', 'c', 'r', 'e', 'H', 'k', 'n']) # >>> print s.union(['R', 'a', 'n', 'k']) # set(['a', 'R', 'c', 'r', 'e', 'H', 'k', 'n']) # >>> print s.union(enumerate(['...
051ea070d6af8e6d4a247a049a592964e0e04262
pVilmos/Ciphers
/ciphers/affine_cipher.py
2,283
3.734375
4
import math, random from constants import LENGTH, CHARACHTERS def gcd(a, b): while a != 0: a, b = b % a, a return b def is_relative_prime(length, key): if gcd(length, key) == 1: return True else: return False def affine_cipher_input(message, enc_table_length): print("Valid...
d5f9692f7b42650035985d113d82c4b2cbae0ccc
waltermblair/CSCI-220
/three_button_monte.py
1,689
4.03125
4
#three_button_monte.py "Guess the right door, win a prize!" from button import Button from graphics import * from random import randrange def drawWin(): win=GraphWin(320,240) win.setCoords(0,0,10,10) door1=Button(win, Point(2.5,6),2,3.5,"Door 1") door2=Button(win, Point(5,6),2,3.5,"Door 2") door3=...
09d4e6f10668017403c653f5c0f79b6a2593558e
GutuAlexei/Instruc-iunea-IF
/problema_5_AG.py
467
3.640625
4
zn=int(input('ziua nasterii =')) zc=int(input('ziua curnta =')) ln =int(input('luna nasterii =')) lc=int(input('luna curenta =')) an =int(input('anul nasterii =')) ac=int(input('anul curnt =')) if (ac>an): print((ac-an) ,'ani') elif lc<ln : print ((ac-an-1),' ani') elif (lc==ln) and (zc<zn): prin...
996da8a7435012a50b9bf8d2181550e034b706fe
diegoaspinwall/Unit3
/baseConverter.py
621
3.90625
4
#Diego Aspinwall #10-2-17 #baseConverter.py num = int(input('Enter a base-10 number: ')) base = int(input('What base would you like to convert it to: ')) num2=num power = 0 ans = 0 ans2= '' while num>0: ans += (num//base**power)%base num = num-ans*base**power power += 1 if ans == 10: ans2='A'+...
50903e6847e241d0edf3c9a4b349c6b8664e870c
Arrro/Python-training
/Python Bootcamp (Udemy)/Exercises and Assignments/Functions Exercise.py
7,786
4.1875
4
# Problems are arranged in increasing difficulty: # Warmup - these can be solved using basic comparisons and methods # Level 1 - these may involve if/then conditional statements and simple methods # Level 2 - these may require iterating over sequences, usually with some kind of loop # Challenging - thes...
a9fe47661335e5e1369e540ae6ac76a4c43f701e
chaofan-zheng/python_leanring_code
/month01/面向对象/类和对象/day01/demo02.py
410
3.84375
4
class Wife: def __init__(self, name, age): self.name = name self.age = age @property # 保障数据在有效范围之内 def age(self): return self.__age @age.setter def age(self, value): if 22 <= value <= 30: self.__age = value else: raise Exception("我不要...
23f1b24f24ceb2f372365cb68a5345d32ed46c48
Zandahlen/exercisesERROR
/exercises/basic.py
1,676
4.1875
4
"""Grundläggande övningar.""" def sum_of_digits(x): """Summera alla värdesiffrorna i ett heltal. Exempel: 389 består av 3, 8 och 9 och resultatet blir 3 + 8 + 9 = 20 """ s = 0 while x: s += x % 10 x //= 10 return s def binary_string_to_int(s): """Översätt en sträng med e...
872bcfcfacd27ccdc6d3cf20eb8356dffcd23709
EustaceMwai/pythonPractice
/main.py
1,795
4
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press ...
66f6550c4ee6ba1e2b59b4f9f3dcfec523509db6
samarthupadhyaya/python-programming
/factorial.py
103
3.953125
4
n=int(input()) fact=1 i=1 while i<=n: fact=fact*i i=i+1 print("factorial of",n,"is",fact)
dde6aeeb9d0c21ee0d87e22bb854561ae1090944
hrndgc/JS-Merge-Arrays
/merge_array.py
233
3.5
4
array1 = [] array2 = [11, 12, 34, 21, 42, 67] def merge_arrays(array1, array2): result = array1 + array2 sorted_result = sorted(list(set(result))) return sorted_result result = merge_arrays(array1, array2) print(result)
e1ab697394781210ef2234465e6f25c2f5899945
serraguti/PYTHON
/metodosstring.py
1,967
4.625
5
print("Ejemplo con métodos de String") texto = "primero python" # En este ejemplo solamente vamos a ir escribiendo los métodos # y viendo que devuelven. print("Mayusculas: " + texto.upper()) print("Replace o-@: " + texto.replace("o", "@")) print("Primera letra: " + texto[0]) print("Longitud texto: " + str(len(texto))) ...
1fe333d499e56166ebaf217df9f72cbe4ce5033f
daniel-reich/turbo-robot
/Nr33pizZC2XdHXAm6_8.py
2,098
4.25
4
""" Create a function that, given 2 dates, returns the names of the months that are present between them (inclusive). ### Examples **Input** january = datetime.date(2017, 1, 1) march = datetime.date(2017, 3, 1) monthsInterval(january, march) **Output** ['January', 'February', 'March'] **...
0f64f2b6c081e5878be8768f1a36406899866a30
Zafichi/python_home_work
/02/hw2.py
3,059
4.21875
4
# 1 try: first_num = float(input('Enter first number:')) second_num = float(input('Enter second number:')) sum_of_nums = first_num + second_num difference = first_num - second_num print(int(sum_of_nums)) print(difference) print(sum_of_nums) except ValueError as n: print("Exception, ", n)...
8a86f55c54884a418f37e25683bef88c53e0d1e5
drewspencerpearson/projects
/algorithms_and_data_structers/nearest_neighbor_search/solutions.py
9,933
3.953125
4
# name this file solutions.py """Volume II Lab 6: Nearest Neighbor Search Drew Pearson Math 320 10/15/15 """ import numpy as np from Trees import BST from Trees import BSTNode from scipy.spatial import distance import math from sklearn import neighbors # Problem 1: Implement this function. def euclidean_metric(x, y...
f4c8dda2990cab960cff8370323f7ef4d16fe2e3
IanCBrown/practice_questions
/skills.py
728
3.671875
4
#!/bin/python3 import math import os import random import re import sys # Complete the differentTeams function below. def differentTeams(skills): # each team can be considered as a set (no duplicates) # once a student is added to a set, remove them from the list teams = set() num_of_teams = 0 ...
5381bc589f32aff86127ff7010877bf40e0f1ba1
moonjihae/p2_201611070
/w6Main2.py
708
3.984375
4
def year(): year=raw_input("get year:") year=int(year) if (year%4 == 0) and (year%100 !=0 or year%400==0): print "leap year!" else: print "normal year!" def updown(): import random number=raw_input("input number(range 1~n) :") n=int(number) num=-1 rn=random.randra...
3e5803d0607cdd4eb2ac9aa8622d762ace60f032
hnlee/exercism-python
/word-count/wordcount.py
352
4.125
4
# Solution to Word Count exercise # Given a phrase, return a dictionary # where each key is a word that occurs in the phrase # and its value is the frequency of that word def word_count(phrase=''): words = phrase.split() unique_words = set(words) return dict(list((word, words.count(word)) ...
f43ba910789611b9a26c3b33b3b9bc30da8a6574
bakunobu/exercise
/1400_basic_tasks/chap_5/5_75.py
61
3.5625
4
for x in range(100, 201): if x % 3 == 0: print(x)
77f6e9c7624b714040254ef321faa11fdb81d68d
wesinalves/codeskill
/hackerrank/interview/array2d.py
1,399
3.953125
4
''' Code for HackerRank Interview Preparation Kit Wesin Ribeiro ############### problem ############### An hourglass in A is a subset of values with indices falling in this pattern Calculate the hourglass sum for every hourglass in arr then print the maximum hourglass sum. The array will always be 6 x 6 ############...
617ec6a342cb58ba08c5da2d837f276a7f841513
neethupauly/Luminarmaybatch
/Fundamentals/raise_keyword.py
389
3.859375
4
# raise - keyword for exception printing # same number # no1=int(input("enter num1")) # no2=int(input("enter num2")) # if no1==no2: # raise Exception("two numbers are same") # else: # print(no2+no1) #age condition exception printing age=int(input("enter your age")) if age>18: print("eligible for vaccina...
a0a12e6232f6b2230f9707c990ba5a87de1ce662
rashmiiiiii/python-ws
/LAB QUESTIONS/q18.py
853
4.0625
4
dic ={} def add(p_id,name): dic[p_id] = name def display(): if len(dic) == 0: print("dictionary is empty") else: for k,v in dic.items(): print(f"{k},{v}") def search(p_id): if len(dic) == 0: print("dictionary is empty") else: for k in dic: if k...
b54e34a1e3786c270d9f4dee6ccf2e21f736ae72
zaghir/python
/python-for-beginner/01-first-python-project/elif_examples.py
138
4.21875
4
i = 2 if i==1: print("i is 1") elif i==2: print("i is 2") elif i == 3: print("i is 3") else: print("i is not 1 or 2 or 3")
0d447abe57ea659e7ec84d45a546ea79545122cb
sgupta59/PythonAlgorithms
/src/test/print_test.py
245
3.640625
4
''' Created on May 14, 2015 @author: sanjeev ''' ''' Print abc, 5, eft in one line Change the seperator to be a , The end is not a new line but a : character ''' print('abc', 5, "efg",sep=',',end=':') print('abc '*5," ")
052f4f77f3cd78ce69e908c9de886647b99e9195
jihargifari/latihan_git
/materi dan pembahasan.py/latihanSoal2.py
814
3.640625
4
# soal 2 def spinWord(s): word = [] for i in s.split(): if len(i) >= 5: word.append(i(::-1)) else : word.append(i) # print(word) return ' '.join(word) # s = "hello" # print(reversed(s)) # # spinWord = input("insert Word: ") # # spinedWord = spinWord....
4b10bbad051318a09ca86f951c498e580f71c1d3
souravs17031999/100dayscodingchallenge
/arrays/rockpaperscissorgame.py
1,812
4.09375
4
import random def computer_choose(): ''' parameters : None Returns: string containing name of choosen object ''' return random.choice(['S', 'P', 'R']) def player_display(player, option): print(f"{player} chose {option}") def play_game(): player1 = "You" player2 = "Computer" ...
45dd3e33afb86f82c25839b63859dcdfbb729f4b
zaphran/Facpya_programacion
/PresupuestoMaestro.py
46,882
3.625
4
import os def borrarPantalla(): if os.name == "posix": os.system ("clear") elif os.name == "ce" or os.name == "nt" or os.name == "dos": os.system ("cls") separador = ("-" * 30) def menuPrincipal(): print("\n-- MENÚ PRINCIPAL --") print("[1] Presupuesto de Ventas") print("[2] Deter...
9c2bd145e3319544f74a7592bfeb378eed6a66a9
stevenpclark/aoc2020
/02/02.py
743
3.640625
4
def parse_line(li): a, c, password = li.split(' ') a1, a2 = a.split('-') c = c[0] lower = int(a1) upper = int(a2) return lower, upper, c, password def is_valid1(lower, upper, c, password): return lower <= password.count(c) <= upper def is_valid2(lower, upper, c, password): return (pass...
d2e0c7b72cf77e152e4f3155ae00ce6800d9785e
AKLeee/LeetCode_OJ
/Sprial_Matrix_II#68/SprialMatrixII.py
902
3.8125
4
# # Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. # # For example, # # Given n = 3 # [ # [ 1, 2, 3 ], # [ 8, 9, 4 ], # [ 7, 6, 5 ] # ] class Solution: # @param {integer} n # @return {integer[][]} def generateMatrix(self, n): result = [[0] * n for...
cc5b561df75e33e26c8448bfb844bfd97e991996
yasserglez/programming-problems
/cracking_the_coding_interview/chapter_17/min_unsorted_seq1.py
764
3.84375
4
# Interview Question 17.6 # Time complexity: O(n^2) # Auxiliary space complexity: O(n) def min_unsorted_seq(intergers): if not integers: return 0, 0 N = len(integers) farthest_less_than = [0] * N for i in range(N): for j in range(i, N): if integers[j] < integers[i]: ...
e5f834f7d488c4429c5a4c57681bcd8d7052d75d
Shantanu2645/ctf_tools
/php_juggling_generator.py
345
3.5
4
from hashlib import md5 var = input("Enter your string for type juggling hash gen:") i = 0 while ( True ): plaintext = var+str(i) plain = plaintext.encode() m = md5() m.update(plain) h = m.hexdigest() if h.startswith('0e'): if h[2:].isdigit(): print (plaintext, h) ...
86190fe635298628437f113d1e7c58b882f2053d
TejaswitaW/Python_UnitTesting
/Two.py
547
3.515625
4
#python testing import unittest class TestDemo(unittest.TestCase): @classmethod def setUpClass(cls): print("This is setup class method") def setUp(self): print("This is setup method") def test(self): print("This is test method") @classmethod def tearDownClass(cls): ...
ad77f22688f5938cf275a4e63dc2737195c82406
Gilli10/Project-otta
/Airline_seating.py
3,347
3.984375
4
big_list = ["A","B","C","D","E","F","G","H","I"] def input_plane(): #Fáum fjölda af röðum og sætafjöldan í hverri röð rows = int(input("Enter number of rows: ")) seats = int(input("Enter number of seats in each row: ")) return rows , seats def to_seats_list(big_list,rows,seats): # Notum raða- og sætafjö...
51d2c6b687e06617762b8b89f3de9db115840ac0
cutejiejie/PythonFirstPro
/列表/列表对象的创建.py
542
4.03125
4
a=10 #变量存储的是一个对象的引用 '''创建列表的第一种方式,使用[]''' lst=['hello','world',98] # print(id(lst)) # print(type(lst)) # print(lst) '''创建列表的第二种方式,使用内置函数list()''' lst2=list(['hellojiejie','world',18,'jiejieBSL','world']) # 正向索引从0到N-1 print(lst2[4]) # 逆向索引从-N到-1 print(lst2[-5]) # 如果列表中有相同元素只返回列表中相同元素的第一个元素的索引 print(lst2.index('world')) ...
eef77453c2dea374cee30c42cceb15f81ae444ea
sagar8080/Algorithms
/Data_Structures/Segment_Tree.py
3,996
3.796875
4
import math # Defines Segment Tree and takes in the input in form of an array class SegmentTree: def __init__(self, input_sequence): self.sequence = input_sequence self.length = len(input_sequence) self.tree = [-1] * (2 ** math.ceil(math.log2(self.length) + 1)) # The maximum length o...
2f9a422950eb5f5b2c482451ca9d13573196714d
revanth96/coding
/noofwordsinaletter.py
143
3.625
4
value = "madam" result={} for i in value: if i in result: result[i]+=1 else: result[i]=1 print(result)
5c6d5813620aa7c8c78b22d0488601008d01dbf9
broach44/beginning-python
/listMethods.py
265
3.890625
4
# numbers = [5, 2, 1, 7, 5, 4] # numbers2 = numbers.copy() # numbers.append(10) # print(numbers) # print(numbers2) numbers = [2, 2, 4, 6, 3, 4, 6, 1] uniques = [] for number in numbers: if number not in uniques: uniques.append(number) print(uniques)
958d92148805113b498392b2e9f6948060bcdab2
gujie1216933842/codebase
/元类编程/04_new和init的区别.py
588
4
4
''' new 是用来控制对象的生成过程,在对象生成之前 init 是用来完善对象的 如果new 方法不返回对象,则不会调用init函数 ''' class User: def __new__(cls, *args, **kwargs): print('in new') def __init__(self,name): print('in init') self.name = name class User1: def __new__(cls, *args, **kwargs): print('in new') retur...
c2d92b6eaaa3b5dec90a365725221f22c168d79a
xiaohaiguicc/CS5001
/lab04_Chenxi_Cai/christmas_tree.py
483
4.25
4
# Draw a christmas tree with input of number of base def main(): width = int(input("Please enter an odd-valued of 3 or greater representing the width of the tree:\n")) if(width % 2 == 0): width = int(input("The value should be odd-valued. Please enter again:\n")) half = width // 2 print(" " * ...
0c5ae9cd61ec979f6fc1902370e297b2f6681a43
psmchan/nlp100
/n03.py
329
3.59375
4
Piwords = [] Pi = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." words = Pi.split() # 単語ごとに取り出す kosu = len(words) while kosu > 0 : # 単語の個数が0になるまで words[0] Piwords = [word[0] for word in words] kosu -= 1 print(Piwords)
ad636bc7f497d9ffa9a678c57729ce205cc3acc5
Wrexan/Geekbrains_Python_basics
/l01_wrex/l_01_hw1_wrex.py
876
4.65625
5
# Поработайте с переменными, создайте несколько, выведите на экран. # Запросите у пользователя некоторые числа и строки и сохраните в # переменные, затем выведите на экран. # tell me about your cat a little cat_name = input("Tell me your cat's name:") cat_age = int(input("Your cat's age?:")) cat_color = input("What co...
093ab8ea3c8f3582b2b1e3248221649e07d28d48
djimenez81/mixbag
/txtfiles/merge.py
762
3.5625
4
def merge_files(file_list): # This methods opens all the files with names specified in a list of strings, # and combines them in a single file, intercalating a line of every file, as # long as there are more lines in the file. list_of_lines = [] lines = [] flag = True for file_name in file_l...
6bc70f1aa8a29aa1040b90523bc239276646bfce
chenkc805/CS61AProjects
/Lecture30.py
2,773
4.5
4
# Lecture 30 # Implicit Sequences """ An implicit sequence is a representation of sequential data that does not explicitly store each element Example: The built-in range class represents consecutive integers. We remember the start and end, but nothing in between. range(-2,2) --> -2, -1, 0, 1 We can build a class tha...
a284807461873cb4d13837b3729d7b5adc3dac5a
aladdinpersson/Machine-Learning-Collection
/ML/algorithms/linearregression/linear_regression_normal_equation.py
817
3.765625
4
""" Implementation of Linear Regression using the Normal Equation. Let m = #training examples, n = #number of features and the input shapes are y is R^(m x 1), X is R^(m x n), w is R^(n x 1). Using these shapes, the normal equation implementation is exactly as the derived formula :) Programmed by Aladdin Persson <al...
ef14ca6f6b5ac1fd89820949c214a758d9da1e7e
carleton-cs257-fall-2018/assignments-mashnoon33
/books/booksdatasourcetest.py
3,799
3.65625
4
''' booksdatasourcetest.py Mash Ibtesum, 18 Septembor 2018 Tests booksdatasource.py ''' import unittest from booksdatasource import BooksDataSource class testBooks(unittest.TestCase): def setUp(self): self.bds=BooksDataSource('books.csv', 'authors.csv', 'books_authors.csv') def test_book(...
be961fd1c01cb27d4253c485cf085320563890d3
AnumaThakuri/pythonassignment
/assignment 6/question 5.py
254
4.03125
4
def string(string): length=len(string) if length>2: if string[-3:]=='ing': string=string+'ly' else: string=string+'ing' return string print(string('ab')) print(string('abc')) print(string('string'))
8bddb90784e2dc9e6d4ae2d6e643ab59d9653ae6
99mini/Baekjoon-Algorithm
/implement/10828.py
567
3.625
4
from sys import stdin stack = [] t = int(stdin.readline()) for _ in range(t): operation = stdin.readline().split() if operation[0] == 'pop': if stack: print(stack.pop(-1)) else: print(-1) elif operation[0] == "size": print(len(stack)) elif operation[0] ...
e888dc50f544212a2fc2ecabae604dd76c63ba88
anamdey03/Python-Basics
/WriteFiles.py
550
3.515625
4
''' r - Reading from a file w - Writing to a file r+ - Reading and writing to a file a - Appending content to the end of the file ''' # employee_file = open("employees.txt", "a") # # employee_file.writable() # employee_file.write("\nAnamitra - Software Developer") # # employee_file.close() # student_...
750f8c4d04bdd56ed851412e6b4b478ff9b4a0c3
gchh/python
/code/7-5.py
1,295
4.1875
4
class Student(object): def __init__(self,name): self.name=name s=Student('Bob') s.score=90 print(s.__dict__) del s.score print(s.__dict__) class Student1(object): name ='Student' p=Student1() print(p.name) #打印name属性,因为实例并没有name属性,所以会继续查找class的name属性 print(Student1.name) #打印类的name属性 p.name='Mich...