blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
64029718781f0f862fed1741ef8c28bea8d80233
kcc3/hackerrank-solutions
/data_structures/python/linked_lists/insert_node_at_specific_position_in_linked_list.py
2,513
4.09375
4
"""Hackerrank Problem: https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list/problem Given the pointer to the head node of a linked list and an integer to insert at a certain position, create a new node with the given integer as its data attribute, insert this node at the desired ...
93d2c4f2eb3485d73051a93cfa531070aa46a563
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/implementation/bigger_is_greater.py
1,021
4.28125
4
def bigger_is_greater(w): """Hackerrank Problem: https://www.hackerrank.com/challenges/bigger-is-greater/problem Given a word, create a new word by swapping some or all of its characters. This new word must meet two criteria: - It must be greater than the original word - It must be the smallest word t...
fcb4d9bc984884d587811ceb50aa624e520e709d
kcc3/hackerrank-solutions
/python/itertools/itertools_combinations_with_replacements.py
303
3.578125
4
""" Hackerrank Problem: https://www.hackerrank.com/challenges/itertools-combinations-with-replacement/problem """ from itertools import combinations_with_replacement string, k = input().split(" ") for combination in combinations_with_replacement(sorted(string), int(k)): print("".join(combination))
ef1ff7bf8a43249a3848049ae41e3506578d44ab
kcc3/hackerrank-solutions
/problem_solving/python/algorithms/implementation/encryption.py
653
3.953125
4
import math def encryption(s): """Hackerrank Problem: https://www.hackerrank.com/challenges/encryption/problem Encryption function based on the specifics as provided in the challenge. Args: s (str): The string to encrypt Returns: str: The string after passing through specified encry...
8e6a005a4c9160c79ac341f317dedb5c6f04d9cb
cisquo/cours_python_hepia
/ex50.py
1,803
3.53125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #s = input ("Entrez une valeur: ") def longueur(l1): nb = 0 for x in l1: nb += 1 return nb def moyenne(l1): total = 0 for x in l1: total = total + x return total / longueur(l1) if l1 else 0 def plus_grand_ou_egal (l1, n): res...
72aa1573e269adc097e788feba4bec118353f114
cisquo/cours_python_hepia
/ex512.py
513
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #s = input ("Entrez une valeur: ") def add(dic,k,v): dic.append((k,v)) def index(dic,val): for k,v in dic: if v == val: return k def lenght(dic): return len(dic) def is_in(dic, cle): for k,v in dic: if k == cle: ...
49f4e08c38d8f2429e77d4af1d29e4010c381208
archeranimesh/pythonFundamentals
/code/pyworkshop/02_list/list_sort.py
556
4.21875
4
# Two ways to sort a list. lottery_numbers = [1, 3, 345, 123, 789, 12341] # 1st method does not modify the original list, # returns a shallow copy of original list. print("sorted list: ", sorted(lottery_numbers)) # reverse the list. print("reverse list: ", sorted(lottery_numbers, reverse=True)) x = sorted(lottery_...
d7b87d4a7e4d87be392508d92cd10d2ff1e033e5
archeranimesh/pythonFundamentals
/code/pyworkshop/07_loops_if/05_break_continue_return.py
645
3.828125
4
# Break, stops the execution of loop and jumps to end of loop. # Continue, doesn't continue the following loop statement, but jump to start of loop. names = ["Jimmy", "Rose", "Max", "Nina", "Phillip"] for name in names: if len(name) != 4: continue # Start new iteration when len is not 4 print(f"Hello...
63a6c50f451fd165eeff0b514a9c5e87b44b531d
michalecki/codewars
/sum_of_intervals.py
1,528
4.1875
4
''' Write a function called sumIntervals/sum_intervals() that accepts an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once. Intervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less t...
aa970b317af5316d42807008efbc5b41e8347486
michalecki/codewars
/sum_of_numbers.py
582
4.34375
4
def get_sum(a,b): ''' Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b. Note: a and b are not ordered! :param a: int :param b: int :return: int ''' i...
67c080061bd2de6a136ca201be47f659b7770fa3
oostlab/python-pen-web
/bruteforce/postgress_brute.py
3,582
3.53125
4
#!/usr/bin/python3 ''' Postgress bruteforce script. A script for bruteforcing postgress Test with the following commandline python3 postgress_brute.py 192.168.2.5 users.txt passwords.txt ''' import psycopg2 import sys from time import sleep def execute_scan(host, userfile, passwordfile, port, connect_...
791406611128204f4689899bf23292904e7e1c7d
trandaniel/project-euler-solutions
/python/problem004.py
393
4.03125
4
# A palindromic number reads the same both ways. The largest palindrome made from # the product of two 2-digit numbers is 9009 = 91 x 99. # # Find the largest palindrome made from the product of two 3-digit numbers. largest = 0 for i in xrange(100, 1000): for j in xrange(100, 1000): if (i * j > largest) a...
7e3dbd35ab956465da78d9d923a7ffe37f9005bc
makcg/HomeWork
/HW5/Lesson 5 Prictice task 3.py
635
4.0625
4
# Вспоминаем работу с файлом. Есть файл, в котором много англоязычных текстовых строк. # Считаем частоту встретившихся слов в файле, но через функции и map, без единого цикла! from collections import Counter file = open('text_for_ practice_task_3.py', 'r') def lower(a): return a.lower() def counter(f): li...
6f4909312fd87ec11a1e4c74c70a2e05fca8a840
makcg/HomeWork
/HW5/Lesson 5 Task 3.py
311
4.03125
4
from itertools import zip_longest s = [1, 2, 3, 4] u = ['q', 'w', 'e', 'r', 't'] y = [5, 6, 7, 8] def zip_func(a, b, c): """ input: three random lists combines three lists (including different lengths) return: one list """ return list(zip_longest(a, b, c)) print(zip_func(s, u, y))
23d50115da2e3217dfde2bd62ff14039ca1044f2
MayaYosef/Synthetic-Digits-Classification
/python/makegraphs.py
3,332
3.984375
4
""" this python file is responsible for making and saving graphs of the training process """ import matplotlib matplotlib.use( 'tkagg' ) import matplotlib.pyplot as plt import numpy as np import os import printmessage def graphs(H, plot_path, epoches): """ responsible for making, saving...
81e3bc5134fd6998b582378871194a42a9373528
melissawm/rse2017
/examples/example 1/IDEB.py
8,455
4.0625
4
# coding: utf-8 # # Example: IDEB Analysis # We are going to analyse data corresponding to the IDEB (Basic Education Development Index) for brazilian cities. The data comes from the file # In[1]: ideb_file = "IDEB por Município Rede Federal Séries Finais (5ª a 8ª).xml" # which was obtained from the main brazil...
a013fb32d1e0ffc470c56a9f7ec6fefc8daf831c
NgoHarrison/CodingPractice
/7. Graphs/employee_inheritance.py
675
3.75
4
""" # Employee info class Employee: def __init__(self, id: int, importance: int, subordinates: List[int]): # It's the unique id of each node. # unique id of this employee self.id = id # the importance value of this employee self.importance = importance # the id of dir...
ee9eacd0237b3283f840b5b6b3ef338e2bc53cd4
NgoHarrison/CodingPractice
/3. Arrays/Longest_Mountain_In_Array.py
1,232
3.84375
4
def longestMountain(A): print(A) left = 0 right = len(A)-1 while left < right: #print(A[left:right+1]) middle = (right+left)//2 print(left,middle,right) temp = sorted(A[left:middle+1])+sorted(A[middle+1:right+1],reverse=True) if len(temp) < 3: ...
e000295cea431c02d05cc166379d0c564f0c7f1b
ShreyanGoswami/coding-contests
/Leetcode weekly contest 188/array_with_stack_ops.py
1,263
3.890625
4
''' Given an array target and an integer n. In each iteration, you will read a number from list = {1,2,3..., n}. Build the target array using the following operations: Push: Read a new element from the beginning list, and push it in the array. Pop: delete the last element of the array. If the target array is already...
a72af4074104f47c32f8714796c4a1f6948bc8d1
ShreyanGoswami/coding-contests
/Leetcode weekly contest 189/rearrange_words_in_sentence.py
860
4.25
4
''' Given a sentence text (A sentence is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words hav...
a16a99abd5d197bb93f5d17c11d014c27a8424d3
mit-mc-clas12/clas12osg
/client/options.py
1,066
3.625
4
# Import packageds/modules import argparse # This function will return all command line arguemnts as an object def get_args(): # Initalize an argparser object. Documentation on the argparser module is here: # https://docs.python.org/3/library/argparse.html argparser = argparse.ArgumentParser(prog='Submit', usage='...
9f94ef405e1ec63735e1e17bca483e706a86b3f9
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/continuedenemeleri.py
126
3.953125
4
liste = list(range(10)) for x in liste: if(x==3 or x== 6): continue print(x,"için değer sağlanmadı")
616234224c32a4d65e39ccc22ec1a7ae629adc20
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/atm_mak.py
815
3.5625
4
print("""************************* ATM Makinesine Hoşgeldiniz. işlemler; 1. Bakiye Sorgulama 2. Para Yatırma 3. Para Çekme Programdan çıkmak için "q" tuşlayın. *********************""") bakiye=1000 while True: işlem=input("İşlem Girin:") if(işlem=="q"): print("Yine Bekleriz...") ...
4ed1796d9ce52c82fa6a4c7b79f706567ccd38db
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/basithesapmak.py
635
4.0625
4
print("""************************* Basit Hesap Makinesi Programı İşlemler; 1.Toplama İşlemi 2.Çıkarma İşlemi 3.Çarpma İşlemi 4.Bölme İşlemi ************************* """) a=int(input("Birinci Sayı:")) b=int(input("İkinci Sayı:")) işlem=input("İşlemi giriniz:") if (işlem=="1"): print("{} ile {} ...
388977d7fb69ba87b4074e8e31afe89d45b7a1fc
mebaysan/LearningKitforBeginners-Python
/ozelMethodlar.py
809
4.03125
4
class Fruits(): def __init__(self,name,calories): # bu sınıf initialize olduğunda yani türetildiğinde içine gelen parametreler bu sınıfın attribute'ları olacak self.name = name self.calories = calories def __str__(self): # bu sınıf türetildiğinde instance.name demeden bize bu sınıfın name'ini d...
9a95bd01ae50049a5a8ecf46bf7d0f0ecd8d9e7d
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/fordöngüdenemeleri.py
805
3.78125
4
print("for döngü denemeleri") liste=[1,2,3,4,5,6] for denelem in liste: print(denelem) print("**********************") liste1=[2,123,132,432,123,543,753,123,76,986,10980,123,6,7,8,88,12,43,54] toplam = 0 print(liste1,"\nBu liste için:") for eleman in liste1: toplam = toplam + eleman pr...
7ea8ef1011dbc1b781cf98c8f93dc4f079b0fcfc
mebaysan/LearningKitforBeginners-Python
/python_ders10_ileriseviye_veriyapıları_objeler/ileriseviye_kümeler.py
3,958
4.34375
4
print(""" İleri Seviye Kümeler (Sets) Kümeler, matematikte olduğu gibi bir elemandan sadece bir adet tutan bir veritipidir. Bu açıdan kullanıldıkları yerlerde çok önemli bir veritipi olmaktadırlar. x = set() # boş küme aynı zamanda x={\\1,2,3,1,2,3,1,2,3} dersekte küme oluşur yani {\\} süslü parantez liste = [1,2...
d420487746d453766dba6c07946925311fba04ce
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/döngüler ödev dosyası/100ekadar3ebölünensayılar.py
382
3.828125
4
print(""" ************************* 1'den 100'e kadar olan sayılardan sadece 3'e bölünen sayıları ekrana bastırın. Bu işlemi continue ile yapmaya çalışın ************************* for i in range(1,101): if (i % 3 != 0): continue print(i) """) for i in range(1,101): ...
81651c545870eb4c63fc32d1efa43f939755e07c
mebaysan/LearningKitforBeginners-Python
/basic_ödevler/listcomprehension.py
863
3.890625
4
liste1=[1,2,3,4,5,6,7,8,9] liste2=list() for eleman in liste1: liste2.append(eleman) print(liste1,liste2) print("***************************") liste3=[1,2,3,4,5] liste4=[eleman for eleman in liste3] print(liste4) print("***********************") liste5=[3,4,5,6] liste6=[z*2 for z in liste5] print(...
13b2b73f35314cd4c54953ab352aecccc3536064
PC-reloaded/dsmp-pre-work
/Et-tu-Preetus/code.py
1,289
3.6875
4
# -------------- # Code starts here class_1=['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio'] class_2=['Hilary Mason', 'Carla Gentry', 'Corinna Cortes'] new_class= class_1+class_2 #new_class =class_1.extend(class_2) print(new_class) #n=class_1.append('preeti') #print(class_1) new_class.append("Pet...
fa28369256363fc99fc9dbc34c8759d4b257226c
huai8551516/PythonPractice
/practice/3.py
559
3.765625
4
#!/usr/bin/python #-*- coding: utf-8 -*- #Author: hz #Environment: Linux & Ubuntu 17.10 #Filetype: Python Source Code #Tool: Vim #Date: #Decription: 一个整数,它加上100和加上268后都是一个完全平方数, # 请问该数是多少? from math import sqrt max = int(raw_input("你要求n以内的整数:")) num_seq = [] for i in range(max): ...
7992912bc6663e6485469094e125dc8d624a0ea0
epitaciosilva/estudosProgramacao
/lp2/atividadeHeranca/questao2/figura.py
594
3.609375
4
class Figura: def __init__(self, lado1, lado2): self.lado1 = lado1 self.lado2 = lado2 def __str__(self): return "Lado 1: {} \nLado 2: {} \nÁrea da figura: {}".format(self.lado1, self.lado2, self.calcularArea()) def calcularArea(self): return self.lado1*self.lado2 @...
93e646aecd279d4479ad3e285a64307fec5f1560
epitaciosilva/estudosProgramacao
/lp2/atividadePolimorfismo/questao1/main.py
428
3.578125
4
class Viajante: def __init__(self, cls): self.__cls = cls def dizerOla(self): self.__cls.dizerOla(self) class Brasileiro(Viajante): def dizerOla(self): print("Olá") class Espanhol(Viajante): def dizerOla(self): print("Hola") class Americano(Viajante): def dizerOla(self): print("Hello") v1 = Viajan...
6a05ff59530c8b61f12c66d45a5a1d116a68f48b
Nick-Ohman/Intro-Python-II
/src/adv.py
5,620
3.5
4
from room import Room from player import Player from items import Item # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons"), 'foyer': Room("Foyer", """Dim light filters in from the south. Dusty passages run north and east....
d7cb0e91a9a37a49840f85845d499a92cafb85ca
cwang-armani/learn-python
/04 python核心/10 闭包.py
786
4.03125
4
''' 如果在一个内部函数里,对在外部作用域(但不是在全局作用域)的变量进行引用,那么内部函数就被认为是闭包(closure)。 一个闭包就是你调用了一个函数A,这个函数A返回了一个函数B的引用给你。 这个返回的函数B就叫做闭包。你在调用函数A的时候传递的参数就是自由变量 ''' def test(number): print("---1---") def test_in(number2): print("---2---") print(number+number2) print("---3---") return test_in a = test(100) a(2...
5327645fe2ad9a4bff50f3347cc8937c7c5b8645
cwang-armani/learn-python
/02 面向对象/8 继承.py
512
3.6875
4
class Animal(): def eat(self): print("吃") def drink(self): print("喝") def sleep(self): print("睡") def run(self): print("跑") '''继承父类的名字,直接打在里面,前面定义的就不用重写''' '''调用方法 先子类 后父类''' class Dog(Animal): def bark(self): print("汪汪叫") class Cat(Animal): def catch(self): print("抓老鼠") a=An...
1eb433504868fbaa75faaa7bac81000f9431dee6
cwang-armani/learn-python
/09 数据结构与算法/5 栈.py
699
4.1875
4
class Queue(object): '''定义一个栈''' def __init__(self): self.__item = [] def is_empty(self): # 判断列表是否为空 return self.__item == [] def enqueue(self,item): # 入队 self.__item.append(item) return item def dequeue(self): # 出队 r...
1cb3ec8f915657b3df448ea3f05b7705e69a1823
cwang-armani/learn-python
/04 python核心/15 带有参数的装饰器.py
443
3.703125
4
def func_args(arg): def func(function_name): def func_in(): print("日志 arg = %s"%arg) if arg == "hehe": function_name() function_name() else: function_name() return func_in return func #先执行@func_args("hehe"),返回了func的引用 #test=@func(test) @func_args("hehe") def test(): ...
687c1ddb9719b34698ac3cb7f0bbfa158ac35760
cwang-armani/learn-python
/10 MySQL/1 表的创建.py
2,641
3.671875
4
数据库命令: 创建create database 数据库名 charset=utf8; 删除drop database 数据库名; 查看所有数据库:show databases; 使用数据库:use 数据库名; ---------------------------------------- 表命令: create table 表名(列...); 唯一标识的要求:id 类型:int unsigned 约束1:not null 约束2:primary key 约束3:auto_increment 列的格式:列的名称 类型 约束 create table students( -> id ...
0ff2bdb2f351f3b15b54683fb4abed165d7f4dfa
cwang-armani/learn-python
/09 数据结构与算法/8 冒泡排序法.py
561
3.921875
4
# coding:utf-8 def bubble_sort(a_list): '''冒泡排序法''' n = len(a_list) for i in range(n-1): count = 0 # 中间的某次已经排序好了,直接跳出循环 for j in range(n-i-1): # 游标 if a_list[j] > a_list[j+1]: a_list[j],a_list[j+1] = a_list[j+1], a_list[j] count += 1 if count == 0: break print(a_list) if __n...
b66fd6478fd1c2a2fa3714dd3f6ce463cea6b48b
lisseta/Algorithm-Analysis_FESAr.
/problemaUno.py
676
3.84375
4
# Solución para el problema N° 1 de Diseño y Análisis de Algoritmos # Autor: SouYui # ! Requiere una lista de elementos tipo str # R Devuelve el indice del primer elemento que su predecesor es menor a él def primerElementoMenor(lista): if(type(lista) == list and len(lista) > 1): for i in range(1, le...
c5f0af436ab49400f930ec8436b3264e45f598b8
bobbykwariawan/m26415067
/PR/PR Minggu 4/Python Basic Exercises/list1.py/A.py
180
4.125
4
#!/usr/bin/python def match_ends(words): a=words if len(a)>2 and a[0]==a[len(a)-1]: a=len(a) else: a=0 return a print(match_ends(raw_input('Input words: ')))
ceb2b2a2b5d2a0bd0b2d1d52ce9b4973f5b9559b
UrviMalhotra/Inventory-Management-System
/shop.py
5,071
3.625
4
import json shop=open("shoprecored.json","r") sale=open("sales.json","r") shop_data=shop.read() sale_data=sale.read() record = json.loads(shop_data) record_sale=json.loads(sale_data) shop.close() sale.close() def check_inventory_item(): print("\n\n") Item_ID = input("Enter Item ID: ") if Item_...
5de9cfb12de98f8b6a7c76464769c66a3114981b
cesaralmeida93/python_settings
/src/start.py
303
3.828125
4
def soma(num_1: int, num_2: int) -> int: """Somando dois numeros :param - num_1: primeiro numero da soma - num_2: segundo numero da soma :return - Soma entre dois numeros """ soma_dois_numeros = num_1 + num_2 return soma_dois_numeros SOMA_DOIS_NUMEROS = soma(1, 2)
9b9c346df8541a4277617683cc140410632d6fe1
casteluc/space-invaders
/src/entities.py
3,271
3.546875
4
import pygame from pygame.locals import * FRIEND, ENEMY = 0, 1 UP, DOWN = 1, -1 START, STOP = 0, 1 RIGHT, LEFT = 0, 1 BIG, SMALL = 0, 1 # Loads game images shipImg = pygame.image.load("C:\casteluc\coding\spaceInvaders\img\ship.png") enemyImg = pygame.image.load("C:\casteluc\coding\spaceInvaders\img\enemy.png") broken...
2588dfde5582125de98eb50ab20e76762e01be8d
pragatij17/General-Coding
/Day 1/si_ci.py
447
4
4
# Create a program to calculate simple interest and compound interest, take input from the user. def simple_interest(p, r, t): si = (p * r * t)/100 return si def compound_interest(p, r, t): amount = p*(pow((1+r/100),t)) ci = amount-p return ci p=int(input('The principal is: ')) t=float(input('The ...
985bb44337d98dcf1b07803b84ae7417f48c0015
pragatij17/General-Coding
/Day 6/python/sum_of_numbers.py
256
4.25
4
# Write a program that asks the user for a number n and prints the sum of the numbers 1 to n. def sum_of_number(n): sum = 0 for i in range(1,n+1): sum =sum + i return sum n = int(input('Last digit of sum:')) print(sum_of_number(n))
67e3db0c3723dccacf09bbdcf56f8e4aae14cbcd
CarelHernandez/chatter-bot
/Chatter bot.py
1,506
3.984375
4
print(" hi my name is Car-two-el, I am here to help you get comftorable with talking to people so dont get intrigued. So whats your name?) Name == input () print (" Hi there" + Name + " so I heard your shy? its okay let me help you get comfortable?" ) answer = input () if answer == "okay" or ans...
79580d10f09043e7703f0f49c88116037f0c4e48
kartikhans/competitiveProgramming
/Min_Stack.py
643
3.578125
4
class MinStack: def __init__(self): """ initialize your data structure here. """ self.arr=[] self.prr=[] self.mini=100000000000 def push(self, x: int) -> None: self.arr.append(x) if(x<self.mini): self.mini=x self.prr.append(self...
448d642fc8db9bd6bc2f4fd654cff693dcc77f25
kartikhans/competitiveProgramming
/missing_Number.py
192
3.65625
4
def missingNumber(nums): n=len(nums) arr=[0]*(n+1) for i in nums: arr[i]=1 for i in range(n+1): if(arr[i]==0): return(i)
c84859d03e6df77d8575dddd7192f2f36852ba31
RojieEmanuel/intro-python
/102.py
2,170
4.1875
4
weekdays = ['mon','tues','wed','thurs','fri'] print(weekdays) print(type(weekdays)) days = weekdays[0] # elemento 0 days = weekdays[0:3] # elementos 0, 1, 2 days = weekdays[:3] # elementos 0, 1, 2 days = weekdays[-1] # ultimo elemento test = weekdays[3:] # elementos 3, 4 weekdays ...
714406f52f4bd8bd2569626d6ac185aadea1e33e
Worcester-Preparatory-School-Comp-Sci/python-2-for-loop-with-input-KurtLeinemann
/PigLatin.py
265
3.921875
4
## Kurt Leinamann Pig Latin September 26 2019 word=input("Pick a word") vowelList=['a','e','i','o','u'] if word[0] in vowelList: print(word +"yay") #yikes... print(print... also didn't need to select a slice of word.. just whole word else: print(word[1:] + word[0] + "ay")
e3c4390df61f4a0bc49568058e76bcbec10b4c24
Ram-cs/Interview-prep-Cracking-the-coding-solutions-by-chapter
/Inheritance.py
1,328
4.03125
4
# class Vehicle: def __init__(self,brake=0, accelerate=0): self.brake = brake self.accelerate = accelerate def accelerate(self, accelerate): self.accelerate = accelerate def brake(self, brake): self.brake = brake class Car(Vehicle): def __init__(self, brake, accelerat...
fbe429daf028265ea14c3a945938f8b0b4a2d6f0
Akif-Mufti/Machine-Learning-with-Python
/plot1Barhist.py
522
3.59375
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 26 14:23:46 2017 @author: user """ from collections import Counter from matplotlib import pyplot as plt grades = [83,95,67,54,23] decile = lambda grade:grade // 10*10 histogram = Counter(decile(grade) for grade in grades) plt.bar([x-4 for x in histogram.keys(...
c1503433697543bdd5f5a3bd16ffd47a86574dbd
Akif-Mufti/Machine-Learning-with-Python
/FS3.py
522
3.515625
4
# Feature Extraction with PCA from pandas import read_csv from sklearn.decomposition import PCA # load data filename = 'pima-indians-diabetes.data.csv' names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class'] dataframe = read_csv(filename, names=names) array = dataframe.values X = array[...
14acca9d50adbf5c80ae0b1884ec5236410c5138
captain204/Python-notes
/circle_rectangle.py
542
3.8125
4
from circle import Circle from rectangle import Rectangle class ShapeDemo(): @classmethod def main(cls, arg): width = 2 length = 3 radius =10 rectangle= Rectangle(width,length) print("Rectangle with:",width,"Length",length, "Rectangle area",rectangle.area(),rectangle....
b32bde9d8552deda474e649b149e96dda4262915
Tu-Jiawei/For-study
/CNN for mnist.py
3,517
3.859375
4
''' from book 'Tensorflow+Keras 深度学习人工智能实践应用' TensorFlow MNIST数据集,卷积神经网络 ''' import tensorflow as tf import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) def weight(shape): return tf.Variable(tf.truncated_normal(shape,stddev=0.1),name='W...
65307d9013fa55f166c2c669bd7290547c4e986b
DavidFitoussi/InheritanceSample
/Person.py
1,433
3.734375
4
from enum import Enum class TypePerson(Enum): student = 1 worker = 2 class Person: def __init__(self,name ="ingonito", age = None , height = None ): self.name = name # if name != None else "incognito" self.age = age self.height = height def WhoIam(self): ...
5a2c158aeb9c35af7c7cc3d5b2f8c08afc6200d5
GVK289/aws_folders
/backend-PY/car1.py
492
3.53125
4
class Car: def __init__(self, in_color,car_type, car_acc): #print('GVK') self.color = in_color self.accleration = car_acc self.type = car_type self.current_speed = 100 self.decelerate = 15 def accelerate(self): self.current_speed += self.accleration ...
1b1e1d95577219087180b5ef9f66c08fa339fc59
GVK289/aws_folders
/backend-PY/robo-main.py
1,146
3.59375
4
class Employee: bonous = 10000 no_of_employees = 0 raise_amount = 1.04 def __init__(self,first_name, last_name, salary): self.first_name = first_name self.last_name = last_name self.salary = salary self.email = first_name + '.' + last_name + '@gmail.com' ...
1343e30afb43c35c44b16ddf3abf57dcae7ce2de
GVK289/aws_folders
/clean_code/clean_code_submissions/clean_code_assignment_002/test_car.py
10,605
3.546875
4
import pytest from car import Car ########### ******** Testing wether One object is creating ******** ########### def test_car_creating_one_car_object_with_given_instances_creates_car_object(): # Arrange color = 'Black' max_speed = 200 acceleration = 30 tyre_friction = 7 car_obj = Car(color=c...
b293cdff81ef8d76c469aa41d74e33b26cbb64d3
zzynggg/python
/Sorting Algorithm.py
25,041
3.953125
4
# Author: Yong Zi Ying # Sorting Algorithm # Grade: 19.6/20 HD #%% Task 1:Radix Sort def best_interval(transactions, t): ''' This function is used to search for the total number of transactions within the best interval by using 2 pointers. :Input: An unsorted list of non-negative integers and a non-negative int...
dcf7913f53b7ea31ba263c2a26ecd5a52334846e
SaidRem/algorithms
/find_biggest_(recursion).py
404
4.21875
4
# Finds the biggest element using recursion def the_biggest(arr): # Base case if length of array equals 2 . if len(arr) == 2: return arr[0] if arr[0] > arr[1] else arr[1] # Recursion case. sub_max = the_biggest(arr[1:]) return arr[0] if arr[0] > sub_max else sub_max if __name__ == '__mai...
97789c67c970f11cc90742a11d1bb43e7f94fb01
ekaterina533/lab2.2
/2задание.py
211
3.765625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- if __name__ == "__main__": a=input("Введите слово:") b=input("Введите ещё одно слово:") c = set(a).intersection(set(b)) print(c)
c31a7cc8af986a8823b96cc4cc72293040f3b710
richi1325/Markovian_decision_processes
/main.py
3,864
3.5
4
from time import sleep from menu import portada, eleccion from lectura import lecturaPMD, validadorEnteros from algoritmos import * from os import system from examples import base1 def main(): portada() input() tipo = None while True: system("cls") eleccion() seleccion = input(...
402632370f075fec73ef83f052aaee9150349108
zoulala/exercise
/leetcode/Sort_quick.py
1,338
3.90625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # # ***************************************************** # # file: Sort_quick.py # author: zoulingwei@zuoshouyisheng.com # date: 2021-12-29 # brief: # # cmd>e.g: # ***************************************************** """快速排序: 说白了就是给基准数据找其正确索引位置的过程,本质就是把基准数大的都...
8266e8603f0e2123137e0dadaf27ee36bafc4ac4
zoulala/exercise
/thoth-test/mongodb_test.py
7,399
3.53125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- from pymongo import MongoClient # 连接mongodb # ------------------------------ conn = MongoClient('localhost', 27017) db = conn.mydb #连接mydb数据库,没有则自动创建 my_set = db.test_set # 使用test_set集合,没有则自动创建 # 插入数据(insert插入一个列表多条数据不用遍历,效率高, save需要遍历列表,一个个插入) # ----------------------...
ad820701830b1218dae30ec6f8168979064f2da9
zoulala/exercise
/others/a_stock_simulate.py
2,878
3.53125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # # ***************************************************** # # file: a_stock_simulate.py # author: zoulingwei@zuoshouyisheng.com # date: 2020-04-16 # brief: 看了一个操盘策略,用公式进行模拟。https://www.toutiao.com/i6815418938378158606 # # cmd>e.g: # ******************************...
cf7b11055a31306a15a1485840d9c409020cb356
PromasterGuru/Hackerrank-Solutions
/Capitalize!/main.py
171
3.625
4
# Complete the solve function below. def solve(s): return ' '.join([word.capitalize() for word in s.split(' ')]) if __name__ == '__main__': print(solve(input()))
660e41b5a8d6da7ff132d7fd1c91ad29943cd1a0
PromasterGuru/Hackerrank-Solutions
/Alphabet Rangoli/main.py
321
3.53125
4
import string def print_rangoli(size): alphabets = list(string.ascii_lowercase)[:size] for i in range(size-1, -size, -1): res = '-'.join(alphabets[size-1:abs(i):-1] + alphabets[abs(i):size]) print(res.center(4*size-1, '-')) if __name__ == '__main__': n = int(input()) print_rangoli(n)...
11649567de31fd5543c30fd786c222bb1438321a
PromasterGuru/Hackerrank-Solutions
/Electronics Shop/main.py
779
3.78125
4
from itertools import product def getMoneySpent(keyboards, drives, b): result = -1 for ar in list(product(*(keyboards, drives))): if sum(ar) <= b and sum(ar) > result: result = sum(ar) return result if __name__ == '__main__': # fptr = open(os.environ['OUTPUT_PATH'], 'w') bnm = ...
d16a3efed1b1437a0e4ed382af134e3510b5aac5
iuryferreira/python-data-structures
/data_structures/open_address_hashtable.py
2,174
3.71875
4
from data_structures.hashtable import HashTable from data_structures.utils.data_structures_visualization import DataStructuresVisualization class OpenAddressHashTable(HashTable): """ This class inherits from HashTable, using open address collision treatment. """ def __init__(self, size): ...
5a1edee22fe63654a519259ee3b4ceaa2f4a345a
NaokiEto/CS171
/hw3/raster.py
4,108
4.3125
4
# Must be called before any drawing occurs. Initializes window variables for # proper integer pixel coordinates. def initDraw(xMin, xMax, yMin, yMax, xr, yr): global windowXMin, windowXMax, windowYMin, windowYMax, xRes, yRes windowXMin = xMin windowXMax = xMax windowYMin = yMin windowYMax = yMax ...
91cd0209f59bcbdb4c4324ff8bcfaa0cc6b782a4
exload/CS50-2019
/pset6/bleep/bleep.py
889
3.765625
4
from cs50 import get_string from sys import argv, exit def main(): if len(argv) != 2: print("Usage: python bleep.py dictionary") exit(1) # Prompt the user to provide a message print("What message would you like to censor?") text = get_string() # Open file dict_file = open(argv...
bc49cd0006cb106bfa069970a3e37d84ec093b2f
ubco-mds-2018-labs/data533_lab2_vaghul_jiachen
/xuebadb/dfanalysis/cleanup.py
419
3.5
4
import numpy as np import pandas as pd import missingno import matplotlib.pyplot as plt def show_nulls(input_df): if(not isinstance(input_df, pd.DataFrame)): print("Can't cleanup an object that is not a dataframe") return None input_df.replace("None", np.nan, inplace = True) # Matrix t...
11cc2c6083d06171c1e2db5e0c2c1b1502e3289a
lucasadelino/Learning-Python
/Automate the Boring Stuff Practice Projects/Chapter 7/regexstrip.py
218
4.0625
4
# A regex version of the strip() method import re def regexstrip(some_string, arg = '\s'): strip = re.compile('^' + arg + '*|' + arg + '*$') return strip.sub('', some_string) print(regexstrip('AAAbruceAAA'))
f3a85aff075359dfbbeedde83d6727735d3b7e29
BSkullll/DSA
/Stacks and Queues/balanced_parenthesis.py
393
3.796875
4
def balanced_parenthesis(data): if len(data) % 2 != 0: return False opening = {'{','(','['} datas = { ('(',')'), ('[',']'), ('{','}') } stack = [] for e in data: if e in opening: stack.append(e) else: if len(stack) == 0: return False ch = stack.pop() if (ch, e) not in datas: re...
51eef942ba2281b2f49dc1a8bc7ec8ee8990184f
BSkullll/DSA
/Array Question/anagram_by_sorted_approach.py
341
3.703125
4
def func(a, b): a = a.replace(' ', '').lower() b = b.replace(' ', '').lower() result = None if len(a) != len(b): return False else: a = sorted(a) b = sorted(b) for i in range(len(a)): if a[i] == b[i]: result = True continue else: result = False break return result print(func("abc...
4eb482a93d598a005ef04360363310916c619eeb
PdxCodeGuild/class_mudpuppy
/Assignments/Racheal/python/Lab2.py
713
4.0625
4
# lab2 """ instructions Search the interwebs for an example Mad Lib Create a new file and save it as madlib.py Ask the user for each word you'll put in your Mad Lib Use an fstring to put each word into the Mad Lib """ """ The wheels on the bus go round and round Round and round Round and round The wheels on the bus go ...
6af4513c000f0bf8ae449e915e146515187fed08
PdxCodeGuild/class_mudpuppy
/Assignments/Terrance/Python/lab07-rock_paper_scissors.py
1,327
4.25
4
#lab07-rockpaperscissors.py import random user_input = 'yes' while user_input == 'yes': print('Let\'s play rock-paper-scissors!') print('The computer will ask the user for their choice of rock, paper or scissors, and then the computer will randomly make a selection.') #computer tell user how the game wil...
f5bac030adc72702c31328a37f3c483b445bd25c
PdxCodeGuild/class_mudpuppy
/1 Python/solutions/repl-example.py
227
3.8125
4
# Running state running = True # While it's running # LOOP while running: # READ value = input("Enter anything or done to exit: ") # EVALUATE if value == "done": running = False break # PRINT print(value)
10ad2eef9da72722ff2354360db06a58c6ff05af
PdxCodeGuild/class_mudpuppy
/3 JavaScript/js_py/rot13/rot13.py
334
3.5
4
import string unencoded = "helloiliketocode" unencoded = "uryybvyvxrgbpbqr" num_list = [] for letter in unencoded: num = string.ascii_lowercase.index(letter) num_list.append(num) encoded = '' for num in num_list: index = (num + 13) % len(string.ascii_lowercase) encoded += string.ascii_lowercase[index] p...
0ee076081c0c54572abae5c4ab18625918c643f8
PdxCodeGuild/class_mudpuppy
/Assignments/Manny/Python/lab23.py
2,197
3.859375
4
with open('contacts.csv', 'r') as file: lines = file.read().split('\n') list_of_lines = [] for line in lines: line = (line.split(",")) # makes our contact file nice and neat list_of_lines.append(line) # headers = list_of_lines[0] # other_lines = list_of_lines[1:] # 1: starts at the second item on the lis...
4885b4212545ee9f635fed82f045478503adc865
PdxCodeGuild/class_mudpuppy
/Reviewed/Brea/python/lab17/lab17_version2_checked.py
1,009
4.125
4
#Lab 17, Version 2 Anagram def split(word): return list(word) # good practice, but generally don't make a function # that calls a single function, especially one that's already well-known like list() def remove_spaces(str): new_str = '' for i in range(len(str)): if(str[i] != ' '): new_...
37675d15d25aa51006258ff94564fbc04ff6e685
PdxCodeGuild/class_mudpuppy
/1 Python/class_demos/function-lecture/add-number-words-ultimate-solution.py
986
4.125
4
import operator def get_valid_input(): valid_input = False while not valid_input: num1 = input("Spell out a number with letters: ") if num1 in number_dict: return num1 else: print(f"{num1} is not supported. Try entering a different number: ") def reduce_list_to...
096d0dc863ab7739debf8e8000545f4e7f7f3cda
PdxCodeGuild/class_mudpuppy
/Assignments/Devan/1 Python/labs/lab11-simple_calculator.py
1,098
4.21875
4
# Lab 11: Simple Calculator Version 3 def get_operator(op): return operators[op] def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y def eval(fn, n1, n2): return fn(n1, n2) operators = {'+': add, '-': subtrac...
541761c20e5cdc6eb60fb7316866f139754f0841
PdxCodeGuild/class_mudpuppy
/Assignments/Terrance/Python/wacky_functions.py
252
3.59375
4
wacky_functions.py def noisey_add(num1, num2): print(f"ADDING {num1} AND {num2}!!!!:D") return num1 + num2 def bad_add (num1, num2): print(num1 + num2) print(noisey_add(1, 3) + (-2 + 5)) # (1 + 3) + (-2 + 5) # 4 + (-2 + 5) # 4 + 3 # 7
50962379cef04f28b24854aeeaccc11e9f673a9b
PdxCodeGuild/class_mudpuppy
/Assignments/Eboni/labs06.py
1,170
4.21875
4
# Lab 6: Password Generator """ Let's generate a password of length `n` using a `while` loop and `random.choice`, this will be a string of random characters. """ import random import string # string._file_ = random.choice('string.ascii_letters + string.punctuation + string.digits') # #print((string._file_)) # pass_n...
b88a20e027f7711bff9a5b8a9d0658d3b8a638cb
PdxCodeGuild/class_mudpuppy
/Assignments/Brea/Python Labs/Lab25_version2.py
1,603
3.765625
4
#Lab 25, version 2, April 17th, 2020 class Atm: def __init__(account, balance = 0): account.negative = False account.balance = balance account.interest_rate = .01 account.transactions = [] def check_balance(account): #returns the account balance print(f"Your account...
042467884095a0b0e7a52c67df4cae6033eb4f88
PdxCodeGuild/class_mudpuppy
/Assignments/Terrance/Python/lab09-written_addition.py
1,444
3.90625
4
#lab09-written_addition.py units = { "m": 1, "ft": 0.3048, "mi": 1609.34, "km": 1000, "yd": 0.9144, "in": 0.0254 } user_unit = input("What unit are you using?") user_number = input("Enter the number of units.") user_number = int(user_number) if user_unit == "m": solution = units["m"] * u...
9686df41204e02ef1e69ce6eda1c5cc539826484
PdxCodeGuild/class_mudpuppy
/Assignments/Terrance/Python/lab03-grading.py
491
3.984375
4
#lab03-grading.py user_grade = int(input("What is your grade? ")) if user_grade > 100: print("Good job, you got an A+!") elif user_grade <= 100 and user_grade >= 90: print("Good job, you got an A.") elif user_grade <= 90 and user_grade >= 80: print("Not bad, you got an B.") elif user_grade <= 80 and user_g...
efb3cc272635bad1eac58a5a54352b76d8aaf03b
PdxCodeGuild/class_mudpuppy
/Assignments/Brea/Class Examples/Test3.26.20.py
935
3.953125
4
# import random # eye = random.choice(';:') # nose = random.choice('->') # mouth = random.choice(')]') # output = eye + nose + mouth # print(output) # def make_face(eye, nose, mouth): # return eye + nose + mouth # # def make_eye(): # # return # # def make_nose(): # # return # # def make_mouth(): # # ...
29ea796e4e8cf9ed5da93f437c836b23eba80c34
PdxCodeGuild/class_mudpuppy
/1 Python/examples/book_recommender_v2.py
2,420
3.625
4
import requests import random from bs4 import BeautifulSoup # Create your own error called InvalidGenreError class InvalidGenreError(Exception): pass def get_books(genre='horror'): # Get html data from a website response = requests.get(f"https://www.goodreads.com/genres/new_releases/{genre}") # Turn it into...
ba0752e6e9750a6b832ba939613811df382ee644
PdxCodeGuild/class_mudpuppy
/1 Python/solutions/lab12-v1.py
318
4.0625
4
import random computer_guess = random.randint(1, 10) won = False print(computer_guess) for i in range(10): guess = float(input("Guess a number between 1-10: ")) if guess == computer_guess: won = True break print(f"Guess again, you meat bag! You have {9 - i} tries left...") if won: print("You won!")
361ac4d33c0fd3855b67ebb14103f6a2db052c0f
PdxCodeGuild/class_mudpuppy
/1 Python/hints/lab_23/list_to_dict.py
571
3.609375
4
# list_to_dict.py start_list = [['a', 'b', 'c'], ['d', 'e', 'f']] output = [] for one_list in start_list: # one_list = ['a', 'b', 'c'] print(one_list) one_dict = {} for index in [0, 1, 2]:#range(len(one_list)): #index = 0 #one_list[index] = 'a' one_dict[index] = one_list[index] ...
d67ad475fcc9930444dfc9dba97ea0d380a8ce72
PdxCodeGuild/class_mudpuppy
/Assignments/Haoua/PYTHON/function.py
3,960
4.75
5
'''def my_function(fname): #fname is the argument, functions can have as many arguments as possible. just separate with commmas. #When the function is called, we pass along a first name. print(fname + " Refsnes")#used inside the function to print the full name: #shortened to args in Python documents #parameter ...
2874845c72626487f96500a7aac40ba91891870e
PdxCodeGuild/class_mudpuppy
/1 Python/solutions/lab09-v2.5.py
617
4.34375
4
# Supported unit types supported_units = ["ft", "mi", "m", "km"] # Ask the user for the unit they want unit = input("What unit do you want: ") # If an invalid unit is specified, alert the user and exit if unit not in supported_units: print("Please enter a valid unit! Options are ft, mi, m, km...") exit() # Get t...
94aaa7a1f356fae443a91b748d7ad8f8fe395882
PdxCodeGuild/class_mudpuppy
/Assignments/Haoua/PYTHON/lab10.py
330
3.8125
4
list1 = [] i = 0 while True: num1 = (input("Input your first number: ")).lower() # print(num1.isdigit()) if num1.isdigit(): num2 = int(num1) list1.append(num2) elif num1 == "done": total = (sum(list1)//len(list1)) print(f"Your average is: {total}") b...
7d22fbd58d09e95c2ab94e8adb567da9c3932b36
PdxCodeGuild/class_mudpuppy
/Assignments/Eboni/lab18.py
439
4.125
4
import string input_string = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9] #change variable name #create an empty list for index in range(1,len(input_string)-1): left_side = input_string[index-1] middle = input_string[index] right_side = input_string[index + 1] if left_side < middle an...
adbf42f3752456bea0736e70ac0ac4133ede4db8
PdxCodeGuild/class_mudpuppy
/Assignments/Haoua/PYTHON/lab08.py
593
3.703125
4
amount = float(input("Enter a dollar amount (0-99) : ")) ver = amount.is_integer() print(ver) if ver is False: print(amount//.25, "quarters") amount = amount%.25 print(amount//.10, "dimes") amount = amount%.10 print(amount//.05, "nickles") amount = amount%.05 print(amount//.01, "p...