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
3190dbd2a1629c99b07c0804563b76d9a6d26449
Izzle/learning-and-practice
/Daily_Programmer/tricky.py
1,146
3.890625
4
'''Python tricks, hacks, and work-arounds A living document by Ron Martin ''' # Trick 1 # Create a single string from all the elements in a list a = ['Ron', 'loves', 'to', 'code', 'in', 'Python'] print(" ".join(a)) # Trick 2 (less of a trick, more of a reminder) # Multi-variable assignment b = [3, 2, 1] x, y,...
6c47d33dc224e0b7da0ddb10262a3465018c999a
prog-o-meter/prog-o-meter
/congratulations/Congratulations.py
3,669
3.640625
4
import webbrowser as webbrowser from urllib.parse import quote try: import Tkinter as Tk # Python < 3.0 except ImportError: import tkinter as Tk # Python >= 3.0 class Congratulations(object): """Displays a dialog congratulating the user for completing the challenge. Allows the user to sh...
b00c896ef5fd16ad0fc2c5242fb6fecbaec6d48c
SinianSung/ken_ai_project
/ken_ai.py
9,496
3.671875
4
import csv import math import random as rd import matplotlib.pyplot as plt import numpy as np class Datapoint: """ Creates a 2-dimensional Datapoint with a tag to identify the coresponding class """ data = tuple() def __init__(self, x,y, tag): """ initialises the datapoint w...
a7f7957f2f66e22f7288a077fe773fb16bab4f02
6188506/LearnPythonHardWay
/ex29.py
966
4.125
4
people = 20 cats = 30 dogs = 15 if people < cats: print "Too many cats! The world is doomed!" if people > cats: pass print "Not many cats! The world is saved!" if people < dogs: print "The world is drooled on!" if people > dogs: print "The world is dry!" dogs += 5 if people >= dogs: print "People are great...
cdc83aed767914f36b346640018c73460133c996
6188506/LearnPythonHardWay
/anagrams(word, words).py
685
3.796875
4
def anagrams(word, words): result = [] word_letter_sort = sorted(word) for element in words: if len(element) == len(word): counter = 0 for i in range(len(word_letter_sort)): if sorted(element)[i] == word_letter_sort[i]: counter += 1 ...
e4266fc583ccf9f51e0357ae267614fa69e185dc
para-de-codar-alek/Respostas-Uri
/1019.py
300
3.875
4
# Converter segundos em horas minutos e segundos # Ler segundos # Fazer divisão por resto e guardar na variavel # criar outra var para min com time = int(input()) hora = time//3600 min = time-hora*3600 minn = min//60 seg = time-hora*3600-minn*60 print ('{}:{}:{}'.format(hora, minn, seg))
85bb8600c27ff7d815bf1324be1775775ec24be9
para-de-codar-alek/Respostas-Uri
/2686.py
872
3.734375
4
while True: try: M = float (input()) M1 = M hora = ((M1 * 240)/ 3600) % 60 min = ((M1 * 240)/ 60) % 60 M1 = (M1 * 240) % 60 if (M >= 0 and M< 90 or M== 360): print ('Bom Dia!!') print ('{:02d}:{:02d}:{:02d}'.format(int((ho...
bd06a7b8c5c81530c21812b4b6c85e991690a585
para-de-codar-alek/Respostas-Uri
/1281.py
1,176
3.65625
4
n = int(input()) i = 0 while i<n: dictionarie = {} lista= [] num_products = int(input()) for l in range(num_products): products_price = tuple(input().split()) #Criando uma tupla que recebe dois valores em sua posição lista.append(products_price) #add as tupla a lista, para fa...
66dad62f348eb42e0d7196bdc87f4cfa0ef84520
para-de-codar-alek/Respostas-Uri
/1037.py
978
4.28125
4
#Você deve fazer um programa que leia um valor qualquer # e apresente uma mensagem dizendo em qual dos seguintes intervalos # ([0,25], (25,50], (50,75], (75,100]) este valor se encontra. # Obviamente se o valor não estiver em nenhum destes intervalos, # deverá ser impressa a mensagem “Fora de intervalo”. #O sí...
647835ddbe5bde909d59944fb474421c1cbcad69
para-de-codar-alek/Respostas-Uri
/2342.py
354
3.78125
4
max_value = int(input()) line = input().split() v1,sign,v2 = line if sign == '*': v1 = int(v1) v2 = int(v2) if v2*v1<=max_value: print('OK') else: print ('OVERFLOW') elif sign == '+': v1 = int(v1) v2 = int(v2) if v1+v2<=max_value: print ('OK') else:...
47cf79dd9a397205da4f5ad2050cd5e339718a83
berkcivek/python_denemeler
/sifreOlusturma.py
2,109
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 30 22:59:36 2019 @author: berk """ print('Merhaba,Şifre oluşturma programına hoşgeldiniz.Lütfen şifre oluşturmak için gerekli adımları takip edin.') zorluk=input('Şifreniz nasıl olsun? - (1)Kolay (2)Orta (3)Zor - Numarasını tuşlayın:\t').strip() i...
356a248bdd932d89094a1618fdda9818e523d31d
munirwanis/arquitetura-fundamentos-tp3
/9.py
1,553
4.09375
4
# -*- coding:utf-8 -*- ''' 9) Usando a biblioteca Pygame, escreva um programa que desenha 10 quadrados de tamanho 50 na tela. Eles devem ter cores e posições aleatórias. Quando cada um deles for clicado, ele deve ser apagado da tela (C). ''' import sys, pygame import random pygame.init() size = width, height = 800,...
afd3410724824466ee851ceb98fd2466459ccbbc
beatorizu/dojo-campinas
/2010_08_11_jokenpo/jokenpo.py
918
3.5
4
import unittest def Jokenpo(item1, item2): if item1 == item2: return 'empate' if 'tesoura' in (item1, item2): if 'pedra' in (item1, item2): return 'pedra' else: return 'tesoura' if 'papel' in (item1, item2): if 'pedra' in (item1, item2): ...
7a74442d7b01450ba8f58f0c8132801b92c4e872
beatorizu/dojo-campinas
/2010_11_09_Tennis/tennis.py
1,111
3.609375
4
GAME_POINT = 40 ADVANTAGE = 'A' PONTOS = [0, 15, 30, GAME_POINT, ADVANTAGE] ESTADOS = { "EM_ANDAMENTO": "em andamento", "VENCEU": "%s venceu", "EMPATE": "deuce", "VANTAGEM" : "vantagem %s", } class Game(): def __init__(self): self._pontos = {} self._pontos["jogador1"] = 0 se...
fb468b0e50f111a886b962180d8f79d166c63e83
beatorizu/dojo-campinas
/2011_07_23_CaipiraAgil_Fizzbuzz/teste-dojo-caipira.py
1,807
3.578125
4
# -*- coding: utf-8 -*- import unittest def imprime(): for i in range(1,101): print fizzbuzz(i) def fizzbuzz(n): return 'fizzbuzz' if n % 3 == 0 and n % 5 == 0 else 'fizz' if n % 3 == 0 else 'buzz' if n % 5 == 0 else n def fizzbuzz_old(n): retorno = n if divisivel_por_tres(n) and divisiv...
66c6e5ba0979f21f1562764b2d78ded18d02813c
MerajBighamain/python_projects-1
/scores.py
253
3.640625
4
#calculate scores scores = [["hasan",18,12,13],["mahdi",20,19,18],["meraj",17,18,10]] for person in scores: total=0 for value in range(1,len(person)): total+=person[value] avg=total/(len(person)-1) print(person[0],avg)
7555f0ffc9b1401bb0a4c91d51f7e3f260f7d1d4
MerajBighamain/python_projects-1
/jazr.py
264
3.828125
4
def show_jazr(number): error = 0.01 guess = number/2 iteration = 0 while(abs(number-guess**2)>error): iteration=iteration+1 taghsim = number/guess guess = (taghsim+guess)/2 print("The square root of",number,"is",guess)
0ec5f79e973e112f8f98d08c05e423faddeb9352
MerajBighamain/python_projects-1
/mac_address.py
191
3.5625
4
# mac address find import uuid print ("The formatted MAC address is : ", end="") print (':'.join(['{:02x}'.format((uuid.getnode() >> elements) & 0xff) for elements in range(0,2*6,2)][::-1]))
fd9641197b902c843771255abd1387798b1823cd
michaelkim9/work_log
/search.py
7,945
3.765625
4
# Imports import csv import re import os from tasks import Task def clear_screen(): '''Clears the command screen''' os.system('cls' if os.name == 'nt' else 'clear') # This class has methods to search based on different parameters class Search: def __init__(self): self.results = [] with ...
7dc05621d7b01036ba4596055148d5d2bf684c3a
zhaoninge/csdn_python_data_rough
/src/01 numPy/4.4 多维度聚合.py
634
3.53125
4
''' numpy研究的数据经常是多个维度的,这时候经常需要的操作是沿着某⼀轴进⾏操作,此时,聚合函数 都会有⼀个参数axis,⽤来表示需要沿着哪个轴进⾏聚合。 ''' import numpy as np a = np.random.randint(100, size=(4, 5)) print("a = \n", a) # 求最⼤值,每⼀⾏ b = a.max(axis=1) print("a每⼀⾏的最⼤值是: ", b) # 求每⼀列的和 c = a.sum(axis=0) print("a每⼀列的和是:", c) ''' a = [[62 94 38 4 43] [70 40 71 16 99] [40 28 ...
f5a6c501725b54a0b6d2aca35ce1add67e3a19d0
zhaoninge/csdn_python_data_rough
/src/03 matplotlib/10.3 三维等⾼线.py
662
3.859375
4
''' 三维图默认的观察视⻆可能不是最后的,我们可以时候⽤ ax.view_init 来改变观察视⻆,两个参数: 俯仰⻆度,即x-y平⾯的旋转⻆度 ⽅位⻆度,即沿着z轴顺时针转动⻆度 ''' import numpy as np import matplotlib.pyplot as plt def f(x, y): return np.sin(np.sqrt(x ** 2 + y ** 2)) fig = plt.figure() ax = plt.axes(projection='3d') x = np.linspace(-6, 6, 30) y = np.linspace(-6, 6, 30) X, Y = ...
641d7dcb11b620e12e3dbdefe8fa3a15d8b0f088
zhaoninge/csdn_python_data_rough
/src/03 matplotlib/7.2 plt.subplot 建议⽹格⼦图.py
651
3.71875
4
""" plt.subplot可以创建整⻬排列的⼦图,这个函数有三个整形参数: ⼦图⾏数 ⼦图列数 索引值: 索引值从1开始,左上⻆到右下⻆逐渐增⼤ """ import matplotlib.pyplot as plt import numpy as np ''' # matlab⻛格 for i in range(1, 7): plt.subplot(2, 3, i) plt.text(0.5, 0.5, str((2, 3, i)), fontsize=18, ha='center') ''' # ⾯向对象⻛格 # plt.subplots_adjust调整⼦图间隔 # plt.add_subplot f...
862c693ca001704ae320f235e7b509facba07150
ragnargwyn/AMS
/Display/farve_algoritme.py
711
3.609375
4
def rgb_rgb565(r, g, b): r = (r >> 3); g = (g >> 2); b = (b >> 3); return(str(r) + ", " + str(g) + ", " + str(b)) print(rgb_rgb565(255, 255, 255)) print("unsigned char IntToRGB[256][3] = {") for i in range(0,256): if (i<=32): r=0 g=0 b=127+(i*4) elif (i>32) and ...
3096d27bb7b07d2e8570d387887cecd752927e64
Steve-Jadav/LeetCode
/BSTIterator.py
1,217
3.96875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class BSTIterator: def __init__(self, root: TreeNode): self.index = -1 self.sorted_nodes = list() s...
b30b133a4482aa7b059a3d0dcc27498c98124ba2
Steve-Jadav/LeetCode
/MergeKSortedLists.py
1,726
4.03125
4
# Problem 23 # Approach: Merge 2 linked lists (k-1) times # Complexity: O(kN) # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: if l...
87419121a46d1a8c0d88c5f62d4c7fdfb052d62e
Steve-Jadav/LeetCode
/PalindromeNumber.py
298
3.53125
4
class Solution: def isPalindrome(self, x: int) -> bool: if (x < 0): return False i, reverse = 0, 0 temp = x while (temp): reverse = (reverse * 10) + (temp % 10) temp = temp // 10 return reverse == x
be0eafa1b8ecd4da1f808b1566d8de9bdbfc8878
Steve-Jadav/LeetCode
/RightRotateArray.py
1,002
3.734375
4
# Problem 189 # Approach 1 class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ k = k % len(nums) for _ in range(0, k): self.rightRotate(nums) return num...
7c3d1f965818058958bb143b72a6f03b2824a8d6
dimatkach11/Torno_Subito
/base_python/the_dictionary.py
2,936
4.625
5
# # ! A dictionary is a set of objects which we can extract from a key # * The keys in question are the one we used in the phase of the assignment print('\n\t\t\t\t\t\tDICTIONARY\n') keynote = dict() keynote['tizio'] = '333-3333333' keynote['caio'] = '444-4444444' print(keynote) # * copy() : keynote_copy = keynote.c...
8c802650065dec7d5744576ebb7cb08744cc8087
dimatkach11/Torno_Subito
/base_python/the_strings.py
2,889
4.4375
4
h = 'hello' print(h[2]) print(h[1:3]) # stampa da 1 a 2, l'etremo destro 3 non viene compreso, il sinistro invece si lower = 'dima' upper = 'TKACH' print(lower.capitalize() + upper.lower()) print(lower.islower()) print(upper.islower()) # * join l1 = 'egg' l2 = '123' print(l1.join(l2)) # egg sarà inserito in mezzo a...
c0ae348fb2459beb8bcfa9aff8561a0b86ad0ae5
shivang98/DS-Algo-Practice
/inorder_list.py
526
3.640625
4
from BST import BST def inorder_list(root): if root == None: return [] leftside = inorder_list(root.left) rightside = inorder_list(root.right) ans = [root.data] return leftside + ans + rightside arr = [54,12,5,8,3,7,0,23] tree = BST() for i in arr: tree.insert(i)...
1a71700af244cfab85b0d1203e2fa081aa6bd4ee
shivang98/DS-Algo-Practice
/palindrome_permutatiomn.py
669
3.65625
4
def palindrome_perm(S): S = S.lower() S = ''.join(S.split(' ')) fm = {} for i in S: if i in fm.keys(): fm[i] += 1 else: fm[i] = 1 print(fm) if len(S) % 2 == 0: for k in fm.values(): if k % 2 != 0: return False else: ...
cc0f2bc409cc9d72c792ae38c2b84b353d6bcb3d
ChakshuVerma/Python-SEM-3
/Question 6/code.py
1,333
4.46875
4
""" Q6.Consider a tuplet1 ={1,2,5,7,9,2,4,6,8,10}. Write a program to perform following operations : a) Print another tuple whose values are even numbers in the given tuple . b) Concatenate a tuplet2 = {11,13,15) with t1 . c) Return maximum and minimum value from this tuple . """ ch=0 # Given len=10 t1=(1,2,5,7,9,...
37294a3b02588d7abed8f0b72e0880842183118d
ChakshuVerma/Python-SEM-3
/Question 9/code.py
1,540
3.984375
4
""" Q9 .Use dictionary to store marks of the students in 4 subjects . Write a function to find the name of the student securing highest percentage . ( Hint : Names of students are unique ) . """ #Function To Find The Maximum Percentage def maximum_percentage(data,Max): print("") for i in data:...
d88192491dae06345f6aa3392cca8e667760fbf7
TianGong42/LearningHardWay
/ex17.py
855
3.5625
4
from sys import argv from os.path import exists script, from_file, to_file = argv # 这一行只是一个文本,并打印输出变量 print(f"Copying from {from_file} to {to_file}") # we could do these # 打开需要复制的文件 in_file = open(from_file) # 并读取为一个文件对象 indata = in_file.read() # 打印输出这个文件对象的长度 print(f"The input fi {len(indata)} bytes long") # 判断是t...
f6900b6410ee6e650dbdac93155674845310ebe9
TianGong42/LearningHardWay
/ex15.py
378
3.953125
4
# 通过argv获取文件名 from sys import argv script, filename = argv # open方法,接受一个参数。获取一个文件对象 txt = open(filename) print(f"Here's your file {filename}:") # 调用read()方法打印文本对象的内容 print(txt.read()) print("Type the filename again:") file_again = input("> ") txt_again = open(file_again) print(txt_again.read())
4889ac58968420001ed2a0c7d6de8097f6c341ae
KarinaMapa/Exercicios-Python---Sequencial
/ex.17.py
1,044
3.65625
4
lata18 = 80 lata36 = 25 area18 = 6*18 area36 = 6*3.6 area = float(input('Qual a área total a ser pintada (m²)? ')) from math import ceil area_total18 = ceil(area/area18) area_total36 = ceil(area/area36) print('Se você optar por comprar apenas latas de 18 l irá precisar de {} latas e o valor total gasto será de R$ {:....
0409d18fbb6e21128fbaed8780c6822e7acca46e
jarvis004/PyJam
/audioplayer.py
994
3.65625
4
import simpleaudio as sa import time class AudioPlayer: """ Audio player which give simple methods to handle the audio player. The audio player is provided by simpleaudio library. """ def __init__(self, filename=None, timeSlice=0.3): """ Constructor to create audio player. """ ...
53d881a83a6efe9b9e4db5dadab8f45e2668d780
rmirandarj/ufrrj
/MetodosNumericos/find/root/bisection.py
703
3.953125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from communs import util def bisection(a, b): n = 0 approximation = [] roots = [] while n < util.MAX: c = (a + b) / 2 fc = util.f(c) fa = util.f(a) approximation.append(abs(fc)) roots.append(c) n += 1 ...
d765e1dd1c114162c0abaad87523b8832d4fc5a3
GodMode-On/Tasks-from-different-sites
/Codewars/Molecule to atoms.py
2,617
3.859375
4
from string import digits def count_nums(text, position): ''' Returns how many digits in a row in text, starting from pos. ''' if not text[position].isdigit(): return False count = 0 while text[position].isdigit(): count += 1 position += 1 if position == len...
f78a17ac7abb55ebd806be28ac805768ff6fd36d
astory/cs4740_4
/packer.py
1,125
3.859375
4
#!/usr/bin/env python # Tools to fit answers into fixed-byte data. def pack(data, length, pack=False): """ Pack data (a sorted list of (score, candidate) into length bytes. If pack = True, will continue to look for smaller words to fit in until there is no space or no more words. If pack = False, stops at the fi...
e7154baf51a1eee0b9b1ca2aff0ee134020427e7
astory/cs4740_4
/read_questions.py
2,293
3.796875
4
#!/usr/bin/env python #this will read in the questions without the answers and return a list #where each item in the list is a question. Each question is a list #of two things. The first item in this list is the question number #and the second is the actual text which is a continuous string def read_questions_no_ans...
1484eed3499805916e67f8399eab2997ec2a615e
zn-zyl/Blog
/python基础高阶编程/py_03day/04闭包函数.py
825
3.671875
4
""" ============================ Author:柠檬班-木森 Time:2020/5/11 21:44 E-mail:3247119728@qq.com Company:湖南零檬信息技术有限公司 ============================ """ """ 闭包: 闭包函数实现的三个条件: 1、函数中嵌套一个函数 2、外层函数返回的是嵌套的内层函数 3、嵌套的内层函数对外部作用域有非全局变量的引用 """ # 这个不是闭包 # a = 100 # def func(): # # a = 100 # # ...
c51ce36c5f876fb9a861d15af945acd2d3b6e1c7
zn-zyl/Blog
/python基础高阶编程/py_06day/03__str__方法.py
542
3.6875
4
""" ============================= @Time : 2020/5/24 13:07 @Author : AllyZhou @FileDec: ============================== """ class Myclass: def __init__(self, name, age, gender): self.name = name self.age = age self.gender = gender def __str__(self): """ 在打印类对象的时候会被调用 ...
2ec455f1ad2ac1ec50a3ce094b30034d2934efae
zn-zyl/Blog
/python基础高阶编程/py_06day/08类的私有属性.py
1,375
3.53125
4
""" ============================= @Time : 2020/5/24 15:56 @Author : AllyZhou @FileDec: ============================== """ """ 类里面的私有属性:声明这个属性仅限类内部使用,外部不要引用 (如有私有属性进行修改,恕不通知,引用者后果自负) _开头 在类外面可以访问 __开头 在类外面可以间接访问,不能直接访问 """ class Mytest: attr = 100 _attr = 100 __attr = 100 def __init__(self, name): ...
82af59cee878318ba259e6ca73dabbc102b4e65c
zn-zyl/Blog
/python基础高阶编程/py_01day/py04_01day_06.py
617
4.125
4
""" ============================ Author:柠檬班-木森 Time:2020/5/6 21:32 E-mail:3247119728@qq.com Company:湖南零檬信息技术有限公司 ============================ """ """ 数值:int float 序列:list str tuple 散列:set dict 可迭代对象: """ from collections import namedtuple tu = (11, 22, 33) # stu = ('木森', 18, 'python自动化') ...
7b840d26e327da2dc003c0647989f1e088499f46
JitenKumar/Data-Analysis-Visualization-With-Python
/Pandas Practice/Data Frames/dataframes.py
1,267
3.703125
4
import numpy as np import pandas as pd from pandas import Series,DataFrame # importing browser # import webbrowser # website_url = 'https://en.wikipedia.org/wiki/List_of_all-time_NFL_win%E2%80%93loss_records' # webbrowser.open(website_url) # copying a data from clipboard nfl_data = pd.read_clipboard() print(nfl_data)...
d7fe766e233fd304d3ba59f8438614f9f2e23541
coonsdune/ECE-404
/Homework 3/multiplyinv.py
908
3.8125
4
#!/usr/bin/env python ##Homework Number: 3 ##Name: Adam Bahrainwala ##ECN Login: abahrain ##Due Date: 06/02/2014 import sys if len(sys.argv) != 3: sys.stderr.write("Usage: %s <integer> <modulus>\n" % sys.argv[0]) sys.exit(1) def BIMI(num,mod): NUM = num; MOD = mod x, x_old = 0L, 1L y, y_...
04c27b52f3e7b40e042d364621608097570a81aa
eoinlees/Labsheets2020
/Lab 03/Lab03.07-randomFruit2.py
278
3.921875
4
#Eoin Lees #This program prints out a random fruit import random fruits = ["Apple", "Orange", "Mango", "Bananna", "Pear"] #We want a ranodm number between 0 and length -1 index = random.randint(0,len(fruits)-1) fruit = fruits[index] print("A Random Fruit: {}".format(fruit))
7dd9606b8d86bfc92f8ddca64f2496d153edbdea
eoinlees/Labsheets2020
/Lab 06/Lab06.02-students.py
1,398
3.90625
4
#Eoin Lees students=[] def displayMenu(): print("What would you like to do?:") print("\t(a) Add new student") print("\t(v) View students") print("\t(q) Quit") choice = input("Type one letter (a,v,q):").strip() return choice def readModules(): modules = [] currentName = input("\t\tEn...
9e9a278e830c5491c1795049db82b51b2e59053e
bharatr21/MayLeetCodeChallenge
/Solutions/S22.py
164
3.515625
4
class Solution: def frequencySort(self, s: str) -> str: return "".join([k * v for k, v in sorted(Counter(s).items(), key=lambda x: x[1], reverse=True)])
c007a5bec52bc4db8ea17186c13a9145dbd9ca11
InsolvencyService/rps-alpha
/rps/claimants_user_journey/forms/validators.py
5,073
3.59375
4
import re from datetime import date from wtforms.validators import Regexp, ValidationError, StopValidation, DataRequired def convert_string_to_date(date_string): split_string = date_string.split('/') if type(split_string) != list or len(split_string) != 3: raise SyntaxError('Was expecting dd/MM/yyyy.'...
4c3287395c983dbab0c658f366605ead1517d794
lugeluge/PythonScript
/bracket.py
2,177
3.578125
4
#coding:utf-8 #python2 """ 括号匹配算法。 """ SYMBOLS = {'}':'{', ']':'[', ')':'('} SYMBOLS_L, SYMBOLS_R = SYMBOLS.values(), SYMBOLS.keys() def check(s): arr = [] for c in s: if c in SYMBOLS_L: # 左符号入栈 arr.append(c) elif c in SYMBOLS_R: # 右符号要么出栈,要么匹配失败 ...
40536219da06d6fb7f310b275b88714e981464ff
lcford2/python_examples
/taylor_series_approximation/taylor_series.py
3,079
4.125
4
from scipy.special import factorial class TaylorSerApprox(object): """ A simple python representation of the Taylor Series Approximation. Taylor Series Approximations are often useful in representing non-linear equations as a linear summation of terms relating to those non-linear equations. ...
8c67095e3342ea13f00743a814edd8bd25fc1b2c
AshishGoyal27/Tally-marks-using-python
/tally_marks_using_python.py
301
4.25
4
#Retrieve number form end-user number = int(input("Input a positive number:")) #how many blocks of 5 tallies: ||||- to include quotient = number // 5 #Find out how many tallies are remaining remainder = number % 5 tallyMarks = "||||- " * quotient + "|" * remainder print(tallyMarks)
8fc3056d3cf8554b2806c4dbb3e0eeaa355c98e0
Mitashi-11/Ray-casting-code
/collisions.py
2,616
3.515625
4
from typing import List, Optional, Tuple import v_math import data import math # Function to return a normal vector at a point on the surface of a sphere # input: the sphere of type Sphere from data # input: the point on the surface of type Point from data # output: the normal vector of type Vector from data def spher...
c17fc73a2cab082cc07a62cf44f7a1178d070bfd
johli/aparent-legacy
/cnn/logistic_sgd_global_onesided2.py
28,052
3.9375
4
""" This tutorial introduces logistic regression using Theano and stochastic gradient descent. Logistic regression is a probabilistic, linear classifier. It is parametrized by a weight matrix :math:`W` and a bias vector :math:`b`. Classification is done by projecting data points onto a set of hyperplanes, the distance...
fa73cf6cb762b53b456c9dc2dc665dabec235f79
shahrukhijaz-31/beginner_scrapy_task
/second.py
1,150
3.65625
4
# # # def remote_control_next(): # print("yeild 1") # yield "a" # print("yeild 2") # yield "ab" # print("yeild 3") # # itr=remote_control_next() # # print(next(itr)) # # print ("/////") # # print(next(itr)) # # print ("/////") # # print(next(itr)) # # def func(): # for i in range(3): # ...
41ae92d6d6687fee55afacc893276014fbf5a1fd
Bryan-Guner-Backup/DOWN_ARCHIVE_V2
/LAMBDA_LABS/betterreads-ds/readrr_api/route_tools/gb_funcs.py
3,826
3.703125
4
""" A set of helper functions to process data from the google books API. The functions are as follows: retreive_details() - Retreive specific keys from a dictionary object clean() - Alter data to match data model process_list() - Process a list of dictionaries to endpoint output format """ import ...
e06846d6b7b47bc102fb5339c22f930fcec42df0
akshitkaul/ass2
/aasi2.py
490
3.90625
4
#ques1 print('i am aditya') #ques2 print("acad"+"view") #ques3 x=int(input("enter value of x\n")) y=int(input("enter value of y\n")) z=int(input("enter value of z\n")) print("value of x",x) print("value of y",y) print("value of z",z) #ques4 print("let's get started") #ques5 s="Acadview" print("s=",s) co...
437b204b3e9898dd0335703657f81c8a14a21854
omritz/Checkers-Board-Search
/main.py
20,155
3.828125
4
import random as random import copy as copy import math import numpy as np import sys # This script contains 5 Algorithms to search a path from a Starting board, # according to the rules of Checkers, to a goal board. # you can simply insert the boards under this lines or while runing the main. startBoa...
0f3f75d0f3c7a9b1598661525789e3044bc575c9
ErikSeiki/curso-em-video-python-mundo1
/Aula 09 - Manipulando Texto/ex022.py
731
3.890625
4
n = str(input("Digite o seu nome completo: ")) print("Seu nome com todas as letras maiusculas: {}".format(n.upper())) print("Seu nome com todas as letras minusculas: {}".format(n.lower())) print("Você tem {} letras no seu nome completo".format(len("".join(n.split())))) nn = n.split() print("Seu primeiro nome é {} ...
72422871a02bd22eeda92d90c6d6b577b332db24
ErikSeiki/curso-em-video-python-mundo1
/Aula 07 - Operadores Aritméticos/ex013.py
139
3.5
4
s = float(input("Digite o salario R$")) a = (s / 100) * 15 pca = s + a print("Seu salario com o aumento é de R${:.2f}".format(pca))
799a79586990d779e6bced3745d54aad9dc4ec1f
ErikSeiki/curso-em-video-python-mundo1
/Aula 10 - Condições/ex028.py
373
3.71875
4
import random import time na = random.randint(0, 5) print("-=-"*20) print("Estou pensando em um numero de 0 a 5. Tente adivinhar...") print("-=-"*20) ne = int(input("Em que numero pensei? ")) print("Processando...") time.sleep(2) if na == ne: print("Parabens! Voce ganhou") else: print("Eu ganhei, ...
c3dec2a0e3e0f5db500c3b99d3bd018bd51cfb41
ErikSeiki/curso-em-video-python-mundo1
/Aula 10 - Condições/ex032.py
267
3.828125
4
from datetime import date n = int(input("Que ano quer analizar? ")) if n == 0: n = date.today().year if n % 4 == 0 and n / 100 != 0 or n / 400 == 0: print("O ano de {} é bissexto".format(n)) else: print("O ano não {} é bissexto".format(n))
2d837252cc3b6440761f53419c307f70269a9c62
ErikSeiki/curso-em-video-python-mundo1
/Aula 09 - Manipulando Texto/ex026.py
282
3.96875
4
f = str(input("Digite uma frase: ")).upper().strip() print("Tem {} 'A' nesta frase ".format(f.count("A"))) print("A letra 'A' aparece pela primeira vez na posição: {}".format(f.find("A")+1)) print("A letra 'A' aparece pela ultima vex na posição: {}".format(f.rfind("A")+1))
5fcb98af90f173b41b71476b0adc3b0418081b71
lxd262/CoffeeMachine
/Coffee Machine/Problems/Calculator/task.py
440
4.03125
4
# put your python code here a, b, operand = float(input()), float(input()), input() if operand == "+": ans = a + b elif operand == "-": ans = a - b elif operand == "*": ans = a * b elif operand == "pow": ans = pow(a, b) else: if b == 0: ans = "Division by 0!" elif operand == "/": ...
371900df81c1406736a3690a8d5e3e00802f08df
unfuse/aoc2019
/day1.py
333
3.71875
4
import math # part 1 def fuel(parm): calc = math.floor(parm/3) - 2 return calc # part 2 def fuel_recursive(parm): calc = fuel(parm) if calc <= 0: return 0 return calc + fuel_recursive(calc) f = open("input1.txt", "r").readlines() total = 0 for l in f: total += fuel_recursive(int(l)) ...
acdae4022066d09a72a7b58db469fa8071193ac9
Richiewong07/alien_invasion
/ship.py
1,792
3.765625
4
import pygame class Ship(): def __init__(self, ai_settings, screen): """Initialize the ship and set its starting position.""" self.screen = screen self.ai_settings = ai_settings # GIVE SHIP ACCESS TO SPEED SETTINGS --> TO USE IN UPDATE() # LOAD THE SHIP IMAGE AND GET ITS RECT. ...
37dd5c5639533438548510b74c7f68cb703390ce
nayanemaia/tcc
/point.py
549
4.0625
4
class Point(object): #define uma classe com valores de coordenadas X e Y no plano cartesiano def __init__(self,x,y): #construtor da classe com teste se os valores sao do tipo float try: if type(x) == float and type(y) == float: self.X = x self.Y = y ...
af76471bfd5b994f8a2914c859b2965cc66b9ee7
maulikrathod/CodeTestHODLife
/writeToXlsx.py
1,975
3.515625
4
## This file is used for write updated data in excel import openpyxl import xlsxwriter import os import pandas as pd from convertBinaryToEmail import binary_to_str from dataFilesPaths import * ## read excel file excelFile = openpyxl.load_workbook(input_file_path) ## get workbook to write back workbook = xlsxwriter.Wor...
412d0b927fba80e9dba6fb94d94c5a3b50a6bcb8
Airandiel/3d_tictactoe
/BoardDrawing.py
715
3.671875
4
from clear import clear import sys size = 4 def draw_board(matrix = [[[0 for k in range(size)] for j in range(size)] for i in range(size)]): clear() print('--------- --------- --------- ---------') for y in range(4): print('|', end='') for z in range(4): for x in range(4...
17f5d941d835fed981a50521ed296af444ee74b1
Aniruddha-Deb/digit_recognizer
/and_gate_nn.py
2,550
3.53125
4
import numpy as np class Network: # this is all mostly taken from Nielsen's book def __init__(self, sizes): self.num_layers = len(sizes) self.sizes = sizes self.biases = [np.random.rand(y,1) for y in sizes[1:]] self.weights = [np.random.rand(y,x) for x,y in zip(sizes[:-1], sizes[1:])] def feedforward(sel...
d2ae8398e09ebc1a3bf108aa7c0194b86eb87dbb
EricRobertCampbell/backend-testing
/simple-testing/subtract.py
83
3.515625
4
# subtract.py def subtract(a, b): """Subtracts two numbers""" return a - b
c75b0b26e8f1a20cb80aaa4f5c6563cb8775465d
agileshaw/Project-Euler
/Python/Problem0004.py
386
3.546875
4
# Problem0004 - Largest palindrome product # # https://github.com/agileshaw/Project-Euler import math if __name__ == "__main__": result = 0 for i in range(100, 999): for j in range(i, 999): num = i * j if (str(num) == str(num)[:: -1]) and (result < num): result ...
c13e1098d4961657c96ac9351c65adfa4fd2748b
agileshaw/Project-Euler
/Python/Problem0012.py
614
3.671875
4
# Problem0012 - Highly divisible triangular number # # https://github.com/agileshaw/Project-Euler import math import itertools def numOfFactors(num): count = 0 root = int(math.sqrt(num)) for i in itertools.islice(itertools.count(1), root): if num % i == 0: count += 2 if root * root...
963d39fc37656b66c14f00e481b9c91732a9175b
agileshaw/Project-Euler
/Python/Problem0017.py
958
3.90625
4
# Problem0017 - Number letter counts # # https://github.com/agileshaw/Project-Euler def letterCount(num): below_twenty = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] ...
d0d239931fdd0cfba7961a59500b3098ceadc81a
nicomo/exercism-python
/rna-transcription/rna_transcription.py
448
3.625
4
def to_rna(dna_strand): if dna_strand == "": return "" else: l = [] for c in dna_strand: if c == "G": l.append("C") elif c == "C": l.append("G") elif c == "T": l.append("A") elif c == "A": ...
d0a8eb11c46592f99e9088c1149b9d1bb0c1da01
nicomo/exercism-python
/reverse-string/reverse_string.py
107
3.953125
4
def reverse(text): l = [] for letter in text: l.append(letter) return "".join(l[::-1])
4ec895492e8ce9a5ad94f0c8f8073873bcc5ee73
eve066/WordCount-0725
/wordcount.py
562
3.59375
4
# put your code here. import string file = open("test.txt") word_dict = {} new_word = "" for line in file: words = line.strip("\n").lower().split(" ") for items in words: if "http" in items: new_word = items else: for i in range (0,len(items)): if item...
4d5477866885122688680686f0e01d2f070874c6
piravp/scripts
/code-comment-counter/main.py
1,203
3.765625
4
import re import argparse FILENAME = "commentfile.py" def block(): block_comments = 0 with open(FILENAME, "r") as file: # check for block comments for line in file: reg = re.search("^\s*#",line) # if not none if reg: block_comments += ...
800db245fc0da43b53abd665f3a162b76b1b398a
asaiapalacios/holbertonschool-higher_level_programming
/mvc_let_s_interact_with_print/task_view.py
1,450
3.84375
4
''' Python View Script Using Tkinter Library: Tkinter Turns Python Code into Tcl Code with Tcl's TK Widgets to Build GUI Applications in Python ''' import Tkinter as tk '''Class is a subclass of the Tkinter Toplevel''' class TaskView(tk.Toplevel): '''Constructor''' def __init__(self, master): tk.Topl...
d13c2593985d83c54b852e5ad78a6194debf0675
xyuae/Software-Design
/Problem_Set_2/Problem_Set_2/logest_subpalindrome_slice_2.py
1,251
3.796875
4
def longest_local_subpalindrome(text, index1, index2, n): """Return (i, j) of the longest palindrome centered by [index1, index2], n is the length of string text""" l1 = index1 r1 = index2 while l1 >=0 and r1 < n: if text[l1].lower() == text[r1].lower(): l1 -= 1 r1 += 1 ...
27f4685d0a6bc00083754c2b52af7a98ad6e8341
xyuae/Software-Design
/Problem_Set_1/L1/test_shuffler.py
1,067
3.5625
4
from collections import defaultdict from math import factorial from random import randrange from shuffle import shuffle, swap def test_shuffler(shuffler, deck='abcd', n=100000): counts = defaultdict(int) for _ in range(n): input = list(deck) shuffler(input) counts[''.join(input)] += 1 ...
71d6194bc0849294cf9e5b164411a54750aa1bea
MarkyWicked/tkzmwukWpjnr
/CryptoLib.py
647
3.640625
4
class CryptoLib: arr = None def __init__(self,arr): self.arr = arr def Encrypt(self,text): j = 0 string = "" for c in text: c = chr(ord(c) + self.arr[j]) string = string + c if j < len(self.arr)-1: j =j+1 else:...
94718cd85f90beec11cb8267fdf30662ea8aa4bd
georgeJzzz/learning_spider
/example/0_Basic_usage_of_the_library/encode_decode/0_ascii.py
573
4
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : 0.py @Time : 2021年1月11日 @Author : Recluse Xu @Version : 1.1 @Contact : 444640050@qq.com @Desc : ASCII 相关 ''' def char_to_ascii_num(text: str): for char in text: print(char, ord(char)) def ascii_num_to_char(char_num_list : s...
388ebacd1f4aa8e375ba2c73924e3bf9c90e0f97
georgeJzzz/learning_spider
/example/0_Basic_usage_of_the_library/encode_decode/2_aes.py
1,193
3.53125
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @File : 0.py @Time : 2020年8月18日16:20:45 @Author : Recluse Xu @Version : 1.0 @Contact : 444640050@qq.com @Desc : None ''' import base64 from Crypto.Cipher import AES class AES_Cipher(object): def __init__(self, key): self.bs = 16 ...
5c373f7ed68db2572c93efc11efc2d998fd6aee4
yonoel/Python
/JoinQuant/demo/Average.py
167
3.78125
4
# 计算一个list的平均值 def pjs(list): sum = .0 for i in list: sum += i return sum / len(list) print("{:.2f}".format(pjs([1,2,3,5,3.3])))
eeb06d4f1d2c7d928aa45401ae3951495cd64520
yonoel/Python
/Test/python_quiz/demo.py
320
3.71875
4
def fn(): try: return 1 finally: return 2 # print(fn()) # print (4.5//2) import random # print (random.seed(3)) for i in range(1, 5): print(str(i) * 5) var1 = True var2 = False var3 = False if var1 or var2 and var3: print("True") else: print("False") for i in range(1,6): print (++i)
54bc198426ba77c8742a5fb9f2306c002af79da1
veruskasilva/ProjectEuler
/ProjectEulerPy/ProjectEulerPy/problems01.py
186
3.6875
4
class Problems01(): def problem1(self): soma = 0 for x in range(0,1000): if (x % 3 == 0) or (x % 5 == 0): soma += x print(soma)
785d31e9e0ee300d05ba083550f1eaa22018388b
13LD/edu
/algorithms-design-and-analysis/Algorithms_Week1/closest_paris.py
2,617
3.953125
4
from merge_sort_2d import * import math, random, re def pre(points): '''Pre-process for closest pair problem, 'points' being a list of 2-tuples. return two ordered list based on x and y coordinates using merge sort.''' px = merge_sort_2d(points, 0) py = merge_sort_2d(points, 1) return px, py #pri...
d4e51e77d66182f3e612c70ed3905535cbedfa7a
alsevilleno-38/Machine
/tinker.py
308
3.75
4
from tkinter import * from tkinter import messagebox root = Tk() e = Entry(root, width=50) e.insert(0, "Tkinter") e.grid(row=1, column=1) def screen(): messagebox.showinfo("Information", "Please close this") btn1 = Button(root, text="Click me", command=screen).grid(row=0, column=1) root.mainloop()
64c8df6c90866ba462839f70973d2a5c1c3d7e37
LoralieFlint/python-2-guided-lecture
/function2.py
1,270
4.0625
4
def mult2(x, y): print(f"{x} is being multiplied by {y}") return x * y print(mult2(2, 7)) a = 12 print(mult2(a, 6)) b = 10 print(mult2(a, b)) # --------------------------------------------- def foo(x): x[2] = 99 a = [1, 2, 3, 4] foo(a) print(a[2]) print(a) # --------------------------------------...
4c5d8498f06e5ed8be3e37112e896ec23457aa5a
rania-glass/StaffSelection
/SSSCode/RunMe.py
3,028
3.59375
4
import os import re from Tkinter import Tk from tkFileDialog import askopenfilename from tkFileDialog import askdirectory from Messages import PrintMessages from Modules import handleCSV from Modules import Sorter from Modules import SortFileByName def getFile(): #get the file to be operated on print "Please...
e261061c60a13e4ddd0da85027fdc83a95a57d90
rram/aoc
/2020/day17p1.py
3,262
3.5
4
#!/usr/bin/python3 import collections import logging class Point(collections.namedtuple("Point", ['x', 'y', 'z'])): def __lt__(self, other): if self.z < other.z and self.y < other.y and self.x < other.x: return True return False class Space(object): def __init__(self): s...
2a42e12ae42087d991bed0ba4bea44b29470651f
rram/aoc
/2020/day2p1.py
713
3.515625
4
#!/usr/bin/python3 import logging def run(data): good = 0 for line in data: nums, let, passwd = line.split() low, _, high = nums.partition("-") low = int(low) high = int(high) assert let[1] == ":" let = let[0] if low <= passwd.count(let) <= high: ...
0c5e0b20254ca9d2ea71a5599ed6ec2d397bb3c2
zrowland885/posim
/src/posim/velocities.py
447
3.625
4
# -*- coding: utf-8 -*- """ Velocity functions to define movement speed and direction """ def random(t, params): """ Random velocity """ import random if params == None: b_min = 0.1 b_max = 1.0 else: b_min = params['min'] b_max = params['max'] velocity = random.unifo...
4c398e439318541994cbab734b5414f60f3137c3
AZERTAL/python
/Untitled5.py
1,359
3.671875
4
#!/usr/bin/env python # coding: utf-8 # In[4]: print("Je vais trouver un programme qui trouvera des numéros divisibles par 7 mais ne sont pas un multiple de 5 entre 2000 et 3200") print("reponse de la premiere question") LISTOFNUMBERS = [i for i in range(2000,3201) if i % 7==0 and i %5!=0] print(LISTOFNUMBERS) # I...
e1e8998c3ea49c9cc24419f82c623631d9c49c6a
qibinjin/Python_kim
/other_test/2进制.py
362
3.65625
4
# jinzhi = input('请输入二进制数字') # sum = 0 # for i in range(len(jinzhi)): # if jinzhi[::-1][i] == '1': # sum += 2 ** i # print(sum) jinzhi = int(input('请输入二进制数字')) sum = 0 for flag in range(len(str(jinzhi))): if jinzhi <= 0: break sum += (2 ** flag) * (jinzhi % 10) jinzhi = int(jinzhi /10) ...
36d593eaf31d9f8cfdf8cf079618419e1909cbb9
qibinjin/Python_kim
/test/mianshi2.py
190
3.609375
4
A = [1, 2, 2, 1, 3, 4, 3] for i in range(len(A)): for j in range(i, len(A)): if A[i] == A[j]: A.remove(A[i]) A.remove(A[i]) else: print(A[i])
264a636ff29b793fd080ff081e88155674d22321
qibinjin/Python_kim
/test/my_dfs_city.py
762
3.734375
4
def dfs(start, dis): global min if dis > min: return if start == dest: if dis < min: min = dis print(searched) print(min) return for i in my_map: if i[0] == start: if i not in searched: searched.append(i) dfs(i[1], dis ...