blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
70cbe1aa492cc0f28430bba876229ee42ab62ec2
sacdallago/dataminer
/conv_net_one_against_all.py
11,730
3.5
4
# coding: utf-8 # In[ ]: ''' A Convolutional Network implementation example using TensorFlow library. This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/) Author: Aymeric Damien Project: https://github.com/aymericdamien/TensorFlow-Examples/ ''' # In[ ]: import tensor...
e68b660237b66f9a832bacc13b2c0e0311d24613
link0233/python-dodge-ball-game
/pythonm/wd/ball.py
962
3.59375
4
class ball: def __init__(self,canvas): self.canvas=canvas self.item=canvas.create_oval(0,0,20,20,fill='White') self.kd=[1,1] def loop(self,speed): self.canvas.move(self.item,speed*self.kd[0],speed*self.kd[1]) self.xy=self.canvas.coords(self.item) if self.xy[0]<0 o...
10c8d46409b1ac493cc539dd7192745e214f083a
MitchDziak/crash_course.py
/python_work/messing_around.py
462
3.734375
4
# This is my first fun program. print("Welcome to my first program that's supposed to be fun or something!") print("") title = "A NEAT STORY" print("\t\t\t" + title) name = "mitch" age = 23 girlfriend = "SHANNON" print("You wake up, and as usual your first thought is, 'I am " + name.title() + "' and I am ...
56176eda107308ea31db050bfa030596f0c14046
balajisaikumar2000/Python-Snippets
/Sets.py
1,397
4.46875
4
#sets are unordered and unindexed and immutable: #every time we run a code the result will be different in output #sets never allow duplicates ,even if we have two same items it will show only one x = {"apple","banana","cherry","cherry"} print(x) print("banana" in x) #add(): y = {"apple","banana","cherry"} y.add("man...
3e9428e03d1ed8ea92825f0ebcd3f5679a87cba0
hookeyplayer/exercise.io
/算法/100_same tree.py
859
3.59375
4
# Input: p = [1,2], q = [1,null,2] # Output: false class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isSameTree(self, p: TreeNode, q: TreeNode) -> bool: if p == q: return True try: ...
78024de7257eb2c7ab1756a476f251256f45106f
haichao801/learn-python
/7-文件处理/f_read.py
715
3.75
4
""" 语法格式: f = open(file='d:/练习方式.txt', mode='r', encoding='utf-8') data = f.read() f.close * f = open(file='d:/练习方式.txt', mode='r', encoding='utf-8') 表示文件路径 * mode='r'表示只读(可修改为其它) * encoding='utf-8'表示将硬盘上的010101按照utf-8的规则去断句,再将断句后的每一段010101转换成Unicode的010101,Unicode对照表中有010101和字符的对应关系 * f.read()表示读取所有内容,内容是已经转换完毕的字符串 ...
f5d37a7ba9f5aff3f421a4380564843b4727b1a1
CoderMP/PythonPassGen
/PassGen.py
3,661
3.75
4
####### REQUIRED IMPORTS ####### import os import sys import click import random import string from time import sleep ####### FUNCTIONS ###### def displayHeader(): """ () -> () Function that is responsible for printing the application header and menu """ # Clear the console window os.syste...
e292710bb2c757b52dfd939390e70bf9832fdab6
notaidea/python
/adv/zhuangshiqi5.py
904
3.625
4
# -*- coding: utf-8 -*- """ 装饰器用在类方法上(非静态) 内部的function,第一个形参对应类方法的self 装饰器用在类静态方法上 不能和非静态方法共用装饰器(形参个数不一样) @staticmethod要写在最上面 """ def check(func): #第一个形参对应类方法的self def _check(obj): print("checking......") func(obj) return _check def checkstatic(func): #第一个形参对...
bb4244d08950407ac0e9312e2addf354e39e5e2f
PaulGuo5/Leetcode-notes
/notes/0866/0866.py
609
3.609375
4
class Solution: def primePalindrome(self, N: int) -> int: def reverse(n): res = 0 while n > 0: res = res*10 + n%10 n = n//10 return res def isprime(n): for i in range(2, int(n**.5)+1): if n%i == ...
24a36d9a5f8747064a4dfe6b6bd1ff72d16a03a0
StevenSigil/Conways-Game-of-Life
/game/life_logic.py
4,243
3.703125
4
import numpy as np def random_position(arr): # Random position to place active cell relative to board dimensions rows = arr.shape[0] cols = arr.shape[1] random_row = np.random.randint(0, rows) random_col = np.random.randint(0, cols) return random_row, random_col def setup_random(arr): ""...
56d76f7d8ea08912ed786310fc16598fbf90c27b
heiligbasil/Sprint-Challenge--Data-Structures-Python
/names/binary_search_tree.py
2,019
4.03125
4
class BinarySearchTree: """Binary Search Tree, is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys lesser than the node’s key. The right subtree of a node contains only nodes with keys greater than the node’s key. The left a...
977c7c3732c5f5dcf4e6c7105dec21836fc71cc1
caiknife/test-python-project
/src/PythonCookbook/Chapter19/ex19-04/ex.py
463
3.625
4
#!/usr/bin/python # coding: UTF-8 """ Created on 2012-11-25 在多重赋值中拆解部分项 @author: CaiKnife """ def peel(iterable, arg_cnt=1): """获得一个可迭代对象的前arg_cnt项,然后用一个迭代器表示余下的部分""" iterator = iter(iterable) for num in xrange(arg_cnt): yield iterator.next() yield iterator if __name__ == '__main__': t5...
3444f30670edd189748841ad556b9aafb4c8cfd1
curtislb/ProjectEuler
/py/problem_067.py
1,147
3.71875
4
#!/usr/bin/env python3 """problem_067.py Problem 67: Maximum path sum II By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top ...
85e4159fe6900ef200e6154846a9cb934826f304
Nithy-Sree/Crazy-Python-
/simple urlChecker.py
1,166
3.984375
4
# pip install validators # pip install tkinter # import the neccessary packages import tkinter as tk import validators from tkinter import messagebox # create a GUI window root = tk.Tk() # setting the title for the window root.title("URL Validator") # setting the size of the window to display root.geometry("250x1...
81beeefbe30be803983cd0610509cb0f40bbf860
SimonPavlin68/python
/pygame/circle.py
739
3.578125
4
import pygame, math, sys from pygame.locals import * BLACK = (0,0,0) RED = (255,0,0) WHITE = (255,255,255) WIDTH = 640 HEIGHT = 480 RADIUS = 10 screen = pygame.display.set_mode((WIDTH, HEIGHT)) screen.fill(WHITE) x = 320 y = 240 xd = 1; yd = -1; pygame.draw.circle(screen, RED, (x,y), RADIUS) pygame.display.update() ...
58c9f98ce62da07e187ea70818cdfd3ab54056f7
hira66it/pyProject
/Algorithm/3_find_missingNumber.py
239
3.71875
4
def missingNumber(arr): tmp_1=0 tmp_2=0 length = len(arr) print(length) for i in range(length): tmp_1 += arr[i] tmp_2 += i tmp_2 += (length) return tmp_2 - tmp_1 print(missingNumber([0,1,2,3,5]))
a9548f3ba1052f073a456cea261be80b7f1d8089
dyollluap/August5
/primenumber1000.py
333
3.765625
4
# -*- coding: utf-8 -*- """ Paul Lloyd - August 2014 This is a script to find prime numbers under 1000. """ minIdx =1; maxIdx =1001; for i in range(minIdx,maxIdx): isPrime = True; for j in range(2,i): if (i % j == 0): isPrime = False; break if (isPrime == True):...
4ae4595fe4e3d92e783bd8424a99e611d845df42
Vakonda-River/Lesson4
/lesson4_1.py
601
3.546875
4
import less4myfunc name = input('Укажите имя и фамилию сотрудника: ') hour = float(input('Введите выработку в часах: ')) rate = float(input('Введите размер почасовой ставки: ')) prize = float(input('Если предусмотрено, введите размер премии: ')) w = round(less4myfunc.wage(hour,rate),2) w_p = w + prize print(...
121740a86e8ae4526e584863cd3a6c3df44b2a6a
BengiY/Management-of-a-communications-company-python
/venv/Line.py
1,084
3.5
4
# Line Management class class Line(): def __init__(sel,CustomerCode,RouteCode,LineFone): self.__CustomerCode=CustomerCode self.__RouteCode=RouteCode self.__LineFone=LineFone #proprty @property def LineCode(self): return self.__LineCode @LineCode.setter ...
9273587b9f3d7fc9a3639056132c93cc0e40cdce
fossabot/textlytics
/textlytics/sentiment/negation_handling.py
1,865
3.734375
4
# coding: utf-8 import re as _re _full_negation = "not, no, none, never, nothing, nobody, nowhere, neither, nor" _quasi_negation = "hardly, scarcely" _abs_negation = "not at all, by no means, in no way, nothing short of" _negation = _full_negation + ", " + _quasi_negation + ", " + _abs_negation _negation_regexp = "(?...
86c9da450c6beb05fcf713cbdbe2a31d7fd396c4
surenderpal/Durga
/Exception Handling/multiple_except.py
541
3.875
4
# try: # x=int(input('Enter first value:')) # y=int(input('Enter second value:')) # print('The result: ',x/y) # except ZeroDivisionError: # print("Can't Divide with zero") # except ValueError: # print('Please provide only int values only') # try: # print(10/0) # except ZeroDivisionError: # ...
225fe19b785ddc3108a6e37b47ff4cb8fed9ebb1
mashagua/hackercode
/hackercode30/Day_25.py
295
3.9375
4
import math def check_prime(num): if num == 1: return "Not prime" sq = int(math.sqrt(num)) for x in range(2, sq+1): if num % x == 0: return "Not prime" return "Prime" T=int(input()) for i in range(T): num=int(input()) print(check_prime(num))
7d190d11468bd05e997f6789c14ada6e57e42585
miguelabreuss/scripts_python
/CursoEmVideoPython/desafio55.py
447
3.5625
4
peso = 0 maior = 0 menor = 9999 pes_maior = 0 pes_menor = 0 for i in range(0, 5): peso = int(input('Digite o peso [kg] da {}ª pessoa: '.format(i+1))) if peso > maior: maior = peso pes_maior = i if peso < menor: menor = peso pes_menor = i print('O maior peso lido foi {} kg, d...
827ced0d9a3018519f2cf4179e1cb4409f42c61d
Aminaba123/LeetCode
/227 Basic Calculator II.py
2,582
4.1875
4
""" Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty spaces . The integer division should truncate toward zero. You may assume that the given expression is always valid. Some examples: "3+2*2" = 7 " 3/2 " = ...
7210d7f1c3f90fcceb987790f8d585c6e1dcdf16
akassian/Python-DS-Practice
/09_is_palindrome/is_palindrome.py
833
4.21875
4
def is_palindrome(phrase): """Is phrase a palindrome? Return True/False if phrase is a palindrome (same read backwards and forwards). >>> is_palindrome('tacocat') True >>> is_palindrome('noon') True >>> is_palindrome('robert') False Should ignore capi...
406db45850da08ce4a08b0d966883dce55f03e2b
Akhilnazim/Problems
/leetcode/string.py
99
3.75
4
s=input("enter the value") # b=ord(s) # print(b) for i in s: a= ord(i)+2 print(str(a))
f5c85218a843f2131b62b683867a444d695263b2
Jung-Woo-sik/mailprograming_problem
/before_2021/Q28.py
364
3.765625
4
class LinkedList: def __init__(self, data, next=None): self.data = data self.next = next def solution(head): start = end = head while start: end = start total = 0 skip = False while end: total += end.data if total == 0: start = end skip = True break end = end.next if not skip: ...
a35ea4e9cf26d265e8e8cc508b514cc0bae85010
kishoreKumar01/Project_1
/TWITTER Sentiment_Analysis/main.py
1,927
3.546875
4
import string from collections import Counter import matplotlib.pyplot as plt from nltk.tokenize import word_tokenize from nltk.corpus import stopwords import GetOldTweets3 as got def get_tweets(): Tweet_Criteria = got.manager.TweetCriteria().setQuerySearch('CoronaOutbreak').setMaxTweets(500) \ .setSi...
a65db3659b938f74f2ec6b3f20a847b641304fa6
zhaobf1990/MyPhpDemo
/first/com/zhaobf/test15.py
173
3.609375
4
def fun1(n): if n == 1: print("你选择了1") elif n == 2: print("你选择了2") elif n == 3: print("你选择了3") fun1(1) fun1(2)
f632e80951c04fae3d12bb4e773c790e6c01dc2d
2019-b-gr2-fundamentos/fund-Santamaria-Herrera-Lizbeth-Ultimo
/Examen/Borrar-Actualizar-Crear.py
2,880
4.21875
4
print("Con este programa se podra crear, actualizar y borrar nombres de dinosaurios") DINOSAURIOS = ["Brachiosaurus", "Diplodocus", "Stegosaurus", "Triceratops", "Protoceratops","Patagotitan", "Apatosaurus","Camarasurus"] import random def main(): dinosaurios() def dinosaurios(): print (" ",DINOSAURIOS) ...
1ce8a38810e2bcb958f79e71aaa570ce62f28260
SaItFish/PySundries
/algorithm_questions/LeetCode/剑指Offer/55-1二叉树的深度.py
953
3.734375
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- # @author: SaltFish # @file: 55-1二叉树的深度.py # @date: 2020/07/23 """ 输入一棵二叉树的根节点,求该树的深度。从根节点到叶节点依次经过的节点(含根、叶节点)形成树的一条路径,最长路径的长度为树的深度。 例如: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最大深度 3 。 """ # Definition for a binary tree node. class...
280dbe664cbe6a89dde47dd7a850b26a448e2f59
ckimmons/code2040Assessment
/ReverseAString.py
472
3.9375
4
# Stage 2. # Reverses a string, posts the result. from ApiRequestHandler import RecieveProblem, ValidateProblem REQUEST_URL = 'http://challenge.code2040.org/api/reverse' VALIDATE_URL = 'http://challenge.code2040.org/api/reverse/validate' # Uses the slicing operator to return the reversed string. def ReverseAString(st...
5ae73e1b62af982d36d0664776865bd680d571fa
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Python Data Structure/Dictionary/11_NestedDictfromList.py
460
4.40625
4
"""Program to convert a list into a nested dictionary of keys""" numbers = [1, 2, 3, 4, 5] for num in numbers: dict1 = dict.fromkeys([num]) # creating dictionary in each iteration if num == 1: my_dictionary = dict1 # parent dictionary if num > 1: dict2[num-1...
a99f0f49ec1455b3e25748b64a001d0557147770
TesioMatias/othello-reinforcement-learning
/othello_solutions.py
2,200
3.515625
4
from urllib.request import urlopen # Python 3 import os import numpy as np def download_value_func(link, filename): response = urlopen(link) file_size = response.length CHUNK = 16 * 1024 downloaded = 0 print('Donwloading: ', link) print('Saving it as: ', filename) with open(filename, 'wb') ...
3a4050db7e4cf187f1fad1072b4cfe49b9505eb0
Alan6584/PythonLearn
/demos/D019_thread.py
653
3.984375
4
#! /usr/bin/python # -*- coding:UTF-8 -*- import threading import time class MyThread(threading.Thread): '自定义线程' def __init__(self, threadID, count): threading.Thread.__init__(self) self.threadID = threadID self.count = count def run(self): print "MyThread:%d -->run start......count:%d" % (self.threadID...
ae5db1f411e0d8d9215fb28791011fc60bbb9b31
Walker-TW/Python_Projects
/fizzbuzz_python/fizzbuzz.py
519
3.953125
4
def better_fizzbuzz (x): for x in range(x): output = "" if ( x % 3 == 0): output += "Fizz" if ( x % 5 == 0): output += "Buzz" if output == "": print ( x ) else: print ( output ) # OR def simple_fizzbuzz(x): if x % 3 == 0: print ("Fizz") elif x % 5 == 0: ...
1c171d37832d685379130b36b83db0f3c9469af3
liruileay/data_structure_in_python
/data_structure_python/question/chapter3_binary_tree/question20.py
3,151
3.515625
4
""" Tarjan算法与并查集解决二叉树节点间最近公共祖先的批量查询问题 题目: """ from development.chapter10.ChainHashMap import ChainHashMap from development.chapter7.FavoritesList import FavoritesList as LinkedList class Node: def __init__(self, value): self.left = None self.right = None self.value = value class Query: def __init__(sel...
a3938c06c8f4a8e282e6739bcd914e6c3bdae488
Elain26/elains_leetcode_practice
/8Check If N and Its Double Exist.py
313
3.609375
4
arr=[10,2,5,3] def doubleornot(arr): n=len(arr) #暴力穷举对比任意两个数是否有两倍关系,注意两数不能同为0 for i in range(n): for j in range(n): if arr[i]*2==arr[j] and i!=j: return True return False print(doubleornot(arr))
e3ba323f94745f35e6e5b4890e9049b851a5d856
p83218882/270201032
/lab4/example1.py
180
3.546875
4
if 0 <= a < 10: print(a) elif a == 10: print(1) elif 10 < a <= 99 : print((a % 10) + ((a - (a % 10)) / 10)) elif a >= 100: print((a % 10) + ((a - a % 10) / 10) % 10)
8b9dad1d0e76314bbc07118194630d3bc4f7b7fb
andrezzadede/Curso-de-Python-POO
/interfaceclassabstrata.py
404
3.640625
4
# Classe abstrata ou interface #Uma classe abstrata nãoo pode ser diretamente instanciada, ela serve apenas para que outras classes possam ter ela como base from abc import ABCMeta, abstractmethod class MinhaClasseAbstrata(metaclass=ABCMeta): @abstractmethod def fazer_algo(self): pass @abstr...
0c864d46d32d37d371fa0685ced591190e30411f
RebeccaML/Practice
/Python/Challenges/fizzbuzz.py
455
4.1875
4
# Fizzbuzz challenge # For all numbers from 1 to 100, if number is a multiple of 3 print Fizz # if a multiple of 5 print Buzz, if a multiple of both print Fizzbuzz # Otherwise print the number def fizzbuzz(): for i in range(1, 101): if i % 3 == 0 and i % 5 == 0: print("Fizzbuzz!") elif ...
b7a1f9b331f27df994bc721003cdb236fde991b8
prashanthr11/Leetcode
/practice/Backtracking/N-Queens.py
2,698
3.5625
4
class Solution: def solveNQueens(self, n): # Time: O(N!) where n is the size of the chess board. # Space: O(N ** 2) Keeping track of all possitions in N * N board. def solve(board, a): if a >= len(board): # Base case: When all Queens are placed. ...
349edb0cc4d510c37a3cd91559f91448228a67ef
ishitadate/nsfPython
/Week 2/w2_homework_solutions.py
591
3.703125
4
# Week 2 Solutions # 1. // is integer division. It takes the floor of a number. # 2. % is a modulus. It finds the remainder of the division between numbers. # 3. Apples is not updated in memory. It should read: apples = 6 apples -= 3 # 4. Ilikecookies # 5. Yes. You can't subtract from a string, this is a syntax ...
170ba0f1681910726fe92a96e02d523ddc0af520
Anuar7/TSIS5
/7.py
177
3.5625
4
def file(f): arr = [] with open(f) as a: for line in a: arr.append(line) print(arr) file('test.txt')
6afb96f2a75a2c5f883cbd971c464095780c888f
Antechamber/sandbox
/sumTo100.py
1,086
4.125
4
# this module searches for combinations of '+', '-' and '', placed between the numbers 1-9 in order and finds # expressions which evaluate to exactly 100 from itertools import product numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] arr = ['', '-', '+'] operators_combos = product(arr, repeat=8) # evaluate exp...
1702050be4acd0aabae929727fb48bdd68e83655
ioef/PPE-100
/Level1/q9.py
233
4.25
4
#!/usr/bin/env python ''' Define a function that can convert a integer into a string and print it in console. Hints: Use str() to convert a number to string. ''' number = 3245 def int2str(num): print(str(num)) int2str(number)
8e82b70ac64be6ccadf6ed5064d712506f922607
dwagon/pydominion
/dominion/cards/Card_Huntingparty.py
2,676
3.75
4
#!/usr/bin/env python import unittest from dominion import Game, Card, Piles import dominion.Card as Card ############################################################################### class Card_Huntingparty(Card.Card): def __init__(self): Card.Card.__init__(self) self.cardtype = Card.CardType....
0ccfb9a5ea6bd60956afcd3876e61dececbfcdc4
Matthew-Lin-Duke/Class_02072020
/dictionary.py
1,374
3.78125
4
def create_dictionary(): new_dictionary = {"day": "between sunrise and sunset", "food": "something to eat", "night": "when the moon is out", "star": "Blinking lights in the night sky"} return new_dictionary def create_patient(): new_patien...
8b473ccb6315120ca87783d87e0ebfda07f42030
wwtang/code02
/wordcount3.py
2,308
4.1875
4
""" The problem in you code: 1, you read the whole file one time, that will be slow for the large file 2, you have another method to sort the dict by its values 3, you do not have the clear train of thought Here is the train of thought(algorithm) first, do the base, derive a dict from the file secondly, define the two ...
1f5c2478f011d39acca7096c40ae962b089258b5
WilliamO-creator/Digital_Solutions
/Chapter 3/Exercises_4.py
395
3.703125
4
num1 = input("enter number 1 to 10") if num1 == ("1") : print("I") if num1 == ("2") : print("II") if num1 == ("3") : print("III") if num1 == ("4") : print("IV") if num1 == ("5") : print("V") if num1 == ("6") : print("VI") if num1 == ("7") : print("VII") if num1 == ("8") : print("VIII") i...
9652da3a491426d6ade172c8da875fdc3b854503
sccdcwc/Newcode
/14.py
1,740
3.515625
4
''' 请实现一种数据结构SetOfStacks,由多个栈组成,其中每个栈的大小为size,当前一个栈填满时,新建一个栈。该数据结构应支持与普通栈相同的push和pop操作。 给定一个操作序列int[][2] ope(C++为vector<vector<int>>),每个操作的第一个数代表操作类型, 若为1,则为push操作,后一个数为应push的数字;若为2,则为pop操作,后一个数无意义。 请返回一个int[][](C++为vector<vector<int>>),为完成所有操作后的SetOfStacks,顺序应为从下到上, 默认初始的SetOfStacks为空。保证数据合法。 ''' # -*- coding:utf-8 -...
624c1ba2d6971e2ea8e2f5c197eacb6f4468bae9
neelakantankk/AoC_2019
/Problem_03/main.py
3,033
3.953125
4
from collections import namedtuple Point = namedtuple('Point',['x','y']) class Path: def __init__(self): self.path = [Point(0,0)] def __repr__(self): return ', '.join([str(point) for point in self.path]) def go_right(self,steps): current_point = self.path[-1] for step in ...
33af13dbdeb2321144dab3c7863e20ed5cc87f8c
akadir/CodingInterviewSolutions
/Matrix Spiral/MatrixSpiral.py
1,783
3.515625
4
import unittest def first_solution(number): result = [] for i in range(0, number): result.append([None] * number) counter = 1 start_row = 0 end_row = number - 1 start_column = 0 end_column = number - 1 while start_column <= end_column and start_row <= end_row:...
69d013e50fd7991b9a69f2efcddb57ed85cfed40
RakeshSuvvari/Joy-of-computing-using-Python
/speech-text.py
598
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Feb 27 11:12:16 2021 @author: rakesh """ import speech_recognition as sr AUDIO_FILE = ("sample2.wav") # use audio file as source r = sr.Recognizer() # initialize the recognizer with sr.AudioFile(AUDIO_FILE) as source: audio = r.record(source) ...
7fde89a195460769eb57aaf12566ed983edfbe45
santos816/curso_python_2020
/exec03.py
498
4.09375
4
valor_1 = int(input("Forneça o valor 1:\n")) valor_2 = int(input("Forneça o valor 2:\n")) soma = valor_1 + valor_2 print(f'Soma: {soma}') subtracao = valor_1 - valor_2 print(f'Subtração: {subtracao}') divisao = valor_1 / valor_2 print(f'Divisão: {divisao}') divisao_inteiro = valor_1 // valor_2 print(f'...
0a3950b13fcb35fe6471279ea0dbad3433668a86
salvadorhmutec/python_curse
/session01/011_concatenation_format.py
164
3.8125
4
#variables, formato y operacioens foo=10 bar=12 print ("{}+{}={:.2f}".format(foo,bar,foo+bar)) print ("{foo}+{bar}={res:.2f}".format(foo=foo,bar=2,res=foo+bar))
03a16a337524cfb8ea3827994b6342935171a7d6
Sofista23/Aula1_Python
/Aulas/Exercícios-Mundo3/Aula018/Ex088.py
395
3.6875
4
from random import randint from time import sleep cont=0 lista=[] jogos=[] quant=int(input("Quantiade de vezes de palpites:")) tot=0 while tot<=quant: while True: num=randint(1,60) if num not in lista: lista.append(num) cont+=1 if cont>=6: break lista....
53a6ce49a45b4a2ee1569ad82dd194eee137c1fe
lqa9970/J.A.R.V.I.S
/Understanding.py
202
3.796875
4
you = "hello" if you == "": jarvis = "I can't hear you" elif you == "hello": jarvis = "Hello QA" elif you == "date": jarvis = "Saturday" else: jarvis = "I'm good, thanks" print(jarvis)
c78e80626a76212673e0504a27a275663e5c35bb
superniaoren/fresh-fish
/python_tricks/functions/test_function_return.py
743
3.921875
4
# programmers should know the ins and outs of the language they're working with # after all, code is communication # today's topic: implicit return statement def pretend(value): if value: return value else: return None def pretend_none(value): """ bare return, implies `return None` """ ...
d7475b96024b7a05d49674d826789af2da9d8f6e
MijaToka/Random3_1415
/Tarea 2 Transformadores de Binario-Decimal/decimalABinario.py
567
3.75
4
# -*- coding: utf-8 -*- """ Created on Fri Oct 2 13:29:26 2020 @author: Admin """ def decimalABinario(n10,n2= ''): """Traduce una representacion decimal de un valor a su representacion binaria.""" if n10 == '0' and n2 == '': return '0' elif n10 == '0' or n10 == '': return '' else: if int(n1...
2f69b8cbce4604f02b90bd9fa0c591c619f7db7c
Dan-Vizor/SmallProjects
/python/incCode/.goutputstream-AZB37Y
2,352
3.984375
4
#!/usr/bin/python3 ################################################## def encrypt(): key = int(input("enter key: ")) data = raw_input("enter text: ") loop = int(input("enter loop (min 1): ")) for x in range(0,loop): if x > 0: out = encryptword(olOut, key) olOut = out else: out = encryptword(data, key) ...
ddceece488cdbf8134db701ff95a96b897a67975
araujomarianna/codingbat-solutions
/warmup_1/sleep_in.py
396
3.671875
4
def sleep_in(weekday, vacation): """ This function verifies if you can or cannot sleep taking into account weekday and vacation values. :param weekday: Any bool value :type weekday: bool :param vacation: Any bool value :type vacation: bool :return: It returns True if weekday is False or vac...
2b29d733701024692d259066f9be8ecd50998fb2
kennethokwu/Leetcode-Blind-75
/PythonSolutions/InsertIntervals.py
471
3.703125
4
from typing import List class Solution: def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: intervals.append(newInterval) intervals = sorted(intervals, key = lambda x: x[0]) ans = [intervals[0]] for interval in intervals: if interval...
b120badc64c9522a7c5dc281ef41310e7860ee41
rayhanzfr/latihan_github
/lat4-Loop_Statements/lat4-5.py
415
3.71875
4
x=str(input("masukan sebuah kalimat: ")) panjang=len(x) while 0<=len(x)<=50 or len(x)>50: if 0<len(x)<=50: y=x.replace(" ","") print("*"+str.upper(y)+"*") break elif len(x)==0: print("Masukkan sebuah inputan") x=str(input("masukan sebuah kalimat: ")) else: ...
fb3ce2c07e04110b1c43ce429f47243178798a81
artie63/SMU_Homwwork-
/PythonAPI homework/weatherhomework
4,606
3.953125
4
#!/usr/bin/env python # coding: utf-8 # # WeatherPy # ---- # # #### Note # * Instructions have been included for each segment. You do not have to follow them exactly, but they are included to help you think through the steps. # In[19]: # Dependencies and Setup import matplotlib.pyplot as plt import pandas as pd im...
9bbc430428dbed0e737c0616f7edf3e939e088e6
denismoroz/ds-and-alg-p2
/problem_5.py
3,954
4.28125
4
#!/usr/bin/env python # coding: utf-8 # # Building a Trie in Python # # Before we start let us reiterate the key components of a Trie or Prefix Tree. A trie is a tree-like data structure that stores a dynamic set of strings. Tries are commonly used to facilitate operations like predictive text or autocomplete feature...
9f183efe234d243fcae07959919ff78dd70f653b
nikolaCh6/nikolaCh6
/kurs/python/trojkat.py
1,082
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # trojkat.py import math def prostokatny(a, b, c): trojkat = False if a**2 + b**2 == c**2 or a**2 + c**2 == b**2 or c**2 + b**2 == a**2: trojkat = True if trojkat: print('Trójkąt będzie prostokątny :D') else: print('T...
ccff04e26f54c2d02d1e79406183782ee2e736d6
kirtivr/leetcode
/281.py
1,053
3.765625
4
class ZigzagIterator(object): def __init__(self, v1, v2): """ Initialize your data structure here. :type v1: List[int] :type v2: List[int] """ self.totalSize = len(v1) + len(v2) self.index = 0 self.data = [] smaller = min(len(v1),len(v2)) ...
9b66fdb9e5f811e837d88de60b2262d6c095aae1
jcschefer/sudoku
/sudoku.py
12,515
3.5625
4
# Jack Schefer, pd. 6 # import heapq from time import time from copy import deepcopy # def blankBoard(): board = {} for i in range(9): for j in range(9): board[ (i,j) ] = '.' return board # #print(board) # ALL_COORDINATES = [] for i in range(9): for j in range(9): ALL_COORDINATES.append( (i,j) ) #...
3d09932eefc806c63a2d152c58f10945abbef70c
gracomot/Basic-Python-For-College-Students
/ProgrammingExercises/Lesson 4/question3.py
376
4.5
4
# Question 3 (Draw a Triangle) # Write a program that draws a triangle. Your program should ask for the height # of the triangle and it should display a triangle with the specified height. # Get the height of triangle as input height = int(input("Enter the height of the triangle: ")) for i in range(1, height+1): f...
4381abb8aac66cdf3760fc0ea0ccb73581222972
daviddwlee84/LeetCode
/Python3/Array/ReconstructItinerary/DFS332.py
963
3.65625
4
from typing import List from collections import defaultdict class Solution: def findItinerary(self, tickets: List[List[str]]) -> List[str]: """ https://leetcode.com/problems/reconstruct-itinerary/discuss/709877/Python3-DFS-Solution https://leetcode.com/problems/reconstruct-itinerary/discus...
c660d1b2086414a3afb54a563c487b9579e542e0
mingeun128/algorithm
/LeetCode/Valid Sudoku Solution.py
1,362
3.546875
4
class Solution: def isValidSudoku(self, board: List[List[str]]) -> bool: checkValid = [False] * 10 for i in range(9): for j in range(9): if board[i][j] != ".": if checkValid[int(board[i][j])] == True: return False ...
870eb4065cdcc78427c434c86e3d137dbbb6755d
junekim00/ITP115
/Assignments/ITP115_A6_Kim_June/ITP115_A6_Kim_June.py
7,001
4.09375
4
# June Kim # ITP115, Fall 2019 # Assignment 6 # junek@usc.edu # This program allows for airplane seat reservation, displays seat arrangement, and prints boarding passes. def main(): # setting initial empty seats seating = ["", "", "", "", "", "", "", "", "", ""] totalSeats = 10 filled = 0 ...
96988cac8c8e2cf8dd2bb33c9ab0f251a4f92554
ahmadabudames/Train-data-structure
/data_structure/preorderTraversal.py
608
3.625
4
class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def preorderTraversal( root): if root is None: return [] global ans ans = [] def preorder (root): global ans ans.append...
2a0ce67ed6914dfa1c41ae7646bcdd8cb5ec0325
technicaltitch/pipelines
/functions/dataframe.py
1,670
4.125
4
import pandas as pd def merge_dataframes(df_merge_list, how='inner', on=None): """ Merge a list (or dict) of dataframes using a shared column or the index """ try: # df_merge_list is a dict df_merge_list = df_merge_list.values() except AttributeError: # df_merge_list is alr...
deb094506bd1b121466383b03a85eca5f452aba9
BibiAyesha/Python
/UnHash.py
178
3.8125
4
def unHash(num): res="" letters= "acdegilmnoprstuw" num = int(num) while num >7: res = letters[int(num%37)] + res num = num/37 return res[1:]
11216033586c87d383e50492a27a71bf255d8fb6
ndminh4497/python
/Exercises 21.py
254
4.15625
4
def check_number(n): # n = int(input("Please enter an integer number:\n")) if (n % 2 == 0): return str(n) +" Is an even number" else: return str(n) +" Is an odd number" n = int(input("Please enter an integer number:\n")) print(check_number(n))
280194e23a3e3123254f558a5c663e78c21def17
mattkuo/gtfs-tools
/scripts/peuker.py
2,505
3.734375
4
import sys import math class Point(): """Represents a point on a map""" def __init__(self, shape_id, lat, long, point_num, traveled): self.lat = lat self.long = long self.shape_id = shape_id self.point_num = point_num self.traveled = traveled def __str__(self): ...
80f59bb4c4cb3f6956ea6986ecc710d4ff30987c
scyser/my_works
/Geodesy/pgz.py
577
3.9375
4
import math X1 = float(input("Введите X1: ")) Y1 = float(input("Введите Y1: ")) print("Введение дирекционного угла") grad = float(input("Введите градусы: ")) minut = float(input("Введите минуты: ")) sec = float(input("Введите секунды: ")) print(" ") d = float(input("Введите расстояние до точки 2: ")) alpha = math.ra...
908fd9e7fd4c6087092ccf1454c76fee351dd6c8
zasdaym/daily-coding-problem
/problem-062/solution.py
967
3.921875
4
from typing import List def count_ways(row: int, col: int) -> int: """ 1. Create 2d table to as "cache" table. table[i][j] contains number of ways to reach this coordinate from top-left. 2. All cells in first row and first column have only one way to reach them. 3. Any other columns possible ways is s...
78a6ac5c6ada68978155541f529d55032758961c
chris-mlvz/Python-for-Everybody
/12-Networked programs/using_urllib.py
750
3.625
4
# * Using a urllib in Python # import urllib.request # import urllib.parse # import urllib.error # fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt') # for line in fhand: # print(line.decode().strip()) # * Like a file... # import urllib.request # import urllib.parse # import urllib.error # fhand =...
08e43464c83418749a11ce7c71ecd79af23f2c71
Archit9394/BOOTCAMP_Python_Functions
/task12.py
194
3.84375
4
# 12. Write a function to compute 5/0 and use try/except to catch the exceptions def divide(): return 5/0 try: divide() except ZeroDivisionError: print ("The denominator is zero")
f930e3eebd9d520fd8ffe9e1ce76b1458f8f0a2d
alizkzm/BioinformaticsPractice
/Bio4_2.py
4,042
3.5
4
import math class Tree(object): def __init__(self,N=-1,bidirectional = True): self.nodes = list(range(N)) # {node : age} self.edges = {} self.bidirectional = bidirectional self.N = N self.weight = {} def half_unlink(self, a, b): links = [(e, w) for (e, ...
f5774ea2fdc3048eea43e9822b4169290c28640f
lcnodc/codes
/09-revisao/practice_python/hangman.py
2,935
4.46875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Exercise 32: Hangman This exercise is Part 3 of 3 of the Hangman exercise series. The other exercises are: Part 1 and Part 2. You can start your Python journey anywhere, but to finish this exercise you will have to have finished Parts 1 and 2 or use the solutions (Par...
0a1c886ea2e08e76800a990a6834761f2bfc3e0b
18sby/python-study
/vippypython/chap8/demo8.py
519
3.875
4
# 集合的数学操作 s1 = { 10, 20, 30, 40 } s2 = { 20, 30, 40, 50, 60 } # 交集操作 intersection = &,不更改原集合 print(s1.intersection(s2)) print(s1 & s2) # 并集操作 union = | ,不更改原集合 print(s1.union(s2)) print(s1 | s2) # 差集操作 s1.difference(s2) 在 s1 中除去 s1 和 s2 的并集 print(s1.difference(s2)) print(s1 - s2) print(s2.difference(s1)) print(s2 ...
970146e52061c35f09465a60c060f156c9417d71
laukikpanse/Python-Practice-Examples
/Practice3.py
234
4.3125
4
'''Write a Python program which accepts the radius of a circle from the user and compute the area''' radius = int(input("Please enter the radius of the Circle: ")) print("The area of this circle is: {0}".format(3.14 * (radius**2)))
34ed72c6902bd461f26f20ea10aac276bec3a750
fsym-fs/Python_AID
/month01/simple_mall/my_shopping.py
5,237
3.734375
4
# 简单商城 class Merchants_Views: pass class Merchants_Controllers: pass class Shopping_Models: def __init__(self, name, price, number, id): self.name = name self.price = price self.number = number self.id = id class Shopping_cart_Models: def __init__(...
bc8a0652480153aba374378e646fe4bf9aa56885
EdikCarlos/Exercicios_Python_intermediario
/ex_Matriz2.0.py
701
3.6875
4
matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] par = 0 soma = 0 maior = 0 for l in range(0,3): for c in range(0,3): matriz[l][c] = int(input(f'Digite o valor na posição [{l}, {c}]: ')) if matriz[l][c] % 2 == 0: par += matriz[l][c] if c == 2: soma += matriz[l][c] i...
5fbf448dda046aaba7d3a52b1b011e96604b3bf1
forest-float/python
/03/线程.py
2,577
3.75
4
# -*- coding: utf-8 -*- # @Author: wlp # @Date: 2020-04-08 14:12:15 # @Last Modified by: forest-float # @Last Modified time: 2020-04-08 15:01:04 import _thread import time def thread_function(threadName, delay): n = 5 while n > 0: time.sleep(delay) n -= 1 print(time.ctime(time.time()), threadName) try:...
ea48bc97395027293178fe58071b453441240bd1
NiltonGMJunior/hackerrank-python
/text_wrap.py
626
3.859375
4
import textwrap # My solution without textwrap (works fine) # def wrap(string, max_width): # lines = [] # total_length = 0 # for i in range(len(string) // max_width): # lines.append(string[i * max_width : (i + 1) * max_width]) # total_length += max_width # if total_length != max_width: ...
4c7626742b0773a9f838d90a6cd3a6cc3eb3f8a5
nirupamaBenis/FAIRnessOmicsRepositories
/apiSearch.py
15,937
3.609375
4
## Import packages required for the search import dill import math import numpy import re import pandas ## Function to parse json or xml files from the API responses def getParsedOutput(apiLink, respType): import requests import json resp = requests.get(apiLink) searchResult = resp.text ...
62c0978cec5f9d589fe7ce3c9378824e98ada987
rueuntal/AdventofCode2020
/scripts/day3.py
1,274
4.1875
4
def data_parser(): """ Parse out data in ../data/day3.txt Returns: list: list of str where each string shows open space and trees in one row. """ file_path = '../data/day3.txt' with open(file_path, 'r') as stream: raw = stream.readlines() out = [x.strip() for x in raw] re...
a7b1ecdfa56e96e9c93097f685486f134e685bb3
zzsyjl/crack_the_coding_interview
/chap03栈和队列/01三合一.py
1,800
3.84375
4
import unittest """ 用一个数组实现3个栈 思路: 一个线性的数组, 是怎么实现这个的呢? 可以加一个计数器, 每个栈都有计数. 就弄三个平行的吧. 我们可以增加一下难度, 把3换成n, 那么这样就需要不固定数量的函数了. """ class ManyStacksInOne: def __init__(self, n) -> None: self.n = n self.array = [] self.len_max = 0 self.lens = [0] * n def push(self, i, num): le...
fbe33798e2bf01ba4c38621cb4b91f61cc0a69ad
duynhatldn/pythonCode
/venv/lib/python2.7/code/python/BigSorting/BigSorting.py
329
4.03125
4
import os import sys def bigSorting(unsorted): return sorted(unsorted) if __name__ == '__main__': n = int(raw_input()) unsorted = [] for _ in xrange(n): unsorted_item = raw_input() unsorted.append(long(unsorted_item)) result = bigSorting(unsorted) for x in result: ...
d34ad946c62da37ce38b4555205a4c9c2ee21650
silvioedu/TechSeries-Daily-Interview
/day15/Solution.py
1,091
3.671875
4
def arraySquare(nums): square = [] [square.append(pow(i, 2)) for i in sorted(nums)] return square def findPythagoreanTriplets(nums): n = arraySquare(nums) # print(nums) for a in (range(len(n) - 2)): # print("a -> ", nums[a]) for b in (range(a + 1, len(n) - 1)): ...
a49ab6ceec93af3f922e82b77b12aedece2491ea
ntuckertriplet/Advent-Of-Code-2019
/day1/day1.py
476
4.03125
4
def calculate(mass): return mass // 3 - 2 def recurse(int_input): final = int_input // 3 - 2 if final <= 0: return 0 return final + recurse(final) final_answer_part_1 = 0 final_answer_part_2 = 0 with open("data.txt", "r") as file: data = file.readlines() for line in data: f...
51298ab6d1e8f086179776b20cd4d528f60c8855
ahmedfahmyaee/Cyber-Security
/Ciphers/demonstration.py
3,275
4.1875
4
import math from matplotlib import pyplot from string import ascii_lowercase from collections import Counter """ This is a module to demonstrate how the Caesar Cipher works and how it can be broken using frequency analysis In addition this module contains a function which plots 2 graphs to illustrate how freq...
262b70798ea2fc9e060604ba6f8313402783a0ec
rndviktor2devman/11_duplicates
/duplicates.py
2,001
3.71875
4
import os import sys import shutil def are_files_duplicates(file_path1, file_path2): if os.path.basename(file_path1) == os.path.basename(file_path2): if os.path.getsize(file_path1) == os.path.getsize(file_path2): return True return False def are_folders_duplicates(folder_path1, folder_p...
ad351ca484312ebb24ecc713e6509d76cbc42a92
bopopescu/Glowing-Grass
/NicksGardens/venv/Pseudocode.py
420
3.765625
4
import datetime customer_details_csv = open('contact_details.csv', 'r').read() day = int(input("Input day: ")) month = int(input("Input month: ")) year = int(input("Input year: ")) date = str(datetime.date(year,month,day)) print(date) if date in customer_details_csv: print("Date used") else: print("Date not ...
a0eb02a5455ec95869bc79c5ccce98167d027b88
sf19pb1-petercooper/graph_paper
/graph_paper_1.py
753
3.875
4
import sys rows = int(input("How many rows of boxes? ")) columns = int(input("How many columns of boxes? ")) row_spaces = int(input("How many rows of spaces in each box? ")) column_spaces = int(input("How many columns of spaces in each box (e.g., 3)? ")) for i in range(rows): for i in range(columns): print("+...