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
19606934c7c41e6397b9afa1f3b66f38da77ad5e
moneyDboat/offer_code
/56_删除链表中重复的结点.py
833
3.703125
4
# -*- coding: utf-8 -*- """ # @Author : captain # @Time : 2018/10/30 1:22 # @Ide : PyCharm """ # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteDuplication(self, pHead): # write code here if not pHead: r...
8caf1374f02dccfeb97115de3d442ba2db756441
HugoGranstrom/pymatica
/kernels/multiply.py
320
3.875
4
def work(a, b): a = int(a) b = int(b) return [a * b, True] def run(): output = 1 nums = input("Write the numbers you want to multiply separated by spaces:\n") nums = nums.split(" ") for i in range(0, len(nums)): current = int(nums[i]) output *= current print(output)
a960e130a903deec3f574b604f7ac5c5aadd2632
adithyabangolae/project-100
/Atm.py
372
3.765625
4
class Atm(object): def __init__(self,cashWithdrawl,name,typeOfCard): self.cashWithdrawl= cashWithdrawl self.name = name self.typeOfCard= typeOfCard def atm(self): print("ATM:") atm1 = Atm("50","Adithya","credit card") print(atm1.atm()) print(atm1.cashWithdraw...
c8d4718a81f3cfbfab215ee69595d4346515cb90
cs-fullstack-fall-2018/python-challenge-fizzbuzz-myiahm
/homework16th.py
468
3.6875
4
# try: # for i in ['a', 'b', 'c']: # print(i ** 2) # except: # print("type error occured ") # x= 5 # y = 0 # # # try: # z = x/y # print(z) # except: # print("zero division error ") # finally: # print("All done") import sys def ask(): numberToBeSquared = input("interger") try: ...
48de00dd42f21168199ece2781044fe936f027de
willassad/ram
/syntaxtrees/expressions.py
3,454
3.96875
4
""" Overview and Description ======================== This Python module contains expression subclasses. Copyright and Usage Information =============================== All forms of distribution of this code, whether as given or with any changes, are expressly prohibited. This file is Copyright (c) 2021 Will Assad, Za...
5c873b59c51902a20591522be6312b109f0f4095
alulec/CYPAlexisCC
/libro/problemas_resueltos/capitulo_2/problema2_2.py
259
3.671875
4
# dados dos números enteros (p y Q) determina si satisfacen la siguiente expresión p^3 + q^4 - 2*p^2 < 680 p = int(input("Dame p: ")) q = int(input("Dame q: ")) if (p**3 + q**4 -(2 * p**2)) < 680: print(f"Los valores {q} y {p} cumplen la expresión. ")
06647b8bf87a1e7a2b4b59b32cb15c518445c343
amssj/python
/archive/helloword/function_return.py
171
4.0625
4
## return def maximum(x,y): if x > y: return x elif x == y: return "the numbers are equal " elif x < y: return y print(maximum(2,3))
6e2052065614a7ff1f2a46cfd3304cd884262be5
JaeZheng/jianzhi_offer
/01.py
2,658
3.96875
4
""" 题目描述: 在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 解决思路: 第一种:暴力法,逐个遍历 第二种:暴力法,逐行二分查找 第三种:从左下或右上开始找。比如左下:如果<target,按行递增,如果>target,按列递减。 弟四种:两次(按行+按列)二分查找。先按行二分查找,找到<=target的值,再按列二分查找。 """ # -*- coding:utf-8 -*- class Solution: """从左下开始找""" # array 二维列表 ...
81ef99cb13b88b5a52e5e60ec3fe5f350d954239
u-ever/CursoEmVideoPython
/exercises/ex016c_Ler_Real_Mostrar_Inteiro.py
215
3.984375
4
#Importando toda a biblioteca e usando trunc (que mostra só a porção inteira) import math n= float(input('Digite um número real: ')) print('A porção inteira do número real {} é {}.'.format(n, math.trunc(n)))
20e8f176180c33e51a06fadf08ff41c3ca4f84d2
jiapengjun/notes
/code/python/lib_codecs.py
955
3.578125
4
#!/usr/bin/python #coding:utf-8 """ test code for module: codecs """ import codecs text = u'中华人民共和国' t1 = codecs.encode(text, "utf-8") t2 = codecs.encode(text, "gb2312") print str(type(text)) + str(type(t1)) + str(type(t2)) with open("out1.txt", "w") as o1, open("out2.txt", "w") as o2: o1.write(t1) o2.write(...
44392f7ae0cb38a86baefb630bb17fa0e6c581ae
Erikarodriguez22/Clasealgoritmosyprogramacion
/Phyton_taller_selectivas_semana3/Ejercicio_9_S.py
1,142
4
4
""" Entradas: Nombre--->str--->nombre montocompra--->float--->moncomp Salidas: montoapagar--->float--->total descuento--->float--->desc """ nombre=str(input("Nombre del cliente: ")) moncomp=float(input("Monto de la compra: ")) if(moncomp>0 and moncomp<=50000): total=(moncomp-(moncomp*0.05)) desc=(moncomp-total) p...
aef3b5a8f43ba3dc1c77ed21478315dcc08cb6b3
geffenbrenman/Link-a-Pix-AI-final-project
/Project/xml_parser.py
2,373
3.609375
4
import xmltodict def get_xml_from_path(path): """ Create dictionary with the following items: name - Puzzle name width - Puzzle width height - Puzzle height colors - List of RGB values [str] paths - dictionary where the keys are the colors and the values are lists of lists o...
c532760fbc534892753c21c7bdc45d09f483b7c9
Gracedonyx/SSGDATASCIENCE
/ACCUMULATOR PATTERN.py
367
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[7]: #ACCUMULATOR PATTERN WORKS LIKE GETTING THE TOTAL NUMBER OF THE VARIABLES IN THE LIST num = [1, 10, 3, 7, 8, 4, 3, 8, 99, 69] accum = 0 # THIS ASSIGNS THE ACCUMULATOR TO BE ZERO for y in num: #FOR EVERY NUMBER IN num accum = accum + y # ADD IT ACCUM AND T...
4a248b127e9c7b0e2630a56537a04f004f674b17
mturke/PythonSearchingMethods
/sequential_test.py
1,124
3.625
4
import timeit class SequentialStringList: def __init__(self): self.list=[] def add(self,str): self.list.append(str) def find(self,str): for i in self.list: if i == str: return i return None list = [] string = SequentialStringList() string...
be8e030dbfe6707ba2b450fc7a4d679a8f959f68
m-nosrati/springboard-course
/machine-learning/naive_bayes/src/naive_bayes.py
25,837
3.8125
4
#%% [markdown] # # Basic Text Classification with Naive Bayes submitted by Ahrim Han (2019/3/25) # *** # In the mini-project, you'll learn the basics of text analysis using a subset of movie reviews from the rotten tomatoes database. You'll also use a fundamental technique in Bayesian inference, called Naive Bayes. Thi...
1dd2b468ceba01de296e7eab1b7a41cf72fc7015
imrezol/korinna
/general/scope/local_scope.py
526
4.03125
4
# https://www.w3schools.com/python/python_scope.asp age = 30 def my_func(): age = 20 print("age inside my_func", age) def my_func2(): age = 20 print("age inside my_func2", age) if 1==1 : age = 10 print("age inside if", age) print("age inside my_func2 after if", age) def my_fu...
a1287c93fb8c646f9e23d86f0daaf0021d17d037
g0per/flightsimtools
/tod_calc.py
1,821
3.71875
4
#! python3 # coding=utf-8 # print('\t=============================================') print('\t\t CALCULADORA DE APROXIMACIÓN') print('\t=============================================') print('\tCalculadora de descenso óptimo del 3%.\n\n\tDatos típicos: airliners -1800 fpm // GA -700 fpm.\n\n') while True: while Tr...
01df23efbfbc74184585d014bf3b5ec966085ba3
Bassell-Iddisah/Password-Manager
/tests/Temp.py
6,262
3.671875
4
import secrets import sqlite3 import os, os.path as path connection = sqlite3.connect("DB") conn = connection.cursor() enter_key = input("Enter master Key: ") class PasswordManager: # The dawn of creation. def __init__(self): # Begin the application by authenticating master key if enter_key ...
bb929aa91cbda354d84fe24c1e2b725d3fccb37e
DmitrySPetrov/simulation_g11
/l06/32.py
1,285
4.21875
4
# Задача №3: # Сформировать массив вида: # ['a','b','c' ...] # количество элементов должно быть равно N. # # Вариант решения №2, через превращение range() в массив # # =!!= Запускать с помощью Python3 =!!= # Указываем количество N = 10 # Создаем массив A = [ chr( ord('a') + i ) for i in range(N) ] # Выводим A prin...
48b27ab91f90e17086a16c037e8101cf6e89eb50
colinfrankb/py10000
/Metaclasses/metaclasses.py
524
4.21875
4
# Abstract: # An object is created for the class name, this object is of type `type` # Using a metaclass allows you to change the type of that object class Man: pass print(type(Man)) # <class 'type'> class Human(type): def __new__(cls, *args, **kwargs): print('creating Human object') return s...
3b6be7d18842baba7f59caa2251a1909aed3d1af
Vayne-Lover/Effective
/Python/Effective Python/item15.py
791
4.0625
4
# -*- coding: utf-8 -*- def sort_priority(num,pro): res=num[:] def helper(x): if x in pro: return (0,x) return (1,x) res.sort(key=helper) return res def sort_priority2(num,pro): found=[False] def helper(x): nonlocal found if x in pro: found[0]=True return (0,x) return...
ed360f4037e741e818b2b1dc76325fe9e990769d
Reynazhang2014/DataCamp
/HW3/PyBank/main.py
1,633
3.65625
4
import os import csv import numpy as np # get the path of the file pathfile = os.path.join('Homeworks_HW03-Python_PyBank_Resources_budget_data.csv') # initialize the variables max_increase = 0 max_decrease = 0 tot_month = 0 tot_value = 0 previous_value = 0 change = [] month = [] with open(pathfile, e...
4557c6dc3421d1d01a9f956e83915c76f54bfda2
slobjnb/python
/pizza.py
721
3.96875
4
# 函数2 ''' def make_pizza(*toppings): print(toppings) make_pizza('pepperoni') make_pizza('mushroom','green peppers','extra cheese') def build_profile(first,last,**user_info): profile = {} profile['first name'] = first profile['last_name'] = last for key,value in user_info.items(): ...
a9b8f35a73730818339b7b73a0f896972e7baf9a
OceanicSix/Python_program
/Gavin_Code/Chess/chess.py
2,699
3.984375
4
from board import Board from piece import Piece class Chess: def __init__(self): self.chessBoard = Board(8,"-:-") i = 0 while(i < 8): firstPiece = Piece("pawn",0) self.chessBoard.place_piece(1,i,firstPiece) secondPiece = Piece("pawn",1) sel...
90cd321459fc1c64e9676862aa5b49c5fcd03605
wmm98/homework1
/视频+刷题/函数/递归函数.py
266
3.8125
4
# 功能: 如果不是直接知道结果的数据就进行分解 # 如果说,直接知道结果的数据,就直接返回 # 例如计算一个数的阶乘 def jiecheng(n): if n == 1: return 1 return n * jiecheng(n - 1) print(jiecheng(5)) # 120
a117eadedb3d1ec196261a89bdf653b0ac714430
ericaschwa/ProjectEuler
/problem02.py
769
3.890625
4
# Each new term in the Fibonacci sequence is generated by adding the # previous two terms. By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not # exceed four million, find the sum of the even-valued term...
aa66e54953e0cfc7da57ba28d0a2f6f08646422f
userlions/ProjectOne
/CalculateFactorial.py
467
3.765625
4
""" Program for calculating factorial of a number. """ # Date of creation:11-July-2020 # Author: Prabhu Prasad Behera. class CalculateFactorial: def factorial(num): if num!=0: res=num*CalculateFactorial.factorial(num-1); return res; return 0; print (CalculateFac...
4e2a0928bb9745dac13440fd634916fe46a39a0a
KaraKala1427/python_labs
/task1/15.py
197
3.734375
4
foot=int(input("Enter the foot: ")) inch=foot*12 yard=foot*0,333333 mile=foot*(1/5280) print(foot, " foots in inch: ",inch) print(foot, " foots in yard: ",yard) print(foot, " foots in mile: ",mile)
72372613e59a40cb0236d5bdcdc2872d79b08d0f
BlazingSkyward/PHYS476-AppliedMachineLearning
/Labs/phys476-basics.py
4,144
4.03125
4
""" This is actually a python 2.7 file, but everything here will work in python 3, including the printing, which was done with the python 3 print_function import below. The numpy and/or scipy libraries are almost automatically required for any scientific coding. Note the two different kinds of commenting... this ty...
f636be2b2ee8571e01f2376b6aebbe55413fca25
Scott-Larsen/LeetCode
/1423-MaximumPointsYouCanObtainfromCards.py
939
3.734375
4
# https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/ # There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints. # In one step, you can take one card from the beginning or from the end of the row. You have to ...
78c64e23a661114e903c8177f12a8cdf7ecf9a6c
ch0r1es-1n-ch0rge/starting_out_with_Python
/Chapter 6 - Programming Exercises/CH:6 - File Display.py
430
4.21875
4
# Assume a file containing a series of integers is named numbers.txt and exists on the computer's disk. Write a program # that displays all of the numbers in the file. # Create Main Function def main(): read_file() def read_file(): infile = open('numbers.txt', 'r') for numbers in infile: number...
6526b8d42b8abc83cfb09ce9845bee321a2f65cf
mparham2004/python-challenge
/PyPoll/main.py
963
4.09375
4
import pandas as pd # Reference the file where the CSV is located election_csv_path = "../Resources/election_data.csv" # Import the data into a Pandas DataFrame election_df = pd.read_csv(election_csv_path) election_df.head() #calculate a values showing: # Total number of votes cast # List of candidates who got vote...
52511553ee119ebc0d701bca1ea10b2101b55c8e
odvk/ynd-da-crs
/code/ya-ds-03-06.py
4,376
3.953125
4
# 6. Срезы # Тяжело держать в голове сразу много чисел. Поэтому после сортировки таблицы имеет смысл оставить только самые верхние строки — например, первые пять. Такие фрагменты списков называются срезы. #Они похожи на индексы, но используются для обращения не к отдельным элементам, а к их диапазонам. Для среза указы...
841fd886d4a45b78c65c08e108b07b921af482b1
Aniket-Pradhan/multi-core-python
/core_test.py
1,803
3.890625
4
#!/usr/bin/python # -*- coding: utf-8 -*- from multiprocessing import Process, Queue, current_process from time import sleep functionQueue = Queue() Queue_2 = Queue() Queue_3 = Queue() def fast_loop(): while True: pass def test_process_1(): """ Function to run a loop that processes f...
00d71a4d769b466f1f1195bd9beb0ab0c1667cc6
anshul-patil/coding-classes
/sophomore-ap-cs/stamper_v2.py
2,543
3.921875
4
''' stamper.py uses a GUI to create a montage from rotated and reduced iterations of an image. Rotation, reduction, and iteration are entered by slider. Rotation direction is entered by a toggling button. The stamp is initiated by a mouseclick. version 1 creates the GUI window with the sliders, button, and c...
2c8deca7f2fd86ac33b658700b92e878a9eeda90
Exquisition/LeetCode-Problems
/graphs/numIslands.py
1,604
3.5625
4
class Solution(object): def numIslands(self, grid): """ :type grid: List[List[str]] :rtype: int Adapted to find the sizes of the islands as well, and how many of each size """ self.count = 0 numIslands = 0 ...
473e4f149b95225b300f1c61f5187e847f8982ab
JoshuaShinkle/COS-120
/LABS/LAB05/Lab_05_12.py
2,961
3.8125
4
def printChars1(word): for x in range(0, len(word)): print(word[x]) print("L05-1") printChars1("right") print() def printChars2(word): for x in word: print(x) print("L05-2") printChars2("right") print() def printChars3(word): buildWord = "" for x in word: buildWord = buildWor...
84ce0f113b682af2354804fda7b340870599b547
mcduta/python-hpc
/notebooks/lecture01-python/warm_up_1.py
272
4.03125
4
""" A function to calculate the median of a list""" def my_median(years): ages = [] for y in years: ages.append(y - 1900) ages.sort() mid = len(ages)/2 return ages[mid-1:mid+2] years = [1989, 1955, 2011, 1943, 1975] print my_median(years)
a3a57b408c7c2c10b365bce78c0e25d3adce92c1
vipulsingh24/Python
/Binary_File.py
2,784
4.125
4
''' “Binary files” is the term used to refer to all files that are not text files. The handling of binary files is quite similar to the handling of text files. You have to open() a file when you want to access its contents, close () it when you are finished, read () from the file and write () to the file. ''' # hw1 =...
2fb4a8a884ab418b78eb3d9ca4995d75566024b3
adiffloth/kattis
/speedlimit/speedlimit.py
317
3.828125
4
i = int(input()) while i != -1: dist_traveled = 0 prev_time = 0 for _ in range(i): speed, time = map(int, input().split()) elapsed_time = time - prev_time prev_time = time dist_traveled += speed * elapsed_time i = int(input()) print(f'{str(dist_traveled)} miles')
8e19cbd150f029e66a2040f1beb77926995d81e1
renitro/Python
/Estruturas de Repetição/Exerc19.py
510
4.1875
4
#Altere o programa anterior para que ele aceite apenas números entre 0 e 1000. qtd = 0 while qtd > 1000 or qtd < 1: qtd = int(input("Digite a quantidade números a digitar: ")) i = 0 lista = [] soma = 0 while (i < qtd): n = 0 while n > 1000 or n < 1: n = int(input("Digite o "+str((i+1))+"º número:"))...
6b401ccca83b2341e4e7a966e933b6b9aa26fa10
carlavtovarg/alg1
/Class_20/class_Review_4.py
1,208
3.640625
4
import datetime class Author: def __init__(self, author: str): self.author = author class Document: def __init__(self, authors: str, date: datetime): self.authors = [] self.authors.append(authors) self.date = date def get_authors(self): return self.authors ...
21a121f38be8a6ad61ddc1bf13267e5b1de3e346
marcos862/SaturdayAI_Mex
/PracticePython/02_Odd_Or_Even.py
986
4.5625
5
""" Exercise 2 Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? Extras: 1. If the number is a multiple of 4, print out a different message. 2. Ask the user for two numbe...
c96e8f9fe4630e4648abef579fba2cb936bbac3e
wwclb1989/python
/itcast-python/cn/itcast/chapter01/demo.py
704
3.546875
4
# 第1章 开启学习python之旅 # python的一些web框架,如Django、Flask、Tornado、web2py # python2与python3的区别: # print()函数替代了pring语句 # python3默认使用utf8编码 # python3中的/号,整数相除结果会是浮点数 print(1 / 2) # 使用//进行的除法,为向下取整除法 print(8 // 3) # python3八进制字面量表示 print(0o1000) # python3不等运算符只有一种写法!= print(1 != 2) # python3去除了long型,只有一种整型int,新增了bytes类型 b = b'chi...
0eac57099d5d121544e316b1f6dd7c73f8e4ad0c
excelsky/Leet1337Code
/243_shortest-word-distance.py
333
3.796875
4
# https://leetcode.com/problems/shortest-word-distance class Solution: def shortestDistance(self, words: List[str], word1: str, word2: str) -> int: return min(abs(x - y) for x in [i for i, w in enumerate(words) if w == word1] for y in [i for i, w in enumerate(words) if ...
f5963d6d37cbbad70054eab57bb03aaa4b3c54a8
ganeshhubale/programs
/python/sort.py
1,025
4.53125
5
# You can use sorting to solve a wide range of problems: # Searching: Searching for an item on a list works much faster if the list is sorted. # Selection: Selecting items from a list based on their relationship to the rest of the items is easier with sorted data. For example, finding the kth-largest or smallest valu...
b1a21a309e53057b2ca850cf2edf5b2dfa6446d3
anjasardiyanazhari/Python_Youtube
/Belajar Python 3.x Bahasa Indonesia [Dasar]/5 - If Elif Else.py
903
3.625
4
nilai = 49 if nilai == 75: #equal eksplisit print("nilai anda:", nilai) if nilai is not 60: #equal print("nilai anda:", nilai) if nilai is not 60: #not equal print("nilai anda bukan: 60") print(20 *"=") if 80 <= nilai <= 100: print("nilai anda adalah A") elif 70 <= nilai < 80: print("nilai anda...
f6c90f7b66f5a9568411462893c554b2b51f4d64
green-fox-academy/ithomas91-1.0
/Else/python/python_tutorial/main.py
1,013
4.1875
4
def addFunction(num1, num2): result = num1 + num2 return result is_last_week = True is_exam_week = False def enter_your_name(name): print("Welcome", name, "in Python program!") if is_last_week and is_exam_week: print("This is the very last week of GFA.") else: print("You've got still something ...
ff26c44eadb9ad0d0aae286986d4fd5213a474b7
GAZDA-EDU/SP_Programowanie_komputerow_OOP_lab_2
/Lab2.5.py
784
3.59375
4
class Pracownik: Wynagrodzenie_pracownika = { 'P1': '2500 zł', 'P2': '2750 zł', 'P3': '3150 zł', 'P4': '3525 zł' } def __init__(self, imie, nazwisko, wynagrodzenie): self.imie = imie self.nazwisko = nazwisko if wynagrodzenie not in Pracownik....
010941240ada95dc4cd87e74fb1b93524b3eebad
pndwrzk/Python-fundamental
/upack.py
536
3.828125
4
angka = (1, 2, 3) # contoh bukan cara unpack x = angka[0] y = angka[1] z = angka[2] print(x, y, z) print("=============") # unpack adalah cara mudah untuk memasukan elemen tuple kedalam sebuah variabel , seperti dalam contoh diatas # contoh menggunakan cara unpack a, b, c = angka print(a, b, c) p...
0600d57de181568f7ded2975eb7f096bfabc7cac
zhaorui-creator/project
/22222.py
136
3.515625
4
def min(a,b,nocp=False): if not nocp: b = a*a return b if __name__=='__main__': c=0 c=min(1,0) print(c)
fa7a5ea94a2c447a62f3bc9f46021d46adfd5530
abhayshekhar/PythonPrograms
/whileBreak.py
249
3.796875
4
while True: print('who are you') name=input() if name!='abhay': continue print('Hey abhay ! whats the passowrd') print('enter your password') password=input() if password=='55': break print('Acess granted')
acee042ab2f58a829ec29e469281d58703213f39
codeandrew/python-algorithms
/6kyu-sort_odd_array.py
558
4.1875
4
""" Task You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions. Examples [7, 1] => [1, 7] [5, 8, 6, 3, 4] => [3, 8, 6, 5, 4] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] => [1, 8, 3, 6, 5, 4, 7, 2, 9, 0] """ def sort_array(s):...
a79d98eda484ad9569fefa153f3f46d250aab060
chakradharchinnam/Python
/ICP3/ICP3.2.py
442
3.546875
4
from bs4 import BeautifulSoup import urllib.request url="https://en.wikipedia.org/wiki/Deep_learning" 0 #parsing the source code source_code = urllib.request.urlopen(url) plain_text = source_code soup = BeautifulSoup(plain_text, "html.parser") #Printing the page title print(soup.title.string) #searching the li...
6e33240c45aa56fe6e08aed75a980e97ff3bcaab
zhongyn/coding-man
/NextRightBT/excel_column_number.py
325
3.640625
4
class Solution: # @return a string def convertToTitle(self, num): title = [] while num > 0: digit = (num-1) % 26 title.append(chr(ord('A')+digit)) num = (num-digit)/26 return ''.join(title[::-1]) test = Solution() print test.convertToTitl...
83ea53a464987f3095cdc9731fadffabbaf44dfb
wlsk5882/Python_for_Developers_Academic_Projects
/capstone/Source codes/CAPSTONE3_LEE_JINA.py
3,763
4.21875
4
''' author : Jina Lee original creation date : Dec. 9, 2015 last modification date : Capstone Project Activity #3 1.) Print out CAPSTONEA2_LASTNAME_FIRSTNAME_FILE1.txt, and manually identify the noise and normalization you have to complete. Prior to completing step #1, you can use ...
dd9477923ebffd88f217f71140311396a92c2dfe
themeliskalomoiros/the_deutch_quiz
/show_words.py
282
3.5
4
#!/usr/bin/python def print_words(): import words repo = words.WordRepository() words = repo.get_words() for w in words: print w.text.encode('utf8'), w.translation.encode('utf8'), w.word_class.encode('utf8') if __name__ == '__main__': print_words()
876f4db7601a58458f74e61423782e57db58a471
annguyenict172/coding-exercises
/exercises/dynamic_programming/traverse_2d_array.py
625
4.09375
4
""" Find the number of ways to get from the top-left to bottom-right of a 2D array. We can only go down and go right. EPI 16.3 """ def num_of_ways(n, m): def num_of_ways_to_pos(i, j, memos): if (i, j) in memos: return memos[(i, j)] if i == 0 and j == 0: return 1 else...
42ff95dfea94368c170aac6dd8f5c1670fc291f7
rajdeepslather/Scraps
/Scraps/Python/py_scraps/hacker_rank/repeated_string.py
609
3.6875
4
#!/bin/python import math import os import random import re import sys from collections import Counter def repeatedString(s, n): chars = [] map(chars.extend, s) remainder = n % len(chars) count = Counter(chars)['a'] * n // len(chars) i = 0 while remainder > 0: if 'a' == chars[i]: ...
b073228a8e72620a96b5fd955480496b3148895a
yksgzlyh/python_basic
/函数/function_loca(局部变量)l.py
258
3.9375
4
# x 是我们这一函数的局部变量。因此,当我们改变函数中 # x 的值的时候,主代码块中的 x 则不会受到影响 x=5 def fun(x): print ('x is ',x) x=2 print('Change local x to ',x) fun(x) print('x is still ',x)
d9e1707f3f8c4c744ef7fc30353b1cf61cd4f3ed
Mekazara/Chapter3
/task1.py
391
3.8125
4
text_from_user = input("Введите текст: ") up_case = 0 low_case = 0 for i in text_from_user: if i.isupper(): up_case += 1 elif i.islower(): low_case +=1 summ = up_case + low_case x = (up_case * 100) / summ y = (low_case * 100) / summ print(f"В введенном тексте {round(x, 2)}% заглавных и {round(y,...
0be9a323e127a6ce02b82b7a76b11e3620278b8d
jrc98-njit/CalculatorJRC
/src/Stats/Mean.py
394
3.8125
4
from Calc.Addition import addition from Calc.Division import division def mean(data): numValues = len(data) if (numValues == 0): raise Exception('empty list passed to list') total = 0 for num in data: if (isinstance(num,str)): raise Exception('List must contain numbers') ...
97412c1976e153f690bcbcb92786afc27a02e9ec
Wenslaus-Makumba/address-book1
/GUI/acw.py
4,042
3.734375
4
"""Add Contact Window Authors: group 5 Window that pops up when user chooses to add a contact. """ import tkinter as Tk import AddressBook as ab import gui import addcw as cw class AddContactWindow(object): def close_window(self): self.top.destroy() def field_return(self): """Grabs contact form data and se...
b85313925f497a96231c9725977e0a9026712593
miaopei/MachineLearning
/LeetCode/github_leetcode/Python/split-linked-list-in-parts.py
2,379
3.8125
4
# Time: O(n + k) # Space: O(1) # Given a (singly) linked list with head node root, # write a function to split the linked list into k consecutive linked list "parts". # # The length of each part should be as equal as possible: # no two parts should have a size differing by more than 1. # This may lead to some parts b...
a0508fec48aa2ccf8d5a75bfb605c653788370ba
vinodrajendran001/python-interview-prep
/deque_palindrome.py
751
4.03125
4
''' A palindrome is a string that reads the same forward and backward, for example, radar, toot, and madam. ''' class Deque: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def addFront(self, item): self.items.append(item) def addRear(self, item): self.items.insert(0, item...
d1155cd454e4413dd1aa30e93ee0fb17b78e3506
Endleyson/Python
/idade.py
176
3.890625
4
id = int(input('digite a sua idade:')) if id < 18: a = 'você é menor de idade' else: a = 'você é maior de idade' print('sua idaded é de {} anos e {}'.format(id,a))
9bcdf7abebf6b393c447d8a2824b22034badd341
noknok200/2018-OOP-Python-BARKBARK
/examples/matplotaction.py
773
4.1875
4
# 참고: http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/ """ Matplotlib Animation Example author: Jake Vanderplas email: vanderplas@astro.washington.edu website: http://jakevdp.github.com license: BSD Please feel free to use and modify this, but keep the above information. Thanks! """ import num...
b240df340da0423d273725854982b9674ae810e6
Japetus1/Projects
/Classes/product_inventory_daytron.py
2,241
4.0625
4
class Product: def __init__(self,pId,name,price,quantity): """ Initialises attributes """ self.id = pId self.name = name self.price = price self.quantity = quantity def updatePrice(self,new_price): """ Updates the product's price ...
1ce599ba8d92eb7bcd80dfc74dd7b36ea5e5546d
samoel07/desafios-python
/DESAFIO 50.py
183
4.1875
4
nomes = ['samoel', 'joao', 'carlos', 'samanta'] print(nomes[-3:]) #colocando na variavel nomes[] o "-3" dentro da funçao print() e sera mostrado os ultimos 3 elementos da sua lista
981936d124e9c7b7a5b8a1dc1bf7da0ef310a1a4
BXSS101/KMITL_HW-Data_Structure
/08 Tree 1/0803.py
3,283
3.921875
4
################### # Disclaimer part # ################### ''' Lab#8| Tree 1 Course : Data Structure & Algorithm Instructor : Kiatnarong Tongprasert, Kanut Tangtisanon Semester / Academic Year : 1 / 2020 Institute : KMITL, Bangkok, Thailand Developed By : BXSS101 (Ackrawin B.) Github URL : https://github.co...
34510cb9faffaceddee7edaf1c38debce35f5f5d
Maher-Reven/HackerRank
/Algorithms/Greedy/Marc's Cakewalk.py
641
3.796875
4
input() print(sum(c * 2 ** j for (j, c) in enumerate(sorted(map(int, input().split()), reverse=True)))) #2nd solution py3 #!/bin/python3 import math import os import random import re import sys # Complete the marcsCakewalk function below. def marcsCakewalk(calorie): sum=0 calorie.sort(reverse=True) fo...
2399a22d6d330199701e1d3022cd448e3ac30e57
EmilioOldenziel/sudokusolver
/test_sudoku_solver.py
1,033
3.53125
4
import recognize_sudoku import sudoku_solver import json import sys, os def get_sudoku_numbers(sudoku): numbers = [] for row in sudoku: for number in row: if number: numbers.append(number) return numbers def main(): with open('tests.json') as tests_file: ...
dbba2ed6ea81476e4e27587c8121a17d767341e5
AlexandrDaultukaev/quizzler
/question_model.py
245
3.8125
4
class Question: def __init__(self, question="", answer=""): if question != "" and answer != "": self.text = question self.answer = answer def print_dict(self): print(f"{self.text} {self.answer}")
30088a7639246c30548959b94dc453157b935a09
AcidicNic/CS1.3
/word_jumble.py
5,585
4.03125
4
import os import sys from sys import argv from random import randrange def setup_dict(): """ Returns a list of every dictionary word in the mac 'words' file""" with open("/usr/share/dict/words", 'r') as dict_file: dict_list = dict_file.read().splitlines() return dict_list def sort_word(word): ...
acd8ee85bad28777990c4ecceaf5716dffdf6d7d
bfemiano/misc_scripts
/python/algos/flatten.py
311
3.75
4
#Python 3.6.7 def flatten(arr_in): out = [] for i in arr_in: if isinstance(i, int): out.append(i) else: out.extend(flatten(i)) return out print(flatten([1, [2, [3, 4]]])) # [1, 2, 3, 4] print(flatten([1, [2, 3, [4, 5], 6, [7,8]]])) # [1, 2, 3, 4, 5, 6, 7, 8]
2e1029deccc9abdbb6933509e64399de159f3965
Jecosine/Slime
/get_list.py
402
3.5
4
def get_list(content): l = [] #f = open("saved",'rb') #content = f.read() content = content[1:-1] elements = content.split('], [') temp = "" for element in elements: c = element.split(',') if c[0][0] == '[': c[0] = c[0][1:] if c[1][-1] == ']': ...
b68913504bf2d15f7e37cc92290d0f73dd12dd47
qq906907952/play_with_machine_learning
/src/sort/merge_sort.py
1,249
4.21875
4
def __merge(array, start, middle, end): temp = [] i, j = start, middle + 1 while i <= middle and j <= end: if array[i] < array[j]: temp.append(array[i]) i += 1 else: temp.append(array[j]) j += 1 while i <= middle: temp.append(arra...
55eba3524fc109b839664d3e8150e0a3cce91cc4
felaube/cs50AI-problem-sets
/tictactoe/tictactoe.py
6,021
4.09375
4
""" Tic Tac Toe Player """ import math from copy import deepcopy X = "X" O = "O" EMPTY = None class InvalidMoveException(Exception): """ Define a custom Exception, raised when a invalid move is made """ pass def initial_state(): """ Returns starting state of the board. """ ret...
cf3d924746eef57f099f2e5dafd1c89062e9dc57
dcronqvist/advent-2020
/day-12/solution.py
2,047
3.6875
4
def read_input(): with open("input.txt", "r") as f: return f.read() def read_input_lines(): with open("input.txt", "r") as f: return [l.strip() for l in f.readlines()] def read_input_separated(c): with open("input.txt", "r") as f: return f.read().split(c) def part1(): lines = ...
512bb94e046fbce8223062bd611646a404f0764e
LisaRuijg/WISB256
/Opdracht2/CountPrimes.py
702
3.53125
4
import sys import math bestand = sys.argv[1] C_2 = 0.6601618 prime_list = list(open(bestand)) pi_n = len(prime_list) for i in range(pi_n): prime_list[i] = int(prime_list[i]) N = prime_list[-1] A = N/math.log(N) prime_number_theorem = pi_n/A twin_pairs=[] for i in range(0, pi_n -1): if prime_list[i+1]-pri...
ddf68149c936244ff30a2d03f3128635e9049f8a
Sloffcraft/Python-Projects
/game1.py
563
3.578125
4
import turtle win = turtle.Screen() win.bgcolor ('black') win.setup(width = 800 , height = 600) win.title('To show someone') win.tracer() #object1 ob = turtle.Turtle() ob.shape('square') ob.shapesize (stretch_wid = 2, stretch_len=15) ob.speed(0) ob.color('white') ob.penup() ob.goto(0 , -450) #Ball ball = turtle.Tu...
00eaa9d5028d8e796c8b1a0ee394ce532ec84ac0
akashgupta910/python-practice-code
/Try Except & Else finally all.py
331
3.84375
4
# TRY EXCEPT AND ELSE FINALLY ALL try: f1 = open("file/file.txt") # except Exception as error: # print(error) except EOFError as eoferror: print("IO Error!",eoferror) except IOError as ioerror: print("IO Error!",ioerror) else: print("Exception do not Run.") finally: print("This is very Imp...
e17aa579c05c56927e553bb92e425660d6e439e0
JDavid121/Script-Curso-Cisco-Python
/184 math module.py
493
3.8125
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 13 08:55:07 2020 @author: David """ pi = 3.14 # line 08 def sin(x): if 2 * x == pi: return 0.99999999 else: return None # line 14 # from line 08 to line 14 we define our own pi and sin names # in the namespace code. print(sin(...
0b827c9dc6a8ca0889e10da2edb1d60a2bc686ab
Anson008/Data_Structures_and_Algorithms_in_Python
/Chapter_04/Examples_C04/disk_usage.py
443
3.625
4
import os def disk_usage(path): """Return the number of bytes used by a file/folder and any descendents.""" total = os.path.getsize(path) if os.path.isdir(path): for filename in os.listdir(path): childpath = os.path.join(path, filename) total += disk_usage(childpath) pr...
9b9758c901cffba2ee6d81d1935fbf17240be16f
JuanDiazUPB/LogicaProgramacionUPB
/Taller algoritmos/Ejercicio 24.py
279
3.515625
4
vproducto = int(input('Introduzca el valor del producto: ')) vventa = vproducto + (vproducto * 0.19) if vventa >= 150000: print('Valor superior a 150000 pesos, restando 5% al valor...') vventa = vventa - (vventa * 0.05) print(f'El valor de la venta fue: {vventa}')
5772e28df65a56b5bbf630d7cb6be652c857b9df
PacktPublishing/TensorFlow-Machine-Learning-Cookbook
/Chapter 06/improving_linear_regression.py
4,769
3.96875
4
# Improving Linear Regression with Neural Networks (Logistic Regression) # ---------------------------------- # # This function shows how to use Tensorflow to # solve logistic regression with a multiple layer neural network # y = sigmoid(A3 * sigmoid(A2* sigmoid(A1*x + b1) + b2) + b3) # # We will use the low birth weig...
b4f072fa5091503be2550d8ed7173129dd112868
algono-ejercicios-upv/CACM
/Programming-Challenges/Chapters/8/LittleBishops/little_bishops_lib.py
2,684
3.84375
4
""" Create an n*n matrix (board) Assign -1 when placing a bishop, and add 1 to each spot in its diagonal Assign only if the spot has a 0, use recursion, and undo the placing to make backtracking Example of a solved state (n=3, k=3): [ [ -1 , 1 , 1], [ 0 , 1 , -1], [ -1 , 1 , 1] ] Count these states, an...
8680be4a9c440f63f969592550f9ab8acf746e2b
cmf3673/CS_313E_Projects
/Radix.py
2,938
4
4
## Problem: In this assignment you will modify the Radix Sort algorithm so that # it sorts strings that have a mix of lower case letters and digits - # similar to your UT EIDs. # Input: # You will be given a file radix.in in the following format. # The first line in the input will be a single integer n that # stat...
fae3b60c3b84088e3a858e9cc1328085c96e8dc2
tslearn-team/tslearn
/docs/examples/classification/plot_shapelet_distances.py
4,258
4.375
4
# -*- coding: utf-8 -*- """ Learning Shapelets: decision boundaries in 2D distance space ============================================================ This example illustrates the use of the "Learning Shapelets" method in order to learn a collection of shapelets that linearly separates the timeseries. In this example, ...
0b16cff97d94275920afc07dcdda7c3c494a01a3
Manuel-X/python
/loops_task.py
581
3.8125
4
dictionary = {} item = "" total = 0 while item != "done": item = input('item (enter "done" when finished): ') if item!="done": price = input('price: ') quantity = input('quantity: ') dictionary[item] = [price, quantity] print ("""--------------- receipt ---------------""") for item in dic...
0714ada4d81afea327b3effb08c4cabb3fe92980
Rice-Field/Computer-Vision
/Graph/bipartite.py
2,388
3.546875
4
# Jonathon Rice # Build graphs to visualize solving hungarian assignment import numpy as np import scipy as sp import os import networkx as nx import matplotlib.pyplot as plt from networkx.algorithms import bipartite from scipy import optimize from hungarian import hungarian, allSolutions def buildAffGr...
5148aa5eb2279c5a2aa65b4c67429646ba99bdaa
kjrashmi20/python_class
/find word in statement.py
326
4.09375
4
stat1=input("statement1") stat2=input("statement2") word=input("enter word") if(word in stat1): if (word in stat1 and word in stat2): print("word in both statement") else: print("word is in statement1") elif(word in stat2): print("word in statement2") else: print("word not in any stateme...
5f650b9eef6ad4fa5584f6b63267d0797a0f2de0
larrytao05/pythonclass2020
/homework-0329/ex-1.py
542
3.9375
4
def most_cheeses(dic): biggest = [] final = [] values = list(dic.values()) keys = list(dic.keys()) for i in range(len(values)): if len(biggest) == 0: biggest.append(i) elif values[i] == values[biggest[0]]: biggest.append(i) elif values[i] > values[bigg...
9292c1bf5daab27efabc2f3317c8885eb774823c
rajlath/rkl_codes
/LeetCode_Top_100/GoodBy2016_A.py
619
3.609375
4
# -*- coding: utf-8 -*- # @Date : 2018-09-28 09:18:53 # @Author : raj lath (oorja.halt@gmail.com) # @Link : link # @Version : 1.0.0 from sys import stdin max_val=int(10e12) min_val=int(-10e12) def read_int() : return int(stdin.readline()) def read_ints() : return [int(x) for x in stdin.readline().spli...
bcc4c2be26f0b45d4f53070f67e064dee260e68c
Gustavo-Lourenco/Python
/Exercícios/ex098.py
702
3.625
4
from time import sleep a1 = b1 = c1 = 0 def contagem(a, b, c): print('-=' * 20) print('Contagem de {} a {} de {:.0f} em {:.0f}'.format(a, b, (c*c)**0.5, (c*c)**0.5)) if c == 0: c = 1 if a < b: for d in range(a, b+1, c): print(d, end=' ') sleep(0.2) print(...
e0ad66a88f1fe67ed3f85294f070e8a60f1cdf35
VijayVignesh1/Competitive-Programming
/18thNov2020/countServersThatCommunicate.py
1,767
3.765625
4
class Solution(object): # Loop row wise and column wise and find the list of isolated servers # Find the set intersection of the row wise isolated servers and column # wise isolated servers and subtract it with the total servers. def countServers(self, grid): """ :type grid: List[List[in...
7d5408bdb689127c65e035d7be0b1cac62786f1b
Mcdonoughd/CS4803
/HW/hw2/dmcdonough-hw2/problem2.py
3,424
3.84375
4
from problem1 import elo_rating import numpy as np # ------------------------------------------------------------------------- ''' Problem 2: In this problem, you will use the Elo rating algorithm in problem 1 to rank the NCAA teams. You could test the correctness of your code by typing `nosetests test2.p...
63d7bbfff91a921701a106dd41ca1d1100adbc88
nsavla007/Python-Project-On-VG-Sales
/plot&graph.py
285
3.921875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 9 12:03:51 2018 @author: neelsavla """ import matplotlib.pyplot as plt lst_pop=[] for i in range(5): lst_pop.append(i) lst_year=[2000,2001,2002,2003,2004] print(lst_year) plt.plot(lst_year,lst_pop) plt.show()
79c0fbfba119a40866c30b19132cd63b2d465fe5
ShawnWuzh/algorithms
/quick_sort.py
831
3.875
4
# written by HighW # This is the source code for quick sort class QuickSort: def quickSort(self, A, n): self.pivot_split(A,0, n-1) return A def pivot_split(self, A, start, end): if start > end: return else: pivot_loc = start for i in range(star...
2a06f35e506c4020e6e2d80f234e98d9500cb8d6
wjhlittlefive/zhangsan.github.io
/2-3tree.py
7,434
4.03125
4
class Node: def __init__(self, key1,key2 = None, key3 = None,left=None, right=None, right2 = None,middle = None, p=None): self.left = left ## 当节点为3-节点时,right为节点的右子树 self.right = right ## 当节点为2-节点时middle为节点的右子树 self.middle = middle ## 这个为临时4-节点的最右子树 self.right2...