blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
542aaa5ad309ea0202940209291a0d88d830752c
BabuGumpu/PythonProject
/src/trust_fund_bad.py
250
3.859375
4
print( """ Please Enter the requested,monthly costs """ ) car = int(input("Enter Car -- ")) rent = input("Enter Rent -- " ) food = int(input("Enter Food -- ")) total = int(car) + int(rent) + int(food) print("\n Grand Total -->",long(float(total)))
be54ac7925ba7dfb2848a52b902c67fdc18b8bde
bonus-tm/euforia
/events/vizier.py
5,977
3.640625
4
# Визирь from event import Event class Vizier(Event): """ Визирь Армия: довольствие, дезертиры Население: рождаемость, смертность, недовольство, голод Урожай: засухи-наводнения, урожайность, крысы Визирь: украл золото и скрылся """ def __init__(self, data, say, ask): self.data ...
ffb145ebef92d4a9a1cf9c5ecb97129219d09391
ErisonSandro/Exercicios-Python
/exercicios/ex044Gerenciador de pagamentos.py
1,139
3.765625
4
print('=' * 10, 'Loja Nene', '=' * 10) preço = float(input('Preço das compras: R$ ')) print('Forma de pagamento:') print('[1] à vista dinheiro / cheque') print('[2] à vista no cartão') print('[3] 2x no cartão de credito') print('[4] 3x ou mais no cartão de credito') opção = int(input('Qual é a sua opção: ')) if opçã...
726072a543a2208b184e61c1284ec4ffd408f0d7
sivakurella/python-programming
/Python Scripts/Binary_tree.py
687
3.890625
4
class Node: def __init__(self, value=None): self.value = value self.left = None self.right = None class BinaryTree: def __init__(self, root=None): self.root = root # Add `insert` method here. def insert(self, value): if not self.root: self.root =...
312ab3b07594f45eb9fa3b3c1ac67346fc9b9ef8
glayn2bukman/jermlib
/fuel.py
6,014
3.65625
4
''' this module calibrates a fuel tank for the fuel sensor the module then stores the tank details in a global jfms data library ''' false = False # just in case i forget I'm in Python and not C++ def read(pin=23, against=0): ''' read the height(or volume?) value on the RPi sensor if `against` is given, t...
7f9ec22771bc635ef95deb23d4a04ddb39177256
harman666666/Algorithms-Data-Structures-and-Design
/Algorithms and Data Structures Practice/LeetCode Questions/String/647. Palindromic Substrings.py
1,435
4.28125
4
''' 647. Palindromic Substrings Medium 1753 88 Favorite Share Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Example 1: Input: "abc" Outpu...
bd59f0322ba2268faa921e3a1c93ef86bc633d8d
zhuqiangLu/leetcode
/JumpGame.py
529
3.734375
4
from typing import List class Solution: def canJump(self, nums: List[int]) -> bool: n = len(nums) dist = 0 for i in range(n-1): if i <= dist: dist = max(i + nums[i], dist) print(dist) if dist >= n-1: return ...
65ff86e12c9f6673be4e5b43d6bd40d7f593aa4a
dpebert7/TIdy
/TI.py
16,823
3.703125
4
# @title TI Class import re from defaults import DEFAULT_OUTDIR, DEFAULT_TAB def is_comment(line): """ Determine if a line is a comment """ strip = line.strip() if len(strip) > 0 and strip[0] == '#': return True return False def find_parentheses(s): """ Find and return the locati...
15abd9b50900c9cf56e440a34b453527d507f19f
Skipper609/python
/Sample/class eg/lab questions/1A/5.py
162
3.8125
4
'''''' inp_num = input("Enter a number :") res = "" for i in inp_num: res += str((int(i) + 1) % 10) print(f"The resultent for the input {inp_num} is {res}")
422abad6882219cd3df3d100aba8c382b3e8b032
Pekmen/dailyprogrammer
/Easy/e.53.py
97
3.75
4
#!/usr/bin/env python3 lista = [1, 5, 7, 8] listb = [2, 3, 4, 7, 9] print sorted(lista + listb)
86537efbcae42a9638222088cd5255b553e185a4
vlad17/deeprl_project
/src/keyboard_pong.py
1,048
3.734375
4
""" This file lets you play pong with the keyboard. Simply run this file and then enter 0, 1, 2, 3, 4, or 5 on stdin to make an action. """ import argparse import random import tensorflow as tf import numpy as np import atari_env def _read_action_from_stdin(): allowable_actions = ["0", "1", "2", "3", "4", "5"] ...
820a9b5b77d2b353208cd495992dc0702de1c1bf
i1196689/GitPython
/python_exercise/day_11.py
746
3.609375
4
#敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换,例如当用户输入「北京是个好城市」,则变成「**是个好城市」。 import os s=input("intput:") filePath="D:\\test\\" fileName=os.listdir(filePath) with open(filePath+fileName[0],encoding="utf-8")as f: context=f.readlines() #去掉空格 def Rep(st): return st.replace("\n","") #代替*的数量 def R...
b092ee0df9f4c49676af20b90191cdfd3a331798
BenYanez/Yanez_Ben
/PYLESSON_03/RudeAI.py
845
4
4
name = input("What is your name?") print(name , "?!! Why would anyone name a baby that?") old = input("How old are you,Ben?") print(old , "Oooooo!!! 14 is getting up there.") fun = input("What do you do for fun, Ben?") print(fun , "? I thought only nerds like to play soccer?") music = input("What kind...
1413a0848d7548cf3e353307c6d1a562c86f44de
shivamnamdeo0101/Pyhton_OOPS
/OOP_8_Ques.py
314
3.78125
4
class Simple(): def __init__(self,value): self.value = value def add_to_value(self,amount): print("{} Added To Your Account".format(self.value)) self.value = self.value +amount myobj = Simple(300) myobj.value myobj.add_to_value(300) print("Your Current Balance Is : ",myobj.value) print(myobj.value)
5d2101c72d077a2ece51c28dd0fad958f2618c03
WinCanton/PYTHON_CODE
/SumSquareDifference/sum_square_diff.py
173
3.671875
4
# setup a list containing the first 100 natural numbers numbers = range(1,101,1) # calculate the difference diff = sum(numbers)**2 - sum([x*x for x in numbers]) print diff
875fd11b9edbcf975c9f18ffab2f60e98a7fdffb
jambran/elite_speak
/models/define.py
1,793
3.625
4
from PyDictionary import PyDictionary from models import words def generate_definitions(word_list, lemmatizer): """ Gets dictionary definitions for passed words. Only deals with nouns, verbs, adjectives, and adverbs as there aren't really any other types with "obscure" lexical items. Uses PyDictionary...
b00889eacd46136d3832062f93f5afc3900b5013
itscrisu/pythonPractice
/Ejercicios/listaDeEjercicios.py
2,608
4.125
4
# Multiplicar dos números sin usar el símbolo de multiplicación a = 2 b = 8 resultado = 0 for x in range(a): resultado += b print(resultado) # Ingresar un nombre y apellido e imprimelo al revés nombre = 'Cristian' apellido = 'Dominguez' ambos = nombre + ' ' + apellido print(ambos[::-1]) # Intercambiando va...
c5cf8a111f3e83fa96f1343bc8b3efa6836bcdb2
malayh/neural_network
/randomTest.py
103
3.78125
4
x=[3*a for a in range(0,10)] for c,i in reversed(list(enumerate(x))): print("{} {}".format(c,i))
fd4fc12f7cd9b3160191d174f55483d4553ffba0
jiangliu2u/PythonCoreLearn
/LearnDaemon.py
567
3.640625
4
import threading from time import ctime, sleep def loop1(): print('start loop1 func at:',ctime()) sleep(5) print('end loop1 hhhhh') def loop2(): print('star loop2 func at:',ctime()) sleep(2) print('end loop2') def main(): threads = [] t1 = threading.Thread(target=loop1) t1.setDaemon(True) threads.append(...
0e5b0ac41f8fb927a2fb999c6cb98ab5bc871cad
ranggamd/Simulasi-Dadu_Rangga-Mukti
/Dadu.py
709
3.78125
4
import random putaran= {} def putardadu(min, max): while True: print("Memutar Dadu.....") angka = random.randint(min, max) if angka in putaran: putaran[angka] +=1 else: putaran[angka] =1 print(f"Kamu Dapat Angka : {angka}") choic...
d2aab00a704ac0ab7bd23e82331e9a8c9dc7ff23
mak131/Pandas
/3.csv/5.how to write in csv file in pandas (prefix) parameter v6.py
1,089
4.09375
4
import pandas as pd df = pd.read_csv("E:\\code\\Pandas\\3.csv\\Bill_details23.csv") print(df) print() # this method is used to change header using header parameter # if none header change to string header # so this method is used both parameter header and prefix but Header =None prefix_data = pd.read_csv("E:\\code\\Pa...
6c76aeb69324ac2db3bd37c9c82c95cf5e6db9f0
SixuLi/Leetcode-Practice
/Second Session(By Frequency)/994. Rotting Oranges.py
926
3.671875
4
# Solution 1: BFS # Time Complexity: O(mn) # Space Complexity: O(mn) in the worst case from collections import deque class Solution: def orangesRotting(self, grid: List[List[int]]) -> int: queue = deque() m, n = len(grid), len(grid[0]) level = 0 for r in range(m): fo...
9d79d51d832f0f97c03990c05b2ae62e9f57a6fc
carden-code/python
/stepik/old_problem.py
449
3.625
4
# There is 100 rubles. # How many bulls, cows and calves can be bought with all this money if the payment for # a bull is 10 rubles, for a cow - 5 rubles, for a calf - 0.5 rubles and you need to buy 100 head of cattle? # # Note. Use a nested for loop. bull = 10 cow = 5 calf = 0.5 for i in range(1, 100): for j in ra...
4973420e7b132def09cfedfa6cdae3c4b5a971fe
macinspiresedu/python
/programs/rot13.py
328
4.03125
4
text = input("Please enter what you want me to translate: ") result = '' for c in text: if c >= 'a' and c <= 'z': result += chr(((ord(c) - ord('a') + 13) % 26) + ord('a')) elif c >= 'A' and c <= 'Z': result += chr(((ord(c) - ord('A') + 13) % 26) + ord('A')) else: result += c print ...
8a4ea9ea9c8aaaca9de6c7ae32eff346f8144c22
kim-soohan/2018_PythonStudy
/PythonBasicAlgorithm/p03_3_1.py
753
3.703125
4
# -*- coding: utf-8 -*- #n명 중 두 명을 뽑아 짝을 짓는다고 할 때, #짝을 지을 수 있는 모든 조합을 출력하는 알고리즘을 만드시오 #예를 들어 "Tom", "Jerry", "Mike" 라면 Tom - Jerry / Tom - Mike / Jerry - Mike def bindPerson(a): n = len(a) for i in range(0, n-1): for j in range(i+1, n): if a[i] != a[j]: print(a[i],"-", a[j]...
7aa73f4c3be5943ee43f5d8976882969deee1099
AnastasiiaPosulikhina/Python_course
/lab4/lab_04_07.py
5,817
3.65625
4
class Row: id = 1 # идентификатор строки def __init__(self, collection, value): self.id = Row.id Row.id += 1 self.collection = collection # список значений переменных для текущего значения функции self.value = value # значение функции def display(self): # вывод таблицы на экр...
78cd87c5b8cf572d54fcc7c451626aa800c8fffe
Deekshaesha/Python
/maths/factorial_python.py
85
3.828125
4
n = int(input("Enter a number")) s = 1 for i in range(1,n+1): s*=i print (s)
aee0990db5d58b8a412d602b02641a26ac57eef3
cmanny/expert-octo-garbanzo
/mathematics/fundamentals/find_point.py
223
3.578125
4
import sys def find_point(px, py, qx, qy): return (2*qx - px, 2*qy - py) if __name__ == "__main__": n = int(input()) for _ in range(n): print(" ".join(map(str, find_point(*map(int, input().split())))))
390841c12e02773b297f12f5beabc0cfdab274d9
Spartabariallali/Pythonprograms
/pythonSparta/Listsparta.py
724
4
4
#lists #manage data #access data #add, remove data # syntax variable = [] , () = tuple, dictionary {key:value} pairs #tuples are immutable # guestlist = ["Muhammed Ali","Mike Tyson", "Tyson Fury","Don King"] # print(guestlist[3]) # guestlist[3] = "Roy Jones jr" # replaced the data at index 3 with the new data # p...
268e753e855e3df702576f318cd4c17a00cbec9f
charlesats/curso_python
/pythonExercicios/ex022.py
1,173
3.84375
4
# Elabore um programa que calcule o valor a ser pago por um produto, # considerando o seu preço normal e condição de pagamento: # # – à vista dinheiro/cheque: 10% de desconto # # – à vista no cartão: 5% de desconto # # – em até 2x no cartão: preço formal # # – 3x ou mais no cartão: 20% de juros# print('=-=' * 5, 'Loja...
58bcb93d45999ce3d86221e6acb7d2c49e80113a
thelmuth/cs110-spring-2019
/review_turtle.py
575
4
4
import turtle, math def main(): t = turtle.Turtle() t.fillcolor("coral") t.begin_fill() t.up() t.backward(150) t.down() height = math.sqrt(60 ** 2 - 30 ** 2) for _ in range(2): t.forward(300) t.left(90) t.forward(height) t.left(90)...
fef6da3597d671e772702a7f5506dfeb61e125c5
Mauricio-Amr/TF_Faculdade
/LIST_PLP_01/05.py
639
4.03125
4
''' ----------------------------------------------------------------- UNIVERSIDADE PAULISTA - ENG COMPUTAÇÃO - BACELAR Nome: Mauricio Silva Amaral RA : D92EJG-0 Turma : CP6P01 Data: 09/10/2021 Lista: 01 - 05 Enunciado: 05 – Escreva um programa que calcule a soma de três variáveis e impri...
093383cec9e0d92911b52647584352b452cd5161
hartnetl/unitTest-lessons
/refactor-lesson/test_evens.py
995
4.03125
4
import unittest from evens import even_number_of_evens class TestEvens(unittest.TestCase): # Remember test names MUST start with the word test # Keep them related def test_throws_error_if_value_passed_in_is_not_list(self): # assertRaises is a method from TestCase and when ran will check if a ...
02c925ced562e543ce1dcd98ec15bd5884b134f4
ajmathews/Algorithms-Python
/LinkedListPalindrome.py
1,150
3.890625
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def isPalindrome(self, head): """ :type head: ListNode :rtype: bool """ fast = head slow = head whi...
4f5d9b68529998efef5e51b2f724735a81fe1237
sandrews98/400B_Andrews
/Homeworks/Homework5/CenterOfMass.py
14,462
3.5625
4
# Homework 4 # Center of Mass Position and Velocity # Samantha Andrews #2/9/20 ############################################################################### # Keep in mind this is just a template; you don't need to follow every step and feel free to change anything. # We also strongly encourage you to try to develop...
db209d1295e7fd3279e1889876fdb533fdd39c9e
jguardado39/A-Kata-A-Day
/Python/find_short.py
854
4.375
4
def find_short(s): """ Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. """ text_array = s.split() shortest_word = len(text_array[0]) for i in range(1,len(text_array)): if len(text_array[i]) < sh...
e94e3658282b9f6b67a6773d2ae3efb0e98c3de0
sherlocklock666/shuzhifenxi_python
/第一章上机程序/chapter1_17_2.py
174
3.546875
4
j = 2 N = 10**2#从2到N S_N = 0 S_N_list = []#S_N的每次输出值列表 while j <= N: M = 1/(N**2-1) S_N = S_N + M S_N_list.append(S_N) N -= 1 else: print(S_N_list)
ec07d64f6b8f58db398e0149ac81b799ea7736f7
Kevin-Howlett/edabit-problems
/sum_dig_prod.py
482
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 28 19:16:54 2019 @author: kevinhowlett """ #Function that takes numbers as arguments, adds them together, and #returns the product of digits until the answer is only 1 digit long def sum_dig_prod(*argv): num = 0 for arg in argv: ...
2ca368fb3ab88a17a73b001f7e23c20fcf578d56
point800411/YZU_python
/Lesson03/Cass 03.py
297
4
4
# 函式(有回傳值) def add(x, y): sum = (x + y) * 1.03 return sum # 函式(無回傳值) def addAndPrint(x, y): sum = (x + y) * 1.03 print(sum) return print(((1 + 2) * 1.03)) print(((2 + 5) * 1.03)) print(add(1, 2)) print(add(2, 5)) addAndPrint(1, 2) addAndPrint(2, 5)
3388cc6602ea2e03f7014158903e9791c57bd4b2
ShashankRaturi/Python-Projects
/3_Hirst Painting/src/Other patterns/shapes.py
428
3.875
4
import turtle as t import random from color import random_color t.colormode(255) tur = t.Turtle() tur.shape('turtle') ################# different shapes ########### def shape(num_of_sides): angle = 360 / num_of_sides for i in range(num_of_sides): tur.forward(100) tur.right(angle) for...
77e1ca633a92d9a27c09a72dfa410c3acee5c4e4
Rauldsc/ExercisesPython
/basic1/ex68.py
202
3.90625
4
""" Write a Python program to calculate the sum of the digits in an integer. """ def digits(num): n = str(num) sum = 0 for i in n: sum += int(i) return sum print(digits(18145))
c44893d9901e49d83bc76e229de4ed79c226ee7c
Gabriel-Coutinho0/Lista-1
/EX 1.py
70
3.703125
4
a = int(input('Número: ')) b = int(input('Número: ')) print (a + b)
e7b526b28cac9b19848978082fe9ccf11c808514
pablogonz/programas-lorenzo
/FactorialIterativo/FactorialIterativo.py
236
4.28125
4
# Factorial forma iterativo n= int(input(" introduzca un numero que desea sacarle factorial ")) def Factorial(n): factor = 1 for i in range(factor, n + 1): factor = factor * i return factor print(Factorial(n))
5e78ed1cdcac1c2396702a6e5ddbcf11af7fff94
draganmoo/trypython
/Python_Basic/list/generator_4_multiconcurrent.py
3,128
3.765625
4
import time """ 通过生成器进行单线程下的并发 故事是这样的: 三个消费者一个生产者 生产者生产包子给三个消费者吃 """ def consumer(name): print('消费者%s准备吃包子啦~~'% name ) while True: baozi = yield print('消费者%s接收到包子编号%s'%(name,baozi)) """注意: 此时并没有调用consumer函数,虽然用consumer(),但其实是赋值给了一个变量 只有这个变量后面加小括号或者指令,才是真正调用这个函数""" c1 = consumer('...
2a1801df465d749be78efd3978b199678429f211
bakunobu/exercise
/1400_basic_tasks/chap_5/5_87.py
283
3.796875
4
def find_nums(a: int) -> list: nums = [] for _ in range(3): num = a % 10 a //= 10 nums.append(num) return(nums) def count_nums(a:int=100, b:int=500) -> int: nums = [x for x in range(a, b+1) if sum(find_nums(x)) == 15] return(len(nums))
376e04dab7ff683d3d109da713f1732885be91a7
VanJoyce/Algorithms-Data-Structures-and-Basic-Programs
/Trie.py
11,959
4.09375
4
""" Vanessa Joyce Tan 30556864 Assignment 3 """ class Node: """ Node class for the Trie. """ def __init__(self): """ Creates a node with a list of links for every lowercase English alphabet character and a terminal character, and frequency. :time comple...
1358e576ef240044c338df3be473d78745aa8d32
Aasthaengg/IBMdataset
/Python_codes/p03624/s532165923.py
212
3.84375
4
s_list = list(input()) result = None for s_uni in range(ord('a'), ord('z') + 1): if not chr(s_uni) in s_list: result = chr(s_uni) break if result: print(result) else: print('None')
2ea137ab340db7d78dcc252370f0b5b60639401d
ash6327/SQLite3beginner
/sql3.py
815
4.09375
4
import sqlite3 conn = sqlite3.connect('Movies.db') cur = conn.cursor() cur.execute('''CREATE TABLE IF NOT EXISTS movie (movie_name TEXT, movie_actor REXT,movie_actress TEXT, movie_year INTEGER,movie_director TEXT)''' ) movies = [ ('Mr robot','Rami Malek','Carly Chaikin','2015','Sam Ishmail'), ('Kuruti','Ro...
d2151f2507379face1da3fc2267f36581ea36bfa
vsikarwar/Algorithms
/Graph/Graph.py
1,645
3.515625
4
''' Created on Mar 9, 2016 @author: sikarwar ''' class Graph: def __init__(self, nodes=0): self.n = set(range(nodes)) self.g = {} self.e = set() self.w = {} def add(self, a, b, weight): self.g.setdefault(a, []) self.g[a].append(b) edge = (a, b) ...
90c529c6af8cf5dabca846a2c9f10def5e3b3798
teenageknight/Python-Beginner-Projects
/Random/Sydney/solution.py
188
4
4
number1 = int(input("What is the first number?\n")) number2 = int(input("What is the second number?\n")) sum = number1 + number2 print("The sum of", number1, "and", number2, "is", sum)
ecbb445f7610eecb78b7b9a8e48cf86f65e81225
shubham14/Coding_Contest_solutions
/DS-Algo/quicksort.py
603
3.921875
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 8 14:27:20 2018 @author: Shubham """ import numpy as np def Quicksort(A, start, end): if (start < end): p = Partition(A, start, end) Quicksort(A, start, p-1) Quicksort(A, p+1, end) def Partition(A, start, end): i = start - 1 ...
fb4925921f17f7c7b8bfa4ffd6f7198cc7a59e0a
JamesPiggott/Python-Software-Engineering-Interview
/Multithreading/Multithreading.py
786
4.0625
4
''' Multi-threading. This is the Python implementation of Multi-threading. Running time: ? Data movement: ? @author James Piggott. ''' import time import threading threads = [2] def printsomething(): print("Starting: ",threading.current_thread().getName()) time.sleep(2) print("Exiting: ",...
25c59fc2724d26b6f94da86d4b166b536568378a
JerryZhuzq/leetcode
/Tree/105. Construct Binary Tree from Preorder and Inorder.py
1,481
3.765625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: if not preorder: ...
8c98f464e41ab55ffbb6b88020d8f6806ea5695d
jdbr827/ProjectEuler
/ProjectEulerProblem56.py
375
3.703125
4
""" Project Euler Problem 56 Considering natural numbers of the form a^b, where a, b < 100, what is the maximal digit sum? """ def digit_sum(n): return sum([ord(i) - ord("0") for i in str(n)]) def solve(): best = 0 for a in range(1, 100): for b in range(1, 100): this = digit_sum(a**b) if best ...
389c53c753cea4596d97e5bfdfc983635be81a2c
cesarsst/PythonProjects
/PythonTeste/Aula09a.py
2,126
4.15625
4
# Manipulando Texto em Python frase = 'Curso em Video Python' # Fatiamento print(frase) print(frase[9]) # Pega a 9 letra da cadeia de caracteres da variavel frase print(frase[9:14]) # Pega do 9 até o 14 (mas vai até o 13, para de conta do 14) print(frase[9:21]) # Apesar de...
f21e2a814f72493d12a75ffe06b81b590d9a5882
yhxddd/python
/阶乘.py
217
3.546875
4
def jiecheng(n): result= n for i in range(1,n): result *= i return result number = int (input("输入一个整数:")) rel = jiecheng(number) print("%d 的阶乘是:%d" %(number,rel))
03528ffb2adde11fbadee01ce1a9906f90f8a7e0
SinglePIXL/CSM10P
/Testing/8-26-19 Lecture/twoNames.py
252
4.28125
4
# We get two names from the user # Then we write them in alphabetical order name1 = input('Enter the first name: ') name2 = input('Enter the second name: ') if name1 < name2: print(name1) print(name2) else: print(name2) print(name1)
da98fdbce014d046498f48662c3ab0eca555f0e8
neasatang/CS3012
/test/directedAcyclicGraph.py
3,656
3.5
4
import sys class DAG(object): # prints graph #def print_graph(self, graph): # print(graph) # prints the nodes from a list from graph #def print_node_list(self,list): # print(list) # create empty set for nodes for the DAG def __init__(self): self.create_graph() # cre...
5dee320d1fd1a2d3215ae0d2594695be7e5639a6
bikramjitnarwal/CodingBat-Python-Solutions
/Logic-2.py
3,759
4.03125
4
# make_bricks: # We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big # bricks (5 inches each). Return True if it is possible to make the goal by choosing from the given bricks. This is # a little harder than it looks and can be done without any loops. def ma...
552e90db821481db33782fbf212ba1911574660a
Hrocio/Python-Programs
/palindrome.py
851
4.40625
4
def word_palindrome(word): '''Function which return reverse of a string. It also works with numbers. any string containing just one letter is by default a palindrome. ''' if len(word) < 2: # Can be less than 2. return True if word[0] != word[-1]: # Comparing input string with the reverse s...
43c6c043624d3f86127bcd0ab897ee7295dd9681
chelseashin/My-Algorithm
/daily_study/ProblemSolving/7490_0만들기.py
1,033
3.53125
4
# 자연수 N의 범위(3 <= N <= 9)가 매우 한정적이므로 완전탐색으로 문제 해결 # 수의 리스트와 연산자 리스트를 분리하여 모든 경우의 수를 계산(재귀함수 이용) # 파이썬의 eval() 함수를 이용하여 문자열 형태의 표현식을 계산할 수 있다. import copy def solve(arr, n): if len(arr) == n: # 가능한 모든 경우 연산자 리스트에 담기 opLSt.append(copy.deepcopy(arr)) return arr.append(' ') solve(arr, n...
b832a8dbf51c93f41c244dcdcded6ce8e7c09542
abonybear/my-python-learning-journal
/a4/4-3.py
114
3.5
4
nums = [num for num in range(1, 21)] print(nums) nums = list(range(1, 1000000)) print(nums) print(sum(nums))
adc4cdc018101b7382d3c6ec6481c99800d126b5
AakSin/CS-Practical-FIle
/Reference/Lab Reference/list worksheet/Q5.py
1,115
3.953125
4
l=eval(input("Enter a list")) print("what do u want to do","Add=0","modify=1","delete=2","sort=3","display=4","exit=5",sep="\n") a=int(input()) while a!=5: if a==0: b=int(input("what do u want to add")) l.append(b) print(l) elif a==1: c=eval(input("what do u want to add")) ...
85907ce4488e8972e66a3619b3d4bc274eb4c2de
TalhaBhutto/Ciphers
/Network Security/RouteCipher.py
1,213
3.90625
4
def encrypt(Data,key): l=len(Data) l2=0 temp="" num=0 while((l/key)%1): l=l+1 Data=Data+"X" col=int(l/key) while(l2<l): temp=temp+Data[(l2%key)*col+num] l2=l2+1 if(l2%key==0): num=num+1 return temp def decrypt(Data,key): ...
69138ee2f67046683fcd2c347946f898fe7dd68e
avinash-rao/Python
/mean_median_mode.py
630
4.125
4
print("Enter the numbers: ") nums = [] n = 0 # to store the length of nums while True: num = input() if num == '': break nums.append(int(num)) n += 1 nums.sort() # Find out mean mean = sum(nums)/n # Find out median if n % 2 == 0: #If total number of elements is even ...
767af29611bf05af512b6ff16abf582d2a96605d
DebasishMohanta/turtle
/practice/Georgias_Spiral_trial.py
442
4
4
import turtle wn=turtle.Screen() wn.bgcolor("black") tina=turtle.Turtle() tina.shape("turtle") tina.pensize(2) def draw_circle(x): for i in range(60,120,x): tina.speed(0) tina.circle(i) def draw_special(x): for _ in range(10): draw_circle(x) tina.rt(36) colors=["white","yellow...
1fa7a74cb60d2df344c9b163342659fc67cee298
patkennedy79/picture_video_file_organizer
/PictureVideoFileOrganizer/DirectoryWithDateSubfolders.py
3,548
4.34375
4
from os import listdir, mkdir, chdir from os.path import isfile, join, isdir from shutil import copy2 from string import replace from Directory import Directory from File import File """ Purpose: This class defines a directory that contains any number of directories that are named by date that will be co...
ceeb4cbb0fe375017ad2ef6ed5908bc4b636be8e
rashmiiiiii/python-ws
/REGULAR EXPRESSION/re6.py
151
3.8125
4
import re data = "Learning- Python, is fun. Python_programming is, easy" data= re.sub(r"-|_|,|\s+"," ",data) data ==re.sub(r"\s+"," ",data) print(data)
4efccf79d7fc734d0e2e58aa6f9097eb69c46985
HAMDONGHO/USMS_Senior
/python3/python_Practice/rockScissorPaper.py
494
3.859375
4
import time, random print('play rock/scissor/paper') play = True while play: player = input('select : ') while (player != 'rock' and player != 'scissor' and player != 'paper'): player = input('select : ') computer = random.choice(['rock', 'scissor', 'paper']) time.sleep(1) if(pla...
34d66e23792573a25fbe48906985d92c9a45ee17
xielongzhiying/python_test100
/61-80/69.py
362
3.828125
4
# -*- coding: UTF-8 -*- #有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数 n = int(input("n个数")) m = int(input("后移m位")) list = [] for i in range(n): list.append(input("data:")) print(list) for i in range(m): for j in range(n-m+1): list[i],list[i+j] = list[i+j],list[i] print(list)
86b242bcb4b4e3fb5e91fb76bb85cf1be2b314a7
jaylenw/helioseismology
/omegas/main.py
2,414
3.578125
4
from gamma1 import omegaP #importing omegaP fxn from gamma1 file from gamma1 import omegaGsquared # ' ' from gamma1 import omegaG # ' ' from plotting import plotomegaP #importing plotomegaP fxn from plotting file from plotting import plotomegaGsqrd # ' ...
5640b1a265006bffd381c46428859bf0c2dee58b
cyclades1/Python-Programs
/p8.py
86
3.828125
4
'''input 13 ''' n = int(input()) if(n%2==0): print("EVEN") else: print("ODD")
b1b9167d445bc301fd534a795c1aec1b3efe9c2f
ramyamango123/test
/python/python/src/python_problems/other_python_prob/regex_special_characters.py
487
3.703125
4
import re p = 'Python is a #scripting language edited new I am learning to? test it!' #x = 'Python is a #scripting language edited new\n', 'I am learning to? test it!' #pattern = re.search("(\w+)\s+(\w+)", p) #pattern = re.search("(.*)", p) pattern = re.search("(\w+.*)\#(\w+)\s+(.*)\?(\s+\w+\s+\w+)\!", p...
4638a95633b9dc9f06fcf18986efc796b06b3672
oreHGA/HomicideAnalysis
/sort_by_rel.py
1,549
3.796875
4
''' File name: homicide_year_sort.py @author: James Boyden Date created: 4/30/2017 Date last modified: 5/8/2017 Sorts the list by relation, and finds the most common relationship between the victim and perpatrator. ''' def sort_by_rel(homicide_array, outputLoc): myfile = open(outputLoc, "...
ceb40a98b541f4c4d4f57e4dc8f0b55fddbe1e77
JKThanassi/2016_Brookhaven
/matplotLibTest/scatter_plot.py
716
4.1875
4
#import matplotlib.pyplot as plt def scatter_plt(plt): """ This function gathers input and creates a scatterplot and adds it to a pyplot object :param plt: the pyplot object passed through :return: Void """ #list init x = [] y = [] #get list length list_length = int(input("H...
8ad72e2a9edb6bdb75d24ad0199f2faa0c43d1aa
ponmanimanoharan/practice_files
/python-prac_till_functions/practice.py
8,743
4.28125
4
# Modify this program to greet you instead of the World! print("Hello, Ponmani Manoharan!") # Modify this program to print Humpty Dumpty riddle correctly print("\n") print("Humpty Dumpty sat on a wall,") print("Humpty Dumpty had a great fall.") print("All the king's horses and all the king's men") print("Couldn't put ...
b69a8a83e9088dc8bc14641ae5ef822831a2f044
CelsoAntunesNogueira/Phyton3
/ex032 - Ano bissexto.py
300
3.875
4
from datetime import date a = int(input('Digite um ano e falarei se é um ano bissexto ou não!E para analisar o ano atual digite 0:')) if a ==0: a = date.today().year if a % 4 == 0 and a %100 != 0 or a % 400 == 0: print('esse ano é bissexto!!') else: print('Não é um ano bissexto!')
2da91076cb9b04d12fc5c8b36e07b7435ab35d00
naresh14404666/guvi
/greater_number.py
165
3.921875
4
a=eval(input()) b=eval(input()) print("enter the numbers:") if(a>b): print(a,"is largest") elif(a==b): print("invalid") else: print(b,"is largest")
2889f294aece486287e2dda1272ab4d40eb359f4
bedekelly/crawler
/tests/test_parsing.py
998
3.515625
4
""" test_parsing.py: Test the functionality of the `parsing.py` module. These tests should be small and self-contained. """ import unittest from crawler.parsing import on_same_domain class TestParsing(unittest.TestCase): """ Test functionality inside the parsing module. """ def test_on_same...
588638e325affa108972eff42dfaf689b348f3fc
grimario-andre/Python
/exercicios/desafio26.py
548
4.0625
4
print('================== Contador de Letras ===================') nome = str(input('Informe o nome completo ')).strip().upper() #contador de letras 'a'. print('A letra aparece tantas {} vezes na fraze '.format(nome.count('A'))) #exibir em qual posição aparece a letra pela primeira vez. #print(letra[:].count('a')) pr...
c0e8a3cc295fad4d96bcf6933e1d5619c2a54b10
pureplayN/LeetCode
/leetcode/tests/_010.py
2,342
3.53125
4
import unittest from leetcode.solutions._010_regular_expression_matching import Solution class RegularExpressionTest(unittest.TestCase): def setUp(self): self.solution = Solution() def testPureStringNotMatch(self): s = 'aabbccdd' p = 'aabbcdd' self.assertFalse(self.solution....
0c0c2cc3abba32531c23322dce5e71be9b90c7c3
AlexanderHughSmith/BasicWordSeach
/ws.py
1,455
3.78125
4
def horizontal(ans,puzzle): for x in range (0,len(puzzle)): temp = "".join(map(str,puzzle[x])) if temp.find(ans) > -1: print("Right to Left: ("+str(temp.find(ans)+1)+","+str(x+1)+")") return True if temp.find(ans[::-1]) > -1: print("Left to Right (Backwards): ("+str(temp.find(ans[::-1])+1)+","+str(x+1)+...
7d370a043cf5135c952b9f0557cdef8f451ace20
dexter2206/flask-pytkrk4
/examples/example_10_json.py
860
3.71875
4
# Example 10: using json with flask from flask import Flask, request, jsonify app = Flask(__name__) @app.route("/incoming-json", methods=["POST"]) def post_json(): # If content type of the request is application/json, Flask can # automatically decode json object for you. # Remember, this will only work i...
064d1ca8676e042147a562493c4342b23bf99e4d
SHPStudio/LearnPython
/batteriesincluded/internal.py
1,335
3.65625
4
# 内置模块 # 时间 # 时间模块 datetime # 导入时间类 datetime # from datetime import datetime # 获取当前时间 # now = datetime.now() # print(now) # 设置一个时间 # dt = datetime(2017,6,30,12,14,30) # print(dt) # 转换为时间戳 # print(dt.timestamp()) # 从时间戳转换为datetime时间对象 是本地时间也就是北京时间 时区为utc+8:00 # dtimestamp = 1429417200.0 # print(datetime.fromtimestam...
5119ac3568bca8b348a326bb745a38ada32bee2b
LCfP-basictrack/basictrack-2020-2021-2b
/how_to_think/chapter_3/third_set/exercise_3_4_4_12_c_variant.py
237
3.625
4
n = -123456789.0 original_n = n count = 0 if n < 0: count += 1 # should the minus sign count as a digit? n *= -1 while n != 0: if n % 2 == 0: count += 1 n = n // 10 print(original_n, "has", count, "digits")
6090c25a7ece3b92c6ad37a7f67ec34b55dec39f
menliang99/CodingPractice
/StringMult.py
608
3.625
4
## Carry Save Combinational Multiplier Architecture in VLSI def StrMult(num1, num2): num1 = num1[::-1] num2 = num2[::-1] print num1 print num2 arr =[0 for i in range(len(num1) + len(num2))] for i in range(len(num1)): for j in range(len(num2)): arr[i + j] += int(num1[i]) * int(num2[j]) ans = [] print a...
c01833c48d68e665ae9656f03f5933c1c5fea35b
cynergist/holbertonschool-higher_level_programming
/0x11-python-network_1/3-error_code.py
716
3.6875
4
#!/usr/bin/python3 import urllib.request import urllib.parse import sys ''' Script that takes in a URL, sends a request to the URL and, displays the body of the response, decoded in utf-8 ''' if __name__ == "__main__": try: with urllib.request.urlopen(sys.argv[1]) as response: ''' The returned ...
9c8ebf5f81bea0c404d9d48aa57f63f8728c44de
YeasirArafatRatul/Python
/SortingAlgorithms/SelectionSort.py
1,412
4.21875
4
#Selection sort #step 1: i = 0 #step 2: if i >= n-1 go to step 11 (for counting the iterations) #step 3: minimum no of the list is i = index_min #step 4: j = i+1 #step 5: if j <= n go to step 9 #step 6: if list[j] < list[index_min] # go to step 7 # else go to step 8 #step 7: index_min = j (set the...
7b3fe01966efd44425e6b8a62e1fb524221ce8fa
oijmark7/python_
/문제300/5차/5차 2급 6_initial_code.py
745
3.703125
4
def solution(korean, english): answer = 0 math = 210 - (korean + english)#최소 점수의 수학을 구하는 방법 수학= 평귵xn-(다른 과목들의 점수의 합)이다 if math > 100:#만약 수학점수가 100점보다 크다면 answer = -1#답은없다 else:#아니면 answer = math#답을 수학으로 지정 return answer#답반환 #아래는 테스트케이스 출력을 해보기 위한 코드입니다. 아래에는 잘못된 부분이 없으니 위의 코드만 수정하세요...
5aa1ca39f9358d0874dbf220f69c9b31f5b87f20
iaslyk/sort_visualizer
/merge_s.py
864
4.0625
4
def swap(A, i, j): A[i], A[j] = A[j], A[i] def merge_sort(nums, left, right): if(right <= left): return elif(left < right): mid = (left + right)//2 yield from merge_sort(nums, left, mid) yield from merge_sort(nums, mid+1, right) yield from merge(nums, left, mid, rig...
2f315c2d0eebe2e191bf4a08fb7db73182c48f71
Localde/scripts-python
/ex10-conversor-de-moedas.py
117
3.59375
4
dinheiro = float(input("Quanto dinheiro você tem?")) input("Você pode comprar {} dolares.".format(dinheiro / 3.27))
609844503c00a9dd82d39fd20185e8e4ef6615ae
Vissureddy2b7/must-do-coding-questions
/strings/6_check_if_string_is_rotated_by_two_places.py
492
3.8125
4
# Input: # 2 # amazon # azonam # geeksforgeeks # geeksgeeksfor # # Output: # 1 # 0 t = int(input()) for _ in range(t): str1 = input() str2 = input() n1, n2 = len(str1), len(str2) if n1 != n2 or (n1 < 3 and str1 != str2): print(0) continue if (str1[n1-2] == str2[0] and str1[n1-1] ...
660849f30452cbd5a614b65b658167ddc9bda9bd
graceknickrehm21/open-cv-
/bitwise.py
1,864
4.1875
4
#bitwise operations: AND, OR, XOR, and NOT #represented as grayscale images #pixel is turned off if it has a value of zero and on if it has a value greater than zero #binary operations #AND: A bitwise AND is true if and only if both pixels are greater than zero. #OR: A bitwise OR is true if either of the two pixels ar...
8ba42e8ddfa0cb9a569b3e8661317a4ad46080a1
shahamran/intro2cs-2015
/ex6/balanced_brackets.py
3,607
4
4
#Constants for the brackets strings OPEN_STR = "(" CLOSED_STR = ")" def is_balanced(s): '''Gets a string varibale [s] and checks if it contains balanced brackets. return True if so, and False otherwise. ''' length = len(s) opened = 0 #checks every character in the string. If it's a closed bracket ...
2c978f5e33ce3157c3a23aba6484fe0726964c01
vivek2319/mercy
/playnumpy.py
1,847
3.890625
4
import numpy as np #create an array of 10 zero's np.zeros(10) #Create an array of 10 one's np.ones(10) #Create an array of 10 five's #First method np.ones(10) * 5 #Second method np.zeros(10) + 5 #Create an array of intergers from 10 to 50 np.arange(10,51) #Create an array of all the even integers frm 10 to 50 ...
acf9fbbd39a6f038c03a68b976f0ce96b6d0e507
chirateep/algorithm-coursera-course1
/week5_dynamic_programming1/1_money_change_again/change_dp.py
524
3.5
4
# Uses python3 import sys def get_change(m): # write your code here coins = [1, 3, 4] min_num_coin = [m + 1] * (m + 1) min_num_coin[0] = 0 for i in range(1, m + 1): for coin in coins: if i >= coin: num_coins = min_num_coin[i - coin] + 1 if num_coins ...
96231fe7aaeabfe5d35585baa3a2c522a023c88a
jardelhokage/python
/python/reviProva/Python-master/23_TriâguloSimOuNao.py
387
4.125
4
print('Informe os valores para os lados do triângulo!') lado1 = int(input('Qual o valor do lado 1? ')) lado2 = int(input('Qual o valor do lado 2? ')) lado3 = int(input('Qual o valor do lado 3? ')) if lado1 >= lado2 + lado3 \ or lado2 >= lado1 + lado3 \ or lado3 >= lado2 + lado1: print('Os lados NÃO formam u...
d2ea19b141730c3cd34422cc8e2048bd24e49faf
neerajp99/algorithms
/problems/leetcode/lt-104.py
702
3.875
4
# 104. Maximum Depth of Binary Tree """ Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, v...
47969230cf60d9c9925917f04557e7a16a04d679
tarsqi/ttk
/deprecated/get_lexes.py
1,738
3.53125
4
""" Standalone utility script to extract all the tokens from a file and print them space separated using one sentence per line. Files are XML files that need to contain <s> and <lex> tags. USAGE: % python get_lexes.py INFILE OUTFILE % python get_lexes.py INDIR OUTDIR Note that in the first case INFILE has t...
d1515ce3cb5bf5fd9993873ac848cbc0a4d17499
kasai05/mashup_py
/kadai1/cost.py
311
3.859375
4
import time, random sum = 0 # ブランクを空ける before = time.clock() # インデントの数を調整する for i in range( 1000000 ) : sum = sum + random.randint(1 , 100) # geptimeの単語の間に'_'をいれる gap_time = time.clock() - before print "dummy:", sum print "gaptime:", gaptime