blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
1cf33f7de27fbe732b35bae1546c82d8556928a0
rebeccasmile1/algorithm
/homework1/test2.py
3,409
3.546875
4
def MaxmalRectangle(matrix): h = [] matrix2 = [] for i in range(0, len(matrix[0])): # 列 h.append(0) m = len(matrix) # 行数 n = len(matrix[0]) # 列数 print(m, n) max = 0 for i in range(0, m): h = [] for j in range(0, n): if i == 0: h.appe...
85b70782db50a99ad55fc86179a6e5585b9185a7
marco-zietzling/advent-of-code-2020
/day12/day12.py
2,548
3.90625
4
print("advent of code 2020 - day 12") directions = ["N", "E", "S", "W"] current_ship_dir_index = 1 current_ship_pos_x1 = 0 current_ship_pos_y1 = 0 current_ship_pos_x2 = 0 current_ship_pos_y2 = 0 current_waypoint_pos_x = 10 current_waypoint_pos_y = 1 instructions = [] with open("input.txt") as file: for line in f...
984662890c19916591461f9e3e953ed05281f8b8
sripathyfication/bugfree-octo-dangerzone
/techie-delight/sockets/echo_server.py
1,491
3.9375
4
#/usr/bin/python ''' A simple tcp server/client application socket is an ipaddress/port. Server operations: create socket bind to serveraddress(ip,port) listen(1) recv sendall close ''' import socket import sys class Server: def __init__(self,ip_address,port): prin...
7247c6980220808b6d9ff0b4f2edb619575e1ee7
DevParapalli/SchoolProjects_v2
/33_sum_diagonals_matrix.py
1,143
4.25
4
"Write a Program to showSum of Diagonals (major and minor) in Two Dimensional List" MATRIX = [] def create_matrix(): global MATRIX row_n = int(input("Enter Dimension (Square Matrix Only):")) for i in range(row_n): MATRIX.append([]) # add new row for j in range(row_n): MATRIX[i]...
21e65ea4897ba065108f685e84c576f58942506a
zhanary/leetcode-python
/0083-28ms.py
572
3.765625
4
In Python, every value is a reference, you can say a pointer, to an object. Objects cannot be values. Assignment always copies the value; two such pointers point to the same object. # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next =...
a160d3f4a86943ca9081c8174e809c98fbfa8184
catechnix/python_1
/generator.py
881
4.34375
4
""" *a function become a generator if it contains a yield *generators return a generator object when called *no code is executed when a generator is called *iterating (or calling next() on the generator object executes all the code until the first yield *once the yield is reached, the execution is paused and a value is...
250f8fa9da16e9fc7beb0eed48ee84536996c940
okipriyadi/NewSamplePython
/SamplePython/samplePython/Modul/os/_06_Glob_Example.py
2,011
4.125
4
""" Purpose Use UNIX shell rules to find filenames matching a pattern. look for a list of files on the file system with names matching a pattern. To create a list of filenames that all have a certain extension, prefix, or any common string in the middle """ #Buat folder dan file contoh import os if not os.path.exists("...
88f4c10311b0bac17c6111b92b343b50019a09fc
Ashmita-bhattacharya/programming-pancake
/scripts/percentage_calc.py
459
4.25
4
print ("Percentage calculator") print ("---------------------") print ("") m = float(input("Maths: ")) s = float(input("Science: ")) e = float(input("English: ")) print ("") percentage = ( (m + s + e) / 300 ) * 100 print ("Your percentage is ",percentage) if percentage >= 60: print ("You got 1st division") elif pe...
710b2cd95ba46fa4fa15ace554ef41a8fcea0442
CandiceDiao/Candice_Python
/DataStructureForLetcoode/link_structure.py
791
4.28125
4
""" 链表 常用操作 """ ###创建链表 from collections import deque #使用队列创建链表 linkedlist = deque() ###尾部添加元素 #时间复杂度:O(1) linkedlist.append(1) linkedlist.append(2) linkedlist.append(3) ###中间添加元素 #时间复杂度:O(N) linkedlist.insert(2,99) print(linkedlist) ###访问元素 #时间复杂度:O(N) element = linkedlist[2] # 99 print(element) ##搜索元素 #时间复杂度:O(N) ...
932d93e11b5e404793a7e0412090867929ccb3aa
ljrdemail/AID1810
/PythonBasic/Day10/execDemo.py
262
3.671875
4
x = 100 y = 200 s = ''' print("hello") z=x+y print(z) #如果你用eval 就不能a=x+y 因为用了赋值表达式 ''' print(exec(s)) print(z) #跑完之后z 也有了 等同于放在代码中直接执行 所以你在里面修改 x y 的话 x y 会受影响
f5d8ade2f73c66905bf39700254f53eedc817bbc
kronkanok/workshop_2
/operators/comparison.py
267
3.984375
4
x = 10 y = 12 print("x > y is", x > y) #output: False print("x < y is", x < y) #output: True print("x == y is", x == y) #output: False print("x != y is", x != y) #output: True print("x >= y is", x >= y) #output: False print("x >= y is", x >= y) #output: True
bc492442f5a52806b9c6c004d2a9822b9d45cb6a
keviv202/Python-Code
/power of 2.py
155
3.984375
4
import math def power(s): if (math.log(s,2).is_integer()): print ("Is power of 2") else: print("It is not power of 2") power(18)
c7aefda49884826dc2e74635ff1e0209dd21d2d1
rainavyas/Phone_Distance_Grader
/convert_legacy_pickle.py
1,133
3.796875
4
''' convert a pickle file saved from python2 into a pickle file that can be read from python3 ''' import pickle import dill def convert(input_file, output_file): # Convert Python 2 "ObjectType" to Python 3 object dill._dill._reverse_typemap["ObjectType"] = object with open(input_file, 'rb') as f: ...
8b1f081faa1587e58b291cbd53e159977a86122b
vgaicuks/ethereum-address
/ethereum_address/utils.py
1,020
3.5625
4
import re from Crypto.Hash import keccak def is_checksum_address(address): address = address.replace('0x', '') address_hash = keccak.new(digest_bits=256) address_hash = address_hash.update(address.lower().encode('utf-8')).hexdigest() for i in range(0, 40): # The nth letter should be uppercase...
f08067f1554b6ddcc1f1432125320393ef81e79c
kwasiansah/coffee_machine
/coffee_machine.py
5,060
4.125
4
class MyCoffee: water = 400 milk = 540 beans = 120 dis_cup = 9 money = 550 def __init__(self, user): self.user = user self.es_water = 250 self.es_beans = 16 self.es_money = 4 self.la_water = 350 self.la_milk = 75 self.la_...
3c5d9ae445180b6c591bd19a731fe2d5c4b907e5
fedpre/cse210
/week2-tictactoe/tic-tac-toe.py
7,349
4.1875
4
# Assignment "Tic-Tac-Toe" by Federico Pregnolato # Create a Tic-Tac-Toe game to play in Python import math from typing import Counter def main(): grid_squared = int(input('How many squares do you want on your grid? ')) max_val = grid_squared**2 n_digits = int(math.log10(max_val)) + 1 grid = create_gr...
3155a38c8284c686f0ac8989c05cefb5ba32cbe2
AndrewLu1992/lintcodes
/119_edit-distance/edit-distance.py
988
3.515625
4
# coding:utf-8 ''' @Copyright:LintCode @Author: hanqiao @Problem: http://www.lintcode.com/problem/edit-distance @Language: Python @Datetime: 16-06-08 10:02 ''' class Solution: # @param word1 & word2: Two string. # @return: The minimum number of steps. def minDistance(self, word1, word2): # ...
13b9d2d5d35df6935394d20a3bda71b60f259f10
JeffreybVilla/100DaysOfPython
/Beginner Day 4 Random & Lists/All50states.py
1,499
4.4375
4
# WITHOUT LISTS state1 = "Delaware" state2 = "Pennyslvania" state3 = "New Jersey" food1 = "Strawberries" food2 = "Spinach" print(f"{state1}, {state2}, {state3}, {food1}, {food2}\n\n\n") # WITH LISTS states_of_america = ["Delaware", "Pennsylvania", "New Jersey", "Georgia", "Connecticut", "Massachusetts", "Maryland"...
6ffe2765ef035f6eac5b922600692ac742aa8aa3
ajskdlf64/Bachelor-of-Statistics
/2019 - 02/[응용통계학과] 빅데이터분석활용/anacondatest.py
413
3.53125
4
# Library import numpy as np import math from matplotlib import pyplot as plt # Error Check print("Hello Anaconda!") # Sine Graph for matplotlib n = 100 sintheta = [ math.sin(theta) for theta in np.random.uniform(0, np.pi, n)] pplot = plt.plot(sintheta) plt.axhline(y=0.5, color='r') plt.title("Sin Values of Uniform...
3d8cce506aaf60964864bae1c1ab8f3a842a2ae3
ghazalerfani/MyMovie
/Simple_Regression_Models.py
9,516
3.796875
4
# Python Project - Section A2 Group 1 - MyMovie ##This is the Simple_Regression_Models script. This script contains the functionality of 3 traditional regression methods over different variables. ## Made by Shayne Bement, Jeff Curran, Ghazal Erfani, Naphat Korwanich, and Asvin Sripraiwalsupakit ## Imported by myMovi...
98dfa255d3f9c8768ad518506330cf238a8d6e00
aliwo/swblog
/_drafts/disk_control3.py
744
3.5625
4
from queue import PriorityQueue def solution(jobs): ''' 채점 시간을 보니 최소 n log n 안에는 끝나야 한다. for 문이 한 번 회전 할 때 마다 job 은 종료되어야 한다. 로직을 정리하면 다음과 같다. 1. 큐에서 새로운 작업을 뽑아낸다. 2. 큐에 아무것도 없으면?? job 의 실행 중에 n 개의 새로운 작업이 들어온다. n 개의 작업은 큐에 추가. 마지막 job 의 실행 중에는 새로운 작업이 들어오지 않는다. ''' ...
19bdaa200f30a380e71d3daca76fe2722957cd38
bodunadebiyi/datastructure_and_algorithms
/MergeSort.py
594
4.09375
4
def merge(left, right, A): i = 0 j = 0 k = 0 while k < len(A): if i >= len(left) and j < len(right): A[k] = right[j] j += 1 elif j >= len(right) and i < len(left): A[k] = left[i] i += 1 elif left[i] < right[j]: A[k] = left[i] i += 1 elif left[i] > right[j]: ...
9aaa8e7a195a18a8c95cd1dceedb64487eca04a7
Ashtalakshmimano/Lakshmi
/Arm.py
188
3.59375
4
lower=int(input()) upper=int(input()) for num in range(lower,upper+1): order=len(str(num)) temp=num sum=0 while (temp>0): rem=temp%10 sum=sum+rem**order temp//=10 if(num==sum): print(num)
f044bdda5876e31b138529c6822aca61ebd110fb
ZhiyuSun/leetcode-practice
/301-500/403_青蛙过河.py
1,465
3.6875
4
""" 一只青蛙想要过河。 假定河流被等分为若干个单元格,并且在每一个单元格内都有可能放有一块石子(也有可能没有)。 青蛙可以跳上石子,但是不可以跳入水中。 给你石子的位置列表 stones(用单元格序号 升序 表示), 请判定青蛙能否成功过河(即能否在最后一步跳至最后一块石子上)。 开始时, 青蛙默认已站在第一块石子上,并可以假定它第一步只能跳跃一个单位(即只能从单元格 1 跳至单元格 2 )。 如果青蛙上一步跳跃了 k 个单位,那么它接下来的跳跃距离只能选择为 k - 1、k 或 k + 1 个单位。 另请注意,青蛙只能向前方(终点的方向)跳跃。 来源:力扣(LeetCode) 链接:https://leetcode-c...
1e7afef369681d6846854c0d8dbbc28316922a10
quentin-auge/bookings_report
/bookings_report/transform.py
2,097
3.921875
4
from datetime import date, datetime from typing import Tuple def parse_amount_and_currency(raw_amount: str) -> Tuple[float, str]: """ Parse raw amount string into float amount and currency. Args: raw_amount: raw amount string Returns: Amount and currency Raises: :exc:`No...
e1af8e8554288b7fdf710402c3d3cf9a0723ffa9
KJeanpol/Tarea3-Anpi
/Parte 2/animacion.py
1,433
3.71875
4
import edo2 from sympy import sympify import matplotlib.pyplot import numpy as np def evalFuncion(): """ Aproximar la solucion de la funcion dada en el codigo. Salidas: [X,Y]: Matriz con los vectores de las soluciones de X y Y evaluadas en la funcion """ a=1 X=[] Y=[] ...
a044d4314e494effdbb0daef06b0df7c0a8b7bb1
Erqiao/Hello-World
/list.py
249
3.78125
4
total = 0 for i in range(1,100): if i%3 == 0 or i%5 ==0: total += i print total sum = 0 i = 0 list1 = list(range(1, 100)) while i < len(list1): if list1[i]%3 == 0 or list1[i]%5 == 0: sum += list1[i] i += 1 print sum
97a20ffe1ee71acb84a88936e245fb3baca58146
jefferson206/destravando-python
/exercicio05/exercicio05.py
354
3.625
4
from listaExercicio.uteis.util import Util def main(): Util().enunciado('PEÇA AO USUÁRIO PARA DIGITAR UM NÚMERO REAL E IMPRIMA A QUINTA PARTE DESTE NÚMERO.') valor = float(input(f'Digite um numero real: ').replace(',', '.')) print('\nA quinta parte de {} é de: {} '.format(valor, (valor*(1/5)))) if __nam...
7c666f85f8faef80fc4fa152d07e9b2551f216f4
innorev14/my-very-first-repo
/hello.py
70
3.5625
4
for i in range(1,12): if i % 2 == 0: print("Hello world")
bbf55396225a24a267f1d3c988d1532b55fbd449
teamdaemons/100daysofcode
/Day21/Multiplayer/snake_game.py
2,052
3.609375
4
from turtle import Screen import time from snake import Snake from food import Food from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.bgcolor("black") screen.title("My Snake Game") screen.tracer(0) snake = Snake("cyan") snake2 = Snake("red") food = Food() scoreboard = Sco...
0a2dd0ed370a6ab14016ebb8175d55652a67d1be
fernandavincenzo/exercicios_python
/26-50/042_TiposTriângulos.py
551
4.03125
4
r1 = float(input('Digite o comprimento da primeira reta: ')) r2 = float(input('Digite o comprimento da segunda reta: ')) r3 = float(input('Digite o comprimento da terceira reta: ')) if r2<r1+r3 and r1<r2+r3 and r3<r1+r2: if r1==r2==r3: print('Estas retas conseguem formar um triângulo Equilátero!') elif ...
11813ed89eb6a97a46a72bf1c8a3623d94c8c56e
dowookims/ProblemSolving
/swea/stack2/stack2_3.py
526
3.65625
4
import sys sys.stdin = open("sample_input3.txt", "r") # 1 가위 2 바위 3 보 def div_list(case): if len(case[0])== 1 or len(case[0])==2: return return div_list([[case[0:idx], case[idx+1:len(case)]]]) for TC in range(1, int(input())+1): N = int(input()) t = 0 while True: t +=1 if N ...
efb3d2a97789aa8ef2b51d1d5bb5c11a6e89a19a
bainco/bainco.github.io
/course-files/lectures/lecture15 -old/creature.py
1,024
3.640625
4
from tkinter import Canvas import utilities def make_creature(canvas, center, size=100, my_tag='creature', my_fill='hotpink'): radius = size / 2 # just a demo of how you might think about making your creature: left_eye_pos = (center[0] - radius / 4, center[1] - radius / 5) right_eye_pos = (center[0] + ...
ae18a0f125b2c9ee0ec80f8b07694ad14ab882e4
YashiSinghania/test_repo
/ifelse9.py
455
4.4375
4
# Write a program to check if a triangle can be formed using the given lengths of 3 sides. # HINT: For example, if the sides are 10, 24, and 67, then you cannot make a triangle # because 10+24 is not greater than or equal to 67. a= int(input("first side of triangle")) b= int(input("second side of triangle")) c= int(in...
39c68268a82e307f66b1d45b930d93175eeaf866
ShivamBhosale/100DaysOfCode
/Day51/generator.py
654
3.765625
4
import sys def mygenerator(n): for x in range(n): yield x ** 3 values = mygenerator(100) for x in range(1,10): print(next(values)) print("Size: {} bytes".format(sys.getsizeof((values)))) def infinite_sequences(): result = 1 while True: yield result result += 5 values2 = in...
76f1ab579654437cdee38b1071b9bc3b84e286a9
pepitogrilho/learning_python
/xSoloLearn_basics/files/text_analyzer_01.py
902
3.671875
4
# -*- coding: utf-8 -*- """ v1 """ filepath = "C:\\GitHub\\learning_python\\files\\text_analyzer_01_file_example.txt" with open(filepath) as f: text = f.read() print(text) """ v2 """ def count_char(text, char): count=0 for c in text: if c == char: count+=1 return count fi...
8e3b1ce44ef1b37205a9afb6b241aef115230b75
shaneweisz/DLOGs
/models/2D-CNN/preprocessing_utils_2d_cnn.py
3,944
3.515625
4
import numpy as np import pandas as pd import tensorflow as tf from tensorflow.keras.utils import to_categorical DEFAULT_FILE_SUFFIX = "14_10000" # Dataset with 10 classes, 10000 packets in each DEFAULT_DATA_PATH = f"/Users/chiratidzomatowe/DLOGs/preprocessing/data/{DEFAULT_FILE_SUFFIX}" MAX_BYTE_VALUE = 255 def r...
6484e95a8a6af9d616a8ffb06fcb9b117ee1df0f
Susmitha95/Internstudy
/firstprogram_add.py
67
3.578125
4
x=int(raw_input("enter x:")) y=int(raw_input("enter y")) print x+y
7be5e79042c9379d35066f2354799f97e626591f
lokeshsenthilkumar/leetcode
/word-search/word-search.py
781
3.6875
4
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: r = len(board) ; c = len(board[0]) def dfs(i,j,w): if w == len(word): return True if i<0 or j<0 or i>=r or j>=c or board[i][j]!=word[w] or (i,j) in path:...
33974da521f14195d8beae7d9ec0694fbff4aae0
LenHu0725/02_JZOffer-Notebook
/题目05:替换空格.py
1,708
3.796875
4
# -*- coding: utf-8 -*- """ 名称: 替换空格 题目: 请实现一个函数,将一个字符串中的空格替换成“%20”。 例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 测试: 输入包括空格(空格在最前 在最后 在中间 多个连续空格) 输入字符串没有空格 特殊输入(空指针 空字符串 只有一个空格 多个连续空格) """ class Solution_1: def __init__(self): pass def replaceSpac...
5582f7fcbb9b7e2f0ed2beaf91ae5fab18e342c7
dzanto/asynchrony
/async_with_gen.py
531
3.53125
4
from time import sleep queue = [] def counter(): counter = 0 while True: print(counter) counter += 1 yield def bang(): counter = 0 while True: if counter % 3 == 0: print('Bang') counter += 1 yield def main(queue): while True: ...
e85d1e88616ffe6f1058bd8374e47a36b604c636
huangm96/Algorithms
/rock_paper_scissors/rps.py
868
3.921875
4
#!/usr/bin/python """ player: 1:3 3**1 r p s player: 2:9 3**2 rr rp rs pr pp ps sr sp ss player: 3 : 27 3**3 """ import sys def rock_paper_scissors(n): # if n = 1 [['rock'], ['paper'], ['scissors']] # if n = 2, add [['rock'], ['paper'], ['scissors']] to the item in n(1), if n == 0: return [[]] elif n ...
7b434d0fcfbc062849a0983ae63397374fe0cbf5
NBlanchar/exercism
/word-count/word_count.py
741
3.59375
4
import string def count_words(sentence): sentence = sentence.lower() for puntuacion in string.punctuation: if(puntuacion != "'"): sentence = sentence.replace(puntuacion, " ") sentence = sentence.replace('\n', ' ').replace('\t', ' ') sentence = sentence.replace(' ', ' ') senten...
99f8e2320cc83eeb12e3ceaca11069b86980bfb9
srininara/pykidz
/sessions/session-7-loops/code/while_ice_cream.py
585
3.890625
4
icecream_flavors = ['vanilla', 'chocolate', 'mint chocolate', 'chocolate chip', 'cookie dough'] fruits = ['apple', 'banana', 'fig', 'mango', 'orange'] flavor_index = 0 print('The combination are:') while flavor_index < len(icecream_flavors): fruit_index = 0 flavor = icecream_flavors[flavor_index] flavor_ind...
0c0f2128b0ea9cbe59babbaa6ea7a44aded6b69f
Jabuf/projecteuler
/problems/problem10/Problem10.py
579
3.59375
4
""" https://projecteuler.net/problem=10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. """ from locals import * TWO_MILLIONS = 2000000 def solution(): current_prime = 2 sum_primes = 0 primes = [current_prime] while current_prime < TWO_MILLI...
658600a522b7823875b27a1d145338692faec934
Oksana1-prog/Python_06.02
/ua/univer/lesson01/lesson01_homework/Homework_chapter_3.py
5,064
4.40625
4
# 1. День недели. Программа должн вывести сообщение об ошибке, если пользователь вводит сообшение вне диапозона x = int(input("Введите число: ")) if x >= 1 and x < 8: print('Зачение лежит в допустимом диапозоне') else: print('Зачение лежит в недопустимом диапозоне') # 2. Площать прямоуголников: вывести сообщени...
ea64b622e024b4a411a93daa297ab8e903807c55
tiaedmead/Data_24_repo
/OOP/Tic_Tac_Toe.py
1,308
3.859375
4
class Board: def __init__(self): self.cells = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " ",] def display(self): print(" %s | %s | %s " %(self.cells[1], self.cells[2], self.cells[3])) print("-----------") print(" %s | %s | %s " % (self.cells[4], self.cells[5], self.cells[6...
f0637adf6dd650834cf68b540a626312075f9e00
rodumani1012/PythonStudy
/Python/Python01_Type/string.py
892
3.8125
4
# 문자 # ''(single quotation) ""(double quotation) 차이 없다. # \ : escape sequence 라고 부름. a='a\nb\'\s' print(a) b="a\nb's" print(b) # ''' 내용 ''' # ''' 3개는 안에 있는 엔터나 공백을 다 포함시켜줌. c=''' a b c d e''' print(c) # """ d="""a b c d """ print(d) # 섞어서 ex="""Weather you're new to programming or an experien...
577dd61501a776dd2399b70ebf20aff4763924cd
yachu0721/Introduction-to-data-sciencl
/Week10/IDS_20200508_2.py
461
3.59375
4
# variable vs. values: 1-on-multiple ( 1 對 多 ) weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] print(len(weekdays)) #觀察長度 lucky_numbers = [7, 24, 5566] print(lucky_numbers) lucky_numbers.append(87) #新增資料至末端 print(lucky_numbers) lucky_numbers.pop() #將最末端資料拋出 print(lucky_numbers) my_fav_gro...
daf9a4787874e5b32017aff437fbfbfa14dd491a
nagireddy96666/Interview_-python
/Reverse_String&List.py
692
3.609375
4
"""1. this is using negitive index""" s="hai this is lakshma reddy" a=s[::-1] print a ," 1st" """@@@@2nd method""" l=s.split() print l r="\t".join(reversed(l)) print r ,"2nd" """@@@3rd method""" z="".join((s[i] for i in range(len(s)-1,-1,-1))) print z """@@@4th method""" def krish(s): if len(s) <= 1: ...
9b8bd42dbc1464a307ff7bff78e53a876b812e64
njcssa/njcssa-python-practice-probs
/misc/instructorlistsanswers.py
2,277
4.03125
4
####################################################################################### # 1.1 # Loop through this list using a for loop and print all the values. list1 = [2, 4, 6, 8, 10, 12] for i in range(len(list1)): print(list1[i]) ###########################################################################...
a290b0f8fceb02aeaf0704160bb27319c00b1771
omrikiei/mina-payout-script
/Currency.py
4,620
3.71875
4
# Credit: https://github.com/MinaProtocol/coda-python-client from enum import Enum class CurrencyFormat(Enum): """An Enum representing different formats of Currency in coda. Constants: WHOLE - represents whole coda (1 whole coda == 10^9 nanocodas) NANO - represents the atomic unit of coda """ ...
e7fac3b77f9786ef9bbbe8aa9e2532f692f91239
shraddhakandale/python1
/fibonaccis series.py
355
3.65625
4
# 0 1 1 2 3 5 8 13 21 def fib(n): a = 0 b = 1 if n<=0: print("invalid series") elif n==1 : print(a) else: print(a) print(b) for i in range(2,n): c = a+b a = b b = c #if c < 100: print(...
53305441e20aecad5ec9f1d90a89af24d50b82c8
neuraloverflow/Learn-python-ex
/ex12.py
169
3.6875
4
name = raw_input("What's your name? ") place = raw_input("Where are you from? ") print "Wow, cool! Your name is %r and you come from %r!\n\tFantastic!" % (name, place)
c05d970a3da14a7af8cc932ad93bad296e4086c0
Rishant96/Expert-Python
/Chapter_2-below_classes/List_n_Tuples.py
1,624
4.34375
4
# print(dir(tuple()), "\n") # print(dir(list())) """ Python Idioms for lists """ """ 1 - Python list 'Comprehension' """ evens = [] for i in range(10): if i % 2 == 0: evens.append(i) print(f'using c style for loop,\n{evens}\n') # ---------------------------------------------- evens = [i for i in ran...
b23da6f37918bd817e05f30c85854af66f9f87aa
Ltrahair/IntroProgramming-Labs
/working_with_objects.py
1,962
3.8125
4
class Product: def __init__(self,productName,productPrice,productQuantity): self.productName=productName self.productPrice=productPrice self.productQuantity=productQuantity def isThatMany(self,n): if n>self.productQuantity: return False else: retu...
047998ca0b449021a85c293ab026bd9bad7de0ca
ECGonzales/Pythonpractice
/ex36.py
3,972
4.28125
4
#To try to do while I am away at momma's. #Create a game like the one from exercise 35. Use lists(ex 32,33,34), functions(sheet), #and modules(ex 13) from sys import exit #Define how you die in game def dead(explain): print explain, "That sucks!" exit(0) #Define how you win def win(explain): print explain, "You w...
b5692d96188cd922c631811b5806dc74358ccb09
marcelo-py/Exercicios-Python
/exercicios-Python/desaf054.py
400
3.9375
4
from datetime import date total = 0 total2 = 0 for c in range(1,8): nascimento = int(input('Ano de nascimento da {}º pessoa'.format(c))) idade = nascimento + 18 if date.today().year - nascimento >= 18 : total += 1 else: total2 += 1 print('Há um total de {} pessoas menores de idade'.forma...
bbf53b5dd1c922d438a75489ffa30168003e8130
mjwakex/Country-guesser
/Main files/countries.py
2,003
3.8125
4
import csv, random, os, time score = 0 lives = 5 dict = {} with open("countries.csv", mode="r") as f: reader = csv.reader(f) dict_from_csv = {rows[0].replace('\xa0', '').lower():rows[1].lower() for rows in reader} def cls(): os.system("cls") def captial_guess(): global lives, score while lives !=...
05391c71b2656f23cf74706f94d9e6e3ed5b56ba
famaxth/Way-to-Coding
/MCA Exam Preparations/Python/3 sum of squares of the digits in the odd position.py
318
3.90625
4
def main(): sum=0 iter=0 number = int(input("Enter a number to check Krishnamoorthy number : ")) num_string = str(number) for each in num_string: iter = iter + 1 if(iter%2==1): sum = sum + int(each)* int(each) print("sum is : ",sum) while True: main()
6602067a98581268fdcdef8731d4a8f990574a71
bilginyuksel/clighter
/clighter/core/dimension.py
479
4.09375
4
class Dimension: def __init__(self, height: int, width: int) -> None: """ Construct dimension object. Dimension is useful when you deal with scene. `height` can be seen as the distance from the starting point of some `y` point in coordinate system. `width` can be seen...
b47f70ee1b356085e3a8bb4e0756e1bf5f4e0619
Estefa29/Ejercicios_con_Python
/Vectores y matrices/ejercicios_matrices.py
8,999
4.03125
4
# Realice un algoritmo que permita diseñar un sudoku, donde se debe de ingresar # inicialmente la posición aleatoria de los valores con los cuales se va iniciar, # luego deberá comenzar el juego y validar las jugadas, si excede el valor total por # columnas o filas deberá emitir un mensaje de error. import numpy as...
d13c158a4f14d436ef8493aa106b9961c0de4108
rcanaan/Functional-Programming-in-Python
/תרגיל 3/ex3q5.py
530
3.75
4
#Rinat Canaan 207744012 #ex 3 question 5 def m(n): f = lambda i: i/(i+1) #the wanted equation def recursiveSumFunc(k): if k == 0: return 0 else: return recursiveSumFunc(k - 1) + f(k) return recursiveSumFunc(n) def main(): n = abs(int(input("Enter a Number: "))) ...
6f7dbb3c039f0defc8c0800ae0a7c9457d7ee0b7
prajaktaaD/Basic-Python1
/add.py
107
3.765625
4
a=int(input("enter val of a:")) b=int(input("enter val of b:")) sum=a+b print("sum=",sum) print(type(sum))
597f25d6a5127e310c4c39dbaf52404bf3657152
Nora-Wang/Leetcode_python3
/Dynamic Programming/背包问题/01背包/416. Partition Equal Subset Sum.py
1,754
3.625
4
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Note: Each of the array element will not exceed 100. The array size will not exceed 200. Example 1: Input: [1, 5, 11, 5] Output: true Explanati...
fb275aa50dcbb302b41ae1e2b257a79d1e728d7e
Aasthaengg/IBMdataset
/Python_codes/p02963/s991598209.py
112
3.578125
4
S = int(input()) x2 = 10**9 x3 = (x2 - S%x2) % x2 y3 = (S + x3) // x2 print('0 0 {} 1 {} {}'.format(x2,x3,y3))
4939763f263e98bb7dd1f78ebdaae9ec3b7e356d
Kimbsy/feed-me
/src/meal.py
740
3.796875
4
#!/usr/bin/python from ingredient import Ingredient class Meal: """The Meal class contains the name of the meal as well as a list of required Ingredients. """ def __init__(self, options): self.ingredients = [] self.hydrate(options) def hydrate(self, options): self.name =...
d08f70e1711874ed57fbdc089835155e4d98bd57
beechundmoan/python
/caesar_8.py
1,359
4.3125
4
""" All of our previous examples have a hard-coded offset - which is fine, but not very flexible. What if we wanted to be able to encode a bunch of different strings with different offsets? Functions have a great feature for exactly this purpose, called "Arguments." Arguments are specific parameters that w...
d425a9a9632134d1822e95cbb631492176be15b8
lynhyul/Coding_test
/프로그래머스/간단한문제/행렬의덧셈.py
1,145
3.53125
4
# 문제 설명 # 행렬의 덧셈은 행과 열의 크기가 같은 두 행렬의 같은 행, 같은 열의 값을 서로 더한 결과가 됩니다. # 2개의 행렬 arr1과 arr2를 입력받아, 행렬 덧셈의 결과를 반환하는 함수, solution을 완성해주세요. # 제한 조건 # 행렬 arr1, arr2의 행과 열의 길이는 500을 넘지 않습니다. # 입출력 예 # arr1 arr2 return # [[1,2],[2,3]] [[3,4],[5,6]] [[4,6],[7,9]] # [[1],[2]] [[3],[4]] arr1 = [[3,4,5],[5,6,7]] arr2 = [[4,5,6],[7...
24c8a810c6d4dfc8359331ac7d38942d82e213fc
ChristopherRogers1/IntroProgramming-Labs
/madlib.py
216
3.578125
4
noun = input("Enter a noun: ") verb = input ("Enter a verb: ") adj = input ("Enter an adjective: ") place = input ("Enter a place: ") print ("Take your " + adj + " " + noun + " and " + verb + " it at the " + place)
bfc963779e73a678577112c764d44057e52b3fd2
Scribbio/pYdioms
/Other/Corpera.py
1,328
3.53125
4
from nltk.corpus import CategorizedPlaintextCorpusReader import nltk, string, numpy reader = CategorizedPlaintextCorpusReader(r'\Users\JoeDi\Desktop\MSC\Idioms Corpera', r'.*\.txt', cat_pattern=r'(\w+)/*') print(reader.categories()) print(reader.fileids()) from random import randint File = reader.fileids() fileP ...
0826ca74846594df618664de35ae8f6ad0fef43f
DropthaBeatus/PythonTutorialForStudent
/BinTree.py
2,712
3.953125
4
import random #TODO make sure to flatten binary tree to linked list #TODO find least common ancestor of binary tree nods #TODO Convert a binary tree to its sum tree(each node is the sum of its children) # 1--2---5--6--19--0--2-20-13-15-3-5-32-1-3-7-6-8 #16 class Node: data = 0 def __init__(self, data): ...
b49e540b3c56972c34ef859bc1f1d554677bfa65
shcqupc/hankPylib
/leetcode - 副本/S0033_1103_distributeCandies.py
1,722
3.65625
4
''' 分糖果 II 输入:candies = 7, num_people = 4 输出:[1,2,3,1] 解释: 第一次,ans[0] += 1,数组变为 [1,0,0,0]。 第二次,ans[1] += 2,数组变为 [1,2,0,0]。 第三次,ans[2] += 3,数组变为 [1,2,3,0]。 第四次,ans[3] += 1(因为此时只剩下 1 颗糖果),最终数组变为 [1,2,3,1]。 ''' class Solution(object): def distributeCandies(self, candies, num_people): """ :type candie...
397c41f65c6efc16407b8b480e75285901e9e27a
johnson365/python
/Design Pattern/Decorator.py
1,020
3.6875
4
from abc import ABCMeta, abstractmethod class Component: __metaclass__ = ABCMeta @abstractmethod def operation(self): pass class ConcreteComponent(Component): def operation(self): print('The operation of concrete component!') class Decorator(Component): def setComponent(self, component): self.co...
7c03130606656cf0b69e09ace9967a1c02c5ee9b
anubhavv1998/Python-While
/armstrong.py
237
3.90625
4
num=int(input('Enter no. to check if it is armstrong or not ')) sum=0 temp=num while temp>0: digit=temp%10 sum=sum+digit**3 temp=temp//10 if num==sum: print('%d is armstrong'%(num)) else: print('%d is not armstrong'%(num))
05593838c86beabfeca6bdcb740e1eeff8e64b34
plasmatic1/Py-Generator
/param_parser.py
1,644
3.53125
4
import random import re def process_param(param): """ Processes the value in the `vars` section in a case config. Generally they are kept untouched except for these extended data types x~y : Random (uniform) number between `x` and `y` (An integer if both `x` and `y` are integers, otherwise it is a f...
5956f9c5593a91286c63ec95b3acdf7bb6d7ea3d
guilhermefsc/Curso-em-V-deo---Python
/Mundo 1/ex007 - media aritmetica.py
188
3.78125
4
n1 = float(input('Primeira nota do aluno: ')) n2 = float(input('Segunda nota do aluno: ')) media = (n1+n2)/2 print('A média entre {:.1f} e {:.1f} é igual a {:.1f}.'.format(n1,n2,media))
b4881cab6161034d1d89dcaf19e46e10ec55f48e
hieuvp/learning-python
/advanced-tutorials/exception-handling/example.py
591
3.8125
4
def do_stuff_with_number(number): print("number = %s" % number) def catch_this(): # This list only has "3" numbers in it numbers = (11, 22, 33) # Iterate over "5" numbers for index in range(5): try: number = numbers[index] do_stuff_with_number(number) # Ra...
55eed8180584350667ebf02679f8c2c30a1f1893
tariksetia/Algx-Practice
/sorting/partition.py
1,481
4.03125
4
def partition (start, end, data): pivot = start lo, hi = start, end while True: while data[pivot] >= data[lo] and lo < end: lo += 1 while data[pivot] < data[hi] and hi >start: hi -= 1 if hi<=lo : break data[hi], data[lo] = da...
866f03082ba16e28f7deb5a2c42ad32930b3fc78
kevmct90/PythonProjects
/Python-Programming for Everybody/Week 3 Conditional/assn_3.3.py
795
4.4375
4
# 3.3 # Write a program to prompt for a score between 0.0 and 1.0. If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following # table: # Score Grade # >= 0.9 A # >= 0.8 B # >= 0.7 C # >= 0.6 D # < 0.6 F # If the user enters a value out of range, print a suitable...
69dbd41a9424dcd06c8556dc197b3e175406cda9
mmcgee26/PythonProjects
/7_2.py
1,089
3.796875
4
def toBin(n): # base case if n <= 1: return str(n) return toBin(n//2) + str(n % 2) print(toBin(14)) ## print nth Fibonacci number : Using loop technique def fib(n): a,b = 1,1 for i in range(n-1): a,b = b,a+b return a print (fib(5)) ## print nth Fib...
073f212117191e2ffb980faf2cc2599c62edf4ac
misohan/Udemy
/Test_udemy.py
1,419
4.375
4
# numbers = 1, 2, 3, data type integer # strings = "ahoj", data type string # lists = [], can be changed # tuples = (), can not be changed # dictionary = {}, key values multiplication = 2.005*50 print(multiplication) divison = 401/4 print(divison) exponent = 10.01249219725040309**2 print(exponent) addition = 100+0....
ded75bf0e0dd84a7789a756dfcfa34afa46bbbd1
test-for-coocn/test-back
/pyton/Histogram_1.py
807
3.78125
4
import matplotlib.pyplot as mpt import math def sqr(x): return x * x data = [66, 59, 62, 64, 63, 68, 65, 59, 68, 64, 65, 51, 67, 64, 83, 59, 61, 62, 57, 72, 65, 64, 54, 60, 53, 65, 67, 60, 53, 79, 74, 53, 61, 68, 75, 50, 57, 55, 66, 56, ...
90468094eba93a44725707f532797ed506a41723
EoghanDelaney/Problem-Sets
/primes.py
1,213
4.46875
4
## In this instance I have used the following link to help me in this question. ## https://www.programiz.com/python-programming/examples/prime-number ## I have adapted it to read the way I would want it. ## The core of this question is how to calculate a prime number & having reviewed the above link it is clear - somet...
e10e469c265b93ffbd98399baa040a58875d0179
jonathansayer/airport_challenge_python
/airport_unittest.py
1,482
3.546875
4
import unittest from mock import Mock from airport import Airport class AirportTest(unittest.TestCase): def test(self): self.assertTrue(True) def test_airport_capacity(self): airport = Airport() self.assertEqual(airport.capacity,20) def test_airport_land_plane(self): airp...
fabc10712901d09eb22d6cfb4e3fe24e50b43aca
JonSeijo/project-euler
/problems 70-79/problem_75.py
2,133
3.859375
4
# Problem 75 # Singular integer right triangles """ It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples. 12 cm: (3,4,5) 24 cm: (6,8,10) 30 cm: (5,12,13) 36 cm: (9,12,15) 40 cm: (8,15,17) 48 cm: (12,1...
d6be744cfb739c1c72df25b46651170a18d59142
LacThales/tic-tac-toe-in-python
/tic-tac-toe.py
4,770
4
4
import sys #para sair do programa explicacao = ''' //// Sobre o jogo: //// Automaticamente você será o 1º Jogador e começará sendo o X, mas pode optar por ser o 2º Jogador (e ser o O (bola)), só deixar seu amigo começar jogando :D. Quando for sua vez, digite o número correspondente à linha e coluna no tabuleiro para f...
d31871ada59d0bdba396bb7bcc8a88278816c5b8
jiewu-stanford/leetcode
/79. Word Search.py
2,275
3.5
4
''' Title : 79. Word Search Problem : https://leetcode.com/problems/word-search/description/ ''' ''' recursive DFS helper function Reference: https://leetcode.com/problems/word-search/discuss/27660/Python-dfs-solution-with-comments ''' class Solution: def exist(self, board: List[List[str]], word: str) -> bool...
b3f71da0b452458ef26a6bae95a3ca9ae3234b2d
Josh7GAS/Oficina
/Python/list.py
224
3.890625
4
#Give me 10 names to add and print names = [] print("Give me 10 names to add and show on my list") for count in range(10): print("Give me the " + str(count + 1) + "th name") names.append(input()) print(names)
aa3d1759bc2c74c61b7d2a6838fad051c3dfe3e8
JaderSouza/exercicios
/ex 035 - analise de triangulos. v1.0.py
788
4.09375
4
print('=-='*20) print('Analisando seguimentos para formar um triangulo') print('=-='*20) l1 = float(input('Digite o primeiro seguimento: ')) l2 = float(input('Dgite o segundo seguimento: ')) l3 = float(input('Digite o valor do terceiro seguimento: ')) # SIMPLIFICANDO OS IF'S (CONDIÇÕES). if l1 < l2 + l3 and l2 <...
87dce6d51ee32b2af497cba2ed9bcbdd5db936df
EdmundHorsch/StockTrading
/test_functions.py
9,728
3.78125
4
# Evaluation function and back-testing methods and simulations import get_data as gd import indicators as ind import random import math import matplotlib as mpl import matplotlib.pyplot as plt ''' Evaluate a symbol and decide buy/sell/sit overnight RETURNS: buy, sell - buy: how much money to invest in th...
330a622f11a65258af937bbdfd14714579a62ffc
impacta-ADS/python
/decimal2binario.py
507
3.84375
4
''' TRANSFORMAR BINÁRIO EM DECIMAL ''' continuar=True contador=0 numeroDecimal=0 while continuar: numeroBinario=int(input("Digite um número binario:")) numeroBinarioInicial=numeroBinario if numeroBinario>0: continuar=False while (numeroBinario!=0): resto=numeroBinario%10 numeroDecimal=n...
69f428aabe854675e64e095960d3574eff7fe7af
vidyasagarr7/DataStructures-Algos
/Karumanchi/Queue/Rearrange.py
647
3.96875
4
from Karumanchi.Queue import Queue def rearrange(input_que): temp_que = Queue.Queue1() is_length_odd = True if input_que.size%2 ==1 else False mid = input_que.size//2 for i in range(mid): temp_que.enqueue(input_que.dequeue()) while not temp_que.is_empty(): input_que.enqueue(temp_que...
bcf7ad8906384ff92c93bd58a2356ccb6470a454
jailukanna/Notes
/Note Pad ++/Troubleshooting/Time calculator.py
410
3.671875
4
while True: speed= input("Enter the speed of video: ") if speed =="quite": break duration = input("Enter the video duration in h:min formate: ") duration = duration.split(':') exact_time = int(duration[0])*60+int(duration[1]) finale_time = (1/float(speed))*exact_time print(f"Fin...
1206ab0afdafa2c50e3f0a63c3fbe3953617dd61
harrylee0810/TIL
/swexpert/python01/6251.py
256
3.984375
4
# for문을 이용해 아래와 같이 별(*)을 표시하는 프로그램을 만드십시오. # 출력: # * # ** # *** # **** # ***** a = int(input()) for i in range(1, a+1): blank = ' '*(a-i) star = '*'*i print(blank, star, sep='')
e9fc665f3a29ef8d7eaa2b3b365beb7b25915c56
think-TL/python-code
/chapter2/Test2_11.py
567
3.59375
4
def general(general): add = [] for i in range(5): add.append(int(raw_input("input number"))) count = 0 for i in add: count += i if general == 1: print count else: print float(count) / len(add) while True: print "five--sum --1" print "five--avg --2" p...
bf11aa74d28aea5f3f8564f135bd7d54f9c2dc6c
ppalves/desafios-de-programacao
/aula-6-3/b.py
146
3.578125
4
n = int(input()) l = 0 r = 0 commands = input() for letter in commands: if letter == "L": l+=1 else: r+=1 print(l + r + 1)
e07ca24c85058507cafbaf33bfccf6d846726e2a
hirekatsu/MyNLTKBOOK
/ch03_06.py
1,802
3.515625
4
# -*- coding: utf-8 -*- from __future__ import print_function from __future__ import division import nltk, re, pprint from nltk import word_tokenize print(""" ---------------------------------------------------------------------- 3.6 Normalizing Text ----------------------------------------------------------...
aa0c06c041d77490f0a8a1bc4233db4aadd4aee6
crouther/data-parsing
/netflix/netflixListParser.py
1,278
3.515625
4
################################################################################ # # Myles Crouther # Netflix List Parser # ################################################################################ import re, json # Variables titles = [] extractedTxt = [] array = [] key = "\"fallback-text\"" # First seperat...
18dbd7ff0e659b5d8bc965c9619ba03d3ac4ab16
kailash-manasarovar/A-Level-CS-code
/challenges/conversion_hex_to_binary.py
1,418
4.03125
4
hex_number = input("Please enter 2 digit hex number") denary_numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] denary_result = 0 bin_result = "" def convert(hex_digit): if hex_digit in denary_numbers: return int(hex_digit) elif hex_digit == "A": return 10 elif hex_digit == "B": ...