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
14cede9fd0abad9d66ab48c55fe78ccc8b5eea14
bhokansonfasig/Project_Euler
/problem014.py
427
3.84375
4
def follow_collatz(number, count): count += 1 if number<=1: return count elif number%2: return follow_collatz(3*number+1,count) else: return follow_collatz(int(number/2),count) if __name__ == '__main__': max_length = 0 for i in range(1,1000000): length = follow_c...
c6f5e41356c0ed7a356e006e6e7bc8a1fc2967b8
silastsui/pyjunior
/functions-and-sorting/selectionsort.py
705
3.84375
4
#!/usr/bin/python #selection sort import random old = random.sample(xrange(1,100000),10000) def selsort(list): new = [] while old != []: #can also use len(old) != 0, but not as efficient small = old[0] for x in old: if x < small: small = x new.append(small...
7ec6c5f2363d20cdd567aff4f9cc48718e77f895
silastsui/pyjunior
/strloops/backwards.py
551
4.15625
4
#!/usr/bin/python #backwards text = str(raw_input("Enter a phrase: ")) #solution1 (wat) print text[::-1] #solution2 (for x in range) reverse = "" a = len(text) for x in range(len(text)-1, -1,-1): reverse += text[x] print reverse #solution3 (for let in text) backwards = "" for let in text: backwards = let + backw...
41b6e2352903bb2459a65f981655f9c7ed7ce60b
silastsui/pyjunior
/intloops/bin2dec.py
245
4.125
4
#!/usr/bin/python #bin2dec converter def bin2dec(num): power = len(num)-1 dec = 0 for x in num: dec = dec + int(x)*(2**power) power -= 1 return dec num = raw_input("Enter a binary number: ") print bin2dec(num)
a032e8bebbc14ab6653040f6c6a6c8a7c9e30fcd
silastsui/pyjunior
/functions-and-sorting/fizzbuzz.py
212
3.90625
4
#!/usr/bin/python #buzzfizz #div by 3, fizz, div by 5, fizzbuzz for x in range(101): if x%3 == 0 and x%5 == 0: print "fizzbuzz" elif x%5 == 0: print "buzz" elif x%3 == 0: print "fizz" else: print x
03d6ee956894438add789415113d78f82254097a
kk456852/CodeReader
/design_pattern/state.py
1,052
3.953125
4
from abc import ABCMeta, abstractclassmethod class Water: def __init__(self, state): self.__temperature = 25 self.__state = state def setState(self, state): self.__state = state def changeState(self, state): self.__state = state def getTemperature(self): ret...
f364bd45f948fb06f8507418c65a124b507223fb
TheXichao/dice-game
/main.py
2,426
3.765625
4
import random import os userList = [] total1 = 0 total2 = 0 def authUser(): userUsername = input("Username: ") userPassword = input("Password: ") loginFile = open("login.txt", "r") for logins in loginFile.readlines(): user, password = logins.strip().split(":",1) if (userUsername ==...
aa6136feb0298a4b8da1286ec5304da565132194
tonyxxq/my-docs
/algorithm/A星/python/student_code.py
2,590
3.875
4
import math from queue import PriorityQueue as PQueue class node(object): def __init__(self, parent, index, g, h): self.parent = parent self.index = index self.g = g self.h = h def setParent(self, parent): self.parent = parent def setG(self, g): sel...
dbf9613339e0974f86f24959ee8f98e7a646d537
jsharpna/LESS
/code/Tree.py
7,106
3.953125
4
import Graph import numpy as np import copy class Tree(Graph.Graph): """ A Tree object. Maintains the invariant that it is a tree. I.e. you cannot add a vertex without adding an appropriate edge to connect it to the tree. This is a connected graph with out any cycles. Allows for more optimized comp...
26f22f4e175cb0ebd8f7f0a0f47a9654c38ba75b
st1ngrayone/stepic-web
/calc1.py
117
3.65625
4
a = 1 b = 10 for i in range(a,b+1): for g in range(a,b+1): print(i,"*",g,"=",i*g,end="\t") print()
abfae45a3d94948815d482e555aef6a6d7832abb
mosamy/Algorithms
/Filewrite.py
386
3.53125
4
__author__ = 'mosamy' def addEmail(filename, name, email): f = open(filename, 'a') # replace the mode # Append name and email, each record should end with f.write(name + ' ' + email + '\n') f.close() return f addEmail("test.txt", "mohamed samy", "msamy@sufgeeks.org") addEmail("test.txt", "mosamy"...
871fd59872b3ad87f6076971c395f7f81bcc5bd0
brentsondgeroth/bioinformatics
/geneFinder/BGChapter9O1.py
5,524
3.609375
4
''' Brent Gaither This program finds possible genes in a sequence for eukaryotes and prokaryotes. Due Date 3/2/2015 ''' import re ''' readIn- Reads in a FASTA formatted file ''' def readIn (infile): infile.readline()#Read first line of Fasta formatted filed sequence = "" for line in infile:#Read in remaining d...
d015c73e042858ef9453925c7487bac3607f6d27
liangxuwhu/computional_physics_N2015301110077
/Chapter_2_2.19/code_4.py
1,457
3.625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Oct 20 08:21:29 2017 @author: lxwhu """ import math import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = Axes3D(fig) class baseball_trajectory: def __init__(self, x=0, y=0, z=0, g=9.8, initial_speed=49, ti...
5a127911e3b7b44c828736813a85ec195a70de55
TimothyMwiti/FoodRecipeParser
/ingredient.py
1,101
3.578125
4
class Ingredient: def __init__(self, name = "", quantity = "", measurement = "", descriptors = [], preparation = ""): self.name = name #string self.quantity = quantity #string self.measurement = measurement #string self.descriptors = descriptors #list of strings self.preparat...
1212f5e8e2a808c4f885f56b1a3af6ca9de12b92
jpfitz44736/trans-market
/econmod-k.py
10,275
3.875
4
#------------------------------------------------------------------------------- # Name: econmod-k # Purpose: Simulates a transactional economy of N agents transacting in pairs and following # a specified rule # # Author: J P Fitzsimmons # # Created: 10/27/2016 # Copyright: (c) J P F...
cafe20c5d03d1298c27859caf0f212666d0ae33d
xiaoyaoshuai/-
/作业/7.24/069.py
957
3.984375
4
''' 设计一个表示学生(Student)的类,该类属性有名字(name),年龄(age),成绩(scores)(成绩包含语文,数学和英语三科成绩,每科成绩的类型为整数)另外有3个方法. (1) 获取学生姓名的方法:get_name(),返回类型为String (2) 获取学生年龄的方法:get_age()方法,返回类型为Int (3) 返回3门科目中最高的分数,get_course(),返回类型为Int ''' class Student(): def __init__(self,name,age): self.name = name self.age = age print...
399a9cc2e455bfac6a31ff152820250af9e73869
xiaoyaoshuai/-
/作业/7.16/033统计字符串的个数.py
188
3.765625
4
''' 接收用户输入的一行字符,统计出字符串中包含数字的个数 ''' a =input('请您输入随机字符') b = 0 for i in a: if i.isdecimal(): b += 1 print (b)
4cdc0078afb012d3695819ae66f5d9149a54e621
xiaoyaoshuai/-
/作业/7.16/035coffeename.py
465
3.984375
4
''' 创建一个名称为coffeename.py文件,内容为依米咖啡厅品名:使用元组保存咖啡馆里提供的咖啡名称,并使用for循环遍历输出 咖啡名称为:1. 蓝山 2.卡布奇诺 3.曼特宁 4.摩卡 5.麝香猫 6.哥伦比亚 最终效果如图: ''' print('依米咖啡馆咖啡名称:') a = ('品名1:蓝山','品名2:卡布奇诺','品名3:曼特宁','品名4:摩卡','品名5:麝香猫','品名6:哥伦比亚') for i in a: print(i)
9ff064d42e751a0ddd14738ce83adf65a427b033
xiaoyaoshuai/-
/作业/7.14/24.py
130
3.5625
4
''' 使用while循环,输出0~100之间所有的偶数 ''' i = 0 while i <= 100: if i % 2 == 0: print (i) i += 1
f6c4afb06393efbcad3e3dfe6bfd6a050b299d08
xiaoyaoshuai/-
/作业/7.18/cards_tools.py
2,626
3.5625
4
card_list=[] def show_menu(): print('*'*50) print('欢迎使用【名片管理系统】V1.0') print('') print('1.新建名片') print('2.显示全部') print('3.查询名片') print('') print('0.退出系统') print('*'*50) def new_card(): print('-'*50) print('功能:新建名片') name = input('请输入姓名:') phone = input('请输入电话:') qq...
708b7544f1f7cfbf8c906a429ded74f3f1161072
xiaoyaoshuai/-
/作业/7.14/22.py
578
3.765625
4
print ("------跳一跳,输入‘退出’即可退出游戏------") score = None print ('欢迎回来,请开始游戏') print ('请输入\(中心、音乐模块、微信支付模块)') while score != '退出': score = input ('请输入:') if score == '中心': print ('您的分数为:32') elif score =='音乐模块': print ('您的分数为:30') elif score == '微信支付模块': print ('您的分数:42') elif scor...
e6fdaef1042ee1932e1666b0db432ac08a7a7b01
JacAbreu/ProjetoEuler
/problem10.py
417
3.578125
4
#Find the sum of all the primes below two million. from math import * def isPrime(x): raiz=sqrt(x) for i in range(2, int(raiz)+1): if(x%i==0): return False x = 2000000 sum_primes = 0 for i in range(2, x): if(isPrime(i) != False): sum_pr...
1802b34d83cbfb6b9026a99c6e30da00d950fa5c
strikingraghu/Python_Exercises
/Ex - 04 - Loops.py
2,676
4.125
4
""" In general, statements are executed sequentially. The first statement in a function is executed first, followed by the second, and so on. There may be a situation when you need to execute a block of code several number of times. Programming languages provide various control structures that allow...
d5d43273000fb4a88b57e33c5fa7377264f2a707
strikingraghu/Python_Exercises
/Ex - 14 - File Handling.py
1,925
4.53125
5
""" In this article, you'll learn about Python file operations. More specifically, opening a file, reading from it, writing into it, closing it and various file methods. """ import os # Opening File file_open = open("c:/python_file.txt") print(file_open) # We can see the path of file, mode of oper...
5fa07f44836ffb22fcd8a237bc1cf8e572c154ac
strikingraghu/Python_Exercises
/Ex - 08 - Tuples.py
2,146
4.28125
4
""" A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. Differences between tuples and lists are, the tuples cannot be changed unlike lists! Also, tuples use parentheses, whereas lists use square brackets. """ sample_tuple_01 = ('Ram', 3492, 'Suresh') sample...
14ebe3e1efe0942c55aaa64908bbb395102ea550
VivakaNand/MYSQL_DATABASE_CONNCETIVITY
/mysql_database_connectivity.py
1,372
3.671875
4
import mysql.connector conn = mysql.connector.connect(host='localhost', user='root', password='password555', database='new_database') # for existing database my_cursor = conn.cursor() # to create database # query = 'CREATE DATABASE new_database' # my_cursor.execute(query) # to show database query = 'SHOW DATABASES'...
7a37c79f1bece97bd399d5aefd80097413a642cc
gomezrondon/KNN
/knn_file.py
2,247
3.578125
4
import sklearn from sklearn.utils import shuffle from sklearn.neighbors import KNeighborsClassifier import pandas as pd import numpy as np import pickle from sklearn import linear_model, preprocessing data = pd.read_csv("car.csv") #print(data.head()) #print de first few lines #Convert non-numerico data into numerica...
35d68e69a4fc3b0c68830f080ddee6019f154415
France-ioi/alkindi-tasks
/2019/2019-FR-AL-03-generators/medium_dictionary_human.py
1,007
3.765625
4
from sys import argv from random import randrange N=int(argv[1]) fd = open("leaked_passwords.txt","r") def is_word_from_dictionary(word1): def lex_less_than_or_equal(word1,word2): for i in range(min(len(word1),len(word2))): if ord(word1[i]) > ord(word2[i]): return False ...
925124af7c9d63790f2c2c3bfbad2babc680e586
France-ioi/alkindi-tasks
/2019/2019-FR-AL-03-generators/medium_random_robot.py
319
3.953125
4
from sys import argv from random import randrange N=int(argv[1]) def random_robot_generator(): l = randrange(6,8+1) word = "" for _ in range(l): n = randrange(33,126+1) # printable chars of ASCII word += chr(n) return word for _ in range(N): print (random_robot_generator())
7ae06afca648bf99e6d73a4a6e063bd5216695b8
N5nissy/chibi
/hello.py
782
3.6875
4
x1 = input("あなたの生年月日を入力してください: ") def digitSum(x): if len(x) is 1: return x array = list(map(int, list(x))) return digitSum(str(sum(array))) if __name__ == "__main__": n = x1 x = str(n) result1 = digitSum(x) x2 = input("相手の生年月日を入力してください: ") def digitSum(x): if len...
e083be45dacb32146104e9a7eff44c07b46958b0
jiwan-12/moneychange
/coin_change.py
650
4.03125
4
#usr/bin/python """ python code to find minimum number of coin required to change money. """ """Function to find the minimum number of coins""" def money_change(money, coins): minimum_coin = [x*0 for x in range(money+1)] for m in range(1, money+1): minimum_coin[m] = 1000 for coin in coins: ...
14d8e5a4a2310204c3e1b32ec83c564b89a3467a
SaketSrivastav/epi-py
/strings/t9_keypad.py
1,121
3.890625
4
import sys k_map = ["0", "1", "ABC", "DEF", "GHI", "JKL", "MNO", "PQRS", "TUV", "XYZ"] def t9_keypad_helper(phone_number, digit, partial_mneumonic): """ Input: phone_number array digit: current digit in processing partial_mneumonic: the mneumonic formaed so far mneumonic: Comp...
041fa7d58b4c8916abf660eb1bfa82ff8f1b0b6f
SaketSrivastav/epi-py
/trees/check_bst.py
1,156
4.1875
4
#! /usr/bin/python class Check_Bst(): def check_balanced(self, node): """ Input: A tree node Output: (+)ve number if BST is balanced, otherwise -1 Description: Start with root node and calculate the height of the left subtree and right subtree. If an absolute difference of...
a81d5d2e962ad9a318d875ae01d7699a63e7fa48
rakibkuddus1109/pythonClass
/Functions.py
3,122
4.1875
4
# Functions : Set of statements to perform a specific task # Function reduces no. of line of codes i.e. code resusability is implemented """ # def -- keyword def functionname(): Statements/ines of code """ # a=34 # b=26 # def mathoperation(): # print(a+b) # print(a-b) # print(a*b) # print(a/b...
454081e675b5dfb9a82293d3a79fa2ff90be90fc
rakibkuddus1109/pythonClass
/polymorphism.py
763
4.375
4
# polymorphism : Many ways to define the method # Method overloading # Method overriding # Method overloading: Considering relevant methods based upon no. of arguments that method has # even though the method names are same # Python doesn't support method overloading # class Operation: # def mul(self,a,...
99355f7b9957a8dcd2c176e4436969861e571a2b
rakibkuddus1109/pythonClass
/exception_handling.py
1,837
4.34375
4
# Exception Handling: Handling the exception or error # In-built exception : comes with programming language itself # User-defined exception : setting up our own defined exception # In-built exception: # a = [6,5.6,'Python',0,67] # for j in a: # print(1/j) # this would give in-built exception when 'Pyt...
b2ace5ba46365f88fd39646263b2cc10531cf5d4
rrrepsac/rus_hyphenation
/hyphenation.py
1,740
3.6875
4
# -*- coding: utf-8 -*- import re def split_syllables_by_hyphen(text): def add_hyphen(m): ret = m.group(1) + '-' + m.group(2) return ret rus_letters = "[абвгдеёжзийклмнопрстуфхцчшщъыьэюя]" rus_vowels = "[аеёиоуыэюя]" rus_consonants = "[бвгджзклмнпрстфхцчшщ]" rus_au...
167408ace5979760e4798586fac4bb9006f2a465
jurijw/Path-Finding
/pathing.py
10,869
3.6875
4
import numpy as np import pygame import sys # Constants size = width, height = (800, 800) cell_count = cells_horizontal, cells_vertical = (15, 15) cell_size = cell_width, cell_height = (width // cells_horizontal, height // cells_vertical) # Colors white = (255, 255, 255) black = (0, 0, 0) red = (255, 0, 0) dark_green...
f9e7461f8f03478bae4e180bd07a3e96c3023e02
jasonliu2050/viz-test
/second.py
3,842
3.703125
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import metrics from sklearn.model_selection import train_test_split # Homework Basic Q1 load boston from remote from sklearn.datasets import load_boston data = load_boston() X_train, X_test, y_train, y_test = train_test_split(data.data...
31e69ff8d7b466e7fba0df249c0cad88c45dd706
cezarb348/python_520
/aulas/estrutura_condicao.py
319
4.09375
4
# -*- coding: utf-8 -*- # if, else idade = int(input('Digite sua idade: ')) habilitacao = True # if idade >= 18: # print('Voce e maior de idade') # else: # print('Voce e menor de idade') # if idade >= 18 and habilitacao is True: # print('Voce pode dirigir') # else: # print('Voce nao pode dirigir')
c57bd3905eeaf98e3b115dab80a65bda37045635
randomguy069/DataPandasPython
/pandas4.py
611
4.03125
4
import pandas df2 = pandas.read_json("supermarkets.json") df2["Continent"] = df2.shape[0] * ["North America"] #Adding a new Column called Continent. Shape returns number of rows and columns df2["Continent"] = df2["Country"]+", "+"North America" #Updating the continent data df2 = df2.set_index("Address") #To update co...
71871790661eeafdedc0297488bc277c25dbbc0f
sjschmidt44/python_data_structures
/data_structures/queue.py
1,058
4.09375
4
from node import Node class Queue(object): def __init__(self, tail=None, head=None): self.tail = tail self.head = head self.size = 0 def __repr__(self): '''Return the size of the queue and node at the head of the queue.''' return 'The Queue has {num} nodes, with {head}...
df99375ddc5223a8026a549901859e82a42cb6d8
rafliI0320080/Rafli-Ridwan-Ramadhan_I0320080_Aditya-Mahendra_Tugas-7
/I0320080_Soal 2_Tugas 7.py
3,402
3.953125
4
import math import os # membuat judul program print("===========================================") print("======== Program Matematika Is Fun ========") print("===========================================") def menu(): print("Menu Program yang tersedia: ") print("1. Program pengecek bilangan prima") print(...
f876a69b0758ec1faf800c70e3403a2e39b7b8c9
StephanRaab/pythonProgramming
/lesson2.py
3,046
4.09375
4
# for i in [2, 4, 6, 8, 10]: # print("i = ", i) # # for i in range(0, 11, 2): # print (i) # # # problem 1: print odds from 1 - 20 # for i in range(1, 21): # if (i % 2) != 0: # print(i) # # your_float = input("Enter a float: ") # your_float = float(your_float) # print("Rounded to 2 decimals: {:.2f}"....
3f86e6d6fe605cf53ba9b2401080768957f4889f
dhimasdityaa/Program-Expedisi-Sederhana
/Expedisi Sederhana.py
11,468
3.609375
4
def menu(): print('++++++++++++++++++++++++++++++++++++++') print('+ Selamat Datang di Program Expedisi +') print('++++++++++++++++++++++++++++++++++++++') print('1. Kirim Paket') print('2. Cek Onkir') def kirimPaket(): namaP = str(input('Masukan Nama Pengirim : ')) descP = s...
8828b31e1798d527ea377dfd811ffae0f9d87af8
Joysingh1709/python3
/CountOfCharInString.py
100
4.0625
4
s=str(input("enter the string :")) count=len(s) print("number of characters in ",s,"is :",count)
eebca7f53a605d810f36add0781f56f7dba56282
usdhkoh/DS_Final_Project1
/k_tweet1.py
4,210
3.5625
4
class User: def __init__(self): self.name = "None" self.tweets = 0 self.friends = 0 self.next_tweet = None self.join_d = "None" # 가입날짜, 이 프로젝트에선 필요없는 데이터 class Tweet: def __init__(self): self.owner = "None" self.content = "None" self.next_tweet = ...
c842c93e4e5b61bc7ebda59c915cd4a8bc3712a8
itsabigaundy/adventofcode2020
/day3/day3.py
765
3.53125
4
import numpy as np def part1(data): n = len(data) m = len(data[0]) return sum([1 if data[i][(3 * i) % m] == '#' else 0 for i in range(1, n)]) def part2(data): n = len(data) m = len(data[0]) slopes = { (1, 1) : 0, (3, 1) : 0, (5, 1) : 0, (7, 1) : 0, (1,...
a37dcf8bba3c32ab2196b694c8bb30cc0dccf297
zhanglintc/tools-lite
/misc/binary_tree.py
1,244
3.5625
4
#encode utf-8 class Tree: def __init__(self, number): self.number = number self.LChild = None self.RChild = None def tree_insert(tree_this, number): if tree_this == None: tree_new = Tree(number) tree_this = tree_new else: if number <= tree_this...
c73cf3480a2ab10b9f3b70487a9a35c7349e0fd6
Jack-Pincombe/PythonPen
/passwordHash.py
221
4
4
''' A function that will hash a password it is given ''' import crypt def hash(word): print("Your hash is --> " + crypt.crypt(word,'HIX')) if __name__ == '__main__': hash(input('Enter you chosen password -->'))
d47a8502d8b6076b417be247b24705244184a247
pjaxon/weather-db-example
/populate_stations_10active_30span_50cover.py
1,960
3.5
4
## This script fetches data from the stations database, adds a two-letter country code ## and saves as stations_10active_30span_50cover.csv import os import psycopg2 from psycopg2.extras import DictCursor import pandas as pd import reverse_geocoder # Function that connects to database def db_connect(): db_name = o...
8c9a02c90341c83834059e50f3784fa1f6ba418b
Amarkharvi/Tkinter-Student-Report-Card-System
/myProject/reportCard_main.py
803
3.71875
4
#program to show a splash screen for 3 seconds. #after 3 seconds another file is opened from tkinter import * import os from PIL import ImageTk,Image sroot=Tk() # creating new tkinter window, sroot is a varible def first():# first() function sroot.destroy() if __name__ == '__main__': import miniProje...
57524f240fe83ca0b697a4a100089166bbfeda2d
SWBalderson/A-Level-Computing
/Python/P7/P7.3_XOX.py
725
3.71875
4
O = 0 X = 0 import math win = 0 def detWin(sym): if sym&7 == 7 or sym&56 == 56 or sym&448 == 448 or sym&292 == 292 or sym&81 == 81: print(sym, "wins! ") return 1 elif X|O == 511: print("Its a draw! ") return 1 else: return 0 def printBoard(a, b): board = list(map(int, str(bin(X|O)[2:][::-1]))) for j in...
5a7c585b4e46173e3129b31e40b31c19270993a9
SWBalderson/A-Level-Computing
/Python/P5/P5.3_Quiz.py
1,104
3.8125
4
import time score = 0 questions = [ "best A-level subject", "best base", "best cookie type", "mode of names in the LVI computing class", "best operating system" ] questionChoices = [ ["Music", "Biology", "Art", "Computing"], ["Denary", "Binary", "Hexadecimal"], ["Oreos", "Choco Chip", "Hobnobs"], ["Ashby", "Adam", ...
d31a1550ba1f32cb1f60c4e0bafbd01189764546
juliaheisler/CSE-231
/proj08.py
8,740
3.828125
4
############################################################################### # Computer Project 8 # # Algorithm # # Program uses 7 functions to take information provided in .csv file and\ # user's region input to create organized table and scatter plot. # # open_file: attempts opening file if it exists ...
09e484069ae320396d7e31bece427efeb1bd9701
JuanMaRo/Python-programming-exercises
/q017.py
562
3.59375
4
#deposit, withdrawal def account(): dep = 0 while True: command = str(input(''' [d] deposito [w] retiro [s] salir ''')) if command == 'd': d = int(input('deposito de $')) dep += d print('deposito de ${}...
3c60baf8608af6501fc6c49270e4a9ba433cb38c
JuanMaRo/Python-programming-exercises
/q006.py
328
3.5625
4
import math def formula(num): l = n.split(',') d = list(map(int, l)) res = [] for i in d: q = (2 * 50 * i)/30 r = math.floor(math.sqrt(q)) res.append(str(r)) print(','.join(res)) if __name__ == '__main__': n = str(input('Tus números son ')) formu...
74fdca8cfc0e09957c8534f63ac8a4545eacc6c8
BertW007/Python-1
/get_ips_from_cidr.py
496
3.6875
4
#!/usr/bin/env python """ Get Possible IPs for a specific CIDR Example: $ ./get_ips_from_cidr.py 10.65.36.23/29 Possible IPs for CIDR 10.65.36.23/29: 10.65.36.16 10.65.36.17 10.65.36.18 10.65.36.19 10.65.36.20 10.65.36.21 10.65.36.22 10.65.36.23 """ from netaddr import IPNetwork import argparse parser = argparse.Arg...
351743b8c60786aea8126640cc9130abb4dced41
WenhaoGe/Leetcode
/Medium/79. Word Search/solution.py
1,011
3.53125
4
class Solution: def exist(self, board: List[List[str]], word: str) -> bool: rows = len(board) cols = len(board[0]) for i in range(rows): for j in range(cols): if self.dfs(board, word, i, j, 0): return True return False ...
5fcb6e4aea19b0c39e1c3aac15b66a7dca314ea4
WenhaoGe/Leetcode
/Medium/75. Sort Colors/solution.py
1,081
3.859375
4
class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ red, white, blue = 0, 0, len(nums) - 1 while white <= blue: if nums[white] == 0: nums[white], nums[red] = nums[red...
84c7958820a17632469fa08654cbf1fc6cc94e99
WenhaoGe/Leetcode
/easy/7. Reverse Integer/solution.py
365
3.671875
4
class Solution: def reverse(self, x: int) -> int: import math sign = 1 if x < 0: sign = -1 x = abs(x) num = str(x) answer = sign * int(''.join(reversed(num))) if answer > pow(2, 31) - 1 or answer < -1 * pow(2, 31): ...
c0c4b67688004c80bb7f950f8373df4fc8dbda79
abhishekchandra2522k/Tkinter-practice
/Calculator/main.py
929
3.671875
4
from tkinter import * from tkinter import ttk # some useful variables fnt = ('Verdana', 22) # creating a window root = Tk() root.title('Calculator') root.geometry('400x500') #picture label pic = PhotoImage(file='Calculator/images/64x64.png') heading = Label(root, image=pic).pack(side=TOP, pady=10) #heading label...
48605760086905e89005691a11d335b3ef3bde5b
is5pz3/automatic-client
/scripts/compare_operations.py
1,098
3.75
4
def find_removed_hosts(prev_hosts, host_names_set): """ Finds host names that have been removed since last iteration of ranking algorithm. Args: prev_hosts: (list) Host names from prevous iteration. host_names_set: (list) Host names from current iteration. Returns: diff_strs: (list) List with removed ho...
4048c47b8e9a6950b9fee8007cc8f4c7f70d1695
Danielmunozgz/SeptiembrePython_30
/menu.py
1,073
4.03125
4
#Crear menú con tres opciones: #1. Opcion 1: Temperaturas #2. Opcion 2: Datos de Personas #3. Opción 3: Salir import os import math def Temperaturas(): print("***TEMPERATURAS***") #Ingresar N temperaturas #Mostrar el promedio de las temperaturas ingresadas sum=0 veces=int(input("Cuantas temperatu...
0e3cc002c2fdd86086804ff3da1a92b993d9c813
gpsyrou/Deep-Learning-A-Z
/Artificial Neural Networks/bank_customers_pred.py
3,636
4.1875
4
# Building an Artificial Neural Network # Part 1 - Importing Data # Importing the libraries # Data processing import numpy as np import pandas as pd # Visualization import matplotlib.pyplot as plt # Goal: Predict which costumers are going to leave the bank (binary classification) # Importing the dataset dataset ...
e16683b3abdcf8d55c22f1f752f4ebce2b8f11e4
yasheymateen/holbertonschool-higher_level_programming
/0x0F-python-object_relational_mapping/4-cities_by_state.py
585
3.6875
4
#!/usr/bin/python3 """Script that lists all cities from the database""" if __name__ == "__main__": import MySQLdb import sys username, password, db_name = sys.argv[1:] cmd = """SELECT cities.id, cities.name, states.name FROM cities JOIN states ON state_id = states.id ORDER BY cities.id""" db = ...
c9dcdcd10f97e2f3a7e4a5b7c17ebad50c132a5c
yasheymateen/holbertonschool-higher_level_programming
/0x0F-python-object_relational_mapping/5-filter_cities.py
726
3.640625
4
#!/usr/bin/python3 """ script that takes in name of state as arg and lists cities of that db""" if __name__ == "__main__": import MySQLdb import sys username, password, db_name, state_name = sys.argv[1:] db = MySQLdb.connect(host="localhost", user=username, ...
aec7ca410ad075100827f13e35eca03f13e036c6
cchen1103/netio
/netio/util/sock.py
617
3.5625
4
import socket class sniff_sock: """ create execution on creating socket, listening to network traffic and destroy it when the sniffing completes. """ def __init__(self): self.s = None def __enter__(self): """ create a socket to sniff internet traffic on IP protocol ...
4dc00ae588f351b8862ad80fb747c57ce5d18d9e
busekara/algorithm-analysis
/online-ders-1.py
835
3.75
4
#!/usr/bin/env python # coding: utf-8 # In[23]: import random # In[24]: def get_n_random_numbers(n=10,min_=-5,max_=5): numbers=[] for i in range(n): numbers.append(random.randint(min_,max_)) return numbers # In[25]: def my_frequency_with_list_of_tuples(list_1): frequency_list=[] f...
00f14d3fd2dda211fe237857699d5894a2c4503f
Gauravkochhar/100-days-of-code
/100 Days Work/Python/NINTH DAY WORK/1. BubbleSort.py
620
3.828125
4
print("Enter the Number of elements:") n=int(input()) a=[] for i in range(n): print("Enter ",i+1,"th element is:") val=input() a.append(int(val)) print("Old Values Are:") print(a,end='\n') lengthArr=len(a) for i in range(lengthArr-1): swap=0 for j in range(lengthArr-i-1): if(a[j]>a[j+1]): ...
6d74b7a783bc6be8e66d3b9ed62449847944bfbc
Gauravkochhar/100-days-of-code
/100 Days Work/Python/TWENTYFIFth-25 DAY WORK/1. TotalSaleUsingCounterDictionary.py
1,124
4.03125
4
""" The first line contains the number of shoes. The second line contains the space separated list of all the shoe sizes in the shop. The third line contains the number of customers. The next lines contain the space separated values of the shoe size desired by the customer and xi, the price of the shoe. Sample Inp...
50a9820ba01bfa48dce52c7059a69ec57aa34669
Gauravkochhar/100-days-of-code
/100 Days Work/Python/NINTEENth-19 DAY WORK/SecondHighest.py
460
3.78125
4
if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) largest1=arr[0] for i in range(n): if(arr[i]>largest1): largest1=arr[i] largest2=arr[0] for i in range(n): if(arr[i]>largest2 and arr[i]<largest1): largest2=arr[i] print(...
4631c442166fc8e4c0d5d319e0bd616f74f4c389
Gauravkochhar/100-days-of-code
/100 Days Work/Python/NINTH DAY WORK/2. InsertionSort.py
485
3.875
4
n=int(input("Enter the number to be Sorted:")) a=[] for i in range(n): print("Enter ",i+1,"th Element:") val=int(input()) a.append(val) print("Old Values Are:") print(a) lengthArr=len(a) for i in range(1,lengthArr): temp=a[i] j=i-1 while(j>=0 and a[j]>temp): a[j+1]=a[j] j=j-1 ...
c95b5120c4c309a05cca16cea63a1ff8d9792f08
Gauravkochhar/100-days-of-code
/100 Days Work/Python/TWENTYth-20 DAY WORK/1. CheckPowerOfTwoOrNot.py
157
4.3125
4
n=int(input("Enter a number to check ,it is power of 2 or not! : ")) if(n&(n-1)==0): print("THe number is power of 2") else: print("Not power of 2")
755b019cfdae4dd6bcffe2b63a5c6a7225d222af
Gauravkochhar/100-days-of-code
/100 Days Work/Python/SEVEN-th DAY WORK/1. LargestConsecutiveArray.py
846
3.75
4
n=int(input("Enter the number of element in the array:")) a=[] largestConsecutive=[] for i in range(n): print(i+1,"->",end=' ') el=int(input()) a.append(el) print("Entered Elements are:",end='\n') print("{",end='') for i in range(n): if i==n-1: print(a[i], end='') else: print(a[i],"...
38f8454cfdcc397234a8b4db2d6ec40a109379f7
ivan-yosifov88/python_basics
/Conditional Statements - More Exercises/07. Flower Shop.py
523
3.6875
4
import math number_of_magnolias = int(input()) number_of_hyacinths= int(input()) number_of_roses = int(input()) number_of_cacti = int(input()) price_of_gift = float(input()) total_money = number_of_magnolias * 3.25 + number_of_hyacinths * 4 + number_of_roses * 3.5 + number_of_cacti * 8 total_money *= 0.95 difference = ...
5b9438fa8d48c91f22c79061b301b0df28d5b664
ivan-yosifov88/python_basics
/Exams -Training/01. Repainting.py
400
3.765625
4
needed_nylon = int(input()) needed_paint = int(input()) paint_thinner = int(input()) hours_of_work = int(input()) needed_paint *= 1.1 needed_nylon += 2 materials_cost = 0.40 + needed_nylon * 1.5 + needed_paint * 14.5 + paint_thinner * 5 workers_money_for_hour = materials_cost * 0.3 total_money = workers_money_for_hour ...
43f8998078a9dfb82fb14c0c0e0a146a06f5b588
ivan-yosifov88/python_basics
/Exam 25.10/01. Moon.py
334
3.828125
4
import math average_speed = float(input()) fuel_for_hundred_kilometers = float(input()) distance = 384400 time_stay = 3 total_distance = distance * 2 total_time = total_distance / average_speed + time_stay fuel_consumption = fuel_for_hundred_kilometers * total_distance / 100 print(math.ceil(total_time)) print(int(fuel...
a5ff6e233a8ce5b8b845db4b2bd0176efb0669f6
ivan-yosifov88/python_basics
/Nested Loops - More Exercises/09. Sum of Two Numbers.py
712
3.703125
4
start_number = int(input()) end_number = int(input()) magic_number = int(input()) is_combination_magic = False number_of_combinations = 0 for first_combinations in range(start_number, end_number + 1): for second_combinations in range(start_number, end_number + 1): number_of_combinations += 1 if magi...
01d9fb6b2beaaf0ec20b04968465667abf6e7a42
ivan-yosifov88/python_basics
/Nested Conditional Statements/03. Flowers.py
954
4.125
4
numbers_of_chrysanthemums = int(input()) number_of_roses = int(input()) number_of_tulips = int(input()) season = input() is_day_is_holiday = input() chrysanthemums_price = 0 roses_price = 0 tulips_price = 0 bouquet_price = 0 if season == "Spring" or season == "Summer": chrysanthemums_price = 2 roses_price = 4.1...
c3bf6526d840f4bf1db8452e20abebd23ad64023
ivan-yosifov88/python_basics
/Nested Loops - Lab/06. Building.py
410
3.921875
4
number_of_floors = int(input()) number_of_rooms = int(input()) for floors in range(number_of_floors, 0, -1): for rooms in range(0, number_of_rooms): if floors == number_of_floors: print(f"L{floors}{rooms}", end= " ") elif floors % 2 == 1: print(f"A{floors}{rooms}", end= " ") ...
540d5a77bcee353e427102fefa6279064c194af5
ivan-yosifov88/python_basics
/Nested Loops - Exercise/04. Train The Trainers.py
735
4.03125
4
number_of_judging_jury = int(input()) command = input() total_grade_sum = 0 presentation_counter = 0 while command != "Finish": presentation_name = command presentation_counter += 1 average_grade_sum = 0 for grades in range(number_of_judging_jury): current_grade = float(input()) average_...
8eb135d6eaeb86836642903155e50ef3594a2297
ivan-yosifov88/python_basics
/Exams -Training/06. Basketball Tournament.py
984
3.890625
4
command = input() win_counter = 0 loss_counter = 0 total_games = 0 while command != "End of tournaments": name_of_tournament = command number_of_games = int(input()) difference = 0 for games in range(1, number_of_games + 1): points_our_team = int(input()) points_opposing_team = int(input...
6cea7c3918b6c4d668b346494313e29623232079
ivan-yosifov88/python_basics
/Exams -Training/03. Oscars week in cinema.py
1,021
3.734375
4
movie_title = input() type_of_hall = input() number_of_tickets = int(input()) price = 0 if type_of_hall == "normal": if movie_title == "A Star Is Born": price = 7.5 elif movie_title == "Bohemian Rhapsody": price = 7.35 elif movie_title == "Green Book": price = 8.15 elif movie_tit...
c6b78c558c8f98ec4dc1dccdeb1c92ec5ecd303f
ivan-yosifov88/python_basics
/While Loop-Lab/06. Max Number.py
213
4
4
import sys read_text = input() max_number = - sys.maxsize while read_text != "Stop": number = int(read_text) if number > max_number: max_number = number read_text = input() print(max_number)
81714561889967ca432ccbae67450c7795357089
ivan-yosifov88/python_basics
/Exams -Training/01. Series Calculator.py
412
3.890625
4
name_of_series = input() number_of_seasons = int(input()) number_of_episodes = int(input()) time_of_series_without_ad = float(input()) special_episodes = number_of_seasons * 10 time_of_episodes = time_of_series_without_ad * 1.2 total_time = number_of_seasons * number_of_episodes * time_of_episodes + special_episodes pr...
4fbded1518fc0c4025eaee105898712be1982703
ivan-yosifov88/python_basics
/Nested Loops - Lab/03. Combinations.py
263
3.9375
4
number = int(input()) combination_counter = 0 for x1 in range(0, number + 1): for x2 in range(0, number + 1): for x3 in range(0 , number + 1): if number == x1 + x2 + x3: combination_counter +=1 print(combination_counter)
5fb562eb6b3d3f9b5983ae879ab4b2f63626b467
ivan-yosifov88/python_basics
/Nested Loops - More Exercises/02. Letters Combinations.py
677
3.96875
4
start_letter = input() end_letter = input() special_letter = input() number_of_valid_combinations = 0 for first_number in range (ord(start_letter), ord(end_letter) + 1): for second_number in range(ord(start_letter), ord(end_letter) + 1): for third_number in range(ord(start_letter), ord(end_letter) + 1): ...
7248381d62a5c4aa3a0e6ace102409e146692be1
ivan-yosifov88/python_basics
/Exams -Training/05. Easter Bake.py
700
3.765625
4
import sys from math import ceil number_of_breads = int(input()) max_sugar = -sys.maxsize max_flour = -sys.maxsize quantity_of_sugar = 0 quantity_of_flour = 0 for breads in range(number_of_breads): used_sugar = int(input()) used_flour = int(input()) quantity_of_sugar += used_sugar quantity_of_flour += ...
784471957de4bc68b92763d871eacfe533be48a7
ivan-yosifov88/python_basics
/While Loop-Lab/07. Min Number.py
211
4
4
import sys read_text = input() min_number = sys.maxsize while read_text != "Stop": number = int(read_text) if number < min_number: min_number = number read_text = input() print(min_number)
2c2fc188c0f0e8f33fca395eeee43be821d5fc40
ivan-yosifov88/python_basics
/First steps Lab 02/08. Fish Tank.py
268
3.71875
4
length = int(input()) width = int(input()) height = int(input()) percentage_occupied_volume = float(input()) volume_fish_tank_litres = length * width * height * 0.001 total_litres = volume_fish_tank_litres * (1 - percentage_occupied_volume / 100) print(total_litres)
bc1e774ca217588ba4a73263971168008f430fe0
ivan-yosifov88/python_basics
/Exams -Training/05. Movie Ratings.py
706
4.15625
4
import sys number_of_films = int(input()) max_rating = 0 movie_with_max_rating = "" min_rating = sys.maxsize movie_with_min_rating = "" total_sum = 0 for films in range(number_of_films): movie_title = input() rating = float(input()) total_sum += rating if rating > max_rating: max_rating = rating...
dbd333e2232ac3b36995ca879473cf4f69e77fee
ivan-yosifov88/python_basics
/Exams -Training/02. Godzila vs. Kong.py
516
3.640625
4
budget = float(input()) number_of_extras = int(input()) price_of_clothing_for_one = float(input()) decor_price = budget * 0.1 if number_of_extras > 150: price_of_clothing_for_one *= 0.9 needed_money = number_of_extras * price_of_clothing_for_one + decor_price difference = abs(budget - needed_money) if needed_money ...
c144776c77f7ae7e06f64449e57ebe9287101ba5
ivan-yosifov88/python_basics
/Exams -Training/05. Care of Puppy.py
459
3.875
4
dog_food = int(input()) dog_food_in_grams = dog_food * 1000 command = input() is_dog_food_enough = True while command != "Adopted": dog_meal = int(command) dog_food_in_grams -= dog_meal if dog_food_in_grams < 0: is_dog_food_enough = False command = input() if is_dog_food_enough: print(f"Foo...
e0fb7aaa436f473ea8ebee57522399a4a8681816
ivan-yosifov88/python_basics
/Exams -Training/02. Family Trip.py
455
3.75
4
budget = float(input()) number_of_nights = int(input()) price_for_night = float(input()) percent_other_costs = int(input()) if number_of_nights > 7: price_for_night *= 0.95 total_money = number_of_nights * price_for_night + budget * percent_other_costs / 100 difference = abs(budget - total_money) if total_money <= ...
4438ef68ce624882d991fd99320186737488535f
ivan-yosifov88/python_basics
/Exams -Training/04. Club.py
635
3.765625
4
desired_profit = float(input()) current_profit = 0 command = input() while command != "Party!": cocktail_name = command number_of_cocktail = int(input()) cocktail_price = len(cocktail_name) order_price = cocktail_price * number_of_cocktail if order_price % 2 == 1: order_price *= 0.75 cur...
6b71ca64eda2419f32feae09a63cb0967b0d1da9
ivan-yosifov88/python_basics
/Conditional Statements- Exercise/18. Weather Forecast - Part 2.py
299
4.125
4
temperature = float(input()) if 26 <= temperature <= 35: print("Hot") elif 20.1 <= temperature <= 25.9: print("Warm") elif 15 <= temperature <= 20: print("Mild") elif 12 <= temperature <= 14.9: print("Cool") elif 5 <= temperature <= 11.9: print("Cold") else: print("unknown")
e8e13056520639fd8ebad56426bff0143a622679
ivan-yosifov88/python_basics
/Exams -Training/01. Easter Bakery.py
456
3.859375
4
price_of_flour = float(input()) weight_of_flour = float(input()) weight_of_sugar = float(input()) number_eggshells = int(input()) number_yeast = int(input()) price_of_sugar = price_of_flour * 0.75 price_of_eggshells = price_of_flour * 1.1 price_of_yeast = price_of_sugar * 0.2 total_sum = price_of_flour * weight_of_flo...
e37595f3b7284bdfcb51d0ccbe14fd369552722f
lintanggilang/Praktik-Machine-Learning
/02. Multivariate Regression/multiregression.py
985
3.5625
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt dataku = pd.read_excel('data.xlsx') print(dataku.head()) print("---") # split dataset: 90% training & 10% test from sklearn.model_selection import train_test_split a, b, c, d = train_test_split( dataku[['ukuran', 'kamar', 'AC']], dataku['h...
25f4ee3e2af2786d56347be1c3f49c4d71ab3b5a
iamsayantan/pycrawler
/my_url.py
391
3.5
4
""" get the content of a web page """ from urllib.request import urlopen def get_page(url): """ Open the given url and return the content of the page. """ try: data = urlopen(url) html = data.read() # decoding is necessary because data returned # by read() is is binary ...