blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
90597f852e1fab8bf523132577e8dfbdde2446c8
franktank/py-practice
/fb/hard/int-to-eng.py
2,111
3.890625
4
""" Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For example, 123 -> "One Hundred Twenty Three" 12345 -> "Twelve Thousand Three Hundred Forty Five" 1234567 -> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven" """ class Solu...
5324abd28ea56372a32fcfba3f6b952b52bea5d0
daniel-reich/ubiquitous-fiesta
/LMoP4Jhpm9kx4WQ3a_11.py
511
3.59375
4
def is_ascending(s): Sample_A = str(s) Length = len(Sample_A) Ending = 1 while (Ending < Length - 1): Sample_B = Sample_A[0:Ending] Number = int(Sample_B) + 1 Length_A = len(Sample_A) Length_B = len(Sample_B) while (Length_B < Length_A): Sample_B = Sample_B + str(...
610eac3b0622cf0471f863facece6fee1a8b03df
NeroCube/leetcode-python-practice
/medium20/singleNumber.py
409
3.6875
4
''' 260. Single Number III [題目] 找只有出現一次的數 ''' class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: List[int] """ one = set() two = set() for num in nums: if num not in one: one.add(num) ...
5faa882e942559db7ed45d4af956a12d7151ae76
xqx1998/learn_python
/fun_triangles.py
163
3.5
4
# -*- coding: utf-8 -*- #!/usr/bin/env python def triangles(): a = [1] while True: yield a a = [sum(i) for i in zip([0] + a, a + [0])]
0d819d7dfe001c89c55437a79f9464cfd9cb7dae
realpython/materials
/python-doctest/user.py
1,278
3.9375
4
class User_One: def __init__(self, name, favorite_colors): self.name = name self._favorite_colors = set(favorite_colors) @property def favorite_colors(self): """Return the user's favorite colors. Usage examples: >>> john = User("John", {"#797EF6", "#4ADEDE", "#1AA7E...
8a86a75419d5c5e817373e4ce0f35ff9f017404d
JorgeTranin/Python_Curso_Em_Video
/Exercicios Curso Em Video Mundo 1/ex026.py
136
3.515625
4
frase = input('Digite uma frase: ') p = (frase.count('a')) print('Aparecem ', (frase.count('a'))) print('A primeira vez aparece em: ', )
df8852014d55250f139db09a4605c66cb643743c
brkyydnmz/PythonCamp
/PythonKamp-Hızlı Kısa/workshop2.py
403
3.78125
4
#girdiğin faktoriyeli hesaplama çalışması sayi=int(input("Kaçıncı faktoriyeli hesaplayayım?:")) faktoriyel=1 if sayi<0: print("Negatif sayıların faktoriyeli hesaplanmaz") elif sayi==0: print("Sonuc:1") else: for i in range(1,sayi+1): # artı 1,5 girdiysek 5 de dahil olsun diye artı 1 var. ...
812f9593a2a3ea3d49c9bbda4b2bac8f8a6535c6
DavidArmendariz/python-basics-hse
/Week_5/list_comprehensions_3.py
249
3.828125
4
#!/usr/bin/env python # coding: utf-8 # In[7]: def isprime(x): for j in range(2, x): if x % j == 0: return False return True x = [(i,'prime') if isprime(i) == True else i for i in range(10,51)] print(x) # In[ ]:
4ad818aa2c682360cebec9e1866e4fe31a6cf990
npmajisha/spam_filter
/megam_formatter.py
1,842
3.515625
4
#this is to convert a file generated from readfiles.py into MegaM format #takes 2 arguments 1.input file which is generated output of the readfiles.py 2.output filename import re import codecs import sys def main(): #usage details if len(sys.argv) < 3: print("Usage : python3 megam_formatter.py i...
e142d546533b59f7a7faf1cfcef614aab687769e
rahulcode22/Data-structures
/Backtracking/The-Power-Sum.py
391
4.15625
4
''' Find the number of ways that a given integer X, can be expressed as the sum of N the power of unique, natural numbers. ''' def countWaysUtil(x, n, num): val = x - (num**n) if val == 0: return 1 if val < 0: return 0 return countWaysUtil(val, n, num + 1) + countWaysUtil(x, n, num+1) ...
8d2b65252c49edc35f9c2e4c93e18666c0a013f7
naranundra/python5
/hicheel7.py
1,108
4
4
# pop -> list ees salgaj awna names = ["bat " , "bold" , 'delger'] a = names.pop(2) print(names) print(a) # remove -> shuud ustgana names = ["bat " , "bold" , 'delger'] a = names.remove("bat ") print(a) #clear names = ["bat " , "bold" , 'delger'] names.clear() print(names) # del names = [...
dada92d04f88313ca59e51edefb2781666fb16c5
AmirrezaGhafoori/DFA-NFA-
/NFA.py
9,745
3.703125
4
''' Converting NFa to DFA, implemented by Amirreza Ghafoori notice: use "λ" character for "landa" in nontations ''' import collections filename = "NFA_Input_22.txt" target_filename= "DFA_Output_22.txt" #first we define class for nfa to extract the features from the file class nfa: def __init__(self, filenam...
486450eff36c703b12133f155b4347170e604408
osmanseytablaev/Learn-Python
/reference.py
1,032
4.09375
4
print('Простое присваивание') shoplist = ['яблоки', 'манго', 'морковь', 'бананы'] mylist = shoplist # mylist - лишь ещё одно имя, указывающее на тот же объект! del shoplist[0] # Я сделал первую покупку, поэтому удаляю её из списка print('shoplist:', shoplist) print('mylist:', mylist) # Обратите внимание, что и shoplist...
df3615b3a1c05af42848b8a64c717efc20174bf7
abhi98khandelwal/Next-episode-date
/send_email.py
959
3.65625
4
import smtplib class SendEmail: """ A class to send email given the email and message. Args: email (str): email id of recipient. message (str): message that needs to be sent. """ #username : senders gmail username username = 'senders gmail username' #password : senders gm...
df095f1a821bcc9b6568a58a5f34ac3a8dd32e13
Yujunw/leetcode_python
/14_最长公共前缀.py
1,072
3.8125
4
''' 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"] 输出: "fl" 示例 2: 输入: ["dog","racecar","car"] 输出: "" 解释: 输入不存在公共前缀。 说明:所有输入只包含小写字母 a-z 。 ''' class Solution: def longestCommonPrefix(self, strs): if not strs: return '' if len(strs) == 1: ...
d12a0177b5905529321a0b4ea7690812194bd979
thu4nvd/project_euler
/prob026.py
1,007
3.828125
4
#!/usr/bin/env python3 ''' Reciprocal cycles Problem 26 A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: 1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0.(142857) 1/8 = 0.125 1/9 = ...
74844bb2b4603d14218a1f157ed8c938577d6a51
xzeromath/euler
/ep29.py
760
3.53125
4
# 2 ≤ a ≤ 5 이고 2 ≤ b ≤ 5인 두 정수 a, b로 만들 수 있는 ab의 모든 조합을 구하면 다음과 같습니다. # 2^2=4, 2^3=8, 2^4=16, 2^5=32 # 3^2=9, 3^3=27, 3^4=81, 3^5=243 # 4^2=16, 4^3=64, 4^4=256, 4^5=1024 # 5^2=25, 5^3=125, 5^4=625, 5^5=3125 # 여기서 중복된 것을 빼고 크기 순으로 나열하면 아래와 같은 15개의 숫자가 됩니다. # 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, ...
d2dc181514425276220c7a2b35d01ec7bf07a053
PedroHenr1que/AtividadesFaculdadeProgramacao
/Outros/Cadastro Pessoa.py
5,812
4.03125
4
nome = [] idadeDefinitiva = [] alturaDefinitiva = [] opcaoDefinitiva = [1,2,3,4,5,6] opcaoAlteracaoDados = [1,2] condicao = True while condicao == True: #----------------------------------------------Opções------------------------------------------ print("\n" * 10) print("-------Opções-------") print(...
a06c2edbe7c34815b3952b7e147bfae43f1e6508
hongxuli/python-learning-
/mongodb/mongo_db.py
527
3.53125
4
import pymongo # client = MongoClient('mongodb://localhot:27017/') client = pymongo.MongoClient(host='localhost', port=27017) # db = client['test'] db = client.test collection = db.students student1 = { 'id': '20170101', 'name': 'Jordan', 'age': 20, 'gender': 'male' } student2 = { 'id': '20170...
6a9ef6554beb0cb61d495960db593157bb2b5d8f
1605125/newthing11
/inherit_multilevel.py
691
3.796875
4
class A: def __init__(self, a): self.a = a def getA(self): return self.a def display(self): return "A:{0}\n".format(self.a) class B(A): def __init__(self, a, b): super(B, self).__init__(a) self.b = b def getB(self): return self.b def display(...
16ccca18cf7f0baf9102f2986e11265d89eb899a
JungChaeMoon/Algorithm
/single_number.py
279
3.640625
4
def single_number(nums): dup_dict = {} for num in nums: if num not in dup_dict: dup_dict[num] = 1 else: dup_dict[num] += 1 for key, value in dup_dict. if value == 1: return key print(single_number([2,2,1]))
404eb31c5d5825de5a20c694576f292d67484991
pontusahlqvist/algorithmsAndDataStructures
/lecture3/python/binarySearch.py
433
3.859375
4
def binarySearch(A,key): n = len(A) if n == 1 and A[0] == key: return 0 elif n == 1: return None if A[n/2] == key: return n/2 elif key > A[n/2]: posInSubArray = binarySearch(A[n/2:], key) if not posInSubArray: return None else: return n/2 + posInSubarray else: return binarySearch(A[:n/2], ke...
bf12562582fc79a90ca62982c4722588fed45ea3
LinkleYping/BlockImage_System
/BImgAssist/getkey.py
581
3.546875
4
from random import Random def random_str(randomlength): str = '' chars = 'abcdef0123456789' length = len(chars) - 1 random = Random() for i in range(randomlength): str += chars[random.randint(0, length)] return str def varserification(): str = '' chars = 'qwertyuiopasdfghjklzx...
2b38262cb4ce0f8eba24636e1224d34850d79f60
almehj/project-euler
/old/problem0078/partitions.py
798
3.5625
4
#!/usr/bin/env python def max_in_table(table): answer = -1 for row in table: for n in row: if n > answer: answer = n return answer def print_table(table): m = max_in_table(table) width = len(str(m)) fmt_str = "%%%dd"%width i = 1 for ro...
570211ba2d75ba42dea06ba488053d1cf998b4bb
Gautham-code/normaldistribution
/normal.py
2,336
3.671875
4
import statistics import pandas as pd import csv df = pd.read_csv("StudentsPerformance.csv") male_list = df["reading score"].tolist() female_list = df["writing score"].tolist() male_mean = statistics.mean(male_list) female_mean = statistics.mean(female_list) male_median = statistics.median(male_list) female_median...
ac8b2b38b04f34d8aab9f35e553ab80dc396acd1
bryanlie/Python
/HackerRank/printString.py
267
3.921875
4
''' Read an integer N. Without using any string methods, try to print the following: 12...N ''' def gen(n): if n == 1: return '1' else: return (gen(n-1) + str(n)) if __name__ == '__main__': n = int(input()) print(gen(n))
51f43080a876765ae956726b9db6457f3a40ed84
yqin47/leecode
/79.searchword.py
321
3.953125
4
"""Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. """ class Solution: def exist(self,board, word): ...
4a25ad2d037044b8f1c16cab805cff13de82a080
cfspoway/python101
/Homework13/Homework13_Palindrome..py
291
3.875
4
s = input('Please input any thing here: ') l = len(s) mid = int((l-1)/2) palindrome = True; for i in range(mid): if s[i] != s[len(s)-1-i]: palindrome = False; break; if palindrome: print(s + ' is palindrome') else: print(s + ' is not palindrome')
8c940fff629593bbee2f120d8c7255b3089360ad
gsaisudheer/ML-Univ-of-Washington
/3_Classification/BinaryDecisionTree.py
9,771
4.03125
4
''' Created on 08-Apr-2017 Programming Assignment 2 of Week 3 from the Classification course of Coursera Machine Learning Specialization @author: sudheer ''' import pandas as pd import numpy as np def identify_categorical_variables(data): categorical = [] for feat_name, feat_type in zip(data.columns, data.dt...
e6d98cf5ebd858dcd54102445ee0de92664d9d3a
fahaddd-git/bachRandomizer
/main.py
1,567
3.703125
4
import random import time suite_data = {1: "Suite No. 1 in G major, BWV 1007", 2: "Suite No. 2 in D minor, BWV 1008", 3: "Suite No. 3 in C major, BWV 1009", 4: "Suite No. 4 in E♭ major, BWV 1010", 5: "Suite No. 5 in C minor, BWV 1011", 6: "Suite No. 6 in D major, BWV 1012"} m...
d300c8d916450a363fef461dff13acc914dc73dc
MuhammedAkinci/pythonEgitimi
/python101/08.08.19/untitled7.py
622
3.5625
4
dizi = [5,6,1,7,10,3,14] print(dizi) dizi.append(10) print(dizi) dizi.append(5) print(dizi) dizi.insert(3,5) print(dizi) dizi.insert(len(dizi), 16) print(dizi) print(dizi.index(3)) index = 10 count = 0 for i in range(len(dizi)): if dizi[i] == index: count += 1 break if count == 0: print("elem...
51cd37aeecbc486ddc965af29a5dcd7ac839e46c
subbuinti/python_practice
/numberpyramid.py
260
3.71875
4
n = int(input()) for i in range(1, n+1): spaces = " "*(n - i) left_nums = "" right_nums = "" for j in range(1, i+1): left_nums = str(j) + left_nums right_nums = right_nums + str(j) print(spaces + left_nums + right_nums[1:])
01fa0a6a4d32a12141511a0c27784f5952e75445
rheehot/Algorithm-coding_test
/괄호 짝 확인.py
565
3.640625
4
from stack import Stack # def solution(str1): # s = Stack() # result = True # index = 0 # while index < len(str1) and result: # symbol = str1[index] # if symbol == "(": # s.push(symbol) # else: # if s.isEmpty(): # result = False # ...
7a960b6a6e335ba8cf87c361070c0e31814046c7
Eacruzr/python-code
/clase 5/autos.py
1,355
3.5625
4
autos = {'autos':{ 1:{'marca':'Tesla', 'modelos':{ 1:'Model S', 2:'Model E', 3:'Model X', 4:'Model Y', } }, 2:{'marca':'Toyota', 'modelos':{ 1:'Fortuner', 2:'Prado', ...
a1361de4d247ed066ce1cfae65cf778a79f94fa7
aryan152345/Python-Spinbox-program
/Spinbox_1.py
477
3.5
4
from tkinter import * mywindow = Tk( ) mywindow.title("COLOUR") rd=Label(text="Red",font="chiller 24",fg="red") rd.grid(row=0,column=0) gr=Label(text="Green",font="chiller 24",fg="green") gr.grid(row=0,column=1) blu=Label(text="Blue",font="chiller 24",fg="blue") blu.grid(row=0,column=2) rd1=Spinbox(from_=0,to=225)...
e0a950b5258c400925d521b42f72a8316979061e
hrandonbong/graph-algorithm
/d_graph.py
10,697
4.03125
4
# Course: CS261 - Data Structures # Author: Brandon Hong # Date: 6/10/21 # Description: A directed graph that utilizes DFS, BFS, and Dijkstra's algorithm to compute graph inputs # and desired outputs. Can be used to find shortest paths to certain problems. import heapq class DirectedGraph: """ Clas...
42d65aec11891ced490bb4f982504103b75b2d58
jlcatonjr/Learn-Python-for-Stats-and-Econ
/In Class Projects/In Class Examples Fall 2019/Section 1/concatenateStrings2.py
389
3.609375
4
#concatenateStrings2.py line1 = "Today we learned things we did not" line2 = "know, and surprised we were and thought" line3 = "Python may not be easy, but its not that hard" line4 = "Learn more I will, and be a Pythonista(r)" # concatenate the above strings while passing to print() print(line1, line2, line3, line4, se...
fb770d5c72587c0665bc0d61be3869da009a6498
wangyannhao/final-stock-market-website
/stock/linear_regression.py
4,547
3.578125
4
from numpy import * import numpy import math # // written by: Yanhao Wang # // assisted by: Xin Zhang # // debugged by: # // etc. alpha = 0.005 beta = 11.1 fileName = {1: 'Square.csv', 2: 'Twitter.csv', 3: 'Facebook.csv', 4: 'Amazon.csv', 5: 'Alphabet.csv', ...
db9ee7dd4555be573c84fb18d2633c6c8c6ea9df
jjh9000507/pythonStudy
/int_convert.py
192
3.703125
4
string_a = input("입력A> ") int_a = int(string_a) string_b = input("입력B> ") int_b = int(string_b) print("문자열 치료:", string_a + string_b) print("숫자 치료:", int_a + int_b)
0e531209c465dbf528a76e786ab75f9a1e3654c0
alexpereiramaranhao/guppe
/lambdas-funcoes-integradas/reduce.py
768
4.3125
4
""" Já foi uma função integrada, mas a partir do Python3, reduce deixou de ser função integrada (built-in). Agora temos que importar o módulo "functools". Utilize a função reduce se realmente precisa delas. 99% das vezes um loop for é mais legível Funcionamento: Na lista, pega o primeiro e o segundo valor, manda para...
fb4e313c4b7dcfdaced531de36d921cd34980cfd
Nasnini/String_Calculator
/tests/test_calculator.py
1,363
3.703125
4
from string_calculator.calculator import add #import pytest # Testing invalid inputs # def test_invalid_input(): # assert add(string) == "invalid input" # Testing id add function is 0 def test_add_empty_str(): assert add("") == 0 # Testing that the add function has one value def test_add_one_integer(): ...
a3e506b82863e83a46712428d2f4df0ca23bfaba
jimmcgaw/CodeEval
/repeatedsubstring.py
2,213
3.796875
4
#!/usr/bin/python import string import sys import re # check that a filename argument was provided, otherwise if len(sys.argv) < 2: raise Exception("Filename must be first argument provided") filename = sys.argv[1] lines = [] # open file in read mode, assuming file is in same directory as script try: file = ...
8d92dcacb8f8db152b2f064ba2f1905424938dff
jzsun/Python
/dict.py
848
3.859375
4
#-*-coding:utf-8-*- print "python里的字典相当于C++里的Map,使用键值对存储" print "{"":"", "":""}","字典花括号为边界,key-value以:分隔,key-avl值遵循python的语法规则" #输出顺序随机 d = {"zhao":18, "qian":17, "sun":20} print d d["zhao"] = 28 print d d["sun"] = 25 d["sun"] = 26 #覆盖上一次的赋值 print d print "print d[\"li\"]", "#key不存在报错" #检测key值是否存在的方法 #方法1,in pr...
507d22523309ea30f8058dfa40ff6e60d7e2a936
natfontanesi/30_dias_de_codigo
/Dia23-desafios/wx_81.py
386
3.59375
4
from random import randint from time import sleep from operator import itemgetter jogo = {"jogador1": randint(1,6), "jogador2": randint(1,6),"jogador3": randint(1,6),"jogador4": randint(1,6)} print("Valores sorteados:") for k, v in jogo.items(): print(f"{k} tirou {v} no dado") sleep(1) ranking={} ranking = s...
3ef96e598d15a995be1156756f514e8023c3fe21
tahsinalamin/codesignal_problems
/my_solutions/43_isBeautifulString.py
687
3.546875
4
def isBeautifulString(inputString): d={} s="abcdefghijklmnopqrstuvwxyz" s=list(s) print(s) for i in range(len(inputString)): if inputString[i] in d: d[inputString[i]]+=1 else: d[inputString[i]]=1 dic = d.items() dic=sorted(dic) p...
24963b434eff3636ca9ef479cbdf1b8c10359568
IanC162/project-euler
/057 sqrtconverge.py
292
3.625
4
#Problem: compute the number of iterations of continued frac. of root 2 # whose numerator has more digits than its denominator n, d, count = 2, 3, 0 for k in range(1000): if len(str(n)) > len(str(d)): count += 1 last = n n += 2*d d += last print count raw_input()
919aa44b7fb7a8639875ee66b629bf898db3e7df
Winte/Python_misc_algorithms
/range_sum_BST.py
1,129
3.84375
4
""" Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values. Ex: Input: root = [10,5,15,3,7,13,18,1,null,6], L = 6, R = 10 Output: 23 """ # Definition for a binary tree node. # class TreeNode:...
522e56e1b3299c1d267992d94f8ad382c612050a
goodwin64/pyLabs-2013-14
/1 семестр/lab 5/5lab_04var_Donchenko.py
259
3.765625
4
# 4) Написати програму виведення всіх чисел # від 1 до N, які закінчуються цифрою 3. N=input('Введіть число N: ') for i in range (1, int(N)+1): if str(i)[-1]=='3': print (i)
051921ef34b8d0f7a12600e33a0990b638af3894
valeriacavalcanti/IP-2019.1
/Lista 01/lista_01_questao_07.py
183
3.734375
4
n1 = float(input("Informe a primeira nota: ")) n2 = float(input("Informe a segunda nota: ")) media_ponderada = ((n1 * 6) + (n2 * 4)) / 10 print("Média ponderada =", media_ponderada)
e63a107deaa34a2b5a4bb3118514a3b60e1a11a0
ZhenJie-Zhang/Python
/workspace/m2_type/casting.py
184
3.859375
4
x = 3.8 print(x) x = int(3.8) print(x) # x= '123' + 456 # print(x) x= '123' + '456' print(x) x= int('123') + 456 print(x) x= '123' + str(456) print(x) # x= int('a123') # print(x)
eab002799de73fcc0d0014e22d82acdf2a1243ab
Mishal-Mansha/Task
/question4sol.py
150
4.125
4
alphabet=input("Enter an alphabet") list={'a','e','i','o','u'} if alphabet in list: print("It is a vowel") else: print("It is a consonant")
9806187bce8ff6e7cb7e5c6d8ba00c600a67da2a
almirgon/LabP1
/Unidade-1/ponderada.py
335
3.546875
4
#coding: utf-8 #@Crispiniano #Unidade 1: Média Mágica nota1 = float(raw_input()) nota2 = float(raw_input()) nota3 = float(raw_input()) peso1 = float(raw_input()) peso2 = float(raw_input()) peso3 = 100 - (peso1+peso2) media = (nota1*(peso1/100) + nota2*(peso2/100) + nota3*(peso3/100)) print "Média Final: {:.1f}".fo...
65ba7aa91008eba1160be5f8d2299e1531fc749b
haorenxwx/python_note
/leetcode22parentheses.py
1,048
3.703125
4
#leetcode22parentheses.py '''def ParenGe(l,r,item, res): if r < 1: return if r == 0 and l == 0: res.append(item) print("for every item append:\n") print(res) if l > 0: print("for every left modify:\n") print(item) ParenGe(l-1, r, item+'(', res) if r > 0: print("for every right modify\n") print(i...
e71c9c1bbd1d1c2e0a002912019453d5b6e6b58a
Baistan/FirstProject
/list_method_tasks/Задача20.py
143
3.65625
4
s = input() if len(s) == 11 and s[0:2] == "+7": print(s) elif len(s) == 10: print("+7" + s[1:]) elif len(s) == 9: print("+7" + s)
09a6475ac8d16fc204e50785c3058bb38661f192
mohammadgoli/sql
/up&del.py
384
3.640625
4
#!/usr/bin/python import sqlite3 with sqlite3.connect('thetable.db') as db: crs = db.cursor() crs.execute("UPDATE population SET population = 9000000 WHERE city = 'New York City'") print "\nNEW DATA:\n" crs.execute("DELETE FROM population WHERE city = 'Boston'") crs.execute("SELECT * FROM population") rows = ...
0016393f414b11be95109d8f4c91a3777c46dabb
dpezzin/dpezzin.github.io
/test/Python/dataquest/enumeration_catching_errors/replace_loop.py
444
4.03125
4
#!/usr/bin/env python # We can replace values in a list with a for loop. # All of the 0 values in the first column here will be replaced with a 5. lolists = [[0,5,10], [5,20,30], [0,70,80]] for row in lolists: if row[0] == 0: row[0] = 5 # We can see the new list. print(lolists) # Loop through the rows in...
00156efaca26c75b2cc092442b9302b0449cde35
Halverson-Jason/cs241
/asteroids/velocity.py
633
3.515625
4
class Velocity: def __init__(self,dx=0.0,dy=0.0): self.velocity_dx = dx self.velocity_dy = dx def copy(self): return Velocity(self.dx,self.dy) @property def dx(self): return self.velocity_dx @dx.setter def dx(self,dx): self.velocity_dx = dx @property ...
67a86fd78c8e834753182e5aef6acf2d9f4ec202
python4eg/Python-test-repo-phase-1
/lesson10_2.py
2,673
3.796875
4
import json class Person: name = None city = None def __init__(self, name, city): Person.name = name Person.city = city person1 = Person('name', 'city') print('Person 1 name: ' + person1.name) person2 = Person('name2', 'city2') print('Person 1 name: ' + person1.name) print('Person 2 name:...
d43c4b3d9485366a4fb8f2a96ee1c1be5346fb26
Viraculous/python
/Recycle and Earn.py
2,830
4.1875
4
#Excercise 1: '''In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one particular jurisdiction, drink containers holding one liter or less have a $0.10 deposit, and drink containers holding more than one liter have a $0.25 deposit. Write a program that reads the...
9359ea6801cbc89c36f0e97c9f7da6357039076b
bperard/PDX-Code-Guild
/python/lab16-pick6.py
1,636
3.875
4
''' lab 16: pick 6 ''' import random # create ticket with definable range parameters def pick_six (low, high): pix = [] i = 0 while i < 6: check = random.randint(low, high) # prevent repeated choices on same ticket while check in pix: check = random.randint(low, high) ...
9d68a1b2394ec1989e454c6caa16045b4df3734e
michaelvitello/python-exercises
/exercise-5.py
981
3.9375
4
#Password verification method # Conditions: # Password OK if : # 1+ cap letter # 1+ lowercase letter # 1 number between 0-9 # 1 spec carac between $ & or @ # length min: 6 carac # Length max: 12 carac import re password = raw_input("Choose a password / Choisir un mo...
f5208676c40fb7812706ff9f0d9a870039c236ed
liaowen9527/multi_tech
/python/zero_learn/6-for_while.py
2,745
4.125
4
#本章节讲得是循环语句 #每件事,我们不可能只做一次,重复做的事,我们可以通过for循环简单实现 #在前面的章节中,我们已经预先学些了一些简单的循环用法 #本章节中会讲解一些更高级的用法,使代码更简洁,好看 #跳出循环 #我们不希望一件事一直运行下去,在必要的时候应该退出循环 def break_loop(): print("告诉你一个秘密哟: 输入exit可以退出循环") #while(True)表达的是一个死循环,死循环的意思就是无限循环 while(True): a = input("随便输入吧,反正我是死循环,嘿嘿\n") if a == ...
eea08c9a582099e2b72e40307bdfa8d946e283e8
atozzini/CursoPythonPentest
/PycharmProjects/ExerciciosGrupo/exercicio113.py
236
3.90625
4
texto = raw_input('Digite qualquer coisa: ') print(str(texto)) # o input pega o valor que e digitado na tela, no codigo pegamos este valor # e atribuimos a uma variavel # o raw_input() e por causa da versao do python que estou usando
6919ad6e10f24adaeb31f6a205d65555826057ff
LYZhelloworld/Leetcode
/keyboard-row/solution.py
464
3.953125
4
class Solution: def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ res = [] row1 = 'qwertyuiopQWERTYUIOP' row2 = 'asdfghjklASDFGHJKL' row3 = 'zxcvbnmZXCVBNM' for word in words: if all([c in row1 fo...
ebabbfb989ce5fadcf5e47dedb6c141f2fe751ed
somphorsngoun/pyhon-_week_17
/Week_17/test.py
359
3.921875
4
def sum(array): sum = 0 for n in array: sum += n return sum def createNewArray(array, value): return array.append(value) def getAvg(array): return int(sum(array) / len(array)) numbers = [10, 5, 7, 8, 6] evenList = [] for n in numbers: if n%2 != 1: createNewArra...
d0d35976135dba7a1acd087dd2c8dd068e2c7e76
Ahsanhabib1080/CodeForces
/problems/A/PensAndPencils.py
802
3.5625
4
__author__ = 'Devesh Bajpai' ''' https://codeforces.com/problemset/problem/1244/A Solution: If we have to take m notes and one stationary item can write n notes, the no. of those stationary items needed is ceil(m/n) = (m + n - 1) / n. This way we calculate the minimum pens and pencils needed. If their sum is <= k, we...
aaafe7a4ae484ae125ed2c0d15f17e0ff18b166b
deepanshu102/python
/ass3.9.py
190
3.90625
4
def count(num): i=int(0) print(num); while(num>0): num=num/10; i=i+int(1); return i; a=int(input("Enter the number")); print("Number of the digit",count(a));
9b9555711299362fd159cd81e8bc285ee0fb2aa4
pierri/ud120-projects
/datasets_questions/explore_enron_data.py
4,034
3.859375
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ Starter code for exploring the Enron dataset (emails + finances); loads up the dataset (pickled dict of dicts). The dataset has the form: enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict } {features_dict} is a dictionary of features a...
ebf9119ed1aa0de3ef2cf4b7573fe3250773a5a0
bukatja567/LP
/examle2.py
390
3.9375
4
#if-elif-else """ company = input("Введите слово: ") if "my" and "google" in company: print("Условие выполнено!") elif "google" in company: print("Он нашел google") elif "my" in company: print("Есть не все") else: print("Неа, не пущу!") """ a=3 b=8 sum = 0 i=3 while i != 1: sum = sum + a + b i ...
0c6d5a16e30be92e3956bfbec2efcb9a17afbb5e
tanaypatil/code-blooded-ninjas
/dynamic_programming_1/angry_children.py
1,482
3.953125
4
""" Angry Children Send Feedback Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has N packets of candies and would like to distribute one packet to each of the K children in the village (each packet may contain different number of candies). To avoid a fight between the children, he would ...
81a74fb841052b705a4f60c85cc7c9b8b4ac45a3
Divisekara/Python-Codes-First-sem
/other/Prime Number checking More Efficiency.py
298
3.96875
4
while True: n=int(raw_input("Give a number ")) is_prime = True for i in range(2,int(n**0.5)+1): if n%i==0: is_prime=False print 'not a prime' break if is_prime==True: print n ,'is a prime'
a96394b510716fbafe4611c12719507e5145be2a
joyonto51/Basic-Algorithm
/check_prime_number.py
218
4
4
n = int(input()) flag = 1 i = 2 while(i<(n/2)): if n%i == 0: flag = 0 break i+=1 if flag==0: print("{} is not a prime number".format(n)) else: print("{} is a prime number".format(n))
9756fe6fd6eca8f9615b71d5e31ca04acad08018
imhari4real/Python-Programming-lab
/CO1/CO1-Q15.py
197
3.53125
4
colorlist1=set(['orange','green','blue','violet','pink','white']) print(colorlist1) colorlist2=set(['white','blue','violet']) print(colorlist2) a=(colorlist1.difference(colorlist2)) print(a)
7e35c3595968329f0cdf5077c5e02216c76fd2d9
awarnes/projects
/card_games/deck_mechanics.py
3,164
4.59375
5
""" This is a method to build a deck of cards for a card game. Using the standard 52 card deck with two optional jokers, calling this method will build a randomized list with the card name (K, Q, 3), the value (10, 10, 3), and the suit (H, D, S, C). This method will be used for other card games between human and comp...
c60937a9cf6f918a91df269780bdae402dfdbcf8
isaacdias/curso-logica-testes-devfuria
/nivel-06-strings/contar_vogais.py
241
3.53125
4
# coding: utf-8 s = 'python' vogais = 'aeiou' # # retorna quantidade de vogais # def quant_vogais(s): cont = 0 for i in s: if i in vogais: cont += 1 return cont # # testes # assert 1 == quant_vogais(s)
bb9ed6cc871d729d6a22e58724095ac4a0c30e7b
buksi91/harness_sudoku
/sudoku_m.py
2,207
3.578125
4
#!/usr/bin/env python3 import os from termcolor import colored player_moves_list = [] def input_check(input): if input.isdigit(): for x in range(len(input)): if input[x] == "0": return True if len(input) != 3: return True elif int(input) >= 111 an...
90ef075e4942b7cc0c08ea9c5a967a5a8a6cd170
wuqiangroy/LeetCodeSolution
/PowerOfFour.py
516
4.40625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ """ Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without loops/recursion? """ def power_of_four(num): if num <...
98071112e537607f01bf58969c36034a3be2e2b0
mashaprostotak/get_ripo
/dz1.py
2,025
3.5625
4
__author__ = 'Ваши Ф.И.О.' # Задача-1: Дано произвольное целое число (число заранее неизвестно). # Вывести поочередно цифры исходного числа (порядок вывода цифр неважен). # Подсказки: # * постарайтесь решить задачу с применением арифметики и цикла while; # * при желании решите задачу с применением цикла for. # код пи...
a3bb2c3d61aa8a779a9e8f72d70b73f82b7b19d2
mominrazashahid/HTRS
/src/hand.py
1,624
3.71875
4
# Example Python Program for contrast stretching from PIL import Image # Method to process the red band of the image def normalizeRed(intensity): iI = intensity minI = 86 maxI = 230 minO = 0 maxO = 255 iO = (iI - minI) * (((maxO - minO) / (maxI - minI)) + minO) return iO # Method...
f0c1eb645da9b68f3f8c64edc4ec645518c2d78e
parkjihwanjay/session5
/assignment_answers/problem6.py
412
4.0625
4
print('문제 2. 영어 이름 받기') print('choi juwon 을 입력 받으면,') print('first name : Choi, last name: Juwon 이 출력되게 만들기') # full_name = input() # name_list = full_name.split(' ') # first_capital = name_list[0][0].upper() # second_capital = name_list[1][0].upper() # print(first_capital + name_list[0][1:], second_capital + name_l...
0c577bfa7402bbd1cf39d2849a7a14b86ee7fe0b
dangiotto/Python
/pythonteste/desafio79.py
609
4.09375
4
num = list() while True: num.append(int(input('Digite um valor : '))) #poderia receber o valor em um variável simpler if num.count(num[len(num)-1]) != 2: # verificar se está na lista print('Valor adicionado com sucesso...') # if n not in num: para add ou não else: num.pop() ...
8d322a3a7d2658292ce214204c93240af31ee112
ragzilla/acnh-shotgunsim
/field.py
2,735
3.609375
4
#! /usr/bin/python3 from itertools import product from numpy.random import shuffle from sys import exit class Field: name = None layout = None matrix = None def __init__(self, name, configuration): self.name = name self.layout = configuration self.x = len(self.layout[0]) self.y = len(self.l...
8bb7f78b1aa02fb3fd0fb45e7634b7801124e9a4
SooYong-Jeong/Python_Quiz
/Day 2/Quiz 2-1.py
156
3.84375
4
Email = input("이메일을 입력하세요.\n") if Email[Email.index('@'):] == "@co.kr": print("domain is co.kr.") else : print("domain is not co.kr")
92d6e54c2534efc5669bccc63f53b2d5dd78ec9c
syurskyi/Python_Topics
/125_algorithms/_examples/_algorithms_challenges/leetcode/leetCode/DepthFirstSearch/306_AdditiveNumber.py
2,012
3.640625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # @Author: xuezaigds@gmail.com class Solution(object): # According to: # https://leetcode.com/discuss/70089/python-solution # The key point is choose first two number then recursively check. # DFS: recursice implement. def isAdditiveNumber(self, num):...
814fc1e147c52d2263f4f2c6b9d7c71b8599a21f
eriickluu/curso-de-introduccion-a-la-programacion
/3-El Comienzo/casting.py
270
3.84375
4
print("Ingresa el primer valor:") numero1 = int(input()) print("Ingresa el segundo valor:") numero2 = int(input()) suma = numero1 + numero2 resta = numero1 - numero2 multiplicacion = numero1 * numero2 division = numero1 / numero2 print("El resultado es:" + str(suma))
a1047a82339bb11a6452b19e22ecfeaa8fd29754
pamelot/calculator-2-practice
/calculator.py
1,943
4.34375
4
""" calculator.py Using our arithmetic.py file from Exercise02, create the calculator program yourself in this file. """ from arithmetic import * def main(): # This is where the user can input the calculation. # This will be a series of if statements for determining which function to call. cond = T...
5a18f6aab5cab399793567accb11ba72858a6d32
Acrelion/various-files
/Python Files/se31.py
271
3.796875
4
a1 = raw_input("Number? ") b2 = raw_input("Number? ") a = int(a1) b = int(b2) if a != b: a += 1 print "a is now %d" % a else: if (a and b) == 2: print "They are now two." else: print "I dont care. a and b are = %d and %d now " % (a, b)
f6d38a206f67aeb05d462dcf49a34140c19ba315
nugroha/BeadTeam15
/ml_modeling.py
850
3.6875
4
# -*- coding: utf-8 -*- """ This program retrieve data from hdfs and perform prediction on the probability of the "Risk of heart diseases" using OLS Regression. @author: ongby """ import pandas as pd import numpy as np import statsmodels.api as sm import sklearn #========================= # Main #====...
246be275398511e273951e708aa135c3ed526c1e
AidenLong/ai
/python-study/base/datatype/01-list.py
2,131
3.828125
4
#_*_ conding:utf-8 _*_ ''' 访问列表 ''' # list01 = ['jack','jane','joe','black'] # print(list01[2]) #通过下标 # list01 = ['jack','jane',['leonaldo','joe'],'black'] # l = list01[2] # print(list01[2][0]) # print(list01[2][0]) # list01 = ['jack','jane',['leonaldo','joe'],'black'] # list01[0] = 'lili' #通过下标获取到元素,并且给其赋新的值 #...
5b5cd489a23edc5c6cac1f1b7b684ecd73d4b030
agentnova/LuminarPython
/Luminaarpython/Functionalpgms/intro.py
462
4
4
#reduce code # lambda # map # filter # listcomprehen #reduce # lambda functions also called anonymous function # f=lambda num1,num2 :num1*num2 # print(f(9,67)) # map-used in where all objects need an alteration #filter-used in where only some objects have to be altered def square(num): return num*num lst=[1,2,3...
57d6eaa8fd6aa8aa1576e35957a4f4e44771f04a
ystop/algorithms
/sword/滑动窗口的最大值.py
1,175
3.78125
4
# -*- coding:utf-8 -*- # 给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3, # 那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; # 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: # {[2,3,4],2,6,2,5,1}, {2,[3,4,2],6,2,5,1}, {2,3,[4,2,6],2,5,1}, {2,3,4,[2,6,2],5,1}, # {2,3,4,2,[6,2,5],1}, {2,3,4,2,6,[2,5,1]}。 # 双端队列,存下标。 遍历num,每次都...
3e2740a668cadf9f03841db92f40dae55c31c568
MichaelSchwar3/LeetCode
/swapnodespairs.py
726
3.828125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def swapPairs(self, head: ListNode) -> ListNode: if head is None or head.next is None: return head newHead = head.next currentNo...
c5e720339d00b998a7c3ab7f8d067f1af91c5d9f
eriamavro/python-recipe-src
/src/062/recipe_062_01.py
66
3.5625
4
list1 = [1, 2, 3] list2 = [val * 2 for val in list1] print(list2)
49efbe7d47924c4bbded0bb985c4dce613592490
pravencraft/engr3703_2_sums_and_products
/old/python_intro_7.py
7,443
4.3125
4
# This is a comment # The following is the import section # This brings in other python files that have pre-defined functions in them # This will be present in every single program you write from math import * import numpy as np from tabulate import tabulate # The following area is a sort of "global" area this code ...
3d63f0745f1bc3e95f9834c0d672954f9453b8e5
wikisity/TestSelf
/step3.py
1,673
4.15625
4
#-----------> STEP3 CODE2040 CHALLENGE # Description: This python code is a solution to the problem of 'Needle in a haystack' # The code obtain a dictionary of two values and keys from an API. One # value of key 'needle' is a string and the other value of key 'haystack' # is an ...
9c79a406fc1eab118de77eae81db48c2227dd84a
Caccer1/Python-Challenge-FINAL
/Python-Challenge/PyBank/main.py/PyBankJC.py
2,602
3.671875
4
import os import csv csvpath = os.path.join('..', 'Resources', 'budget_data.csv') #list total_months = [] total_profit = [] monthly_profit_change = [] #variables #month_count = 0 #total_profit = 0 #average_change = 0 with open(csvpath, newline='', encoding="utf-8") as csvfile: csvreader = csv....
c843d7c55a95e6cfa8cb373e35ba3325f09f82e3
Jai-Prakash-Singh/avg_word_length
/ave_word_length.py
1,022
4.09375
4
#!/usr/bin/env python import sys def ave_word_length(filename): try: f = open(filename) contents = f.read() lst_content = contents.split() set_content = list(set(lst_content)) length = 0 for el in set_content: num = lst_content.count(el) length += num*len(el) avg_w_length = int(len...
e48567e5a658b03f3e37b1959429a2d19688a5e1
gigennari/mc102
/tarefa14/menor_ausente.py
999
4.1875
4
""" Dada uma seuquência ordenada (crescente) de números, o programa encontra o menor elemento ausente dessa sequência Entrada: uma sequência ordenada de números separados por espaço 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 Saída: o menor número ausente da seuência 12 Caso básico: numero atual é diferente do numero ...
8fd7d1f6bea0317a2db553ed35e6128e38cdfdc6
jpages/twopy
/unit_tests/arithmetic/fact.py
178
3.65625
4
def fact(n): if n<2: return 1 else: return n*fact(n-1) print(fact(5)) print(fact(1)) print(fact(20)) print(fact(-10)) #120 #1 #2432902008176640000 #1
7d8c53dde1c54ca0816bc14390aee9a16d5ec7fa
HeraldoAlmeida/EEL891
/src/MBTI_2020/03_Classificar_Digits_KNN.py
5,360
3.625
4
#============================================================================== # Carga e Visualizacao do Conjunto de Dados IRIS (problema de classificacao) #============================================================================== #------------------------------------------------------------------------------ #...