blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
a5e20fe0f211faf863d9645a6890040f99aee9bd
s-londono/labs
/python/ds-from-scratch/examples/visualize/barcharts.py
1,964
4.09375
4
from collections import Counter from matplotlib import pyplot as plt # Barcharts: Show how some quantity varies among some discrete set of items movies = ["Ben-Hur", "Annie Hall", "Casablanca", "Gandhi", "West Side Story"] num_oscars = [11, 5, 3, 8, 10] plt.bar(range(len(movies)), num_oscars) plt.title("My Favorite...
e2288218a618cbd8b7ec7bd7b15b2c10ee6f4756
sanchit0496/Python_Practice
/scratch_42.py
1,626
4.03125
4
class student: """My student class""" noOfStudent = 0 classTeacher = 'Anand Paradkar' @staticmethod def showClassTeacher(): return(student.classTeacher) def __init__(self,rollno,name,marks): self.rollno = rollno self.name = name self.marks = marks self.g...
beca7f8a9a8a4caea549852badd96324da92a245
sanchit0496/Python_Practice
/scratch_36.py
322
4.1875
4
#Dictionary D= {1:"Hello", 2: "World"} print(D) my_dict = dict(item1="Apple", item2="Orange") print(my_dict) my_dict={x:x*x for x in range(8)} print(my_dict) my_dict={y:y*y for y in range(8)} print(my_dict) my_dict={'name':'John',1:[2,4,5]} print(my_dict) my_dict={'name':'John',1:['Hello','World',5]} print(my_dic...
465eadd79452698271d0a5bf9041e71ca5d5755d
sanchit0496/Python_Practice
/scratch_41.py
301
3.671875
4
class point: def __init__(self, x=0, y=0): self.x,self.y = x,y def __str__(self): string = "("+str(self.x)+","+str(self.y)+")" return string def __del__(self): print("Delete") pt1 = point(3,4) pt2 = point(8,9) pt3 = pt2 print(pt1) print(pt2) print(pt3)
b14c98ce6fe9039c4da3c3f7d88db91c05f44f7d
sanchit0496/Python_Practice
/scratch_39.py
444
4.03125
4
basket={'Apple','Orange','Apple','Banana','Orange','Mango'} a=set('Apple') print(a) basket.add('Strawberry') print(basket) a=set() print(a) if 'Mango' in basket: print('Hello') else: print('Hey') if 'pear' in basket: print('Hello') else: print('Hey') if 'pear' not in basket: print('Hello1') i...
2b9e1ab1f6cd5b65d3a9bad002eb0f0de91c7b6a
cfwar/Natural-Language-Processing-Projects
/NLTKNotebook.py
1,423
3.59375
4
#alice.txt is Alice In Wonderland from nltk.corpus import PlaintextCorpusReader corpus_root = '/Users/patrickgrayson/Documents' wordlists = PlaintextCorpusReader(corpus_root, 'alice.txt') from nltk.corpus import stopwords from nltk.tokenize import word_tokenize, sent_tokenize stopWords = set(stopwords.words("engli...
67f9a75a77ae41034dd8ad922754e6ef7fb2b2d1
orgatAI/mlpractice
/word2vec/word2vec.py
2,880
3.53125
4
#!/usr/bin/env python # -*-coding=utf-8-*- class VocabWord(): def __init__(self, word): self.word = word self.cn = len(word) self.code = None self.code_len = 0 def __cmp__(self, other): if self.cn >= other.cn: return True return False VOCAB = [] VOC...
c5a9a5cb629352c607629f1fcde3691c5bdfbedb
suatkummuz/GlobalAlHub
/adam asmacaa.py
1,293
3.546875
4
import random name = input("isminiz") print("adam asmaya hoşgeldiniz", name) word = ["araba", "traktör", "motorsiklet", "bisiklet", "jip", "suv"] new = list(random.choice(word)) ek = [" "] * len(new) claim = 7 fnl = 0 snc = False while claim != 0: chosen = input("lütfen kelime giriniz") for i in new: ...
fc9a1af7a7dab52da9e802dab872726deebb919d
vaishak-github/python-progs
/football_tournament/prac2.py
454
3.625
4
list = [12,20,1,23,2,50,11,45] for i in range(len(list)): for j in range(i+1,len(list)): if list[i]<list[j]: temp = list[i] list[i] = list[j] list[j] = temp print(list) '''for iter_num in range(len(list) - 1, 0, -1): for idx in range(iter_num): if list[idx...
04bf4718cd234e0becc48ebded66a13ee4f0cfd9
AndreyVShamin/tabel
/test.py
404
3.53125
4
import calendar year = 2020 month = 7 day = 8 a = calendar.LocaleHTMLCalendar(locale='Russian_Russia') with open('calendar.html', 'w') as g: print(a.formatyear(2014, width=4), file=g) print (calendar.weekday(year, month, day)) print (calendar.monthrange(year, month)) for currDay in range (1, calendar.monthrang...
636855f4d90fee36a58b778a585812f871840190
GL-Kageyama/LogisticRegression
/LogisticRegression.py
1,788
4.03125
4
#============================================================= #------------- Logistic regression ------------- #============================================================= # A kind of statistical regression model of variables # with Bernoulli distribution. #===========================================...
da9c04153908378e14966702b6d197fbbc2a8320
Nish-19/Unsupervised_Data_Mining
/all_files_generator.py
3,506
3.625
4
''' Used for analysing a directory of html files, it: Extracts data and convertes them to csv Generates heading for each file Finds the heading distribution ''' import os # Importing BeautifulSoup import bs4 from bs4 import BeautifulSoup # Importing csv import csv # Importing defaultdict from c...
3b8da1987cfaa62c69a43030d40eaf1c78936dd3
montassar892/Getting-Started-with-OpenCv
/draw.py
893
3.59375
4
import cv2 as cv import numpy as np blank = np.zeros((500, 500, 3), dtype='uint8') cv.imshow('Blank', blank) img = cv.imread(r'C:\Users\monta\Desktop\Opencv\photos\beach.jpg') cv.imshow('Image', img) Paint an image with certain color blank[200:300, 300:400] = 0, 0, 255 cv.imshow('Green', blank) # Draw a rectangle cv...
5affb038dfcc02a2f75536526fe7a8720824a341
aswwijenayaka/python_Script
/4.py
2,127
3.765625
4
# Anagrams """ def anagrams(s): d = {} # initiating aa dictionary to store signature and corresponding word for words in s: s = ''.join(sorted(words)) # finding the signature for the word if s in d: d[s].append(words) # append the word to existing key else: # o...
60b454bba83d645d65f7f4f5cf8e4dbfc9d91bdb
80085/Professorspelet
/professorspelet/professorspelet.py
4,992
3.546875
4
import copy class Puzzle: """ Professorspelet consists of a 4x4 grid that shall be filled with tiles, each of which has 4 body parts in different colors on each edge. The tiles must be place in such a way that all edges must create one complete Professor. """ def __init__(...
79775ec49f02b7477d55ae38ee2303eb4af723a8
dcsaba89/PYTHON
/FirstJupiterNotebook.py
7,135
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[343]: # LIST --- collection of certain items, separated by coma between square brackets # In[344]: L = [1, '11', "1da", [1, 3], ["X", 10, (11, 7)]] # lists can have different types of elements # In[345]: type(L) # return the type of a variable # In[346]: empty ...
ead1409f14fab983c5612de0e9ba90cbb2e9a64b
przemyslawgr/pythonworkbook
/ex9.py
133
3.984375
4
money = int(input("How much money did you deposit?")) for i in range(3): money = money + 0.04 * money print(round(money, 2))
48427ce605744b9fe4167c3e7171d5719a197890
utsekaj42/uqsa_tutorials
/chaospy/dist/graph.py
19,319
3.859375
4
r""" Constructing an transitional operator requires to construct the distributions different from a stand-alone variable. To illustrate how to construct these types of variables, consider the following example. Let :math:`Q=A+B`, where one of :math:`A` and :math:`B` is a random variable, and the other a scalar. Which v...
e9ba0f061a31f6c4f56c01412d2ea2b6032a5f27
vinicius-cardoso/uri-online-judge
/1_beginner/1019_time-conversation.py
205
3.65625
4
import math N = int(input()) hours = math.floor(N / 3600) hours1 = N - hours * 3600 minutes = math.floor(hours1 / 60) seconds = hours1 - minutes * 60 print("{}:{}:{}".format(hours, minutes, seconds))
2ac4068318a84f0778953705bfc0b99a0f431c86
vinicius-cardoso/uri-online-judge
/1_beginner/1008_salary.py
187
3.78125
4
NUMBER = int(input()) WORKED_HOURS = int(input()) REC_PER_HOUR = float(input()) SALARY = WORKED_HOURS * REC_PER_HOUR print("NUMBER =",NUMBER) print("SALARY = U$ {0:.2f}".format(SALARY))
7801b108dd4f4e06e26be87b848ecd3fa19e4352
chrisna2/algorithm_python
/for/gugudan.py
108
3.75
4
a = int(input()) for x in range(1,10): result = a * x print(str(a)+" * "+str(x)+" = "+str(result))
086c1c05a02829b65308e2ecd3337b4b208444e0
chrisna2/algorithm_python
/string/sum_number.py
500
3.75
4
''' 문제 N개의 숫자가 공백 없이 쓰여있다. 이 숫자를 모두 합해서 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 숫자의 개수 N (1 ≤ N ≤ 100)이 주어진다. 둘째 줄에 숫자 N개가 공백없이 주어진다. 출력 입력으로 주어진 숫자 N개의 합을 출력한다. ''' if __name__ == '__main__': str_length = int(input()) str_num = input() rslt = 0 for var in str_num: rslt += int(var) print(rslt)
01602afaf053f68d46ec31c6b31207e14c5546f5
chrisna2/algorithm_python
/string/verb_study.py
1,170
3.6875
4
""" 문제 알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다. 입력 첫째 줄에 알파벳 대소문자로 이루어진 단어가 주어진다. 주어지는 단어의 길이는 1,000,000을 넘지 않는다. 출력 첫째 줄에 이 단어에서 가장 많이 사용된 알파벳을 대문자로 출력한다. 단, 가장 많이 사용된 알파벳이 여러 개 존재하는 경우에는 ?를 출력한다. """ import operator if __name__ == '__main__': input_string = in...
c9b7ea484d81b9fcd17b508b67fe4d5a44590263
nastinasti/h3_homework
/hw1_types/hw1.py
3,308
4.21875
4
# PYTHON ADVANCED COURSE. FALL # KONVISAROVA ANASTASIIA. # HOMEWORK1 import sys def main(): menu() def menu(): print("Konvisarova Anastasiia. Homework1. Main menu:") choice = input("""Choose the task: 1. Check URL for Catalog 2. Get center characte...
e2d1bbde7bbe65d3189785a78be387b5ab306231
theleenoel/python_study_calculating_machine
/calculating_machine.py
1,812
3.765625
4
'''난수 계산기 만들기''' ''' 0단계 - 음수 없는 빼기 1단계 - 음수 있는 빼기 2단계 - 빼기 더하기 랜덤 3단계 - 빼기, 더하기, 나누기, 곱하기 랜덤 ''' import random round = int(input("단계를 선택하세요(0,1,2,3):")) count = int(input("몇 개의 문제를 풀까요?(1~5):")) score = 0 # score는 정답의 갯수를 출력한다 for i in range(count): x = random.randint(1,100) y = random....
6a93a6201bdf3b46168c3bdc73d4862057047f71
mishyta/task
/Python/itertools_lib.py
3,022
4.15625
4
from itertools import * # The ITERTOOLS module is a collection of useful iterators. # itertools iterators: # # 'accumulate' # 'chain' # 'combinations' # 'combinations_with_replacement' # 'compress' # 'count' # 'cycle' # 'dropwhile' # 'filterfalse' # 'groupby' # 'islice' # 'permutations' # 'product' # 're...
6238c106bc94e511f90e4efd1f7f6d9b548053c7
officialtech/SQLite
/insert_input.py
347
3.96875
4
idno = int(input("ID NO ")) name = input("NAME ") contact = int(input("CONTACT ")) import sqlite3 as s con = s.connect("official tech.db") print("Connection establized!") cr = con.cursor() # to perform operation we use cursor object cr.execute("insert into student values(?,?,?)",(idno, name, contact)) con.c...
8a3a126a19cfe0ab58a96d543242265fced55c4e
annamatras/git
/main.py
1,198
3.953125
4
from todo import Todo from todo_item import TodoItem def main(): todo = Todo() while True: print("How can I help you?\n") print("1.Add task\n" "2.List tasks\n" "3.Toggle done\n" "4.Remove task\n" "0.Exit\n") number = input("\nPlea...
b87520e8d088a2b83032efaca5050cf5109b33b7
cuqjc/curso_python
/asserts_statements.py
834
3.984375
4
def divisons(num): divisors = [i for i in range(1, num + 1) if num % i == 0] return divisors def run(): num = input('Ingresa un numero = ') assert num > '0','El numero es negativo' assert num.isnumeric(), 'Debes ingresar un numero' # aca hay un error y es que si pongo un numero ...
78f8b45115d044260ae548959cb6f9aa98cb7510
sergioarcila/Python
/matrix.py
191
3.921875
4
matrix_3_3 = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] matrix_3_3[0][1] = 20 print (matrix_3_3) print (matrix_3_3[0][1]) for row in matrix_3_3: for item in row: print(item)
0d55a147f488f7cdcafb4888052fd51c58e1c6d9
indexnotfound404/para
/para/conversion.py
11,082
3.765625
4
# -*- coding: UTF-8 -*- """ Convert variables from one type to another. """ from builtins import chr import base64 import binascii import sys import string ASCII_VALUE = '1' # ascii DECIMAL_VALUE = '2' # decimal HEX_VALUE = '3' # hex BINARY_VALUE = '4' # binary BASE64_VALUE = '5' class Conversion(object)...
cf5a0738f7d00ac460cb0612ee8e828a6ea9ded7
skusler/code_eval
/easy_challenges/prime_palindrome/pp.py
656
3.71875
4
# This is for the challenge Prime Palindrome @ https://www.codeeval.com/open_challenges/3/ import sys def pp(arg): # Reversed range to find biggest first for x in reversed(range(2, arg)): # Checks for palindrome first as that's easier than finding if prime. if str(x) == str(x)[::-1]: ...
17562602a8fd08cd5e109698be264b240bd0a8f0
skusler/code_eval
/easy_challenges/even_numbers/en.py
304
3.53125
4
# This is for the challenge EVEN NUMBER @ https://www.codeeval.com/open_challenges/100/ import sys def even(): with open(sys.argv[1], 'r') as test_cases: for line in test_cases: if int(line) % 2 == 0: print(1) else: print(0) even()
7920bca1463af36f95dca6d5de17e7455e12f10c
dk9nr/InterviewProblems
/increasingTriplet.py
500
3.8125
4
def increasingTriplet(self, nums): """ :type nums: List[int] :rtype: bool """ if len(nums)<3: return False mini=min(nums[0],nums[1]) maxi=max(nums[0],nums[1]) for i in range(2,len(nums)): if nums[i]<mini: ...
a1bbf5891ee1a9fbaa04e5a7bb0c731407772724
dk9nr/InterviewProblems
/shiftArray.py
349
4.03125
4
def reverse(nums, start, end): while start<end: nums[start],nums[end] = nums[end],nums[start] start+=1 end-=1 def shift(nums,k): reverse(nums,0,len(nums)-1) reverse(nums,0,k-1) reverse(nums,k,len(nums)-1) if __name__ == "__main__": nums=[1,2,3,4,5,6] sh...
2cf6f22772ef7fc09813138a322944123e275f53
dk9nr/InterviewProblems
/tree.py
1,026
3.734375
4
# def number_of_leaves(self,root): # if self.root.left_child==None: # if self.root.right_child==None: # self.count+=1 # self.root.left_child.number_of_leaves(self) # self.root.right_child.number_of_leaves(self) # return self.count # if root.le...
03f6b186c0858c30b3ec64a7954bc98d6c2b169f
StephenTanksley/cs-algorithms
/moving_zeroes/moving_zeroes.py
1,662
4.1875
4
''' Input: a List of integers Returns: a List of integers ''' """ U - Input is a list of integers. The list of integers will have some 0s included in it. The 0s need to be pushed to the tail end of the list. The rest of the list needs to remain in order. P1 (in-place swap plan) - 1) We need a way of...
5081ee39964be7624179be3dd6b92875314fb545
takatogoto/textmining
/code/ch02/sec2-3-1_defining-new-function.py
247
3.65625
4
# -*- coding: utf-8 -*- # 2.3.1節 Python プログラムの構造 ブロック構造は段下げで表す 関数の定義をする最初の部分 import math def newfunction(x): y = math.sin(x) + 1 return y**x print newfunction(0.5)
a2c752e71011e7f76dc7cebe234eafa09b268c38
takatogoto/textmining
/code/ch02/sec2-3-5_list-comprehensions.py
783
3.75
4
# -*- coding: utf-8 -*- # 2.3.5節 内包 --- enumerate や zip リスト内包の例 input = [1, 3, 5, 7, 9] output = [] # ←空のリストを作る for u in input: output.append(u*2) # ←u*2の要素を1つずつ追加 print(output) # ←結果は[2, 6, 10, 14, 18] output = [u*2 for u in input] print(output) # ←結果...
9cce81d3dbbc7e66f0def62ac6ca77acae929dda
ujjaval-shah/bollyrics-main
/NLP_projrct_ngram/generator.py
2,952
3.640625
4
import random, json def Rand(start, end, num): return random.sample(range(start, end),num) def generate(r_scheme): dicttemp = {} fp = open("dict_3_standard_2.json","r") dict3 = json.load(fp) fp.close() count = 1 # maxima: number of possible 3-grams # maxima = max([int(i[1:]) for i i...
1835d023d29714f1f02bd5efd72b4b9832437410
RenatoFa/Alura
/URI/1021.py
2,389
3.8125
4
dinheiro = float(input("Digite o valor: ")) notas_de_100 = int(dinheiro // 100) notas_de_50 = int((dinheiro - notas_de_100 * 100)//50) notas_de_20 = int(((dinheiro - (notas_de_100 * 100) - (notas_de_50*50)))//20) notas_de_10 = int(((dinheiro - (notas_de_100 * 100) - (notas_de_50 * 50)-(notas_de_20 ...
35de5394387efe6345b16fae7f3ed0eaf2bc07de
kbuzby/euler
/euler15.py
250
3.65625
4
def factorial(n): factorialValue=1 while n > 1: factorialValue *=n n -= 1 return factorialValue def number_combos(n, k): numberOfCombos = factorial(n) / (factorial(k) * factorial(n - k)) return numberOfCombos print (number_combos(40, 20))
a03e6718454616007baa6720462e881c8079e85a
kbuzby/euler
/euler21.py
311
3.546875
4
def d(a): total = 0 for x in range(1,a): if a%x == 0: total += x return total result = 0 x = 2 while x < 10000: num1 = x num2 = d(x) if num1 == d(num2) and num2 == d(num1) and num1 != num2: result += num1 + num2 x = max(num1, num2) print str(num1) + ' ' + str(num2) + ' ' + str(result) x+=1
8b9b70608242e79987922c01b22217eb1053078d
peterliu502/Hello_Python
/函数形参.py
5,953
3.5625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 必选参数(位置或关键词参数):是函数形参的默认形式,可以通过位置匹配或关键词匹配两种方式赋值 def student(name, id_num): return {'name': name, 'id': '{:04d}'.format(id_num)} # 位置参数:作为位置函数的实参是通过位置次序与定义函数时的位置形参进行匹配 print(student('Peter', 1)) # 实参'Peter'和1通过位置关系分别与形参name和id_num进行匹配 # 关键词函数:作为关键词函数的实参通过关键词与同名关键词...
653514308448f4fe0ad5728be406867cb8341a75
peterliu502/Hello_Python
/返回函数.py
2,458
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # 返回函数 def return_func(*args): def return_func1(): def my_list(): return list(args) return my_list return return_func1 result = return_func(1, 2, 3, 4) result = return_func(1, 2, 3, 4, result) print(result) print(result()) print(resu...
57b30765f6b538cc1db5ba57fe80546648bd4fb3
peterliu502/Hello_Python
/函数定义与参数检查.py
1,238
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import math # 空两行 def my_abs(num, condition=0): if type(num) != int and type(num) != float: raise TypeError('bad operand type') else: if condition == 0: if num < 0: return -num else: return n...
abb3b73405fe529d8330398640c91270b5e0b839
SpencerGoulette/Python-Games
/Greatest-Warrior/Greatest Warrior Game.py
13,090
3.78125
4
import random #Title Screen titleScreen = True while titleScreen: print "G R E A T E S T W A R R I O R" print " Press Enter to Start" Start = raw_input() if Start == "": titleScreen = False inventory = { "Coins":20, "Equipped Weapon":[], "Equipped Armor":[], "Bag":[] } shopItems =...
fe2435cbaa4ebd9a2f7baca925e532e4fb5f6261
myllenamelo/Exerc-cio
/Q1_Tupla_Myllena_Melo.py
1,089
4.21875
4
''' seu carlos está abrindo uma lanchonete com apenas atendimento para delivery, levando em conta que não haverá loja fisica, o atendimento será online. Ajude seu Carlos a montar o cardápio da lanchonete. 1- Ultilizando tuplas monte todo o cardápio com comidas e bebidas por enquanto não precisa do preço 2- deve most...
fb312ac9b6147058a2f5c01bb93c283368f09d95
Rollbear-bot/ToolBox
/src/floyd_shortest_path.py
1,849
3.5
4
# -*- coding: utf-8 -*- # @Time: 2020/4/29 23:32 # @Author: Rollbear # @Filename: shortest_path.py INFINITY = 65535 def shortest_path_floyd(d_0: list): """弗洛伊德算法,点对最短路径问题""" n = len(d_0) # n表示图中的节点个数 # 将矩阵转化为映射表 d_cur = {key: value for key, value in [((i, j), d_0[i-1][j-1]) ...
97827ba4e1238e681791aa89494f03b5f9b5d487
abdulahad2307/JudgeSite-Practice-Codes
/Python/Huffman_Encoding_Decoding/Main.py
1,005
3.625
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 27 23:57:17 2019 @author: A AHAD ALIF """ import sys from encode_decode import encoding_func, decoding_func data_file = open("data.txt", "r") data = data_file.readlines() for number, data in enumerate(data, 1): print("Encoding process: ") print("The size of the ...
57d44fda64399e9de3e4bf10f266323f8a6e5f90
tadeze/goproject
/ds/quicksort.py
631
3.984375
4
""" Quick sort implemetnation. The idea of quick sort is to partition the whole array based on the pivot point. The pivot is selected such that the left side is less than the large side of the arra. a = [2, 8, 7,20, 12, 4] """ def quick_sort(a, l, h): if l < h: p = partition(a, l, h) qui...
698107e49aa3ce65e164dec7374f1fd13b9d1387
tobewithyou1996/curricula
/curricula/main.py
2,640
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from login import login while True: ret, login_status = login() if login_status == 1: if ret.level == 0: print("你是管理员,你已经成功登陆了") while True: num = input(''' 1、创建课程 2、创建学生学生账号 3、查看所有课程 ...
86b62720c6bd0555b0c6836dae83c19a789d61eb
HuntedWolf378/studious-octo-dollop
/main.py
6,506
4.34375
4
#Dylan Wanser #COP 1500 CRN 10417 #This program serves as the final version of my integration project #It has been simplified into a demonstration of learned skills from this course #W3Schools #Intro and section one instructions print("Hello World!") print("I was created to demonstrate all the required skills....
269c87e7caef552dd35ddc693fa1cc74c9d2a387
AkDavies/graphing
/src/edge.py
3,514
3.890625
4
import copy from abc import ABC, abstractmethod class Edge(ABC): def __init__(self, ep1, ep2, **kwargs): self.endpoints = {ep1, ep2} self.__dict__.update(kwargs) def __iter__(self): return iter(self.endpoints) def __deepcopy__(self, memo): #https://stackoverflow.c...
61dfadf3441207272d4ec3e26bcf8f98bbae418f
Abhi0496/Python-for-Everybody-Using-Python-to-Access-Web-Data
/Week 3/example_on_socket.py
743
3.53125
4
import socket # Here we are creating socket in our computer which is ready to connect but not yet connected mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connect(('data.pr4e.org', 80)) # Here socket is connecting to that host at port 80 # After connection is made we have to send get request with p...
4186c4b7ce7404bdb82854787a04983a3b1dd7c7
priyankitshukla/pythontut
/Logical Operator.py
594
4.25
4
is_Hot=False is_Cold=False if is_Hot: print(''' Its very hot day Drink Plenty of water ''') elif is_Cold: print('Its a cold day') else: print('Its a lovely day') print('Enjoy your day!') # Excersise with logical operator if is_Cold==False and is_Hot==False: prin...
fc7cf297b7c62f2e82126f3dad3c813015411274
Fernando-De-Santiago/Projects
/Lab 6.py
5,083
4.125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 5 10:40:03 2019 @author: Fernando """ #CS2302 #Fernando De Santiago #LAB5 #Olac Fuentes, Anindita Nath and Maliheh Zargaran #last edited 4/12/19 20:56:00 PM #Section M/W 10:30-11:50 #purpose: To create a correct maze # Starting point for program to build...
9fc7f26701322ed70b29821f888b4e0cc57b90fa
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chap 8 (STRINGS)/exercises/num9(remove_letter).py
688
3.890625
4
import sys def remove_letter (letter, text): result = "" for ch in text: if ch not in letter: result += ch return result def test (did_pass): """Print the result of a test""" line_num = sys._getframe(1).f_lineno #Get the caller's line number if (did_pass): msg = "Test at line {0} ...
4306095604449ed34b81222d8a5835e23f59e80d
afahad0149/How-To-Think-Like-A-Computer-Scientist
/wordtools.py
1,385
4.03125
4
# takes a string as input and returns a string with only alphanumeric characters def cleanword(word): cleaned = "" for char in word: if char.isalnum(): cleaned += char return cleaned # returns False if the input string has extra dashes def has_dashdash(str): ind = str.find("--") ...
b616ac2e9d04050c09e99c7bf1961b37bb12e80a
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chap 7 (ITERATION)/examples/Newton's_method_for_finding_square_root.py
411
3.75
4
import math def Newton_sqrt(n): approx = n/2 while True: better = (approx + n / approx) / 2 print(better) if (abs(approx - better) < 0.00001): return better approx = better #print(Newton_sqrt(1)) #print(Newton_sqrt(4)) #print(Newton_sqrt(9)) #print(Newton_sqrt(16)) #print(Newton_s...
8962dbf6361a4fcba435cebe562becea0b62bc7b
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chap 4 (FUNCTIONS)/exercise/num4(draw_pattern).py
323
3.953125
4
import turtle def draw_square(t, sz): """Draws a square od size sz""" for i in range(4): t.forward(sz) t.left(90) wn = turtle.Screen() wn.bgcolor("lightgreen") tur = turtle.Turtle() tur.color("blue") tur.pensize(3) for i in range (20): draw_square(tur, 150) tur.right(360/20) wn.mainloo...
3460a8a8d766bb68ac2a1a5b2fb1f91e7f3134a0
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chapter 14 (LIST ALGORITHMS)/exercises/problem_1.py
4,563
3.921875
4
# operations on lists, not sets (duplicate elements allowed) from unit_tester import * def merge_intersection(xs, ys): result = [] xi = 0 yi = 0 while True: if xi >= len(xs) or yi >= len(ys): # If either list is finished, return result # And we're done. ...
dcfeb5f5a83c47e5123cf8e0c07c39a8ed246898
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chap 8 (STRINGS)/exercises/num5(percentage_of_a_letter).py
1,515
4.3125
4
import string def remove_punctuations(text): new_str = "" for ch in text: if ch not in string.punctuation: new_str += ch return new_str def word_frequency (text, letter): words = text.split() total_words = len(words) words_with_letter = 0 for word in words: if letter in word: words...
92b1e3b08b13b955593846042566a9536c9d72c0
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chap 4 (FUNCTIONS)/exercise/num6(equilateral_triangle).py
403
3.796875
4
import turtle def draw_poly(t, n, sz): """draws a polygon of n sides""" for i in range(n): t.forward(sz) t.left(360/n) def draw_equitriangle(t,sz): """draws an equilateral triangle of size sz""" draw_poly(t, 3, sz) wn = turtle.Screen() wn.bgcolor("lightgreen") tess = turtle.Turtle() tess...
6355a675b584242f63c92f41f508d88650da9379
afahad0149/How-To-Think-Like-A-Computer-Scientist
/Chapter 11 (LISTS)/exercises/problem_2.py
337
3.875
4
import turtle wn = turtle.Screen() tess = turtle.Turtle() alex = tess alex.color("hotpink") # It creates only one turtle instance to which both alex and tess refer. # so changing the color of alex changes that of tess. # Confirming tess.forward(100) tess.left(90) alex.forward(100) alex.left(90) wn.mainloop() # ...
158fb336375c8e6e15f4c886b5c3bb3fe40c2a88
nsidn98/Machine-Intelligence-and-Brain-Research-ID7123
/Bandit Algorithms/Bandits.py
3,631
3.703125
4
''' ----------------------------------------- Bandits Algorithm: Explore then Commit Upper Confidence Bound ----------------------------------------- ''' import numpy as np import matplotlib.pyplot as plt import random n = 10000 # horizon k = 100 # number of experiments ####### Explore then Commit #...
de6f293720663f6f122908926f914d81a3a0cfd4
magedu-python22/homework
/homework/02/P22034-beijing-guanpenghui/homework-1.py
546
3.84375
4
#get number from random import randint ansnumber = randint(0,999) print('The answernumber is',ansnumber) #compare number while True: gusnumber = int(input('Pls input a number to compare:')) if gusnumber > ansnumber: print('You input number is larger than ansnumber,pls input again') continue ...
04c38b0236520ce438a3d2c5b319b98b30b13077
magedu-python22/homework
/homework/02/P22027-beijing-zhaikun/guessnum.py
369
3.734375
4
import random beguessed = random.randint(0,999) while True: guessnum = int(input("请输入你要猜测的数字:")) if guessnum > beguessed: print("您输入的数字大了!!") elif guessnum < beguessed: print("您输入的数字小了!!!") else: print("恭喜你猜对了") break # 逻辑上没有什么问题
3bd26d45d6d693a88bbc7dfbc50e645727966b2b
magedu-python22/homework
/homework/07/P22012-beijing-liyinkai/week07-re.py
986
3.65625
4
#!/usr/bin/env python ''' Author: Li Yinkai Email: yinkai.li@foxmail.com Blog: https://blog.51cto.com/yinkai Date: 2019/10/26 下午12:01 ''' ''' 2.使用正则序列化。     text = 'foo = 23 + 42 * 10'      将字符串像下面这样转换为序列对:      tokens = [('NAME', 'foo'), ('EQ','='), ('NUM', '23'), ('PLUS','+'), ('NUM', '42'),  ('TIM...
c4d70d36aac58acf24e9dc492266e1e32a36aa4e
magedu-python22/homework
/homework/10/P22048-fuzhou-xiaojie/homework10.py
1,583
4.15625
4
# 自定义 map, reduce, filter 接受两个参数(fn, iterable) # 检测iterable 是否为可迭代对象, 如果不是抛出异常 “Iterable not is Iterable” from collections import Iterable def add(x, y): return x + y def is_odd(x): return x % 2 == 1 class MyException(Exception): pass class Custom: def __init__(self, fn, iterable): ...
a78ce572ec8c89a50488428123d65a67263dba2c
magedu-python22/homework
/homework/02/P22010-chengdu-linqiang/FizzBuzz.py
247
3.65625
4
for i in range(1,101): char= '\n' if i%10==0 else ',' if i%3==0: print('FizzBuzz',end=char) if i%5==0 else print('Fizz',end=char) elif i%5==0: print('Buzz',end=char) else: print(i,end=char) # 写的不错~
080b34f083c64053b7cce56c47cb3c9df4a8d048
magedu-python22/homework
/homework/04/P22047-xiamen-shenshenwen/homework_sort.py
684
4.03125
4
#!/usr/bin/env python """ s = "Sorting1234" 给定一个只包含大小写字母,数字的字符串,对其进行排序,保证: 1 所有的小写字母在大写字母前面 2 所有的字母在数字前面 3 所有的奇数在偶数前面 """ s = 'Sorting1234' upper = '' lower = '' odd = '' even = '' for i in s: if i.isupper(): upper = upper + i elif i.islower(): lower = lower + i elif ...
7ecea2e5884b4bd88d1a1c6ffcf42fd4979473c0
magedu-python22/homework
/homework/02/P22025-SD-zhangqunshan/guessnumber.py
456
3.828125
4
''' 猜数字 随机选择一个三位以内的数字作为答案。用户输入一个数字,程序会提示大了或是小了,直到用户猜中 ''' import random num = random.randint(1,1000) print(num) while True: guessnum = int(input("请输入一个三位数的数字:")) if guessnum > num: print("你猜大了!") elif guessnum < num: print("你猜小了!") else: print("你猜对了!") break
19f3e257f60273c5f3ce7ce143d21bd74e9f8387
magedu-python22/homework
/homework/04/P22014-huizhou-zhangjingni/week4-sorting.py
685
4
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # Author:Miki # Date : 2019/6/19 10:19 # 给定一个只包含大小写字母,数字的字符串,对其进行排序,保证: # 1 所有的小写字母在大写字母前面 # 2 所有的字母在数字前面 # 3 所有的奇数在偶数前面 s = "Sorting1234" lower = [] upper = [] odd = [] even = [] for c in s: if c.islower(): lower.append(c) elif c.isupper(): upper.app...
de0819bcbabbf9d26a448e405e732953e7e6f647
magedu-python22/homework
/homework/05/P22039-shanghai-fengjunfei/PIN.py
861
3.59375
4
""" 随机生成100个验证码,每个验证码由6个元素构成: 1、要求使用random模块 2、验证码由字母和数字构成 3、要求验证码中的每个元素为一种颜色 提示 颜色可以用数字来表示:一般都是3个 (0, 255)之间的数字来构成的 demo: Z (19, 157, 229) 2 (239, 10, 145) Z (145, 142, 244) M (231, 58, 7) T (202, 19, 72) F (182, 136, 237) """ import random import string set1 = set() num1 = 0 while num1 < 100: set1.add(''.join(r...
320713a81ee180fca9292c50dcc6b84de82f7746
magedu-python22/homework
/homework/02/P22051-beijing-haozhaoyang/guessmember.py
547
3.890625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- import random num = random.randint(1,1000) Flag = True while Flag: try: val = input('请输入一个三位以内的数字:') while len(val) >= 3: val = input('请输入一个三位以内的数字:') val = int(val) if val > num: print("biger") elif val ...
871ebd7b297bfcb3b66de5bfae58b3ced4d721a9
magedu-python22/homework
/homework/04/P22045-shandong-liubin/第四周终版.py
418
3.53125
4
def sortl(s): xiaoxie=[] daxie=[] jishu=[] oushu=[] for i in s: if i.isalpha() == True: daxie.append(i) if i.isupper() == True else xiaoxie.append(i) else: jishu.append(i) if int(i) % 2 ==1 else oushu.append(i) d=sorted(xiaoxie)+sorted(daxie)+sorted(jishu...
722a2b9625eb07cbbc92a08dfe0eb4c62774725b
magedu-python22/homework
/homework/03/P22041-shanghai-huanghao/atm.py
2,969
3.96875
4
import sys users = {'user1':['111111', 5000], 'user2':['123456', 10000]} def register(): """ 用户注册 :return: """ username = input('Please enter a user name.\n') while username in users: username = input('User name already exists!\n') users[username] = [None, 5000] password = input('Please enter a password.\n')...
c5262a687592caede04cadc4f18ef5a66c8b9e0d
Chandu0992/youtube_pthon_practice
/core/array_example_one.py
1,044
4.15625
4
'''from array import * arr = array('i',[]) n = int(input("Please Enter size of the array : ")) for i in range(n): x = int(input("Enter next Value : ")) arr.append(x) #manual method print(arr) s = int(input("Enter a Value to search : ")) k = 0 for i in arr: if i == s: print(k) break k ...
e534f25bc49ad27375bec5ae6de498d71c6f9c9b
Chandu0992/youtube_pthon_practice
/core/patterns.py
1,209
3.90625
4
''' print pattern # # # # # # # # # # # # # # # # ''' # method 1 # print("# # # #") # print("# # # #") # print("# # # #") # print("# # # #") #method 2 '''for j in range(4): print("# ",end="") print() for j in range(4): print("# ",end="") print() for j in range(4): ...
dbfb97a06cee0fb3d4a7c81b2252ef8e1041360e
RiftyAgon/cs114
/madlib.py
249
3.71875
4
print ('Input Noun') noun = input() print ('Input Adjective ') adjective = input() print(' Input another Noun') another_noun = input() sentence = "The " + str(noun) + " jumped over the " + str(adjective) + " " + str(another_noun) print(sentence)
de4f70de238c59529282ab3f5728420b62037370
csharrison/Python-Interpreter
/tests-ours/objects/mutation.py
178
3.578125
4
class scott: x = 5 print("before constructor") a = scott() print("before assignment") a.x = 100 print(a.x) b = scott() ___assertEqual(a.x, b.x+95) ___assertEqual(b.x,scott.x)
6c957104c0eecb737e0c9120fa0f7f080d5b2d65
slamatik/Project_Euler
/1-10 Solutions/10. Summation of primes.py
469
3.78125
4
from math import sqrt from time import time def prime_check(n): if n == 2: return True if n % 2 == 0 or n <= 1: return False limit = int(sqrt(n) + 1) for div in range(3, limit, 2): if n % div == 0: return False return True total = 2 cnt, prime = 1, 1 while c...
f0c2537e7328074410ef434e98a516b1242f8b14
slamatik/Project_Euler
/1-10 Solutions/6. Sum square difference.py
275
3.875
4
def find_sum_squares(n): total = 0 for i in range(n + 1): total += i ** 2 return total def find_square_of_sum(n): total = 0 for i in range(n + 1): total += i return total ** 2 print(find_square_of_sum(100) - find_sum_squares(100))
55cfad8c65ed79784562bb4dfcce3cd6f1857429
sdlipp/GP_Python210B_Winter_2019
/students/jeff_shabani/session09/oo_mailroom_tests.py
889
3.734375
4
#!/usr/bin/env python3 import os import unittest from donor import * ANSWER = 'New_Donor' AMOUNT = 4512 class OOMailroonTests(unittest.TestCase): def test_add_donor(self): d = Donor() d.add_donor(ANSWER, AMOUNT) expected = {f'{ANSWER}':[4512]} self.assertDictEqual(expected, d.do...
aae1221b8d79c44ffa91d45e4e617d0639e80893
MrAllanGt/FundamentosProgramacion
/Problema01/Python/main.py
493
3.75
4
# Variables a = b = c = result = 0 # Inputs try: a = int(input("Ingresa el valor de a: ")) b = int(input("Ingresa el valor de b: ")) c = int(input("Ingresa el valor de c: ")) except Exception as e: print("\nSe produjo la siguiente excepción: " + str(e)) # Process & Outputs print("\n--- RESULTADOS ---") resul...
5354b5ce25def354480fbd85463224f527e38e83
Ajat98/LeetCode-2020-Python
/good_to_know/reverse_32b_int.py
702
4.3125
4
''' Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpos...
2921e095c78355d6330120da96a24d7e8adee024
Ajat98/LeetCode-2020-Python
/good_to_know/best_timeToBuy_SellStockV2.py
905
3.8125
4
''' Say you have an array prices for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times). Note: You may not engage in multiple transactions at the ...
6b1563b8e7557ef65a878886d55d1db87f934483
Ajat98/LeetCode-2020-Python
/good_to_know/min_contiguous_subarray.py
695
3.953125
4
''' Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solution, try coding another soluti...
c8f5f16018fcef326306008893182d927b89e472
pbutler15/Python-Challenge
/PyBank script.py
2,718
3.734375
4
import os import csv from pathlib import Path # Collect data from csv datafile in the resources folder PyBank_path = os.path.join('Resources', 'budget_data.csv') months = [] profit_loss = [] profit_loss_change = [] greatest_increase = "" greatest_decrease = "" # Retrieve data from csv datafile with ope...
9926b05fbb649128fe0414a11375c5bea9a0258a
skyrusai/SICP_python
/higher_Functions_1_6.py
328
3.8125
4
def sum_(n, term): total, k = 0, 1 while k <= n: total, k = total + term(k), k + 1 return total def cubes(k): return k * k * k def sum_cubes(n): return sum_(n, cubes) print(sum_cubes(5)) def naturals(k): return k def sum_natuals(n): return sum_(n, naturals) print(sum_natu...
650d64a95d37c57fbcf2ef09cb179e7cccc75b05
42azimut/cs50
/algorithm/python/01_01_max.py
607
3.671875
4
# 이렇게 해보세요! # 책 p.24를 참고해서 풀어보세요! # 리스트 A의 모든요소들 중 최댓값을 찾아 return 하는 함수 find_max( A )를 완성해 보세요. # 공백으로 구분되어 입력되는 숫자들을 받아서 array에 저장해 보세요. # 입력 예시 # 20 34 12 93 84 39 64 55 24 # 출력 예시 # [20, 34, 12, 93, 48, 39, 64, 55, 24] 최댓값= 93 # 1번을 해보세요! def find_max( A ): return max(A) # 2번을 해보세요! array = [int(x) for x...
f7d7425f91a09802a0f4915655991bc9cc66763c
42azimut/cs50
/algorithm/python/02_05_unique_elements.py
562
3.875
4
# 공백으로 구분되어 입력되는 숫자들을 받아서 리스트 A에 저장해 보세요. # 같은 항목이 있으면 False를, 같은 항목이 없으면 True를 반환하는 함수 unique_elements(A)를 완성해 보세요. # 1번을 해보세요! A = [int(x) for x in input().split(" ")] # 2번을 해보세요! def unique_elements(A): len_n = len(A) for i in range(len_n-1): for j in range(i + 1, len_n): if A[i] == A[j]: return F...
a53224ea1abc5fc7b18d42313a04082376a2a729
42azimut/cs50
/algorithm/python/Modu_03_01_sequential.py
309
3.703125
4
# 리스트에서 특정 숫자의 위치 찾기 # 입력: 리스트 a, 찾는값 x # 출력: 찾으면 그 값의 위치, 찾지 못하면 -1 v = [ 17, 92, 18, 33, 58, 33, 43] def search_list(a, x): n = len(a) for i in range(n): if x == a[i]: return i return -1 print(search_list(v, 33))
cb77d1bf28af1fc9f8814dee602446a52ed57349
THINKINGth/data-structure-python
/Stack/Sstack.py
825
3.984375
4
# 单链表实现堆栈 class Node: def __init__(self, elem, next_=None): self.elem = elem self.next_ = next_ class Sstack: def __init__(self): self.top = None def push(self, num): self.top = Node(num, self.top) def is_empty(self): if self.top is None: return Tr...
a30860ac415132a6d3b636a6b30eac9861c5ff21
iruzts/Tarea7-Robotica
/cabeceras.py
840
3.890625
4
cabecera = { "Atlántida":"La Ceiba", "Colón":"Trujillo", "Comayagua":"Comayagua", "Copán":"Santa Rosa de Copán", "Cortés":"San Pedro Sula", "Choluteca":"Choluteca", "El Paraíso":"Yuscarán", "Francisco Morazán":"Tegucigalpa", "Gracias a Dios":"Puerto Lempira", "Intibucá":"La Esper...
57ece6ff2dc3cab33a2bc3ea5c61f68a994b7d21
jongodinez/intro-to-CS-python
/lesson3exercise.py
191
4.125
4
num = float(input('Enter a number: ')) if (int(num) % 2 == 0): if int(num) == 0: print('Zero') else: print('Positive number') else: print('Negative number')
41be49e4cdd1c99d77e0d9cdcf54f47f42a16130
RossMcKay1975/Python_Day2
/generators.py
234
3.8125
4
# numbers = range(11) # # for number in numbers: # print(number) def generate_evens(n): i = 0 while i < n: if i % 2 == 0: yield i i += 1 for number in generate_evens(10): print(number)
26d0e3340f1c7a675bd8514beab127882bd869ee
BuHogeJI/battleOOP
/battleOOP2.py
27,326
3.5
4
class Board(): def __init__(self, x, y): self.x = x self.y = y def setBoard(self): self.board = [[u'\u00B7'] * self.y for _ in range(self.x)] return self.board def setEnemyBoard(self): self.enemy_board = [[u'\u00B7'] * self.y for _ in range(self.x)] return ...
00409eb918845cfc869eb7dec7c9e85292c98d25
sofyansetiawan/learn-python-bootcamp
/02-intermediate/condition.py
943
4.25
4
x = 3 y = 3 if(x == y): print("they are equals") else: print("the are not equals") print("program is working fine") # ------------------ a = 10 b = 10 c = 80 if(a == b): print("a is equals b") elif(b > a): print("b is greater than a") elif(a > b): print("a is greater than b") else: print("th...