blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9212e4283b38b45b13876ad0dd8f1278495243c0
yaominguo/hello-2016
/Douban.py
2,679
3.78125
4
# coding:utf-8 """ 一个简单的Python爬虫,用于抓取豆瓣电影TOP100的电影名称 Anthor: Max Kwok Version: 0.0.1 Date: 2016-01-18 Language: Python 2.7.10 Editor: pycharm 5 """ import string import re import urllib2 class DouBanSpider(object): """page:用于标示当前所处的抓取页面 cur_url:用于标示当前争取抓取页面的url dates:存储处理好的抓取到的电影名称 _top_num:用...
2f4990cc69633539812737e4550ffdd042d0c085
Savas21/MIT_Python_Challange
/practices.py
1,323
4.15625
4
lecture = int(input("Example number : ")) ## Example ! Review of Tuples if lecture == 1 : # Shell vs editor type(5) print(3.0-1) # Python vs Math(Which one is allowed in Python) #x+y = 2 #x*x = 2 #2 = x xy = 2 # Bindings (What's printed?) usa_gold = 46 uk_gold = 27 romani...
918fa47f682798c8cd9f3e0f20911a8c6f675f79
alexpanackal333/Machine-Learning
/Exception handling Assignment.py
1,162
4.09375
4
#!/usr/bin/env python # coding: utf-8 # # Exception handling Assignment # 1. Write a function to compute 5/0 and use try/except to catch the exceptions. # In[1]: def division(a,b): try: c=a/b return c except ZeroDivisionError: print("can't divide by zero") except: print...
5e52235e89f6274646d4933a9925e609f4d45bd6
srdea93/Bioinformatic-Algorithms-Python-
/Complete Algorithms/Permute a String/PermuteAString.py
1,478
4.21875
4
# Recursion demonstration def factorial_recursion(number): if number == 1: return 1 else: return number * factorial_recursion(number-1) # print(factorial_recursion(5)) def to_string(list): return "".join(list) # Given a string, print all permutations of that string def string_permutatio...
eb2180ca03a84fc486f77db8e2bc22f3096b3cdf
srdea93/Bioinformatic-Algorithms-Python-
/Complete Algorithms/Longest Repeating Substring/LongestRepeatingSubstring.py
691
3.9375
4
def longest_repeating_substring(string): # hashtable used to calculate hash for letters and once it is calculated once, can be retrieved with O(1) hash_table = [] # define sliding window size at max - 1: go from largest to smallest k = len(string) - 1 while k > 1: for i in range(len(string) ...
0c298e8657a66d2fc89b22c8b39814cf156db82e
srdea93/Bioinformatic-Algorithms-Python-
/Complete Algorithms/Calculate Protein Weight/CalculateProteinWeight.py
781
3.65625
4
def calc_protein_weight(file): # protein weight dictionary weights = {"A": 71.03711, "C": 103.00919, "D": 115.02694, "E": 129.04259, "F": 147.06841, "G": 57.02146, "H": 137.05891,"I": 113.08406, "K": 128.09496, "L": 113.08406, "M": 131.04049, "N": 114.04293, "P": 97.05276, "Q": 128.05858, "R": 156.1...
c34c49275521e2a186075bf04f27147c58cafd6e
satsukiya/SurveyDesignPattern
/GOF23/Python/yuki2004/Visitor/classes.py
2,072
3.8125
4
from abc import ABCMeta, abstractmethod class Visitor(metaclass=ABCMeta): @abstractmethod def visit(self, file): pass class Element(metaclass=ABCMeta): @abstractmethod def accept(self, v:Visitor): pass class Entry(Element, metaclass=ABCMeta): @abstractmethod def getName(self) ...
17c53edbfae7fcb8ca167e4b0a04ce959f065411
dfvalio/Projet-Matanawi
/structure_syllabique.py
6,727
3.53125
4
#Ouverture d'un fichier .txt avec liste de mots d'une langue text_file = open("lexique_matanawi.txt", "r",encoding="utf-8") list1 = text_file.read().splitlines() #Ouverture d'un fichier .txt pour imprimer les résultats f_results = open("results_structure.txt", "w",encoding="utf-8") #Analyse des contextes vo...
5777acaf0ee6dbe30dde107c21efb5a2d07bbbfa
renan-suetsugu/Livro_Introdcao-programacao-com-Python_Nilo-Ney
/Exercício_3_11.py
451
3.921875
4
# Faça um programa que solicite o preço de uma mercadoria e o percentual de desconto. # Exiba o valor do desconto e o preço a pagar. mercadoria = float(input("Entre com o valor da mercadoria: ")) percentual = float(input("Entre com o percentual de desconto: ")) desconto = mercadoria * percentual / 100 preco_a_...
bbbfec2a4a8c4e8fdb245451525d730da5b48ff4
renan-suetsugu/Livro_Introdcao-programacao-com-Python_Nilo-Ney
/Exercício_4_4.py
453
3.859375
4
# Exercício 4.4 Escreva um programa que pergunte o salário do funcionário e calcule o valor do aumento. # Para salários superiores a R$ 1.250,00, calcule um aumento de 10%. Para os inferiores ou iguais, de 15%. salario = float(input("Entre com o salário: ")) if salario > 1250: novo_salario = salario + salario * 0...
a729a1529b612105343f46714072138719a66eb6
renan-suetsugu/Livro_Introdcao-programacao-com-Python_Nilo-Ney
/Exercício_4_3.py
826
4.21875
4
# Escreva um programa que leia três números e que imprima o maior e o menor. num1 = float(input("Entre com o primeiro número: ")) num2 = float(input("Entre com o segundo número: ")) num3 = float(input("Entre com o terceiro número: ")) if num1 > num2 and num1 > num3: print("O primeiro número é o maior número: %6.2...
da5a6ccf61b533db505664c513609328055432c5
Lokel123/gitrepo
/python/funkcje.py
895
3.75
4
# DRY - don't repeat yourself #print() #input() #int() def witaj(): imie = input("Podaj swoje imię ") print("Witaj", imie, "!" ) def suma2(a, b): """ Funkcja sumuje dwie liczby i zwraca wynik """ return a + b def roznica(l1, l2): pass def iloczyn(l1, l2): pass ...
69d8627731da143ff18e593218e00647713a14bc
DmiFomin/HW3
/victory.py
4,195
3.671875
4
import random from num2words import num2words # Хотел использовать num2word, но получается четырнадцать марта 1879 # Так что добавил строковую дату в словарь def date_to_string(datestr): list_date = datestr.split('.') if list_date[1] == '01': month = 'января' elif list_date[1] == '02': mon...
a0a1878d4677f138146b68ff8003f7fffc7ef24b
bhimbiradar/git_repo1
/class_example.py
3,751
4.53125
5
# class has: # 1.class attribute # 2.instance attribute: the attribute which are defined in constructor is instance attribute # e.g. self.l=mylist # 3.private attribute # 4.constructor: constructor is a method which initilise the object # constructor declaration # def__init__(self,...
1622ec2bc710387badf598cb358affdc06f83aa1
shandrika/questionSG.py
/questionSG.py
646
4.0625
4
#Fix Looping Issue + Add Score #Identify Variables qA = int() choice = False score = int(0) q1t = ("""Which one of these colours are the primary colours? 1.Yellow 2.Green 3.Orange 4.Purple Answer: """) #While Loop while choice == False: try: qA = int(input(q1t)) if qA == 1: ...
14b35571bd0fc727d871a318bfbcc840aa77bf81
vaibhavk5022/Hotel-Management-
/Python_Hotel.Management.Project.py
5,382
3.734375
4
Vaibhav Kashyap, [13.06.21 0o1: 0o6 ] class hotelmanagement: def init(self, rt='', s=0, p=0, r=0, t=0, a=700, name='', address='', cindate='', coutdate='', rno=101): print("\n\n*****HELLO COTTAGE*****\n") self.rt = rt self.r = r self.t = t self.p = p ...
55e8a2926f8373c7c4f2fc38891737e63ff2c79e
alakbar-taghiyev/PragmatechFoundationProject
/Algorithms/Python_practise/Lesson/25iyul_ders02.py
2,254
3.578125
4
#C - Create Data #R - Read Data #U - Update Data #D - Delete Data programMenusu=""" ----Proqram Menusu---- 1-Yeni Tələbə Əlavə Et 2-Tələbələrin siyahısı gör 3-Telebe sil 4-Proqramdan cıx 5-Əsas menuye qayit 6-Ad Filteri 7-Yas Filteri ---------------------- """ telebeler=[] cl...
f0a39fbbdc5e06975bfaef6b6e9f67efbb45bd64
Bonnie-Lin/vsaproject
/proj02_02.py
526
4.46875
4
# Name: # Date: # proj02_02: Fibonaci Sequence """ Asks a user how many Fibonacci numbers to generate and generates them. The Fibonacci sequence is a sequence of numbers where the next number in the sequence is the sum of the previous two numbers in the sequence. The sequence looks like this: 1, 1, 2, 3, 5, 8, 13....
cdb774c45ecce798a4a0fa419f6f522c89291db3
VishalGohelishere/Python-tutorials-1
/programs/EUtoUS-Elevator.py
207
4
4
# Convert elevator floor imp = input('Europe floor? ') usf = int(imp) + 1 # Here at the print function we have used Comma # This is used to print multiple arguments in print function print("US Floor", usf)
d054042d0c5b7e3a9c2fabb92aeb2a53d0907d48
VishalGohelishere/Python-tutorials-1
/programs/excelread.py
637
3.625
4
import xlrd book = xlrd.open_workbook("Book1.xlsx") sheet = book.sheet_by_index(0) # For getting value of total number of rows/colums # As per sheet index totalrows = sheet.nrows totalcols = sheet.ncols valueAtPos = sheet.cell_value(0,0) print(valueAtPos) print(totalrows," ",totalcols) # Program to extract all col...
61661346234f42074033405caf0e3dc910d80250
VishalGohelishere/Python-tutorials-1
/programs/series2.py
241
3.65625
4
# 1+2-3+4-5+6-7+n size = int(input("Enter size ")) sum =0 for i in range(1,size): if(i%2==0): print(i,"-",end=" ") sum = sum - i else: print(i,"+",end=" ") sum = sum + i print("\nSum is ",sum)
b777b8d945b80093415506f3f3ede75af2942a90
freshlea4366/CTI110
/M3HW1_AgeClassifier_Freshley (2).py
374
4.125
4
#CTI 110 #M3HW1: Age classifier #Freshleya #09/20 def main(): age = int(input("What is the age?")) if age<= 1: print("They are an infant") elif age >1 or age < 13: print("They are a child") elif age >= 13 and age <20: print("they are a teenager") elif age ...
5358deaf315fd9805c0532f1779061d924b568ed
freshlea4366/CTI110
/M5T1b_Freshley.py
845
3.71875
4
import turtle def main(): win=turtle.Screen() #t=turtle.Turtle() #color options turtle.pencolor("Green") turtle.shape("turtle") # Letter A turtle.penup() turtle.back(320) turtle.pendown() turtle.forward(320) turtle.left(120) turtle.forward(320) tur...
a59e8f7c7882f8cdcd8c1d0c7ee601c275aec7bc
Elesh-Norn/Mocking_Around
/BFS.py
5,413
4.1875
4
""" Array Backed Grid Show how to use a two-dimensional list/array to back the display of a grid on-screen. If Python and Arcade are installed, this example can be run from the command line with: python -m arcade.examples.array_backed_grid_buffered """ import arcade from collections import deque from grid import Grid...
dfebc2d0928d7ae2174b4412249c50db46ee7780
faizerhussain/TestingEclipseGitUpload
/Hello1/exceptional2.py
265
3.640625
4
def convert(s): '''convert to an interger''' try: x=int(s) print("conversion suceeded! X=", x) except (ValueError, TypeError): x=-1 print("conversion failed ! ") return x convert("20") convert([4,5,6])
af51317322ce1a1d52d25dbb61822858e5523706
faizerhussain/TestingEclipseGitUpload
/Hello1/WithKeyword.py
604
3.578125
4
import sys from urllib.request import urlopen url=url='http://sixty-north.com/c/t.txt' def fetchWords(url): with urlopen(url) as story: story_words=[] for line in story: line_words = line.decode('utf-8').split() for words in line_words: story_words.a...
13ae7881c19bd73b9183ef071184b2cb20c9ac01
faizerhussain/TestingEclipseGitUpload
/Hello1/Funntions.py
478
3.546875
4
def sayHello(name): print('hello', name) sayHello('Faizer') def sayHello1(name= 'hussain'): print('hello', name) sayHello1() sayHello1('Faiz') def getSum(n1,n2): total=n1+n2 return total addSum=getSum(2, 3) print('addition is ',addSum) print('***************') def mu...
f3ff71c1596c12b7c76c739619b6a1d748d35424
lddsjy/leetcode
/python/isSymmetrical.py
923
3.84375
4
# -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSymmetrical(self, pRoot): if not pRoot: return True def isSame(p1,p2): if not p1 and not p2: return...
10c1d5d5c7079475b97a43ed08098395605c5994
lddsjy/leetcode
/python/minStack.py
636
3.828125
4
# -*- coding:utf-8 -*- class Solution: def __init__(self): self.stack = [] self.minN = [] def push(self, node): self.stack.append(node) if self.minN and self.minN[-1] < node: self.minN.append(self.minN[-1]) else: self.minN.append(node) def pop(...
119f5482c41ff0885f8f4a70daadfb44a0593aa3
lddsjy/leetcode
/python/jumpFloorII.py
316
3.703125
4
# -*- coding:utf-8 -*- class Solution: def jumpFloorII(self, number): if number < 1: return None way = 1 number -= 1 # while number: # way *= 2 # number -= 1 way = pow(2,number) return way s = Solution() print(s.jumpFloorII(2))
7b5d9191c3d376cd50c7151d201515a03910023b
lddsjy/leetcode
/python/deleteDuplication.py
895
3.625
4
# -*- coding:utf-8 -*- class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def deleteDuplication(self, pHead): if (not pHead) or (not pHead.next): return None p = pHead pHead1 = pHead.next if pHead1.val != pHead.val: ...
3ef299ac5b6ea423efa0a7982e9bcbb3c063c820
lddsjy/leetcode
/python/kthNode.py
1,395
3.546875
4
# -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # 返回对应节点TreeNode def KthNode(self, pRoot, k): arr = [] arr = self.minnode(pRoot,arr) print(arr) if k<=len(arr) and k>0: ...
f8f63268cdfcbaac7f8e07acceca5b09d2906552
lddsjy/leetcode
/python/PrintMinNumber.py
277
3.796875
4
# -*- coding:utf-8 -*- class Solution: def PrintMinNumber(self, numbers): if not numbers: return None fun = lambda n1,n2:int(str(n1)+str(n2))-int(str(n2)+str(n1)) sorted(numbers,cmp=fun) return ''.join([str(i) for i in numbers])
270ff69d57aba142e7486f30a64f33448c1e8050
onatyap/best_spot_to_meet
/data_structures/priority_queue.py
907
3.65625
4
from data_structures.priority_queue_node import PriorityQueueNode from utils.data_types_utils import PriorityQueueNodeList class PriorityQueue: # Array based Min Priority Queue def __init__(self): self.container: PriorityQueueNodeList = [] def push(self, element: PriorityQueueNode): self.con...
04acfa44dc96fc2d1506720aa79df6177a251f4e
jennyyu73/tetris
/Tetris.py
11,005
3.53125
4
######## # Tetris # Jifeng Yu ####### from tkinter import * import random ###### # Helper functions for math floating point ###### def almostEqual(d1, d2, epsilon=10**-7): # note: use math.isclose() outside 15-112 with Python version 3.5 or later return (abs(d2 - d1) < epsilon) import decima...
e399525a1534169be7714d133d85046a9953ceb2
filipAnt/learning
/functions.py
7,226
4.46875
4
""" source for excercises: https://www.w3resource.com/python-exercises/python-functions-exercises.php """ # 1. Write a Python function to find the Max of three numbers. def max_of_three(a: int, b: int, c: int): return print(max(a, b, c)) # max_of_three(234,456,678) # 2. Write a Python function to sum all the n...
fc4c15c6e52e68d8a48410f0be5b725730f2830c
MariusArhaug/RPNCalculator
/queue.py
483
3.953125
4
"""Queue data structure""" from container import Container class Queue(Container): """Inherits from Container""" def peek(self): """ Return first element without deleting it :return: first element """ assert not self.is_empty() return self._items[0] def po...
a4a6687d12e346d6652f358e839bb46ae77f4b3b
Praveenstein/Intern_Assignment
/For_statement_full.py
875
4.25
4
def main(): # basic use of for statements num = [1, 2, 3, 4, 5, 6] sum = 0 for value in num: sum += value print("The sum of number is: ", sum) # using range in for loops sum = 0 for value in range(1, 20, 2): sum += value print("The sum of number is: ", su...
529f98991d9c8d2e479eddf9fc31330eed6fef0d
Praveenstein/Intern_Assignment
/horner.py
857
4.4375
4
# -*- coding: utf-8 -*- """ Horner's method for polynomial evaluation This script allows the user to evaluate a given polynomial in O(n) time A polynomial 2x^2 + 3x -1 is given as a list of coefficients as: [2, 3, -1] This file contains the following function: * main - the main function of the script ...
d7276a3a08e9febd0a0e9d9a7a09fc9370b7a650
Praveenstein/Intern_Assignment
/numbers.py
894
3.78125
4
from decimal import Decimal as d from fractions import Fraction as f import math def main(): # basic numeric data types in python print(type(6)) print(type(6.5)) print(type(6+7j)) num=6+7j print(isinstance(num, complex)) #operations using binary, octal, hexadecimal print(0b100...
da0cdf20cd0dc97cf87a890549156f526a5c1f95
Crell/PyLife
/world.py
5,669
4.03125
4
import copy import operator """ Occupants: - F: Food - R: Rock - E: Empty (Changeable) - Digit: A player, each species is a different digit Rules: Living cell survives if: (friends + enemies) < 4 friends+food >=2 Cell is born if: friends + food = 3 @todo Create a coord named-tuple and use that instead of the ano...
67fb1d93de36b9c0805a99d2683644a9148715ec
AremanHashemi/Practice_Problems
/LeetCode/Python/anagrams.py
2,405
4.0625
4
''' Anagram solver: Given an array of words print the words that are anagrams of each other ''' ''' isAnagram(w1,w2) returns true if w1 is an anagram of w2 anagram meaning w2 is the same characters as w1 in any order Ideas Brute force Iterate over each character of w1, remove the character from w2 ...
cffe926fc531a8bade23dee2d8bba8c68fd37104
JorgeObis/1evaluacionpy
/sumador python.py
310
3.703125
4
def sumador(): x=input("Dime el primer numero:") y=input("Dime el segundo numero") z=input("Dime el tercer numero") a=input("Dime el cuarto numero") s=input("Dime el quinto numero") print"La suma vale" print x,"+",y,"+",z,"+",a,"+",s,"=", x+y+z+a+s sumador()
d78795309243295a9af62946d75793fdaba95d0f
JorgeObis/1evaluacionpy
/sumador_acumulado.py
197
3.875
4
def sumador_acumulado(): n=input("Dime hasta que numero quiere sumar: ") suma=0 for cont in range(1,n+1,1): suma=suma+cont print "suma=",suma sumador_acumulado()
bf4b08364922ae7c9c5c92314837c03fa4128138
shubham-dalmia/HactoberFest21
/Python/displayoddnumbers.py
152
4.4375
4
#python program to display odd numbers print("Odd numbers are as follows") for i in range(1,100,2): print(i) print("End of the program")
3fd2f6cfaa512311b541d7c79dfc86f63ecdb9d0
daesy13/calculator-1
/calculator2.py
1,448
4.1875
4
#Calculator 2 from arithmetic import * def calculator_repl(): while True: user_input = input("> ") user_list = user_input.split(" ") if user_input == "q": #quit if q is entered print("Exit") break elif len(user_list) < 2: print("Not Enough Inputs") #validate that at least 2 inputs are entered co...
44a9cff2ac9c0a2a5a4aaa65617825a8b58c1872
Emilio-Rdz/Programacion
/Evidencia_2.py
423
4
4
from math import pi class Circulo: def __init__(self, radio=0.0, altura=0.0): self.radio = radio self.altura = altura def area(self): resultado = pi*self.radio**2 return resultado a = Circulo() radio = float(input("Cual es la medida del radio de la base: ")) altura = float (i...
196707f3646822879ee1f7ccb9905a34abf2b13c
i4seeu/ibmcode_ai
/knn_classfier.py
2,244
3.515625
4
import itertools import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import NullFormatter import pandas as pd import numpy as np import matplotlib.ticker as ticker from sklearn import preprocessing #lets reed the dataset using pandas df = pd.read_csv('teleCust1000t.csv') print(df.head()) #data v...
ab0bab29b97fc61b4588257fe819f1ca6cfde5b1
MarleneDraganov/teste
/ex049.py
185
3.921875
4
num = int(input('Digite um número para saber a taboada de multiplicação: ')) print('=' * 12) for c in range(1, 11): print('{} X {:2} = {}'.format(num, c, num*c)) print('=' * 12 )
5006589717ebad563ad7c92d3b3c5b62de7c0d4f
MarleneDraganov/teste
/ex036.py
569
3.9375
4
print('\033[1;34m==========AVALIADOR DE EMPRÉSTIMO IMOBÍLIÁRIO============') casa = float(input('\033[1;36mQual é o valor da casa? R$ ')) salário = float(input('Qual é o salário do Comprador? R$ ')) anos = int(input('Quantos anos de financiamento? ')) prestação = casa / (anos * 12) mínimo = salário * 30 / 100 print('Pa...
f51aeeac434183e5e2246139895a7052c983c6ee
MarleneDraganov/teste
/ex044.py
981
3.65625
4
print('*' * 35) print('{:=^35}'.format(' DRAGANOV STORE ')) print('*' * 35) preço = float(input('Preço das Compras:R$ ')) print('''FORMA DE PAGAMENTO [1] à vista dinheiro/cheque [2] á vista no cartão [3] 2 X no cartão [4] 3 ou mais vezes no cartão''') opção = int(input('Qual é a sua opção?: ')) if opção == 1...
f17723cef81dd8bb6941a501270b8ff49b75578f
bibash44/taxibookingsystem
/RegisterWindow.py
8,892
3.546875
4
from LoginWindow import * from tkinter import * from tkinter import messagebox import re from UserBLL import * # Class declaration for register window class Register: def __init__(self): # Assigning title, width height and setting window to middle of the screen self.registerWindow = Tk() s...
9f5da721dafa6546b7ef34027c87e75014c22a8b
shengu4098/C109156121
/13.py
218
3.53125
4
af=[] bf=[] s1=input("請輸入A的朋友").split(" ") s2=input("請輸入B的朋友").split(" ") for i in range(len(s1)): af.append(s1[i]) for i in range(len(s2)): bf.append(s2[i]) print(len(set(af)&set(bf)))
3a03384238972ff2e54184e80bdc2df3bd2dcce7
shengu4098/C109156121
/5.py
333
3.609375
4
d1={"1":72,"2":62,"3":82,"4":44,"5":60} s1=input("請輸入主餐及升級的套餐") s2=input("是否升級成大杯飲料") s3=input("是否升級成大薯") p=0 if s1[1]=="A": p+=55 p+=d1.get(s1[0]) elif s1[1]=="B": p+=68 p+=d1.get(s1[0]) if s2=="是": p+=7 if s3=="是": p+=13 print("總共為",p,"元")
1b0096acf4595fb93cd32ae262d82140349d764d
shengu4098/C109156121
/11.py
206
3.546875
4
def breakdown(a): c=0 for i in range(1,a): if a%i==0: c+=i return c n=int(input("請輸入正整數n:")) if n==breakdown(n): print("perfect") else: print("deficient")
17ff385fabb11e64b551454cb3228f68335a8b6c
TommasoAmici/uefa_round_16_32
/round16CL.py
3,495
3.828125
4
# AUTHOR: TOMMASO AMICI # simulates draw for round of 16 in the Champions League # prints pandas output to terminal and to draws.csv # the number of simulations is an int passed as argv[1] import random import pandas as pd import sys # checks if match is possible: team from different group and different nation def ...
a9242a8d457fb80d511d4cb1ff537a223d3b5b92
trainesb/CSE331-Algorithms_and_Data_Structures
/Project8_BinaryMinHeap/BinaryMinHeap.py
6,058
3.96875
4
######################################## # PROJECT: Binary Min Heap and Sort # Author: Ben Traines ######################################## class BinaryMinHeap: # DO NOT MODIFY THIS CLASS # def __init__(self): """ Creates an empty hash table with a fixed capacity """ ...
9fee1c84c272e991e7bf33703b03cfb31f10543c
rdtr/leetcode_solutions
/python/0019_remove-nth-node-from-end-of-list.py
766
3.828125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ if not head:...
8381137070be78f201ce12917fd36fef53c44beb
rdtr/leetcode_solutions
/python/0166_fraction_to_recurring_decimal.py
1,204
3.625
4
class Solution: def fractionToDecimal(self, numerator: int, denominator: int) -> str: if numerator == 0: return "0" neg = '' if (numerator < 0 and denominator >= 0) or (numerator >= 0 and denominator < 0): neg = '-' numerator = abs(numerator) denomina...
c362ebf51f95c80c0ab444e495a81ae88c2e9c81
rdtr/leetcode_solutions
/python/0687_longest_univalue_path.py
1,508
3.71875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def longestUnivaluePath(self, root: TreeNode) -> int: if not root: return 0 res = [0] leftpath = rig...
ec0c94dafdb370c0a5fd109e95b3b333aa760861
rdtr/leetcode_solutions
/python/0112_path_sum.py
1,106
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def hasPathSum(self, root, sum): """ :type root: TreeNode :type sum: int :rtype: bool """ ...
145684e6374e2a4e0cdb0efbf35f6d60a7f880c0
rdtr/leetcode_solutions
/python/0457_circular_array.py
1,182
3.53125
4
class Solution(object): def circularArrayLoop(self, nums): """ :type nums: List[int] :rtype: bool """ if not nums: return False for j in range(len(nums)): i = j allVisited = set([i]) visited = set([i]) ...
e56caac8324983196c8f8a768d2ab5c9df8ac0a0
rdtr/leetcode_solutions
/python/0156_binary_tree_upside_down.py
765
3.859375
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 upsideDownBinaryTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: if root is None or r...
dd9f876ca140ca202c88ded56de9fc142d01c32b
rdtr/leetcode_solutions
/python/0844_backspace_string_compare.py
833
3.578125
4
class Solution: def backspaceCompare(self, S, T): """ :type S: str :type T: str :rtype: bool """ s, t = len(S) - 1, len(T) - 1 while True: sback, tback = 0, 0 while (S[s] == '#' or sback > 0) and s > -1: if S[s] == '#': ...
4c6a4c3ccccabe66da77c6a61797d795658675d9
rdtr/leetcode_solutions
/python/0958_check_completeness_of_a_binary_tree.py
998
3.84375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Solution: def isCompleteTree(self, root: TreeNode) -> bool: if not root: return False ...
3a95169e804925c2bf98a04127c0fa360c3efcdb
JFaruk/Py_basics
/dic.py
581
4.28125
4
# python version of hashtable # create mapping with key-value pairs dics={'key':1,'key2':'2','dics2':{'num_1':1,'num_2':'abd','num_3':[1,2,'grab the cookie']}} print(dics['dics2']['num_3'][2].upper()) # example from myself dic_ex={'sharifa':'200','nafisa':'4000','divine_it':{'IT':'86','CEO':3,'other':[3,5,6,'Faruk'...
097905cc4ccc15acd3f61e252732dc3f32b5b5c2
JFaruk/Py_basics
/functions.py
1,222
4.0625
4
# default layout of fun: # def my_function(param='default'): # pass # code start from here: def my_function(param='faruk'): ''' This is the docs of this function param ''' print('My name is {}'.format(param)) my_function() # difference between print statement and return statement: def he...
62380957ba6bdc4884fc4ac0c3412668e7ef43c2
mallorysmith64/udacity-python-solutions
/ExtractFirstNames.py
470
4.375
4
# Instructions: # Use a list comprehension to create a new list first_names containing just the first names in names in lowercase. #solution names = ["Rick Sanchez", "Morty Smith", "Summer Smith", "Jerry Smith", "Beth Smith"] first_names = [name.split()[0].lower() for name in names] print(first_names) #solution if...
8e0e4cc4885d57a6aa805892ad5fb2a729d2ee7a
HamplusTech/PythonCodes2021Update
/max_of_two_numbers.py
1,211
4.3125
4
##print ("This program checks for the maximum of two numbers") ##max_num = 0 ##first_number = int(input("Please enter the first number\n")) ##second_number = int(input("Please enter the second number\n")) ##if first_number > second_number: ## max_num = first_number ##else: ## max_num = second_number ##pri...
4ae10f4281623146cc2cbe4a7972a5cb6cde049a
HamplusTech/PythonCodes2021Update
/fibonacci sequence.py
765
4.34375
4
#A program to print the fibonacci sequence print("The Input") number = int(input("Please enter a number\n")) print() def fib(n): ''''Finds the fibonacci of a positive number''' f0, f1 = 0, 1 if n == 0: return f0 if n == 1: return f1 return fib(n-1) + fib(n-2) ...
929e36af019ab45f00a40bb70bacc30b3fd4c36e
HamplusTech/PythonCodes2021Update
/AnswersToTask - Week 2 Task 1.py
774
4.34375
4
print("Answers to online task by Hampo, JohnPaul A.C.") print() print("Week 2 Answers") print("Data = [2,4,2,1,4,5,6,1,11]. Multiply the elements in the list \ using:\ a) for loop\ b) list comprehension\ c) map function") print() print("Using for loop") print() Data = [2,4,2,1,4,5,6,1,11] data_new = [] for...
03e7b844081fe9fea0db1255f71db5bbddef73fd
HamplusTech/PythonCodes2021Update
/reverse.py
360
4.15625
4
# A program to print a given string in reserve order text = input("Please enter any string\n") text_reverse = [letter for letter in text.split()] print() final = "".join(list(reversed(text_reverse[0]))) print(final) print ("Another Method") textLength = len(text) while textLength > 0: print(text[textLe...
b159fb7be15a305a02fea9ce5f3b3aad483ec2f0
AlexGuDu/UABC-Python
/Parcial 1/crash_course (extra)/variables.py
489
4.125
4
# VARIABLES & DATA TYPES greeting = 'Welcome to Python' greeting = 'Python to welcome' print(greeting) # DATA TYPE myStr = 'Hey' myInt = 22 myFloat = 7.5 myList = [1, 2, 3, 'Hey'] myDict = { 'a': 1, 'b': 2, 'c': 3 } print(type(myStr), myStr) print(type(myInt), myInt) print(type(myFloat), myFloat) p...
fcbb567c8ba8f17e5938fc45ca8fb8be5fbedbde
AlexGuDu/UABC-Python
/Parcial 1/pp_uabc/pp_practicas_p1/pp_functions.py
517
3.953125
4
# User functions: return string def greeting(): return "Hey there " print(greeting()) greeting_message = (greeting()) greetee = "Bob Cernovsky" print(greeting_message + greetee) # User functions: sum x = int(input("Give me the first number ")) y = int(input("Give me the SECOND number ")) def add(num1, num2): nu...
455906d45bd2a54d497f152ed5ea22214a589eb8
AlexGuDu/UABC-Python
/Parcial 1/crash_course (extra)/EPN.py
1,219
3.765625
4
# functions by Python import random def scholarship(student_name, student_age, student_grade): if student_grade >= 90: if student_age >= 18: print("Congratulations", student_name, "your scholarship is of 4000 eurodollars") elif student_age <= 17: print("Congratulations", st...
f5216e3cb0ad8bb013ccd3ba9b49faae736e2598
mihajloracic/plagijatthill
/environment/environment.py
1,046
3.5
4
import random class Environment: def __init__(self): self._state_count = 1 self._state = [random.random()*60+50, random.random()*40+20, 0] self._consumers = [45, 60, 30] def get_state(self): return self._state def next_state(self, action): water_pool = sum(self._st...
6e6b5b722d42c94c39b5e2df19d39767f514f72f
joshuajz/grade12
/0.review/Assignment 15.py
1,113
3.8125
4
import random words = [] with open("Grade 11 Review/words.txt", 'r') as f: for line in f.readlines(): words.append(line.strip("\n")) random_word = words[random.randint(0, len(words))] print("Word: ", end='') print("_ " * len(random_word)) guesses = {'amount': 0, 'guesses': [], 'body_parts'...
ce3912bc4c11f32ccef17be8c8f905a61d6fcf30
joshuajz/grade12
/0.review/7. pythagorean.py
392
3.96875
4
# Author: Josh Cowan # Date: October 5, 2020 # Filename: pythagorean.py # Descirption: Assignment 7: Pythagorean Therom Checker # Input a = int(input("a: ")) b = int(input("b: ")) c = int(input("c: ")) # Checks if a^2 + b^2 = c^2 if (a * a) + (b * b) == c * c: print("a^2 + b^2 = c^2") print("Ther...
ab5078570e824a0721c852e0b2a1be151491ee41
joshuajz/grade12
/1.functions/Assignment 3c.py
2,043
4.09375
4
# Author: Josh Cowan # Date: October 8, 2020 # Filename: Assignment #3c.py # Descirption: Assignment 3: Password Checker import time # Ask the user for a password def ask_pwd(): pwd = input( "Enter an 8 digit password with at least 2 numbers, 1 upper case, 1 lowercase: " ) accepted =...
1e1c7d60e4f26c38373ea36344e35af3d5845a91
joshuajz/grade12
/0.review/056.py
353
3.9375
4
courses = ['computer science', 'msip', 'spare', 'data', 'english'] index = 0 for course in courses: print(f"{index}: {course}") index += 1 nums = [] num = 2 for i in range(20 / 2 - 1): nums.append(num) num += 2 for num in nums: print(f"{num} is divisible by 10" if num % 10 == 0 else...
e4ab7f1a9dace14ba334c73bfd1371985cbb58f6
KickItLikeShika/Neural-Network
/NN - Regression/NN-regression.py
2,707
4.1875
4
import numpy as np def train(X, y, W1, W2): """Perform Forward propagation and backpropagation.""" # Forward propagation # Dot product of X (input) and first set of 3x2 weights Z2 = np.dot(X, W1) # activation function A2 = sigmoid(Z2) # dot product of hidden layer (Z2) and secon...
7b926e12eb91b45606665ba9f23a94d28d3a1f33
coxd6953/cti110
/P3HW2_MealTipTax_Cox.py
643
3.890625
4
# CTI-110 # P3HW2 - MealTipTax # Damien Cox # 3/3/19 # #Enter the cost of the meal. cost = int(input('Enter the total cost of the meal: ')) #Calculate the cost of the meal with tax. wtax = cost * 0.07 + cost #Enter the amount of a tip. vtip = int(input('Enter the tip amount for the meal (choose 15, 18 ...
86931e3d3b5ea71ac1c3d3edc7d677f866bc2f9f
taisazero/GraderPy
/group_aggregator.py
2,532
3.5625
4
from tkinter import * import pandas as pd import collections import statistics def browse(): from tkinter.filedialog import askopenfilename Tk().withdraw() filename = askopenfilename() return filename print('Pick CSV ') csv=browse() csv_data=pd.read_csv(csv) group_column= input('Enter the group colu...
a72eaa200daba02eb327e2003ed02b992608ad80
HotPotter/python_beginner
/Hackerrank/day22Binarytree.py
2,155
4.1875
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None class Tree: def __init__(self): self.root = None def insert(self, data): if self.root == None: self.root = Node(data) else: node = self.root ...
03b404b314484d4f89895d5a0ed957db49d25010
Nahida-Jannat/weather-app
/weather_app.py
2,296
3.734375
4
import tkinter as tk from PIL import Image, ImageTk from weather_api import weather_information def open_weather_icon(icon): # set current weather icon size = int(information_frame.winfo_height()*0.30) img = ImageTk.PhotoImage(Image.open('./img/'+icon+'.png').resize((size, size))) weather_icon.de...
204ddab83ae7dd006fa0266ce2651b370399c652
ksmdeepak/Leetcode
/Python Solutions/Remove_Duplicates_Sorted_Array2_80.py
596
3.53125
4
# https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/description/ class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ i=0 flag=0 while(i<len(nums)): if flag==1 and i+1<len(nums) and...
03417c49ca5ec993f8bf3b45ef250fa276e36c9d
ksmdeepak/Leetcode
/Python Solutions/Remove_Duplicates_Sorted_List_2.py
1,016
3.5625
4
# https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/ class Solution: def deleteDuplicates(self, head): """ :type head: ListNode :rtype: ListNode """ if head is None: return head else: curr = head nxt =...
53f68cbc876458d187298a3e10b661e46fe73e66
sthefanni/pythondecisao
/questao7.py
341
3.9375
4
p = int(input('Primeiro numero: ')) s = int(input('Segundo numero : ')) t = int(input('Terceiro numero: ')) maior = p if (s > maior): maior = s if (t > maior): maior = t print('Maior: ',maior) menor = p if (s < menor): menor = segundo if (t < menor): menor = t pri...
aa6714b72be762ca6045e31aff63b5ab5ba8e0c1
sthefanni/pythondecisao
/questao5.py
239
3.828125
4
n1 = input('Insira a primeira nota: ') n2 = input('Insira a segunda nota: ') r = (n1 + n2) / 2 if r >= 7 and nota < 10: print 'Aprovado' elif r >= 10: print 'Aprovado com Distinção' else: print 'Reprovado'
8d3fe6592de2a65cc2323e2a88df5dc1be235e2e
skilbjo/eval-apply
/lib/parse.py
1,118
4.21875
4
#!/usr/bin/env python3 Symbol = str # A Scheme Symbol is implemented as a Python str List = list # A Scheme List is implemented as a Python list Number = (int, float) # A Scheme Number is implemented as a Python int or float def parse(program): "Read a Scheme expression from a string." return r...
1a634a7976fac61729b8b4702258fdd446338c59
SardulDhyani/MCA3_lab_practicals
/MCA3B/20711074_Vivek-Binjola_MCA(B)/Ans_9_Tuples.py
166
3.921875
4
# Python Tuple tuple1 = [1, 2, 3, 4, 5, 6, 7, 8] print(tuple1) tuple2 = [1, 2, ("user"), 3, 4, 5, 6, 7, 8] print(tuple2) print(tuple2[2][2]) # print users's => e
98216f5d7e322017a4b73936a1fc7b8e3213693f
SardulDhyani/MCA3_lab_practicals
/MCA3A/SardulDhyani_MCA_20561012/Ans_2_WP_Mathematical_Operator.py
202
3.953125
4
value1 = 2 value2 = 3 print("Add :", value1 + value2) print("Difference :", value1 - value2) print("Product :", value1 * value2) print("Divison :", value1 / value2) print("Modulas :", value1 % value2)
acf867c88f773b27b505da8ce03d543b72cb2093
SardulDhyani/MCA3_lab_practicals
/MCA3C/Saurabh_Suman_Section_C/ques_2_4.py
688
4.3125
4
#Write a program to calculate the multiplication of two 3x 3 matrices. num1 = [[15, 4, 13], [12, 14, 16], [4, 17, 9]] num2 = [[3, 12, 4], [14, 31, 6], [12, 17, 5]] Result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for m in range(len(num...
e964f563a7c80dae773fbe1e7de5ce92b2079da1
SardulDhyani/MCA3_lab_practicals
/MCA3C/Saurabh_Suman_Section_C/Ques_2_1.py
712
4.21875
4
# Write a program to find the mean. mode and median of the given range of number. list1 = [1,2,3,4,5,6,7,8,9,10,2] sum = 0 for i in list1: sum = sum + i print("-----------------------------------------") mean = sum /len(list1) print("Mean of the list is: ",mean) print() median =int(len(list1)/2) pri...
f333dc41f3c0cb278b441ea08484c7ebef493977
SardulDhyani/MCA3_lab_practicals
/MCA3A/DeepakSingh_MCA_20561002/Ans4_WPFactorialOfNumber.py
255
4.1875
4
n = int(input("enter no: ")) fact = 1 if n < 0: print(" Factorial does not exist for negative numbers") elif n == 0: print("The factorial of 0 is 1") else: 5 for i in range(1, n+1): fact = fact * i print(fact)
495ddc5d49e9a49555c23dbbf08e1a450cb1f757
SardulDhyani/MCA3_lab_practicals
/MCA3A/Dixit_Gusain_MCA_20711051/q9_searchingsorting.py
221
3.875
4
list = [1,9,55,4,2,0,3] print("Sorted List:" ,sorted(list)) print("without sorting: ",list) # print index of 9 index = list.index(9) print(index) # print 5 is not in list index = list.index(5) print(index)
055a29e1321675060a6940391aaf33c4cfe1bfe9
SardulDhyani/MCA3_lab_practicals
/MCA3C/Saurabh_Suman_Section_C/ques_1.py
935
4.3125
4
#Write a program to use mathematical operation: num = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) print() print("-----------------Common Mathematical Operation-----------------------------") print("Sum of Two Number: " ,num + num2) print("Substraction of two num: ", num -num2) ...
02f03325fe3982ff8b90fa8d1d6886ad4079e578
SardulDhyani/MCA3_lab_practicals
/MCA3A/AnkitPhondani_mca_2001031/Ans_5_WP_Check_No_Prime.py
220
3.984375
4
n = int(input("enter no: ")) flag = 0 m = 0 m = n/2 while (m > 0): if(n % 2 == 0): print("not a prime number") flag = 1 break if(flag == 0): print("is a prime number") break
d87acb3fcc3b846ae4fa2501bee483c1b22093cd
SardulDhyani/MCA3_lab_practicals
/MCA3C/Saurabh_Suman_Section_C/ques_2_2.py
496
4.03125
4
#Write a program to calculate the standard deviation of a given set of numbers. import math list1 = [1,2,3,4,5,6,7,8,9,10,2] list2=[] sum = 0 for i in list1: sum = sum + i mean = int(sum /len(list1)) for i in list1: diff =abs(int( mean - i)) list2.append(diff) sum1 = 0 for i in list2: ...
8f4f78b648821ca73158e43a2a5ece17816ee8b7
SirKitboard/Notes
/CSE310/Lab 4/TempPingClient.py
1,505
3.5
4
import sys, time from socket import * # Get the server hostname and port as command line arguments argv = sys.argv host = argv[1] port = argv[2] # Create UDP client socket # Fill in start # Fill in end # Set socket timeout as 1 second # Fill in start # Fill in end # Command...