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
ae93bc7c0b6aa789aea9f4e073f7d0b603ef4822
samanviekk/algorithms
/level_order_traversal.py
1,640
3.78125
4
import collections class TreeNode: def __init__(self, x): self. val = x self.left = None self.right = None def level_order_traversal(root): if root is None: return [] result = [] q = collections.deque([root]) while len(q) != 0: numnodes = len(q) temp...
6917bb16b16e1a17e127ef08c577760fac45e3ee
hallfox/teampython
/lpthw/wookie/ex11.py
764
4.125
4
#raw_input takes input and returns strings print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weight?", weight = raw_input() print "So, you're %r old, %r tall and %r heavy." % ( age, height, weight) #test test - same as top #found online age = raw_inpu...
1c39e541a34434470b1e0713734df6056d6155af
BobIT37/Python3Programming
/venv/03-Methods and Functions/02-args and kwargs.py
1,057
4.03125
4
#args and kwargs def myfunc(a,b): return sum((a,b)) * .05 result = myfunc(40,60) print(result) def myfunc(a=0,b=0,c=0,d=0): return sum((a,b,c,d)) * .05 result2= myfunc(40,60,20) print(result2) # *args # When a function parameter starts with an asterisk it allows for an arbitrary number of arguments, # and th...
a16c235b262e1c0abd685844c81209639e61f94f
spaderthomas/chinesemoon
/app.py
21,654
3.5625
4
# Features: # - combine units (temporarily) # To-do # - make all positions relative # - Clear unit when deleting last one # - space bar is broken? # - move display mode into this file, add a current display mode for switching without changing the mode youre in # Imports from tkinter import * from tkinter import filedi...
a76bb3bcafd39194bd6314988885e032f078c516
Yusful33/TicTacToeGame
/TicTacToeTake2.py
4,504
4.09375
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 29 10:48:59 2019 @author: ycattaneo """ #Clears the board #print('\n'*100) #Creating a board def display_board(b): print('\n'*100) print(' | |') print(' ' + b[7] + ' | ' + b[8] + ' | ' + b[9]) print('-----------') print(' ' + b[4] +...
301f8042fae2d6f3db204543af865da436088ca3
willbh1992/LPTHW
/ex11.py
1,477
4.09375
4
# Most of what software doe is the following # 1. Take some kind of input from a person # 2. Change it. # 3. Print out something to show how it changed print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh", weight = raw_input() print "So, you're %r o...
4856451dfa52f1c85dc4116b9a55b192702fa54a
mosfeqanik/Python_Exercises
/arithmetic.py
181
3.796875
4
number1 = raw_input("please type an integer and press enter: ") number2 = raw_input("please type another integer and press enter: ") print(" number1 + number2", number1+number2)
e25c0183b1623bf02bf6eaf3c22b181912b1ec6c
sssandesh9918/Python-Basics-III
/Sorting and Searching/6.py
497
4.09375
4
#Binary Search def binarysearch(a,element): l=0 r=len(a)-1 while(l<=r): mid=int((l+r)/2) if a[mid]==element: return mid elif a[mid]<element: l=mid+1 else: return mid return -1 a=[1,5,6,7,13,19,26,33,48] element=int(input("Enter the elem...
9f0f92226daf9256fde6000c2b6b837324df5453
misa9999/python
/courses/pythonBrasil/EstruturaDeDecisao/ex010.py
401
3.859375
4
# pede para inforar o turno de estudo, em seguida da uma saudação no turno esp # pergunta o turno de estudo M-matutino V-vespertino N-noturno horario = input('Turno de estudo: M-matutino/V-vespertino/N-noturno: ') if horario in 'mM': print('Bom dia!') elif horario in 'vV': print('Boa tarde!') elif ho...
4c341c964a04662b51bcbb3cd04ef7c40f1a60b6
cosmic-weber/lets_upgrade_assignments
/day6/day6_question1.py
1,229
3.796875
4
class BankAccount(): def __init__(self, owner_name, balance): self.owner_name = owner_name self.balance = balance self.money = 0 def deposite(self): print(self.owner_name + " You added Rs-/ ",self.balance) def Update_balace(self, amount): self.balance= s...
d8d8e39f5705ff6dff350e393d263fce00f9579a
hanrick2000/DSAL
/ALGO_V2/DS_python/linked_list.py
1,922
4.25
4
# linked list: a chain of node object. # node: value + pointer(to the next node) # head pointer to the first node # tail pointer to the null class Node: def __init__(self, data, next=None): self.data = data self.next = next # join the node to get a linked list # linked list class with a single he...
5069c8f89ba07ef50ca8f1274c8e33ab290be308
theshivambedi/Pythonprojetcs
/cointoss(10).py
126
3.5625
4
import random computerchoice = random.randint(0,1) if computerchoice == 1: print("Heads") else: print("Tails")
b5da18a3f1a74d2c33c94d04d6e0826058e5caa0
chefmohima/Katacode
/data_structures.py
7,054
4.5625
5
# Python data structures # Recipe1 : Unpacking sequences into variables # number and order should match when unpacking >>> data ['ACME', 50, 91.1, (2012, 12, 21)] >>> name, share, price, date = data >>> print('Name: {}, Share: {}, Price: {}, Date: {}'.format(name, share, price, date)) Name: ACME, Share: 50, Price: 91...
772f9f3b8bf58a4ef7ce3531111d99df2a4b777e
AyanChawla/Codes
/Day Of the Programmer/Sol.py
925
3.84375
4
#!/bin/python3 import math import os import random import re import sys # Complete the dayOfProgrammer function below. def dayOfProgrammer(year): if(year>=1919): if((year%400==0) or (year%4==0 and not(year%100==0))): print("12.09.",year,sep="") else: print("13.09.",year,sep...
a95e148f0430382fd47361fa2661aa717e279a7e
pananev/Training
/ML_Courses/dl_course_assignments/assignment3/model.py
3,345
3.625
4
import numpy as np from layers import ( FullyConnectedLayer, ReLULayer, ConvolutionalLayer, MaxPoolingLayer, Flattener, softmax_with_cross_entropy, l2_regularization, softmax ) class ConvNet: """ Implements a very simple conv net Input -> Conv[3x3] -> Relu -> Maxpool[4x4] -> Conv[3x3...
7ddcd10eb2811586de0e92bfee443151d61dafa3
ianpepin/Tensorflow-Tutorial
/machineLearningAlgorithms-classification.py
3,118
3.625
4
import tensorflow as tf import pandas as pd CSV_COLUMN_NAMES = ["SepalLength", "SepalWidth", "PetalLength", "PetalWidth", "Species"] SPECIES = ["Setosa", "Versicolor", "Virginica"] trainPath = tf.keras.utils.get_file("iris_training.csv", "https://storage.googleapis.com/download.ten...
31e3c6875e1ceae10b1ff96c9ca1c5b34ecd0198
Jingyuan-L/code-practice
/tencent3.py
420
3.5
4
from collections import Counter nums = list(map(int, input().strip().split())) strings = [] for i in range(nums[0]): strings.append(input().strip()) # print(strings) counter = Counter(strings) common = counter.most_common(nums[1]) for i in range(nums[1]): print(common[i][0], common[i][1]) uncommon = sorted(coun...
740b44fed84fc8530fe2fceb1e659bd4d843a230
diput102/learnpy
/py100/py_ex4.py
481
3.609375
4
def compday(): Y=int(input('year')) M=int(input('Month')) D=int(input('day')) days1=[31,28,31,30,31,30,31,31,30,31,30,31] days2=[31,29,31,30,31,30,31,31,30,31,30,31] # i=0 # days=0 # count=0 if ((Y%400==0)|(Y%4==0)&(Y%100!=0)): print('润') for i in range(0,M-1): ...
657d7bf9b626e9ff584175b9769562bad870c267
Taddist/CodeForce
/705A.py
345
3.625
4
n=int(input()) ih="I hate " th="I hate that I love" t=" it" s="" if(n==1): print(ih+t) if(n==2): print(th+t) if(n>=3): if(n%2==0): n=n//2 while(n>0): s=s+th n=n-1 if(n>0): s=s+" that " print(s+t) else : n=n-1 n=n//2 while(n>0): s=s+th n=n-1 if(n>=0): s=s+" that...
885ce6d26de250aaca3fae5069493c1d0639651a
ryanpethigal/IntroProgramming-Labs
/pi.py
105
3.84375
4
import math terms = int(input("enter number of terms to sum: ")) for i in range (,terms,2): print(i)
8e72550841d7ac33e52ffc9e99be61af2cfdf6e9
AsherThomasBabu/AlgoExpert
/Arrays/Array-Of-Products/naive.py
748
4.1875
4
# Write a function that takes in a non-empty array of integers and returns an array of the same length, where each element in the output array is equal to the product of every other number in the input array. # In other words, the value at output[1] is equal to the product of every number in the Input array other than ...
4971f3a592af0001bf5b40df0c351ce639de529c
venosu/python
/calculator.py
303
3.96875
4
def calculate(a, b, c): if a == '+': return b + c elif a == '-': return b - c elif a == '*' or a == 'x': return b * c elif a == ':' or a == '/': return b / c number1 = 69 number2 = 69 action = '*' print(calculate(action, number1, number2))
249c082b1cd17c7e3ec646a61d58ff0af0285dc6
Konstantin-Bogdanoski/VI
/Lab03_Informirano prebaruvanje/Подвижни_Препреки.py
4,908
3.625
4
CoveceRedica = input() CoveceKolona = input() KukaRedica = input() KukaKolona = input() from Python_informirano_prebaruvanje import Problem from Python_informirano_prebaruvanje import astar_search from Python_informirano_prebaruvanje import recursive_best_first_search coordinates = {0:(CoveceRedica,CoveceKolona)...
b22f13fb5b6907f37bf3da84e87b974d77f3cde9
sunsun101/DSA
/insertion_sort.py
1,038
4.09375
4
# declaring empty list list = [] take_input = True # taking input for the list while take_input: try: element = int(input("Please enter a number for the list :")) list.append(element) except ValueError: print("Please provide a valid number") condition = False while not condition:...
d24bee8481661a5d55983b14eab7a76c940a8393
AmbyMbayi/CODE_py
/DataStructure/Question4.py
273
3.75
4
"""write a python program to get all values from an enum class Expected output [92,23,42,539,34,53] """ from enum import IntEnum class City(IntEnum): Kisumu = 45 Nairobi = 67 Alego = 56 Usenge =4 city_code_list = list(map(int, City)) print(city_code_list)
0dc4742a017f4f4a5f7551927e311fb1ad64e3af
mdamyanova/SoftUni-CSharp-Web-Development
/00.Open Courses/Python/ExamPreparation/CharsInString.py
468
3.84375
4
input_str = input() dict_chars = {} if input_str is None or input_str is '': print("INVALID INPUT") else: for char in input_str: if char in dict_chars: dict_chars[char] += 1 else: dict_chars[char] = 0 counter_max = 0 most_common_char = '' for key, value in ...
2e5bfe41f92e6f9f8572ccdfe190fc57fca9981e
kneyzberg/python-oo-practice
/wordfinder.py
1,496
3.84375
4
from random import choice class WordFinder: """Word Finder: finds random words from a dictionary. >>> wordfinder = SpecialWordFinder("./test.txt") 4 words read >>> lst = ["kale", "parsnips", "apples", "mango"] >>> wordfinder.random() in lst True """ def __init__(self, path): ...
afb849c33fd86658ae19945fd4190e7a0ac5ddcc
kouroshkarimi/LeNet-MNIST-Classification
/LeNet_predict.py
2,041
3.515625
4
# IMPORT PACKAGES import tensorflow as tf from tensorflow import keras from tensorflow.keras.datasets import mnist import cv2 from tensorflow.keras import backend as K import numpy as np import tensorflow.keras.utils as util # PREPARING DATA print("[INFO] Downloading mnist dataset.") (train_images, train_la...
7f80db20f8bab60cb7726ce14365def14a151d5a
kutayakgn/Python_Poll_Analyzer
/CSE3063F20P2_GRP2_Iteration1/ReadFile.py
5,168
3.59375
4
# Read answer keys, student list and report files from Student import * from Question import * from xlrd import open_workbook from AnswerKey import * from Poll import * import csv class ReadFile: def __init__(self): self.students = [] self.allPolls = [] # Read answer key fil...
0df6221df1aa5b145a40866f3d7ac14081f81d89
milton9220/Python-basic-to-advance-tutorial-source-code
/twelveth.py
208
4.0625
4
#n=int(input("how many times you want to print:")) #i=1 #while i<=n: #print("Hellow World!") #i=i+1 n=int(input("enter number:")) sum=0 i=1 while i<=n: sum=sum+i i=i+1 print(sum)
368dd056a50e84c52b6128dd5e199b6b1c100599
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/aron/lesson08/test_circle.py
1,038
3.875
4
import unittest from .circle import * class MyTestCase(unittest.TestCase): def test_radius(self): c = Circle(4) self.assertEqual( c.radius, 4) def test_diameter(self): c = Circle(4) self.assertEqual(c.diameter, 8) c.diameter = 2 self.assertEqual(c.diameter, 2)...
fafd7a28679e7bcc741c68ff2c10a171d4395cb7
ciecmoxia/moxiatest
/Month1/TCP_Server_outerloop.py
1,828
3.578125
4
# 网络的概念,五层:应用层(应用)、传输层(tcp、udp端口)、网络层(ip)、数据链路层(ethernet mac地址)、物理层(0和1) # tcp 的整个流程类似打电话的一个过程: import socket # 服务端: # a. 建立链接,买手机 tcp_server=socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 基于文件类型的套接字家族,名字:AF_UNIX,基于网络类型的套接字家族,名字:AF_INET ; SOCK_STREAM:TCP协议,Sock_DGRAM:UDP协议 tcp_server=socket.socket(socket.AF_INET,...
f85ad26e411a7c927766de8cdf9fade761dd6ed9
Reshma262/Pythontutorials
/Regex1.py
298
4.125
4
#Check if a string contains only defined characters using Regex import re def check(str, pattern): if re.search(pattern, str): print("Valid String") else: print("Invalid String") pattern = re.compile('^[1234]+$') check('2134', pattern) check('349', pattern)
4eabf5ad76a3e493e12053c1944962a034fd74c1
swarnaprony/python_crash_course
/exercise_10/exercise_10_3.py
779
3.875
4
#exercise_10_3 #guest user_name = input('Write your name here: ') user_name_file = 'guest.txt' with open(user_name_file, 'a') as user_name_object: user_name_object.write(f"{user_name}\n") #exercise_10_4 #guest_book user_name_entry = "Enter your name: " user_name_entry += "if ypu finished with adding name wr...
5b67f97b62c318177c18b11e16b2d7195c9e129f
benjamin22-314/codewars
/number-format.py
297
3.75
4
# https://www.codewars.com/kata/number-format def number_format(n): return format(n, ',') # tests print(number_format(-10)) print(number_format(100000) == "100,000") print(number_format(5678545) == "5,678,545") print(number_format(-420902) == "-420,902") print(number_format(-3) == "-3")
b54eb74e1d90a1b5f005f516963916b4eaf949de
Patrick-Heffernan/Mass-Emailing-Tool
/Autoemail.py
635
3.5625
4
import openpyxl, ezgmail wb = openpyxl.load_workbook('Email Addresses.xlsx') sheet = wb['Sheet1'] emails = {} #Make the excel data into a dictionary for i in range(1,sheet.max_row-1): name = sheet.cell(i, 1).value email_address = sheet.cell(i,2).value emails[name] = email_address subject = "Te...
14faac596d6e8f4abe545956af721337432c8e38
ahmadradmehr/Assorted-Python-Problems
/LongestSubstringWithoutRepeatingCharacters.py
1,030
3.953125
4
""" Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length...
ed25b1e8f5be95cea13165622a8e9cae0f074704
andreaton/kids-code
/Silvia/.idea/hi.py
781
4.03125
4
import math #print("Hello, world!") #name=input("What's your name? ") #print("your name is "+name) area=TriangoloArea(76,4) print (str(area)) area=TriangoloArea(89,5) print (str(area)) perimetro=TriangoloPer(57,14,29) print (str(perimetro)) #base=input("Give me the base of a triangle ") #height=input("Give m...
2534b8c987dce17f3007ddf87504e80baaef8d4e
JohannesBuchner/pystrict3
/tests/data23/recipe-579042.py
1,034
4.375
4
""" dunderdoc.py A Python function to print the .__doc__ attribute (i.e. the docstring) of each item in a list of names given as the argument. The function is called dunderdoc because it is an informal convention in the Python community to call attributes such as __name__, that begin and end with a double underscore...
389498db31a2e1907ccf0ec38995cfd26dc5ae20
taurusyuan/python
/03_function/hm_06_函数的返回值.py
287
3.59375
4
def sum_2_num(num1, num2): sum = num1 + num2 return sum # 注意:return 就表示返回,与return缩进相同格数的下方的代码不会被执行到! result = sum_2_num(50,20) # 使用变量来接受函数执行的返回结果 print("计算结果:%d" % result)
ebe5578369ad2ddd67a53ba297a97ee8d2fb9558
GunjanMA/LSB-Steganographic-Algorithm
/steganography.py
989
3.921875
4
import sys import image_merge as image import hide_text as text def main(): if(len(sys.argv) > 2): steg(sys.argv[1], sys.argv[2]) else: desteg(sys.argv[1]) def steg(cover_path, hidden_path): ''' Function to hide data (either an image or text) within another image INPUT: string, p...
c609060f9520c0490c6bb7fcd1e4dcb59548906f
peeyush1999/p3
/Python Tutorial Sheet/Recursion tutorial sheet/recursion_13.py
388
3.578125
4
def revArray(mylist,start,end): if(end<start): return mylist temp = mylist[start] mylist[start] = mylist[end] mylist[end] = temp return revArray(mylist,start+1,end-1) num = int(input()) inputs = input().split(' ') for i in range(num): inputs[i...
67bdc887c59bdf2d8be5ea18f52b6f70dc0e50fd
iampkuhz/OnlineJudge_cpp
/leetcode/python/passedProblems/144-binary-tree-preorder-traversal.py
1,111
4.25
4
#!/usr/bin/env python # encoding: utf-8 """ Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.v...
f9b4f7565a7511d9d2d27419501b7ebf7fc69013
d-lan2/PythonExampleProject
/src/modules/module.py
512
3.71875
4
"""An example python module""" from typing import List import requests #Dynamic typing def total(x,y): """Returns the sum of xs""" return x + y #Static typing (really just type hints) see https://docs.python.org/3/library/typing.html def listTotal(xs: List[float]) -> float: result: float = 0.0 for ...
d67928afcf6545b4c6b4f0577329f1c250588407
IrenaeusChan/DNA-Sequence-Analysis
/s_complex.py
4,740
3.859375
4
""" String Complexiy Calculations 3 Methods: Standard Bit Compression Ratio Shannon's Entropy Evolutionairy Method (Randomly Generating String) by Irenaeus Chan """ import sys import string import random import zlib import csv import bisect from math import log def weightedChoice(choices): """ R...
614d996694c53ed79255931dc0a8ae20282f2265
JackPMX/leetcode-practice
/algorithm/1047. 删除字符串中的所有相邻重复项/case2.py
338
3.78125
4
class Solution: def removeDuplicates(self, S: str) -> str: hStack = list() for char in S: if(hStack and hStack[-1] == char): hStack.pop() else: hStack.append(char) return "".join(hStack) s = Solution() sstr = "abccbdef" print(s.remove...
7be1c15f35c7097c85375b3fe530504bc9e3eecf
RookieWangXF/py-basic
/basic/list.py
414
4.03125
4
# list 可变的有序集合 classmates = ['Tom','Mike','Bob'] print(classmates) print(len(classmates)) print(classmates[0]) print(classmates[2]) print(classmates[-1]) classmates.append('Adam') print(classmates) classmates.insert(1, 'Jack') print(classmates) classmates.pop(1) print(classmates) # tuple 不可变的无序集合 t = (1, 2, 3, 4, 5...
592469e599587b3de0a292d3ee09dbda0064346e
Raghavkhandelwal7/help-me-
/swappingfile.py
409
3.65625
4
def swapfileData(): filename1=input("Enter the file name: ") filename2=input("Enter the file name to be swapped: ") with open(filename1,'r') as a: data_a = a.read with open(filename2,'r') as b: data_b = b.read with open(filename1,'w') as a: data_b = a.write(filename2) ...
c1f675174216904835fdad2b24df9870a5516f46
Zachary-Jackson/Secret-Messages
/ciphers/cipher.py
1,256
4.0625
4
import os import string class Cipher: """This is a base template class for a cipher""" @classmethod def clear(cls): """This method clears the screen for easier reading and use""" os.system('cls' if os.name == 'nt' else 'clear') def encryption(self, *args, **kwargs): raise Not...
87ac289924683d12e5d5ebbf0f9c87edaed32afc
itsanjan/advent-of-code
/2018/day1/base.py
497
3.6875
4
with open('input.txt') as inputfile: changes = list(map(int, inputfile.readlines())) print(changes) #---P1 current_frequency=0 for change in changes: current_frequency += change print(current_frequency) #----P2 change=0 observed=set() current_frequency=0 while True: for change in changes: ...
b91dca32a7b2c091da236384300b109efc0acdf3
Terrub/RLA
/src/app/world.py
1,653
3.625
4
# coding=utf-8 """ The world object """ from math import pi, sin class Tile: """ The World tile class """ def __init__(self, p_type, p_id): """ Constructor """ self.type = p_type self.id = p_id class World: """ The world class """ def __init_...
0fd470377430f7f1b951a348fdcb9d04685b4a70
ColdGrub1384/Pyto
/Pyto/Samples/SciKit-Image/plot_random_shapes.py
2,049
3.921875
4
""" ============= Random Shapes ============= Example of generating random shapes with particular properties. """ import matplotlib.pyplot as plt from skimage.draw import random_shapes # Let's start simple and generate a 128x128 image # with a single grayscale rectangle. result = random_shapes((128, 128), max_shape...
74f92c768d6ec3e7766a73af03201626575650d3
navroopbath/coding-exercises
/Mergesort.py
2,036
4.25
4
import unittest class Mergesort: ''' Given an array of ints arr as input, return arr in ascending sorted order. ''' @staticmethod def mergesort(arr): if (arr != None): return Mergesort.recursive_mergesort(arr) else: return None ''' Starts the mergeso...
4bdd9f24cd67cca3c2d6c9d2a3ad09248e38a96a
sirjanaghimire/ProjectWork_Infotek
/python_practice/8_OOPS_python/Z12_inharitance.py
959
3.875
4
class phone: def __init__(self, brand,model_name,price): self.brand = brand self.model_name = model_name self.price = price def full_name(self): return f"{self.brand} {self.model_name}" def make_a_call(self,number): return f"calling {number}....." class smartph...
da82412c887586880363bc465d52c77c6cf0f8f3
emilianoNM/Tecnicas3-2
/Repo23.py
256
3.671875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: #Area del Circulo def areaCirculo(): print "..:Area del Circulo:.." tmp = int(raw_input(">Dame el radio del circulo: ")) print "> El area del circulo es: ", (3.1416) * tmp * tmp areaCirculo()
6938c72561cc4160ef178889d818a70c472f5279
sj43/Code-Storage
/DailyCodingProblem/FlightItineraryProblem.py
513
3.78125
4
def get_itinerary(flights, flight_plan): if not flights: return flight_plan last_stop = flight_plan[-1] for i, (coming_from, going_to) in enumerate(flights): flight_minus_current = flights[:i] + flights[i+1:] flight_plan.append(going_to) if coming_from == last_stop: ...
4c5822a04d7b04e09d5a28a233a089344a89e369
RonnyCaicedoV/Exposicion
/basicoo.py
4,906
3.796875
4
from ast import Num class Basico: def numerosN(n1): n1= int(input("Escriba numero de n: ")) print("Los numeros de 1 a n son: ") for x in range(1,n1+1): print(x, end=" ") def numerosNsuma(n): n= int(input("Escriba el valor de n: ")) su...
91e19b53296c8e5b1cc0eb16983b08516715fda8
FullStackToro/Bank_Account
/main.py
1,022
3.796875
4
if __name__ == '__main__': class bankAccount: def __init__(self, interes): self.interes = interes self.saldo=0 def deposito(self, monto): self.saldo += monto return self def retiro(self, monto): if self.saldo >= monto: ...
ffdd499623b49422c8f34b068734a3c72af349e8
dodmaneaditya/python_code
/python_basics/scalar_type_and_values.py
1,274
3.609375
4
''' Author : Aditya Hegde Description : Demo on Scalar Types : integer, float, string & Boolean Date: ''' print("\n ----------- Demo on Integer Type ------------------ \n") a = 10 b = 0b10 #binary c = 0o10 #octal d = 0x10 #hexa decimal e = int(10.5) #decimal to int f = int(-3.5) g = int("105") # fr...
0d3a5ee621d662558770852b8981f1f3dd20b16d
lensabillion/CS487
/RangeSumOfBST.py
670
3.59375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def rangeSumBST(self, root, L, R): """ :type root: TreeNode :type L: int :typ...
3d6e2e5a3822b8012a0e87db42c50bd2b950b554
HwangYoungHa/ComputerNetwork
/chatbot/practice2.py
329
3.515625
4
import requests # request를 통해 api에 요청 params = {'param1': 'value1', 'param2': 'value'} response = requests.get('https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR', params=params) # 요청한 data를 slicing s = str(response.text)[7:15] usd = float(s) # 출력 print("USD :", usd)
bc25110ad1ebde0cc1bfa88d68c7d970913ef2aa
marth00165/pythonBasics
/lesson5.py
1,163
4.34375
4
from math import * # You can import functions from libraries this enables the math library print("You can print numbers") print(2) # You Can Print numbers print("") print("Numbers can be whole or decimal numbers") print(3.14) # You Can Print Whole or Decimal numbers print("") print("You can print strings along with...
5c18e189034c7627712973a66b9f64ef1ddb1d8e
hamidswer/recursive-factorial
/recursive-factorial.py
181
3.828125
4
def recursive_factorial(n): if (n==1): factorial = 1 else: factorial = n * recursive_factorial(n-1) return factorial print(recursive_factorial(4)) # 24
25d8686edf010b02b7a68b6942ec4bf92c08895e
gwyrwch/math-methods-labs
/OutputMethods.py
990
3.765625
4
class OutputMethods: @staticmethod def print_matrix(matrix): for line in matrix: print([round(el, 3) for el in line]) print() @staticmethod def print_system(matrix): for line in matrix: print('[', end='') for el in line[:-1]: ...
99929ee87ac4f4c0e409134de31992298471c23a
Artembbk/fmsh
/Python/xo_game.py
2,103
3.78125
4
from graph import * FIELD_S = 300 SQUARE_S = 100 X_FIELD = 100 Y_FIELD = 100 move = 0 squares = [[0]*3 for i in range(3)] def square(x, y, a): return rectangle(x, y, x+a, y+a) def cross(x, y, a): line(x, y, x+a, y+a) line(x+a, y, x, y+a) def init(): penColor("black") for i in range(3): ...
9b8e0f984188488c447eeb2da69408c199eeb469
mrtomrichy/PiMote
/examples/PiFace/pifaceexample.py
1,213
3.90625
4
''' An example application to toggle the LED's on a PiFace Written by Tom Richardson 2013 To run, type 'python pifaceexample.py' It will run on the Pi's local IP on port 8090 ''' import pifacedigitalio as p from pimote import * # Initialize PiFace p.init() pfd = p.PiFaceDigital() class MyPhone(Phone): # Overri...
5e6acc130314653495c28934f20cfef9ffa1a778
Crush-on-IT/algorithm-study
/src/Shortest Path/1753_최단경로/백준_1753_최단경로_Screwlim.py
1,082
3.515625
4
import heapq import sys INF = int(1e9) V, E = map(int, sys.stdin.readline().split()) start_node = int(sys.stdin.readline()) graph = [[]for i in range(V+1)] distance = [INF] *(V+1) for _ in range(E): s_node, d_node, weight = map(int, sys.stdin.readline().split()) graph[s_node].append((d_node, weight)) def ...
63870e0b5dad088ed29995cd03df35a5cc739a1e
codio-content/Coding_with_Python-Loops
/content/2-loops/utility.py
486
4.0625
4
counter = 1 # This is a 'counter' variable. total = 0 # This is out utility variable 'totla' while counter <= 10: # If the condition is true, it enters the loop total = total + counter # We add the current value of 'counter' to 'total' counter = counter + 1 # He...
ac4cffbbfa06716170b17efd00f2645797dd616d
v1ktos/Python_RTU_08_20
/Diena_1_4_thonny/while.py
800
4.03125
4
# print("Hello") # print("Hello") i = 0 while i < 5: print("Hello No.", i) i += 1 print("Always happens once loop is finished") print("i is now", i) i = 10 while i > 0: print("Going down the floor:", i) # i could do more stuff i -= 2 print("Whew we are done with this i:", i) i = 20 while True: ...
9f0c6c844d916d2658e2aa87dd76fd57d4fa1e45
shabbirkhan0015/python_programs
/inheritance2.py
844
3.828125
4
class shirt: def __init__(self,color,brand): self.color=color self.brand=brand print("color:",self.color) print('brand:',self.brand) class formalwear(shirt): def __init__(self,color,brand,slimfit,dottedOrNot): shirt.__init__(self,color,brand) self.slimfit=slimfit ...
e1a2b90eeb05362462bb241a9a82606a8a3cda7c
Arthur-Lucifer/Python
/类与对象.py
1,196
3.828125
4
# class Circle: # radius = 0 # def __init__(self,radius): # self.radius = radius # def CircleArea(self): # return self.radius**2*3.1415926 # def CirclePerimeter(self): # return 2*3.1415926*self.radius # for i in range (1,11): # c = Circle(i) # print("半径为",i,"的圆,",end='') ...
32190a10b7cced742ca31321e584c0eeef7f2d05
ross-hugo/project_euler
/7_prime_number/sol.py
507
3.765625
4
#!/usr/bin/python import sys def num_primes(n): primes = [2] i = 3 while True: if len(primes) >= 10001: break add_prime = True for prime in primes: if i % prime == 0: add_prime = False if add_prime: primes.append(i) ...
330e35273dd4b3919ba4f7095414b127fa14ea0e
mohammadfebrir/learningPython
/calculate.py
124
3.609375
4
age1=10 age2=2 age3=age1+age2 age4=age1/age2 age5=age1*age2 print("age3 =",age3) print("age4 =",age4) print("age5 =",age5)
93a8b072dae0b2c0c81cce7e14f13c67b59ebeef
crive150/pythonProjects
/LearningPython/subStringCounter.py
354
4.25
4
#Counts amount of times a specific substring is found within larger string, in this case susbtring : 'bob' s = 'azcbobobegghakl' counter = 0 answer = 0 stringHolder ='' for counter in range(len(s)): stringHolder = s[counter:counter+3] if stringHolder =='bob': answer +=1 print ('Number of tim...
c08e2c41b90a30338d54c48fd0c86ea69519e772
roshstar1999/Daily-Leetcode
/First_Bad_Version.py
683
3.609375
4
#isBadVersion () API function predifined that returns whether an entered product no. is defect one or not(True or False) #We are to find the first bad version in the list class Solution: def firstBadVersion(self, n): #used binary search algorithm left=1 right=n ...
b5a2c8087a0519f313bb8a12af07c759bfa0d6a8
linrakesh/python
/pandas/math_operation_series.py
252
3.78125
4
# mathematical operation on pandas series import pandas as pd s= pd.Series(range(10)) s1 = pd.Series(range(20,30)) print(s) print(s1) s2 = s+s1 print("s2 = s+s1") print(s2) s2 = s+50 print("s2= s+50") print(s2) s2 = s*s1 print("s2= s*s1") print(s2)
5fa9898c41992f84a99435fbf9dbeb4ee0cecd92
kevvrites/leetcode_python
/Add_Binary.py
1,672
3.859375
4
# Author: Kevin Liu # Problems available at https://leetcode.com/ # Start Date: 08/19/2021 # Start Time: 09:28 AM ET # Complete Date: 08/19/2021 # Complete Time: 09:52 AM ET # Note: Problem may or may not be completed in one sitting. # Add Binary # https://leetcode.com/problems/add-binary/ # Given two binary strings ...
9f8da68d182fb6a7a10aaad29943aa7d402830bb
epson121/principles_of_computing
/ttt.py
3,213
3.640625
4
""" Monte Carlo Tic-Tac-Toe Player """ import random import poc_ttt_gui import poc_ttt_provided as provided # Constants for Monte Carlo simulator # Change as desired NTRIALS = 10 # Number of trials to run MCMATCH = 1.0 # Score for squares played by the machine player MCOTHER = 1.0 # Score for squares played by t...
b699082e618e829fd3ec270e38e540139d8c3722
ayush-mehta/Competitive_Programming
/Circular Array Rotation.py
341
3.578125
4
# https://www.hackerrank.com/challenges/circular-array-rotation/problem def circularArrayRotation(a, k, queries): out = list() if k > len(a): k = k % len(a) a = a[-k:] + a[:-k] for query in queries: out.append(a[query]) return out a = [1, 2, 3] k = 4 q = [0, 1, 2] print(circularArr...
27da6cf39a47457799b2d111349e423f69a96fb8
ogsf/Python-Exercises
/Python Exercises/src/Ch5_Ex1.py
249
4
4
''' Created on May 17, 2013 @author: Kevin Write a function called 'do_plus' that accepts two parameters /n and adds them together with the '+' operation. ''' def do_plus(a,b): print type(a) return a+b print do_plus(2,3)
d15794dd0aa436fcc8256e8e953b2478da6b1d61
pvargos17/pat_vargos_python_core
/week_02/mini_projects/lyrics.py
777
3.953125
4
''' -------------------------------------------------------- PROGRAMMED SONG LYRICS -------------------------------------------------------- Programmatically create your own song lyrics with multiple verses, interlaced with a repeating chorus. - use one block of text as verse input (hint: linebreaks c...
06ad186bb2bbe72edb8ae904781eaa3e09aeae8c
ankitbarak/algoexpert
/Hard/maxPathSum.py
863
4.09375
4
# Write a function that takes in a Binary Tree and returns its max path sum # A path is a collection of connected nodes in a tree where no node is connected to more than two # other nodes; a path sum is the sum of the values of the nodes in a particular path def maxPathSum(tree): _, maxSum = findMaxSum(tree) retu...
7cad67850c1b3f7439f26d8ebf8fa88eda594409
agiannoul/ArAn
/plotask1.py
233
3.59375
4
import matplotlib.pyplot as plt import numpy as np def f(x): return np.exp(pow(np.sin(x),3))+pow(x,6)-2*pow(x,4)-pow(x,3)-1 t1 = np.arange(-2, 2, 0.02) plt.plot(t1, f(t1) , 'b') plt.grid() plt.ylabel("f(x)") plt.show()
6f880cf19fefa55490c7401a6ba9640e0bb3e537
Swarnava-Sadhukhan/Python-Tkinter-Projects
/Dictionary/dic.py
489
3.671875
4
from tkinter import * from PyDictionary import PyDictionary import json root=Tk() root.geometry('250x200') #search the meaning def find_meaning(): word=e1.get() dic=PyDictionary() l1.config(text=str(dic.meaning(word))) e1=Entry(root,font=('times 15',15,'bold')) e1.grid(row=2,column=2) bt...
f4958ec98c241d7f6b7dda36d5db13a6d560d5ae
mel-haya/42-AI-Bootcamp
/M01/ex02/vector.py
4,147
3.796875
4
class Vector: def __init__(self,values): if isinstance(values,list): self.values = values elif isinstance(values,int): i = 0 self.values = [] while i < values: self.values.append(i) i+=1 elif isinstance(values,tu...
b100a24731332ab6be087d7728bfb419f38bfe72
verabrayan/ADA
/ADA tarea3/templates/gas.py
940
3.515625
4
from sys import stdin """Nombre: Brayan David Vera Leyton fecha: 8/marzo/2019 codigo: 8918691 Recursos: #Codigo mic tomado de la pagina del profesor Camilo Rocha, como se discutio en clase https://bitbucket.org/snippets/hquilo/b6n5e """ def mic(L,H,a): ans,low,n,ok,N = list(),L,0,True,len(a) while ok and low<H an...
f5eeba7c946e9edbe29760d6b612c53d3261c4b7
kmu-cs-swp2-2018/class-01-kyun2024
/homework/10-2/guess.py
746
3.671875
4
class Guess: def __init__(self, word): self.word = word self.guessedChars = set() self.numTries = 0 self.filledWord = "_" * len(word) def display(self): print("Current: " + self.filledWord) print("Tries: " + str(self.numTries)) pass def guess(self, ...
3fce2aaca6025f248d9869d37c9ae60b0fb9e44b
zuhara/Lycaeum-Mentoring
/test_exercise.py
1,807
3.53125
4
import exercise import random def test_digits(): a = exercise.digits(3467) e = 4.0 assert a == e def test_words(): a = exercise.words("Hello World") e = 2 assert a == e def test_Mtable(): a = exercise.Mtable(3) e = [3,6,9,12,15,18,21,24,27,30] assert a == e def test_Mtable2(): ...
0e0a0b5d5a7ce37d158cbc3c1a3121a41b119679
wills201/Challenge-Probs
/increment.py
205
3.859375
4
listofnums = [5,2,3,2] new_list = [] # def increment(nums): # for num in nums: # return num # increment(listofnums) listofnums = str(listofnums) for i in listofnums: print(listofnums)
f1eb61bc3952f6136b6c39c70178ef3aed768f6e
JoeySuttonPreece/IntroProgramming_Group2
/Week3/Python/3.py
325
3.8125
4
def getNum(): while (True): try: print("Guess the magic number. It's somewhere between 1 and 10!!!") num = int(input()) break except ValueError: pass return num while (True): if (getNum() == 5): break print("Congrats on guessing the 5...
ce8ff6d6f3d7cd0e74afee7b273b0b5136e83953
fengsy868/HangmanSolver
/tree_generator.py
3,520
4.09375
4
#this programme generate a set of decision trees for Hangman according to all the English words # I have used Python tree class implemented by Joowani https://github.com/joowani/binarytree import pickle from binarytree import tree, bst, convert, heap, Node, pprint print 'Start reading the dictionary file...' with ope...
f79bd7c5549a4af3cc983c4e0d92753f7fbfeb2b
haodongxi/leetCode
/22.py
937
3.84375
4
from typing import List def generateParenthesis(n: int) -> List[str]: if n == 0: return [] if n == 1: return ["()"] dict = {} for item in generateParenthesis(n-1): for i in range(len(item)+1): j = i+1 tempS = insertStr(item,"(",i) while j<=len(...
3feee02c30bf5d4fd7b9310cddf2ef52b219d865
JS01230/Document_Parser3
/part3.py
3,349
3.59375
4
#Document Parser v3: Final Version #This version of parser gives the user the ability to determine keywords she/he would like #the parser to use when sifting through the meta-data. Here we append sys.argv with those words. #This parser also splits the program into functions to simplify the process. import sys import ...
943db3b5effafd8fc2c9d8bcfb220d59b0a0deab
ahmedfadhil/PyTip
/DepthFirstSearch.py
808
3.921875
4
from collections import defaultdict # This class represents a directed graph using # adjacency list representation class Graph: # Graph constructor def __init__(self): self.graph = defaultdict(list) def addEdge(self, u, v): self.graph[u].append(v) # A function used by DFS def DFS...
f2beb4026244232bb5d261791ec823be69830215
MubashirullahD/cracking-the-coding-interview
/chapter0/perm.py
580
4.125
4
""" Example: Design an algorithm to print all permutations of a string. For simplicity, assume all characters are unique. abcd abdc acbd acdb adbc adcb """ def fac(iteration): if iteration <= 1: return 1 else: return iteration * fac(iteration-1) def perm(remainder, parsed): if not remai...
65818debf30ece5aaea46dd9d09d68e317fa1c6e
saurabh-kumar88/DataStructure
/Tree/tree2.py
4,201
3.9375
4
from collections import deque class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None def depth(self): left_depth = self.left.depth() if self.left else 0 right_depth = self.right.depth() if self.right else 0 retur...
1b8f333f840a3fee154c1433301d5fe4ad2f0610
Friendktt/My-work
/lol.py
241
3.734375
4
"""kuy""" def main(): """kuy""" num = str(input()) num1 = num.split(" ") print(num1[0][-1]+num1[1][-1]+num1[2][-1]+num1[3][-1]+num1[4][-1]+num1[5][-1]\ +num1[6][-1]+num1[7][-1]+num1[8][-1]+num1[9][-1]) main()
a1bd7edb044a69a52667cee2bb04b017b893a721
Raymond-Lind/SFM
/SFM.py
5,596
4.125
4
# Simulated File System Stored in Memory # Created by Raymond Lind # Main Class class Files: def __init__(self, father, name): self.father = father self.name = name self.directory = [] # Directory list self.file = [] # File list # Configure Home Directory & Path Management home =...
140be5baddbfc03cd26d917a51bb872000390714
Punkrockechidna/PythonCourse
/python_basics/data_types/sets_exercise.py
723
4.46875
4
# Scroll to bottom to see solution # You are working for the school Principal. We have a database of school students: school = {'Bobby', 'Tammy', 'Jammy', 'Sally', 'Danny'} # during class, the teachers take attendance and compile it into a list. attendance_list = ['Jammy', 'Bobby', 'Danny', 'Sally'] # using what you ...
e0944ec702bffd17fd2d18643614b1db4e889c23
treywaevin/Tkinter-Calculator
/main.py
4,160
3.859375
4
# Code made by @treywaevin on github from tkinter import * # Create window win = Tk() win.title('Calculator') win.geometry('525x675') win.resizable(False,False) # Instances expression = "" neg = False # Button Inputs def inputNum(digit): global expression global neg if digit is 'C': ...