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
81f61a0ba4f17cf20e443f759802fee974603019
haojian/python_learning
/53. maximumSubarray.py
342
3.890625
4
''' Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the largest sum = 6. ''' class Solution: # @param {integer[]} nums # @return {integer} def maxSubArray(s...
966c3fca1b3816ebd7773064d9762af72523708d
perovsk1te/python_practice
/Python_Lesson/class.py
4,647
4
4
""" objectはいらないがコードスタイル的に書いたほうがいい コンストラクタ:__init__で初期化、インスタンスが出来た瞬間に実行される デストラクタ:__del__, インスタンスがなくなるとき呼び出される クラス全体で使いたい変数はself.paramとしてオブジェクト変数にする クラス変数はすべてのオブジェクトで共有される """ class Person(object): def __init__(self, name): self.name = name print(self.name) def say_something(self): pri...
3358e4bebcd5a66359c2ce219684bddb6a191b76
zhsomin/BP
/aa.py
4,700
3.65625
4
import tensorflow as tf import cv2 import numpy as np # 导入MNIST 数据集,不能直接下载的就先去官网下好,然后拖到工程目录下自己读取 from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("input_data/", one_hot=True) # 神经网络参数 num_input = 784 # mnist数据集里面的图片是28*28所以输入为784 n_hidden_1 = 256 # 隐藏层神经元 n_hidden_2 = 25...
5ad33c1e5167a998560bcbdfd1d8a6abc701ed85
DenysSmyk/Python_Core
/lesson_11.py
3,326
3.65625
4
# 1. Спробуйте переписати наступний код через map. # Він приймає список реальних імен і замінює їх хеш-прізвищами, # використовуючи більш надійний метод-хешування. # names = ['Sam', 'Don', 'Daniel'] # for i in range(len(names)): # names[i] = hash(names[i]) # print(names) # names = ['Sam', 'Don', 'Daniel'] # has...
7e04cb02050bfe656aa3ea63b58aedb4400ffe56
DenysSmyk/Python_Core
/Basic subclasses - Adam and Eve.py
267
3.5625
4
def God(): return [ Man("Adam"), Woman("Eva") ] class Human(): def __init__( self, name ): self.name = name class Man(Human): def __init__( self, name ): self.name = name class Woman(Human): def __init__( self, name ): self.name = name
df20a66e9177f876f4407b90860596bb7efaf413
DenysSmyk/Python_Core
/lesson_4.py
3,870
3.8125
4
#1. Роздрукувати всі парні числа менші 100 # (написати два варіанти коду: один використовуючи цикл while, # а інший з використанням циклу for). # for i in range(1,100): # if i%2==0: # print(i) # i=2 # while i < 100: # print(i) # i+=2 # print(list(range(2,100,2))) #2. Роздрукувати всі непарні ...
cdfb5c90d89acfcc3d2583a20247d2d1a314644e
yanhongqin001/python-exercise
/ex19.py
669
3.578125
4
def cheese_and_crackers(cheese_count,boxes_of_crackers): print "You have %d cheeses!" %cheese_count print "You have %d boxes of crackers!" %boxes_of_crackers print "Man that's enough for a party!" print "Get a blanket.\n" print "We can just give the function numbles directly:" cheese_and_crackers(20,30)...
af565a02934dfc438ccb262507003bc24635f819
yanhongqin001/python-exercise
/ex16.py
679
4.0625
4
# -*- coding: utf-8 -*- from sys import argv script,filename=argv print "We're going to erase %r." %filename print "If you don't want that,hit CTRL-C(^C)." print "If you do want that,hit RETURN." raw_input("?") print "opening the file..." target=open(filename,'w') print "Truncating the file. Goodbye!" #truncate-清空文件 ta...
d6ba12bc3360f600651877f9109bdfd7db1c65ee
suheon/python-study
/7022.py
1,275
3.65625
4
# wikidocs/7022 string = 'abcdfe2a354a32a' print(string.replace('a', 'A')) string = 'abcd' string.replace('b', 'B') print(string) a = "3" b = "4" print(a + b) name1 = "김민수" age1 = 10 name2 = "이철희" age2 = 13 print("이름 : %s 나이 %d" % (name1, age1)) print("이름 : %s 나이 %d" % (name2, age2)) print("이름 : {} 나이 {}".form...
711895f2590aa58911073abb4914d25ae9320548
AyeChanKoGH/Small-code-
/DrawPyV1.py
1,686
4.46875
4
""" get screen and drawing shape with python turtle #To draw line, press "l" key and click first end point and second end point #To draw circle, press "c" key and click the center point and click the quarent point #To draw Rectangle, press "r" key and click 1st end point and second end point #To clean the screen, press...
caabee8f9fe7a3a83688350d57a52e833f5ec206
blefmont/cisc352asgn1
/alphabeta.py
5,375
3.6875
4
''' Alpha-Beta Pruning Authors: Michael Olson 20008033 : Brandon Christof 20014247 This program implements a minimax search algorithm that will determine a score for any given state of a game. The search method uses Alpha-Beta pruning to cut off any redudant searches to give a faster and more...
12aeb6f87c3dda406422152ae6508bbeed6f61cb
Maria-Sparrow/Python_vebinars
/modules/models/My_Test_by.py
1,365
4.0625
4
from abc import ABC, abstractmethod class AbstractParent(ABC): @abstractmethod def hello_friend(): raise NotImplementedError class Mother(AbstractParent): def init(self, age = 0): self.age = age print('Mother constructor!') def cook_meal(self): print("Hey, I was cooked dinner!") d...
274cedfbd8cad4d1293ebccdc015abde1a13d6d7
AnDa-creator/Algorithms_Graph_algos
/MedianCalc.py
2,592
3.546875
4
from heapq import heapify, heappop, heappush import csv import time def medianHeap(List_num): new_list = List_num[:] median = 0 heapify(new_list) if len(new_list) >= 2: # print('hi') decider = len(List_num) if decider % 2 == 0: for number in range(decid...
a2bcd1901a7e874d35263fc20ca61875c64aa07d
kimit956/MyRepo
/Code_Fixed.py
1,942
3.859375
4
def is_num(question): while True: try: x = int(input(question)) break except ValueError: print("That is not a number") continue return x class cat(): def __init__(self): self.name = input("\nWhat is your pet's name?\n") self.ty...
fa085d5bace6c4496c002a929a41548604227ebb
kimit956/MyRepo
/Simple Math.py
402
4.125
4
num1 = int(input("Enter the first number: ")) num2 = int(input("Enter the second number: ")) sum1 = num1 + num2 diff1 = num1 - num2 prod1 = num1 * num2 try: divide1 = num1 / num2 except ZeroDivisionError: num2 = int(input("Cannot divide by 0. Please enter a different number: ")) divide1 = num1 / num2 print(...
aad8fc25fc8901a2ad8c3f430aaae53ebbfe0e25
jschmidt345/FinishedChallenges
/ch3/ch3_solution.py
2,766
3.71875
4
# need a list of all outings, cost of all outings, total cost of all outings # Events : golf, bowling, amusment park, concert # Aspects : # of attendees, date, total cost per person, total cost of event # display of all the outings # add individual outings # calculations: # display combined cost of all outings # di...
dfd0a5c903718388a8522f07d5919ffaac84a66f
spd94/Marvellous_Infosystem_Assignment_2
/Assingment2_6.py
207
3.78125
4
def print_pattern_desc(n): i=n print("Output :") while(i>0): j=i while(j>0): print("*",end=" ") j-=1 print("") i-=1 print("Input :",end=" ") x=int(input()) print_pattern_desc(x)
72c900ad1d5f79614bd04a6c04b80df94c54a566
nbe519/PythonEmailClient
/email.py
3,352
4.09375
4
#Noah Eaton #Exploring Computer Science #Email Client #An email application which will take the subject, who it is to and #the time and tell the user that the email has been sent. #Import the module from tkinter import * import tkinter.messagebox from tkinter import font import datetime import webbrowser #Pull the ...
f7dec414936dd36792a3163b3e7d28c829d91013
doddthomas/tools
/print_ex.py
2,402
3.6875
4
""" Typically, a module has a description at the top giving a brief summary of its functionality and/or some examples. This is housed in a `docstring` (a block of text surrounded by three double quotation marks). Below is an example of what I would write for this script: Examples of how to print objects in Python. Th...
082482fa78f6de049b03599a88b13a895788b765
doddthomas/tools
/dog_name_list_ex.py
662
4.0625
4
#----------------------------------------------------------------------- # # dog_name_list_ex.py - a python script showing examples of dynamically # adding items to an array/list # #--------------------- module history ----------------------------- # # 12-OCT-18 : PTR XXXX, Created, Dod...
e14dde29a0ce84e90bfdef52902645337b9a1f46
proth5150/Simple_Chatty_Bot
/Problems/Leap Year/main.py
211
3.828125
4
# put your python code here year_to_check = int(input()) if year_to_check % 4 == 0 and year_to_check % 100 != 0: print("Leap") elif year_to_check % 400 == 0: print("Leap") else: print("Ordinary")
7051c6b60c42422cf8b0da06b23b36f5090ecb35
robert-kolozsi/sequence_and_prime_numbers
/sum-prime-num.py
2,987
3.9375
4
#! /usr/bin/env python # -*- conding:utf-8 -*- l = [] for i in xrange(1, 8): l.append(i) print(l) new_list = [] result_list = [] result_collection = [] #remain = [] first = None def find_all(): global result_list global result_collection #if not result_collection: # one_pass(l) #else: ...
ad0e3a2b253ccb2b869fe21dbe25ccfd0320a582
NweHlaing/Python_Learning_Udemy_Course
/Section_20_Advanced_Python_obj_datastructures/advanced_list.py
936
4.28125
4
list1 = [1,2,3] #append list1.append(4) print("list after appand..",list1) #count count = list1.count(10) count1 = list1.count(2) print("list count..",count) print("list count 1..",count1) #append and extend x = [1, 2, 3] x.append([4, 5]) print("append...",x) x = [1, 2, 3] x.extend([4, 5]) print(...
9dea0287692cf96acc769688ec728c23a97b2ab5
NweHlaing/Python_Learning_Udemy_Course
/Section_14_Advanced_Python_Modules/datetime_module.py
292
3.6875
4
import datetime t = datetime.time(4, 20, 1) today = datetime.date.today() print(today) # Let's show the different components print(t) print('hour :', t.hour) print('minute:', t.minute) print('second:', t.second) print('microsecond:', t.microsecond) print('tzinfo:', t.tzinfo)
f57866cf75f296a3b531c7b9b98defbad635b52d
FatMaus/Py-Practice
/单链表.py
4,113
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue May 26 18:07:39 2020 @author: Administrator """ # 链表节点,存储元素本身和下一个元素的信息(指针) class Node(): # 值与下一个的地址,两个属性(单链表) def __init__(self, elem, nextEle=None): self.elem = elem self.nextEle = nextEle # 链表 class LinkListNode(): # 首位头元素、末...
c20743ca806704d3cbdb98cb3bed95e4ebf7af61
DeeCoob/hello_python
/_manual/format.py
1,163
4.125
4
# форматирование строки в стиле C s – форматная строка, x 1 …x n – значения # s % x # s % (x 1 , x 2 , …, x n ) # return Python has 002 quote types. print("%(language)s has %(number)03d quote types." % {'language': "Python", "number": 2}) # '#' The value conversion will use the “alternate form” (where defined be...
dcd0873f0dbf3884fea27940dd7ca07bc9f2f902
DeeCoob/hello_python
/_starter/03_elif.py
266
4.125
4
x = float(input("Enter x: ")) if 0 < x < 10: print("Value is in range") y = x ** 2 + 2 * x - 3 if y < 0: print("y = ", y, "; y is negative") elif y > 0: print("y = ", y, "; y is positive") else: print("y = 0")
558c51cde6f1a6992bc7202b5b2cfbbd93e514f6
DeeCoob/hello_python
/_tceh_lection/05_constructors.py
688
4.28125
4
# Constructor is called when new instance is create class TestClass: def __init__(self): print('Constructor is called') print('Self is the object itself', self) print() t = TestClass() t1 = TestClass() # Constructor can have parameters class Table: def __init__(self, numbers_of_leg...
a5c80369e6ea000a2cf097a938200232583bf6e3
DeeCoob/hello_python
/_manual/compares.py
400
3.53125
4
# x < y x строго меньше y # x > y x строго больше y # x <= y x меньше или равен y # x >= y x больше или равен y # x == y x равен y # x != y x не равен y # x is y x и y – это один и тот же объект # x is not y x и y не являются одним и тем же объектом в памяти
97640a1a779bb561864b6d5db62e74cefe56b738
DeeCoob/hello_python
/_practic/starter_02_two_words.py
137
3.984375
4
while True: first = input("Enter first word: ") second = input("Enter second word: ") print(first, second, sep=', ')
d0922c3a88c57e9badfab0b28cc0294eb85eaefd
DeeCoob/hello_python
/_practic/starter_04_loop_factorial.py
405
4.3125
4
# Факториалом числа n называется число 𝑛!=1∙2∙3∙…∙𝑛. # Создайте программу, которая вычисляет факториал введённого пользователем числа. while True: n = int(input("Enter n: ")) f = 1 for i in range(n): f = f * (i + 1) print("Factorial from n is", f)
cbbd3a4dbdd491594904e19541e506860badd28a
DeeCoob/hello_python
/_tceh_home_work/02_devision_by_seven.py
226
3.78125
4
# Пройти по всем числам от 1 до 100, написать в консоль, какие из них делятся на 7, а какие - нет for i in range(1, 100): if i % 7 == 0: print(i)
2b77da4cba8b8bca5ae17bd3758edc7d1c311b1e
DeeCoob/hello_python
/_tceh_lection/05_classes.py
1,248
3.90625
4
class Car: pass c = Car() print(c, type(c)) print() # Classes can have variables called fields class Room: number = 'Room 34' floor = 4 r = Room() r1 = Room() print(r.number, r1.number) print(r.floor, r1.floor) print() # You can modify values: r.number = 12 r.floor = '5 floor' print(r.number, r1.n...
3905e28ea7425ad2b696a59df5194268f2882024
frozen-dumplings/algorithm-playground
/JUMPGAME/hyowon.py
876
3.5
4
if __name__ == "__main__": C = int(input()) for _ in range(C): n = int(input()) inputMap = [] for _ in range(n): inputMap.append(list(map(int, input().strip().split()))) reachable = [[False for i in range(n)] for i in range(n)] reachable[0][0] = Tru...
4d7086a59dd9e999d5e87259b696b583dd6cc839
ETFIRE/ippsi_python
/fonction.py
179
3.75
4
#!/usr/bin/python3 def add(a, b): """function calcul addition""" return(a+b) print(add(1, 2)) print(add(10, 20)) def add3(a, b, c=0): return(a + b + c) print(add(1, 2))
98ed462b0bf705a87a4cb2bb3a9ea5093d908f00
Sophie0829/2020-Jayden-AE401
/猜猜看.py
280
3.625
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 11 11:35:55 2020 @author: jaych """ #召喚模組 import random num=random.randint(1,10) a=input("請輸入數字:") a=int(a) if a==num: print("恭喜你猜對了!") else: print("猜錯了!")
3d2a4044d6cc8831df8a97eca32532b10882d39d
lazear/quant
/vx_sourcing.py
1,788
3.546875
4
import pandas as pd import numpy as np import requests import calendar from datetime import timedelta, date def third_wednesday(d, n): """Given a date, calculates n next third fridays https://stackoverflow.com/questions/28680896/how-can-i-get-the-3rd-friday-of-a-month-in-python/28681097""" def next_third_...
a5dd8877afd4da089e3e7932c903ca869116e040
asansyzb/courses
/CS206 Data Structures/HW5/2b.py
1,608
3.6875
4
from ADT.tree import BinaryTree from ADT.stack import Stack from ADT.queue import Queue file = open('stored.txt', 'r') listTree = file.readline().strip().split() #listTree = ['cat','apple','but','pull','line','food','me','say'] tree = BinaryTree(listTree[0]) #define the root listTree.remove(listTree[0]) def BuildT...
64d4fd7bb9e42b23ed08567a9d6ba23c5985e258
lenssen/ps1
/ps1c.py
1,079
3.90625
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 3 12:54:23 2020 @author: Lenssen """ down_payment = 0.25 * 1000000 current_savings = 0 starting_salary = int(input('Enter the starting salary: ')) low = 0 high = 10000 ans = (high + low ) // 2 steps = 0 portion_saved = 0 Answer = '' while(abs(down_payment - current_sav...
f2621a6a490cb9f85aff73a741d44f11b5b0b28e
guoyang-xie/atom3d
/atom3d/util/file.py
1,502
3.546875
4
"""File-related utilities.""" import os from pathlib import Path import subprocess def find_files(path, suffix, relative=None): """ Find all files in path with given suffix. = :param path: Directory in which to find files. :type path: Union[str, Path] :param suffix: Suffix determining file type t...
23e115c87405a9b78f7c790981205d2fcd8a9c5a
bt14/social-distancing-simulation
/button.py
2,789
3.5
4
import pygame # this file contains the Button and ButtonSet classes class Button: def __init__ (self, x, y, width, height, text, font, text_color, idle_color, hover_color, callback_funct, visible=True): self.x = x self.y = y self.width = width self.height = height self.rect = pygame.Rect(x, y, ...
5f11f06276589e88a0946d273ddceca243504c60
jxxiangwen/PythonStudy
/cn/edu/shu/design_mode/simple_factory.py
1,267
3.796875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'jxxia' """ 简单工厂模式 """ class Operation(object): def get_result(self, num1, num2): pass class AddOperation(Operation): def get_result(self, num1, num2): return num1 + num2 class SubOperation(Operation): def get_result(sel...
3baf3eff47106decb975eac235e777c39844021b
AbbadAnes/social_web_posts_to_mangodb
/modules/Database.py
1,105
3.59375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 16 14:54:20 2020 @author: Anes ABBAD @website : https://abbadanes.github.io/ """ import pymongo class Database(): def __init__(self, db_name="Jacques_chirac",client="mongodb://localhost:27017/"): mangoclient = pymongo.MongoClient(client) ...
bb9db30f7f466941ee6437f77f4ab20ac00c8e20
vikramriyer/FCS
/infix_to_postfix.py
2,075
4.09375
4
#!/usr/bin/python OUTPUT, STACK = [], [] precedence = { '+': 1, '-': 1, '*': 2, '/': 2, '^': 3 } def is_operand(char): if char.isalpha(): return True return False def check_precedence(char): ''' check top ...
a34c861f7c41768a76883e7e6f59c7149f106f36
vikramriyer/FCS
/rotate_image.py
419
4.125
4
#!/usr/bin/python init_list = [[1,2,3],[4,5,6],[7,8,9]] def rotate_matrix(matrix): '''Algo: First: take transpose of the matrix Second: interchange row 0 and row 2 ''' matrix = zip(*matrix) return swap_rows(matrix) def swap_rows(matrix): print matrix row0, row2 = matrix[0], matrix[2] matrix[0] = ro...
9f1dd55147d61f3a53dd1b6f5459dc8010962ce2
vikramriyer/FCS
/searching.py
984
4.0625
4
#!/usr/bin/python def sequential_search(alist, item): # method 1, pythonic way for i in alist: if item == i: return True # method 2, c way position = 0 found = False while position < len(alist) and not found: if alist[position] == item: found = True break position += 1 re...
30fe876edf81a871f0209661f44e6c9be25193e7
jonathanmendoza-tx/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/assignment/rpg_queries.py
3,506
3.921875
4
import sqlite3 import pandas as pd !wget https://github.com/jonathanmendoza-tx/DS-Unit-3-Sprint-2-SQL-and-Databases/blob/master/module1-introduction-to-sql/rpg_db.sqlite3?raw=true -O rpg_db.sqlite3 #create connection conn = sqlite3.connect('rpg_db.sqlite3') cur = conn.cursor() def question_one(): query_characters =...
20c5ba89af7ddd5f98b71c79e2062c2b36156bdc
Ashwin4010/MAS
/cost.py
1,620
3.6875
4
""" COST FUNCTION FOR AUTO TUNING OF PID CONTROLLER """ def sum_lists(l1,l2): """ Arguments: list1, list2 """ l = [] for i in xrange(len(l1)): l.append(l1[i]+l2[i]) return l def dot_multiply(l, k): """ Arguments: list, scalar """ l[:] = [x * k for x in l] return l ...
a192b7e4dd1b255a4fd1aebf4a0c241ec2eaeb8b
hg387/Data-Structures-Algo
/Trees/huffman.py
2,645
3.640625
4
#!/usr/bin/env python #we make the class for base tree of nodes here class tree: def __init__(self,left,right,parent): self.parent = parent self.left = left self.right = right #we make the class alphabet here class alphabet: def __init__(self,char,probability,leaf): self.char = char self.probability = pro...
7b4455500f93ec009bdbbd4874b06b0e2f24bcb7
hg387/Data-Structures-Algo
/Trees/levelorder.py
655
3.734375
4
#!/usr/bin/env python # configuring the level order using pointer tree from lcrstree import * def levelorder(tree): temp = [] count = tree.root() temp.append(count) while(len(temp) > 0): print(temp[0].label()) node = temp.pop(0) if node.left is not None: temp.append(node.left) if node.right is not N...
4382434746bdf25d60f85b498f4c2cdbd8a9d0ae
hg387/Data-Structures-Algo
/ArrayListImpl/timing.py
5,187
3.640625
4
#!/usr/bin/env python import timeit from Pointerlist import * from Arraylist import * from Arraystack import * from Pointerstack import * # Insertion head for 3 cases start = timeit.default_timer() def array(): x = [None]*500 for i in range(0,500): x.insert(i, i) stop = timeit.default_timer() print("I...
539b4b3c131c0a2fe3a8d48c4a484931e9f476da
robreinhold/goodbye
/tokenize.py
2,460
3.5
4
#!/usr/bin/python from Crypto import Random from Crypto.Cipher import AES def pad(s): return s + b"\0" * (AES.block_size - len(s) % AES.block_size) def encrypt(message, key, key_size=256): message = pad(message) iv = Random.new().read(AES.block_size) cipher = AES.new(key, AES.MODE_CBC, iv) return...
b95977ac51a4ab6b1ff10dc07315e75cd2b75a5c
IanBurgan/EulerSolutions
/Problems 31-40/Euler37.py
1,002
3.734375
4
from math import sqrt def main(): start = [2, 3, 5, 7] odds = [1, 3, 5, 7, 9] rights = [] truncs = [] # find 2 digit truncatables for i in start: for j in odds: num = (i * 10) + j if isPrime(num): rights.append(num) # find all right truncata...
136d013945afc4a687b43499c4b9b8c488677cd4
IanBurgan/EulerSolutions
/Problems 11-20/Euler12.py
368
3.71875
4
def main(): i = 2 num = 1 while factors(num) < 500: num += i i += 1 print(num) # Will not return the correct number for perfect squares as it does not # check the square root of the number. def factors(num): facs = 0 for i in range(1, int(num ** 0.5)): if num % i == 0:...
fe1843915bfb35f0f0c9d10180936414ee47856f
IanBurgan/EulerSolutions
/Problems 41-50/Euler50.py
1,654
3.671875
4
def main(): # 546 is max length. sum(first 547 primes) > 1000000. not true for 546 num = 546 extra = 0 primes = nPrimes(num) while not isPrime(sum(primes)): if sum(primes) > 1000000: extra = 0 num -= 1 extra += 1 primes = nPrimes(num + extra) ...
44be0001eb6cf6a67d74df935df74d62a0972df7
IanBurgan/EulerSolutions
/Problems 21-30/Euler21.py
479
3.6875
4
from math import sqrt def main(): total = 0 for i in range(1, 10000): other = sumfactors(i) if i == sumfactors(other): if i != other: total += i + other print(total/2) def sumfactors(x): total = 1 for i in range(2, int(sqrt(x) + 1)): # add all...
fe9c76b453494d5cf57e0c94c186345fa00a8898
IanBurgan/EulerSolutions
/Problems 11-20/Euler16.py
189
3.890625
4
def main(): # the number a = 2 ** 1000 a = str(a) # loop over its digits adding them to total total = 0 for i in a: total += int(i) print(total) main()
f94bc8bab3f94884686eddfdc5fffd59f14f79a9
IanBurgan/EulerSolutions
/Problems 31-40/Euler31.py
543
3.671875
4
def main(): target = 200 coins = [1, 2, 5, 10, 20, 50, 100, 200] # 1 way to make 0 coins at first and 0 ways to make any more than 0 ways = [1] + [0] * target for coin in coins: # starts at coin because no amount less than the coin can be changed by # using the coin. for i i...
5892e586b601e5a5bda23d15770863fcf42efa68
yanbernardo/exercicios-python-3
/Exercícios/Desafio 025.py
334
4.03125
4
ret = 's' while ret == 's' or ret == 'S': nome = str(input('Digite aqui seu nome completo:\n')).strip() nome = nome.upper() if 'SILVA' in nome: print('Você é só mais um SILVA que a estrela não brilha') else: print('Ui Ui Ui, o diferentão não é SILVA') ret = input('Deseja continuar?(S...
b981bc547cea42c8216c30b17bbe64414428dd40
yanbernardo/exercicios-python-3
/Exercícios/Desafio 032.py
217
3.84375
4
print('Calculadora de ANOS BISSEXTOS') year = int(input('Digite o ano para saber se ele é bissexto\n')) if year % 4 == 0: print('{} é BISSEXTO!'.format(year)) else: print('{} NÃO é BISSEXTO!'.format(year))
c49d6a750d724b11f6c5f9514352f38e2fec6a5c
yanbernardo/exercicios-python-3
/Exercícios/Desafio 008.py
126
3.828125
4
med = int(input('Digite o valor em metros: ')) print('O valor em metros é de {}, {}cm, {}mm'.format(med, med*100, med*1000))
ba0e3aee2104495d693e988f744a31d9e72c18dd
yanbernardo/exercicios-python-3
/Exercícios/Desafio 097.py
273
3.703125
4
def escreva(x): print('~' * (len(x) + 6)) print(f' {x} ') print('~' * (len(x) + 6)) while True: frase = str(input('Digite uma frase para o cabeçalho:\n')) escreva(frase) r = str(input('Digite N para parar: ')) if r in 'nN': break
5571e4c1487ba8809b9542253200ca0b55da9b79
yanbernardo/exercicios-python-3
/Exercícios/Desafio 009.py
310
3.8125
4
n = int(input('Digite um número para saber sua tabuada: ')) print('-'*40) print('Tabuáda de',n) print('{}x1 = {} \n{}x2 = {} \n{}x3 = {} \n{}x4 = {} \n{}x5 = {} \n{}x6 = {} \n{}x7 = {} \n{}x8 = {} \n{}x9 = {} \n{}x10 = {}'.format(n, n, n, n*2, n, n*3, n, n*4, n, n*5, n, n*6, n, n*7,n ,n*8, n, n*9, n, n*10))
9c46d81429372ca326bede6be5360ebe04988898
yanbernardo/exercicios-python-3
/Exercícios/Desafio 004.py
236
3.65625
4
def Exercicio(): r1 = input('Digite algo: ') print('É um número?') print(r1.isnumeric()) print('É um texto?') print(r1.isalpha()) print('É alfanúmerico?') print(r1.isalnum()) Exercicio() Exercicio()
7c1221999f6578c46dfabd3161ca29e070dc69b2
yanbernardo/exercicios-python-3
/Exercícios/Desafio 034.py
190
3.859375
4
sal = float(input('Qual o salário do funcionário?\nR$')) if sal > 1250: sal = sal * 1.10 else: sal = sal * 1.15 print('O salário deste funcionário será de R${:.2f}'.format(sal))
d4ce020dee9b589b29a3df86b6cc87aa5890e145
yanbernardo/exercicios-python-3
/Exercícios/Desafio 038.py
471
3.796875
4
print('\033[34m-=\033[m'* 20) print('Comparador numérico') print('\033[34m-=\033[m'* 20) n1 = float(input('Digite o primeiro número.\n')) n2 = float(input('Digite o segundo número.\n')) if n1 > n2: print('O \033[4;32mPRIMEIRO\033[m valor digitado é \033[4;35mMAIOR\033[m') elif n2 > n1: print('O \033[4;32mSEGUND...
f61dbcd9c0e46cb3552b22d80b5c147f4bde105c
yanbernardo/exercicios-python-3
/Exercícios/Desafio 031.py
242
3.75
4
km = float(input('Qual é a distância do seu destino?\n')) if km <= 200: print('O valor de sua passagem é de R${:.2f}.'.format(km * 0.5)) else: print('O valor de sua passagem é de R${:.2f}.'.format(km * 0.45)) print('Boa Viagem!!')
ec2f496ad253da7711af0148278e611de8f14e05
yanbernardo/exercicios-python-3
/Exercícios/Desafio 100.py
480
3.65625
4
from random import randint from time import sleep def sorteia(lista): print(f'Sorteando os valores da lista:', end=' ') for c in range(0, 5): n = randint(1, 10) lista.append(n) print(n, end=' ') sleep(0.4) print() def somaPar(lista): soma = 0 for n in lista: ...
f5ec335a61dd14d8e5de49a96e4711a573445546
yanbernardo/exercicios-python-3
/Exercícios/Desafio 081.py
480
3.859375
4
m_n = 'S' lista = [] while m_n == 'S': n = int(input('Digite um número: ')) lista.append(n) m_n = str(input('Deseja continuar?(S/N): ')).upper()[0] print('-=' * 30) print(f'Foram digitados {len(lista)} números') reverso = lista[:] reverso.sort(reverse=True) print(f'Os valores em ordem decrescente são {rever...
8582a38d30b9bba7da38847b34d6d7446ac18d6d
yanbernardo/exercicios-python-3
/Exercícios/Desafio 019.py
299
3.828125
4
from random import choice a1 = input('Digite o nome do primeiro aluno: ') a2 = input('Digite o nome do segundo aluno: ') a3 = input('Digite o nome do terceiro aluno: ') a4 = input('Digite o nome do quarto aluno: ') list = [a1, a2, a3, a4] r = choice(list) print('O aluno escolido foi {}'.format(r))
31479fa70e35eab299957a6e90052b36a8f53ab1
yanbernardo/exercicios-python-3
/Exercícios/Desafio 084.py
944
3.640625
4
pessoa = list() grupo = list() ac_peso = list() ab_peso = list() tot = 0 while True: pessoa.append(str(input('Nome: ')).capitalize()) pessoa.append(float(input('Peso: '))) grupo.append(pessoa[:]) pessoa.clear() tot += 1 resp = str(input('Deseja continuar?(S/N): ')).upper()[0] if resp == 'N':...
56a71169c30888ad339d98cafd400ce9757acae9
yanbernardo/exercicios-python-3
/Exercícios/Desafio 050.py
180
3.9375
4
soma = 0 for c in range(0, 6): n1 = int(input('Digite um número\n')) if n1 % 2 == 0: soma += n1 print('Os valores pares digitados dão a soma de {}'.format(soma))
eeb55c9016e2e2d09d56b2bf680add73a85a3b6f
yanbernardo/exercicios-python-3
/Exercícios/Desafio 066.py
216
3.6875
4
cont = s = 0 while True: n = int(input('Digite um número(999 para PARAR):\n')) if n == 999: break s += n cont += 1 print(f'Foram digitados {cont} números e a soma entre eles é igual a {s}')
74f15cf391919b14dabf1ec9a7c404ff73016e4f
GabeAboy/PythonScripts
/calc.py
3,706
3.640625
4
import Tkinter as tk from Tkinter import Grid class Calculator: def __init__(self): self.root = tk.Tk() self.root.title("Calculator") self.calcscreen = '' self.calculator = tk.Button(bd=5,text=self.calcscreen,width=20) self.calculator.grid(row=0,column=2) self.lab...
4c98e3e851f88b7c8e601f736a02b062c1e363c3
LauFr/DataScienceDemoData
/Linear Regression/generate_data.py
743
3.578125
4
import numpy as np import pandas as pd N_obs = 1000 # create the city variable city = np.random.randint(low=1, high=10, size=N_obs) # create a variable with m^2 mu_m2, sigma_m2 = 100, 25 # mean and standard deviation m2 = np.random.normal(mu_m2, sigma_m2, N_obs) m2 = m2.round() # create the age variabl...
470a73937a08e0b46fde63d5a2df2631e464016d
lfaipot/board-simu
/src/libproc.py
1,680
3.625
4
# -*- coding:utf-8 -*- # # Copyright(C) 2014 Laurent Faipot (laurent.faipot@free.fr). All rights reserved. # def ltoi(value, size): "convert long integer into sized integer" # value is extracted from memory without taking care of sign # determine sign of integer if (size <= 0): return 0 ma...
ddbc01b74befc3cb94f28d9f0c23ea1392e7eadb
Rkhwong/RHK_CODEWARS
/Fundamentals - Python/Arrays/Convert an array of strings to array of numbers.py
618
4.1875
4
# https://www.codewars.com/kata/5783d8f3202c0e486c001d23 """Oh no! Some really funny web dev gave you a sequence of numbers from his API response as an sequence of strings! You need to cast the whole array to the correct type. Create the function that takes as a parameter a sequence of numbers represented as strings...
6c3c745a5a9f7815a9a9a90f809417eee6a8238d
Rkhwong/RHK_CODEWARS
/Fundamentals - Python/Strings/The Office I - Outed.py
1,517
3.984375
4
#https://www.codewars.com/kata/the-office-i-outed """Your colleagues have been looking over you shoulder. When you should have been doing your boring real job, you've been using the work computers to smash in endless hours of codewars. In a team meeting, a terrible, awful person declares to the group that you aren't ...
714154207332e573cee0c4adfa95239ff0edf2e8
MartynasIT/Pandas-csv-integrity-tester
/file_worker.py
6,996
3.5625
4
import pandas as pd import main import utils as util def read_csv(file): data = None try: data = pd.read_csv(file, error_bad_lines=False, warn_bad_lines=True, header=None) print(util.get_filename(file) + ' red') except Exception as e: print(util.get_filename(file) + ' er...
c800b5edcf4b5bd854046a4ac70906de884bdd96
renarfreitas/Coursera
/indicadordepassagem.py
420
4.09375
4
decrescente = True anterior = int(input("Digite o primeiro número da sequência: ")) valor = 1 while valor != 0 and decrescente: valor = int(input("Digite o próximo número da sequência: ")) if valor > anterior: decrescente = False anterior = valor if decrescente: print("A sequência está em o...
4321fb766b063af654d6fd2e5ef9ff73ff19536b
renarfreitas/Coursera
/pontos.py
326
4
4
import math x = int(input("Informe o primeiro número: ")) y = int(input("Informe o segundo número: ")) x1 = int(input("Informe o terceiro número: ")) y1 = int(input("Informe o quarto número: ")) distancia = math.sqrt(((x - x1)**2) + ((y - y1)**2)) if distancia >= 10: print("longe") else: print("perto...
9435079619be61fcc486b27c067ef277e7e8a4a6
renarfreitas/Coursera
/somadosdigitos.py
197
3.765625
4
import os os.system('clear') n = int(input("Digite o valor de n: ")) soma = 0 i = 1 while i <= n: soma = soma + i i = i + 1 print("A soma dos", n, "primeiros inteiros positivos é", soma)
b2def4fe4337269c05c941cba3043e98e2f604e9
renarfreitas/Coursera
/soma_digitos.py
104
4.125
4
num = int(input("igite um número inteiro: ")) i=0 while num: i += num % 10 num //= 10 print(i)
319f7b2578042fbd1ea15353e238323d8d4fda85
Aka-Ikenga/Word-Cookies
/Cookies.py
753
3.703125
4
import itertools as it import pprint as pp def word_cookies(cookie): with open('Common English Words.txt', 'r') as fh: fh = fh.readlines() valid_words = {i.strip() for i in fh} # a set containing all the words cookies = {} for i in range(3, len(cookie)+1): # permutation produces invalid words, an interse...
d4b2fb6a0358c339c0e5dd7b85962a6ff00bd298
maczoe/python_cardio
/convertidor.py
921
4.21875
4
def convert_km_to_miles(km): return km * 0.621371 def convert_miles_to_km(miles): return miles * 1.609344; def main(): print("Bienvenido a convertidor.py") seleccion = 0; while seleccion!=3: print("----MENU----") print("1. Millas a kilometros") print("2. Kil...
6db0e37c33b66bdce65db37de937472922f082fd
senasaccount/python101
/inheritance.py
528
3.828125
4
#using of __init__(self) with inheritance class employee(): def __init__(self): self.firstName = "" self.lastName = "" self.address = "" class dataScience(employee): def __init__(self): self.language = "" class marketing(employee): def __init__(self): ...
c0acfdcd25c8f4116a2566404d68e5d18142c670
ki4070ma/leetcode
/atcoder/20200503_ABC/A_.py
135
4.0625
4
#!/usr/bin/python3 for _ in range(1): S = input().rstrip() if S == "ABC": print("ARC") else: print("ABC")
c2c84a63e80a92d29359689a7b4cc61f624f229e
ki4070ma/leetcode
/atcoder/20200126_ABC/D_.py
1,094
3.5625
4
#!/usr/bin/python3 from sys import stdin # 1 -> 1 attack # 2 -> 3 # 3 -> 3 # 4 -> 7 # 5 for _ in range(8): H = int(input().rstrip()) ret = 0 if H == 1: ret = 1 elif H in [2, 3]: ret = 3 else: count = 0 while H != 1: H = H // 2 count += 1 ...
8f1e12e3834caf2bea29812ece170c4c47770318
ki4070ma/leetcode
/atcoder/20200613_ABC/A_.py
81
3.625
4
#!/usr/bin/python3 for _ in range(1): S = input().rstrip() print(S[:3])
e03b921c142c61bae48b5fdf5d345e08555ca019
ki4070ma/leetcode
/atcoder/20200307_ABC/D_.py
802
3.75
4
#!/usr/bin/python3 for _ in range(3): S = input().rstrip() Q = int(input().rstrip()) reversed = False from collections import deque q = deque() q.extend(list(S)) for _ in range(Q): l = input().rstrip() if l.startswith("1"): reversed = False if reversed else True...
25a658c562e7bdce94d75292182b101d5eab787b
ki4070ma/leetcode
/leetcode/Easy/1108_Defanging_an_IP_Address.py
328
3.5
4
class Solution: def defangIPaddr(self, address: str) -> str: ret = "" for n in address: if n == ".": ret += "[.]" else: ret += n return ret return "[.]".join(address.split(".")) # the fastest return address.replace(".",...
898a2e111d2333ed77e0bff46acb7301573c9e74
Mohan-Zhang-u/NLPDemoServer
/MyFlaskBackEnd/TextSummarization/capitalize.py
2,818
3.9375
4
import os import sys import argparse import nltk import codecs ''' This python script is searching for any words in the original news article that are capitalized and not the first word in a sentence, then replace the lower cased version of them in the summaries. Also, it replace every word in the summaries that is t...
4e2945720be75987b2c6633ca35992f4544ad7fa
LubosKolouch/hackerrank
/regex/british_american2.py
277
3.6875
4
import re my_str = ' '.join([input() for _ in range(int(input()))]) for _ in range(int(input())): word = input() am_word = re.sub('ou', 'o', word, 0) count = len(re.findall(word+r'\b', my_str)) count += len(re.findall(am_word+r'\b', my_str)) print(count)
b3377c885ed75c6b29457e119232bb57882ef318
LubosKolouch/hackerrank
/regex/identifying_comments.py
545
3.5
4
#!/bin/env python """ https://www.hackerrank.com/challenges/ide-identifying-comments/problem """ import fileinput import re output = '' in_comment = 0 for line in fileinput.input(): pattern = r'(\/\/.*)' x = re.findall(pattern, line) if x: output += x[0] output += "\n" if in_comm...
187e6ed4174089c1e90daa2791882cb2cbbbcf89
guilhemelias/SemGrids-Maker
/SemGridsMakerPyQt/view/manager.py
3,312
3.5625
4
# -*- coding: utf-8 -*- """ Created on Mon Apr 19 10:23:54 2021 @author: gelias """ from maker import Maker from arduino import Arduino class Manager(): """ Manager of the model. It is called by the view. It makes the link between the model and the view """ def __init__(self): """ Th...
8c8861259b03ed4f89574f56a3fff922b05619fa
drazovicfilip/Firecode
/Problems/firecode4_fibonacci.py
1,182
4.1875
4
""" The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. Write a recursive method fib(n) that returns the nth Fibonacci number. n is 0 indexed, which means that in the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ..., n == 0 ...
9cfba274c8e6c45c76f5571b58fe3d94379e3175
drazovicfilip/Firecode
/Problems/firecode3_verticalFlip.py
646
4.03125
4
""" You are given an m x n 2D image matrix (List of Lists) where each integer represents a pixel. Flip it in-place along its vertical axis. Example: Input image : 1 0 1 0 Modified to : 0 1 0 1 """ def flip_vertical_axis(matrix): rows = len(matrix) cols = len(matrix[0]) ...
9698999adb69ef7acbd3155bcfa773c0c8ca775d
amingilani/adventofcode2020
/2/solution.py
1,375
3.515625
4
import re import os, sys data = [line.strip() for line in open(os.path.join(sys.path[0], "input.txt"), "r")] solution = open(os.path.join(sys.path[0], "solution.txt"), "w") # Part 1 count = 0 for line in data: (left_half, right_half) = line.split(":") (lower_limit, upper_limit) = left_half[0:-2].split("-") ...
34cb4ffeefb8d79f69b9096c894cfcb0980ad060
LzWaiting/02.PythonNet
/code/tcp_example.py
803
3.53125
4
'''服务端''' from socket import * # 1. 创建套接字 sockfd = socket(AF_INET,SOCK_STREAM) # 2. 绑定服务端地址 sockfd.bind('0.0.0.0',8888) # 3. 设置监听套接字,创建监听列队 sockfd.listen(5) # 4. 等待处理客户端连接请求 connfd,addr = sockfd.accept() # connfd 客户端连接套接字,addr 客户端地址 # 5. 收接发数据 data = connfd.recv(1024) n = connfd.send(b'相应回复信息') # 6. 关闭套接字 connfd...
65c21678d5253dcb9b07c42566ac525c42100d4f
DiegoMeruoca/Python-1-Primeiros-Comandos
/Desafio 3.py
419
3.84375
4
# Desafio 3 - Desconto do produto preco = float(input("Digite um valor do produto:")) # Recebe o valor e converte para float percDesc = float(input("Digite a porcentagem de desconto(Apenas números):")) # Recebe o valor e converte para float desconto = preco*percDesc/100 novoPreco = preco - desconto print("O desc...