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
59c8e6f654e1236af9c9b71ae9301819d6c70f87
noema-git/Disaster-Response-Pipeline
/data/process_data.py
3,987
3.703125
4
# PREPROCESSING THE DATA # Disaster Response Pipeline Project # # The script takes the file paths of the two datasets and database, # cleans the datasets, and stores the clean data into a SQLite database # in the specified database file path. # It merges the messages and # categories datasets, splits the categories...
d219abdaf6083db33a91aeb5822b91ec8b19279c
NeonLeexiang/codewar_solution
/7kyu/16+18=214.py
798
3.921875
4
""" date: 2020/8/30 1:03 下午 written by: neonleexiang """ # def add(num1, num2): # res = [] # lst1 = list(str(num1)) # lst2 = list(str(num2)) # for i in range(max(len(lst1), len(lst2))): """ def add(a, b): s = "" while a + b: a, p = divmod(a, 10) b, q = divmod(b, ...
56d3f54c6b99687d32d628d59193f45aed620480
lisa-nurfauziyya/kulina_back-end_preliminary_test
/fibbonaci.py
401
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 15 12:26:23 2018 @author: Lisa Nurfauziyya """ def fibbo(n): fibbo = [0, 1] for a in range(n): if a > 1: print fibbo[a-1] + fibbo[a-2] fibbo.append(fibbo[a-1]+fibbo[a-2]) else: print fibbo[a] def main(): pr...
9eeab550f7a887d7a329c9dca9a354f1e2db18e7
ivvez/ZSV-2019-3
/primjeri/selection-sort.py
337
3.578125
4
brojevi = [5, 8, 4, 12, 9, 1] for i in range(len(brojevi)-1,0,-1): naj = 0 for j in range(1, i+1): # usporedi trenutnu najvecu vrijednost i sljedeci element niza if brojevi[j] > brojevi[naj]: naj = j #zamjena brojevi[i], brojevi[naj] = brojevi[naj], brojevi[i] ...
b13142da268a6de57fac1ea6d3b3961d96b79d55
Kuzy53/homework_python
/06.10/06.10.2021.py
558
3.8125
4
def fun(): dic_q = dict() name = '' nomer = '' while name != 'q' and nomer != 'q': name = input() if (name == 'q'): break nomer = input() if nomer == 'q': break if nomer[0]=='+' and nomer[1].isdigit and nomer[2]=="-" and nomer[3:6].isdigit ...
376c45f4b21df79d6505234d5d14f4e1e61411c7
Akansha0211/PythonPrograms
/Assignment4.6.py
1,295
4.40625
4
# 4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. # Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. # Put the logic to do the computation of pay in a function called computepay() and use th...
e677a332475a6cfcb6effff53e0f3a0d3a857595
DmitriiDenisov/Multiprocessing_lab
/Process/3_ex_Process.py
1,220
3.671875
4
from multiprocessing import Process, Queue, current_process from random import random, randint # import multiprocessing import time def worker(a: int, b: int, queue): name = current_process().name print(name, 'Starting') time.sleep(3) print(name, 'Exiting') random_n = randint(a, b) queue.put(r...
50ba95ad13cf0f22ea9813d204747a7b368df827
egimoro/KEsupermarkets
/KEsupermarket.py
5,823
3.5625
4
# %% # Import libraries import pandas as pd # Library for plotting import matplotlib.pyplot as plt from numpy import random import numpy.random as np # Create lists of supermarkets, number of items, and total paid supermarkets = ['acacia', 'acacia', 'acacia', 'acacia', 'nakumatt', 'tuskys', 'chanda...
e80f57ec3d186e82a05ba7c881ac7f1ddccd650d
atilapaes/aggregator-of-functions
/open_microseismic/FunctionsBRP.py
10,186
3.734375
4
################################################################################################## def listKindofFile(folder,extension): """Argunments: string (folder). This function list all the SEGY files into the speciefied folder """ print('Listing SEGYs -> Initializing...') ### Function listSEGYs#### ### Th...
4d23278d8c27a7f73f0fd319a038d413792817b4
johnbh14/MIT-6.0001
/ps0/ps0.py
348
4
4
import math print('Enter number x: ', end = '') x = input() try: x = int(x) except: x = float(x) print('Enter number y: ', end = '') y = input() try: y = int(y) except: y = float(y) print('x**y = ' + str(x**y)) logBase2 = math.log(x, 2) if int(logBase2) == logBase2: logBase2 = int(logBase2) print('...
78098272d540dfb69895366506b3bacc268f3897
kondapavan83/python-practice
/custom_sort_str.py
324
3.75
4
#Leetcode link: https://leetcode.com/problems/custom-sort-string/ def custom_sort(S,T): l=[] pc='' for alpha in S: if alpha in T: pc+=alpha for letter in T: if letter in S: T=T.replace(letter,'') l.append(letter) return pc+T S='back' T='abcd' custom_sort(S...
e2486a43ac0e80941ac8918fc30380c251df88f4
msa/threesmodel-pyml
/threespyml/next_number_determinator.py
515
3.765625
4
import random def highest_number(game_board): flat_board = flatten(game_board) return max(flat_board) def select_number(game_board): possible_cells = [0, 1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144] index = random.randrange(1, (max([3, possible_cells.index(highest_number(game_board)) ...
eb63e2ef69cff0b1994afe6fbebc6de1618f9f67
csMOOC/Stanford.Cryptography
/week5/numbthy.py
6,331
3.546875
4
###################################################################################### # NUMBTHY.PY # Basic Number Theory functions implemented in Python # Note: Currently requires Python 2.x (uses +=, %= and other 2.x-isms) # Note: Currently requires Python 2.3 (uses implicit long integers - could be back-ported thoug...
951ff922500e43387cd3d60ca8f4982b0f2753db
seunghk1206/2-Manhattan-FullStack-Development
/tree.py
1,998
4.09375
4
""" Binary Tree => Binary Search Tree 1. Each node has at most 2 children nodes 2. Left node is always less than the right node Insertion 할때 1. balanced Tree => insert: O(log n), search: O(log n) 2. Unbalanced Tree => insert: O(n), search: O(log n) preorder & inorder & postorder Insert [8, 3, 10, 1, ...
36de735bb2a987530d6a76508a806b31eee4361f
cristianiniguez/PlatziCodingChallenge
/Dia54/ValidadorURLs.py
268
3.75
4
# Validador de URLs en Python import re REGEX = r'^https?:\/\/(\w+\.)+(\w+)(\/\w+)*(\/|\?(\w+=(\w|-)+&)*(\w+=(\w|-)+)|#.+)?$' def isUrl(url): return re.match(REGEX, url) != None print(isUrl('https://www.platzi.com')) # true print(isUrl('hello friends')) # false
bcca2b32fb239ae7c594f884649acc5ba733494b
cristianiniguez/PlatziCodingChallenge
/Dia36/NumerosAleatorios.py
385
3.859375
4
# Números Aleatorios en Python from random import choice def randomNumbers2(dices, faces): results = [] for d in range(0, dices): results.append(choice(range(1, faces + 1))) return results def throwDices(dices): return randomNumbers2(dices, 6) numeroDados = int(input('¿Cuántos dados vas a ti...
6b534aeff9a4566a1fd9108b2b6f441ee057d7f8
cristianiniguez/PlatziCodingChallenge
/Dia55/ValidadorMails.py
214
3.765625
4
# Validador de Emails en Python import re REGEX = r'^\w+@\w+\.\w+$' def isValidEmail(email): return re.match(REGEX, email) != None print(isValidEmail('name@example.com')) # True print(isValidEmail('name.example@com')) # False
fbac7c74f33262bcd43c05c1d5e90520a6fbfd1b
cristianiniguez/PlatziCodingChallenge
/Dia07/PiedraPapelTijera.py
1,021
3.953125
4
#Piedra, papel o tijera en Python def ppt(option1, option2): return { "piedra": { "piedra": "piedra vs piedra -> Empate", "papel": "piedra vs papel -> Gana el jugador 2", "tijera": "piedra vs tijera -> Gana el jugador 1", }.get(option2, "Jugador 2, opción inválida...
2f710fe13efbd25399c4392f54bafdcd46c07565
tc5368/DQS-Code
/CreatingTest.py
5,695
3.59375
4
global root from tkinter import * import tkinter as tk import csv, os, Lecturer_Home from tkinter import messagebox def home(u): global root root.destroy() Lecturer_Home.main(u) class Questionaire(Frame): pop = [] Answer_Storage_Temp = [] PerQuestionStorage = [] temp = [] SavingList= [[]] TestType = ["S"] ...
968fe44599eb9332bcbc6bd68cfc04acc912b418
akashshuklacs/find-and-replace
/findandreplace.py
1,470
3.640625
4
#!/usr/bin/python3 import os import sys import fileinput from Tkinter import * fields = ('Text To Replace', 'Replace With', 'Text File') def findreplace(entries): textToSearch=entries['Text To Replace'].get() print("Text", textToSearch) fileToSearch=entries['Text File'].get() print("Text file", fileToSearch) ...
1aeb561e8ffe55872f912aab1deacad80fe5b17b
nicwill0707/python
/Retrieve-image-and-save-to-path.py
593
3.734375
4
#retrieval of an image from website URL and store in user defined pathway #(folder) on local machine import urllib.request import csv import os # ask user for pathway to local folder where images will be saved) image_Folderpath = input(r'Enter full pathway to which images will be saved: ') #join path input...
a4c43ad5390d38104eb3956ea3b8337ffd789ce2
danielcesarcs/Python_aulas_cursoemvideo
/exercicios/013.py
329
3.671875
4
"""Aumento salário""" # Calculo de aumento de salário s_i = float(input('Digite o salário: ')) aumen = (s_i * 15) / 100 s_f = s_i + aumen print('O seu salário era: R${}, parabéns você recebeu\n' 'aumento de 15% ({:.2f}) e agora seu salário é de: R${:.2f}'.format(s_i, aumen, s_f)) # 1º contato com formatação
9270a8a51f432cd2d2e49a3e7a16027128c3a7fc
danielcesarcs/Python_aulas_cursoemvideo
/exercicios/016.py
233
4.09375
4
"""Parte inteira de um número""" # Operadores aritmeticos num = float(input('Digite um número: ')) inte = num // 2 # Barra dupla retorna parte inteira dos números print('A parte inteira de {} é igual a {}'.format(num, inte))
a07dbd709895bd4efb0115abb9f7cb20486114fc
danielcesarcs/Python_aulas_cursoemvideo
/exercicios/024.py
198
3.921875
4
"""ENCONTRAR PALAVRAS""" # Uso de metodos name = input('Digite um nome de uma cidade: ').strip() # Exclusão dos espaços print(name.count('Santo', 0, 5)) # "Caça" ao objeto definido no metodo
4e119d09f292858920c57523035f2302ee9550ee
hochu-leto/intelligence
/example_http_request.py
853
3.546875
4
import requests URL = 'https://superheroapi.com/api/2619421814940190/search/' def the_most_intelligence(superhero_list): """ самый умный(intelligence) из трех супергероев- Hulk, Captain America, Thanos. Для определения id нужно использовать метод /search/name """ max_intelligence = 0 hero_dict = {}...
c3c31219f80c875442ddb07240424d40c3b8e0ea
dok221/Python
/Les_4.7.py
1,037
3.78125
4
#Реализовать генератор с помощью функции с ключевым словом yield, #создающим очередное значение. #При вызове функции должен создаваться объект-генератор. #Функция должна вызываться следующим образом: for el in fact(n). # Функция отвечает за получение факториала числа, # а в цикле необходимо выводить только первые...
258d58764350aab386c1fd047b0d72ef47906114
WangsirCode/leetcode
/Python/valid-parenthesis-string.py
1,892
4.375
4
# Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules: # Any left parenthesis '(' must have a corresponding right parenthesis ')'. # Any right parenthesis ')' must have a corresponding left...
6e30a82f62e20537dccefe756376ea9cba841529
WangsirCode/leetcode
/Python/permutation-ii.py
762
3.765625
4
# Given a collection of numbers that might contain duplicates, return all possible unique permutations. # For example, # [1,1,2] have the following unique permutations: # [ # [1,1,2], # [1,2,1], # [2,1,1] # ] class Solution: # @param num, a list of integer # @return a list of lists of integers def pe...
b6532bae5b056f3e117106a2f19671f808352330
WangsirCode/leetcode
/Python/groupAnagrams.py
816
4
4
# Time: O(n * glogg), g is the max size of groups. # Space: O(n) # # Given an array of strings, return all groups of strings that are anagrams. # # Note: All inputs will be in lower-case. # # 1.python for 循环 # 2.iterable and iterator # 3. sorted ,map , filter import collections class Solution(object): def groupAn...
6eb4353a48de3406be94ca79ecfb061ac21797fd
WangsirCode/leetcode
/Python/longest-palindrome-substring.py
1,003
3.953125
4
# Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. # Example: # Input: "babad" # Output: "bab" # Note: "aba" is also a valid answer. # Example: # Input: "cbbd" # Output: "bb" class Solution(object): def __init__(self): self.maxLen = 0...
ea403234ac885eb04b1026edf98d48ed7830ef7c
WangsirCode/leetcode
/Python/valid-palindrome-ii.py
1,278
3.984375
4
# Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. # Example 1: # Input: "aba" # Output: True # Example 2: # Input: "abca" # Output: True # Explanation: You could delete the character 'c'. # Note: # The string will only contain lowercase characters a-z. The ...
54884ff658d774875f2e52c24b92ef129547d453
lxngoddess5321/python-web-crawler
/cartoon/manhuatao/hdzj/crawler.py
2,022
3.5625
4
#!/usr/bin/env python3 import urllib.request import re import os #函数:下载网址 #参数:url:用于保存网址地址 fname:网址文件名 def get_web(url,fname): #头信息,用于反爬虫 header={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36'} request=urllib.request.Reque...
b90cd78390942a0858e3d3c899aeb59e0c3f4f05
Kittyuzu1207/Leecode
/LCCI/0325E稀疏数组搜索.py
1,339
3.703125
4
#稀疏数组搜索。有个排好序的字符串数组,其中散布着一些空字符串,编写一种方法,找出给定字符串的位置。 #我:强行遍历一遍。。。 class Solution: def findString(self, words: List[str], s: str) -> int: for i in range(len(words)): if words[i]==s: return i return -1 #其他题解 #用内置函数index class Solution: def findString(self, words: List[st...
aff6636e8b1572ee3a1c23dd672b526584a6428d
Kittyuzu1207/Leecode
/LCCI/0325E主要元素.py
1,374
3.78125
4
#如果数组中多一半的数都是同一个,则称之为主要元素。给定一个整数数组,找到它的主要元素。若没有,返回-1。 #我:借助字典 class Solution: def majorityElement(self, nums: List[int]) -> int: #借用python字典 dic={} for i in range(len(nums)): if nums[i] in dic: dic[nums[i]]+=1 if dic[nums[i]]>len(nums)/2: ...
c1318e2b1e4437fdec82a97b20bc2d9ecce3c3f1
Kittyuzu1207/Leecode
/LCCI/0322E配对交换.py
2,034
3.78125
4
#配对交换。编写程序,交换某个整数的奇数位和偶数位,尽量使用较少的指令(也就是说,位0与位1交换,位2与位3交换,以此类推)。 #e.g. 输入:num = 2(或者0b10) 输出 1 (或者 0b01) #e.g. 输入:num = 3 输出:3 #不太会 #题解 #法1:利用0x55555555 和 0xaaaaaaaa 分别取出奇数位和偶数位 #0x55555555 = 0b0101_0101_0101_0101_0101_0101_0101_0101 #0xaaaaaaaa = 0b1010_1010_1010_1010_1010_1010_1010_1010 #然后位左移奇数位,右移偶数位, #再把奇数位和偶数位...
3333197bec66289878deafe3d03b7a4a85defade
Kittyuzu1207/Leecode
/LCCI/0323E移除重复节点.py
2,298
4
4
#编写代码,移除未排序链表中的重复节点。保留最开始出现的节点。 #我的方法:先把相同值的挪在一起,再按照排序列表的方式删-->超出时间限制:遍历了太多次,链表太长就爆炸 # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def removeDuplicateNodes(self, head: ListNode) -> ListNode: #排序列表:如果下一个和...
d64161ae2978efbfeca4370993616cfae594ed2f
Kittyuzu1207/Leecode
/LCCI/0422M运算.py
4,693
3.8125
4
#请实现整数数字的乘法、减法和除法运算,运算结果均为整数数字,程序中只允许使用加法运算符和逻辑运算符,允许程序中出现正负常数,不允许使用位运算。 #你的实现应该支持如下操作: #Operations() 构造函数 #minus(a, b) 减法,返回a - b #multiply(a, b) 乘法,返回a * b #divide(a, b) 除法,返回a / b #My:会超时 class Operations: def __init__(self): pass def minus(self, a: int, b: int) -> int: #小的那个数需要加多少个1才能加到大那...
2c6a3161652626b8c897555fde0eae62ef2f96cd
aswanthkoleri/Neo
/neo/todo.py
1,106
3.5625
4
def Todo(action,todolist,message="",removeItemNo=-1): if action=="add": # first count the no items in list increment it and add the new no to the list # itemNo=len(item) todolist.append((message,0)) if action=="done": # find the item with that item itemNo=removeItemNo-1 ...
6a1737c6968302c36976f5d06a2488818cc7e2fb
Durgesh0409/assingment2
/Assingment2.py
444
3.859375
4
'''*Q1*''' print("My name is durgesh") '''Q2''' print("Acad" + "View") '''Q3''' x = input('x = ') y = input('y = ') z = input('z = ') print('x = ' + x) print('y = ' + y) print('z = ' + z) '''Q4''' print("Let's get started") '''Q5''' s = 'Acadview' course = 'Python' fees = 5000 print("In {}, {} ...
598b8c72439b4b9a80a2f74c0a1df866fc636cfa
julianhesse/HashCode2018
/main.py
4,476
3.796875
4
import sys import math import numpy as np from car import Car def readFile(filename): ''' This method read the file and gives back the data. ''' with open(filename, 'r') as file: print(file.name) paramenters = file.readline() rows, cols, vehicles, rides, bonus, steps = [int(n) ...
a707227d3a8fb93f73a8f33414f424bb637e076c
vcolano/projectEuler
/p6.py
329
3.875
4
# difference between the sum of the squares of the first one hundred # natural numbers and the square of the sum nums = list(range(1, 101)) sum_of_squares = 0 sum_of_nums = 0 for num in nums: sum_of_squares += num*num sum_of_nums += num square_of_sum = sum_of_nums*sum_of_nums print str( square_of_sum - sum_of_sq...
2bf68990a774d072e440a8aa58f9ab14e7ae50ed
Sayak9495/_100daysofcoding_
/ransome_note.py
279
3.703125
4
def find(mag,note): for i in note: if not i in mag: return "No" else: del mag[mag.index(i)] return "Yes" k=raw_input() mag=[i for i in raw_input().split()] note=[i for i in raw_input().split()] print(find(mag,note))
66645e4f9d47336b3327224cd2d6b87ac0bc8759
saish-khade/Basic-Calculator
/calc.py
727
4.09375
4
print("======MENU======") print("1.Add\n2.Subtract\n3.Multiply\n4.Divide\n") while True: ch=input("Enter your choice") def calc(a,b): if(ch == '1'): c=a+b print(a," + ",b," = ",c) elif(ch == '2'): c=a-b print(a," - ",b," = ",c) elif(c...
5527a03296e46408df62651d07207f638184aaac
mattb1969/BT_Sender
/RFIDSender/RFIDSender/RFIDRoutines.py
3,457
3.765625
4
""" RFID Reader Routines to get the data from the tag. """ import wiringpi2 import time import sys # set for GPIO Pin to use based on the jumper connection # GPIO_PIN = 1 # Jumper 1, also known as GPIO18 GPIO_PIN = 0 # Jumper 2, also known as GPIO17 # GPIO_PIN = 2 # Jumper 3, also known as GPIO21 (Rv 1) or GPIO27 (...
327adc7432d621c66865248250a20d233671e2b9
MuhammadAzizShobari/praxis-academy
/novice/02-01/latihan/kekekalan.py
552
4.1875
4
mutable_collection = ['Tim', 10, [4, 5]] immutable_collection = ('Tim', 10, [4, 5]) # Reading from data types are essentially the same: print(mutable_collection[2]) # [4, 5] print(immutable_collection[2]) # [4, 5] # Let's change the 2nd value from 10 to 15 mutable_collection[1] = 15 # This fails with the tuple i...
d13439eeb5465dd81cd167dd03b8626e1c22e2b7
MuhammadAzizShobari/praxis-academy
/novice/01-02/kasus/QuickShort.py
506
3.859375
4
def QuickSort(A,start,end): if start<end: pindex=partition(A,start,end) QuickSort(A,start,pindex-1) QuickSort(A,pindex+1,end) def partition(A,start,end): pivot = A[end] pindex = start for i in range(start,end): if (A[i] <= pivot): A[i]...
8de817492696613981dd6ccf47da766c4347311d
mjayant/DataStructures
/sorting_and_searching/binary_search.py
472
4.03125
4
def binary_search(sorted_list, item): """ :param sorted_list: :return: """ if not sorted_list: print("List is empty") return False else : midpoint = len(sorted_list)//2 if item == sorted_list[midpoint]: return True elif item < sorted_list[mi...
06d4b5c4655d3f7014f00b851f5b1d3e3ca982cb
sagarkarn/blog-post-1
/python/AreaOfCircle.py
182
3.734375
4
r = 10 area = 3.14 * r * r cf = 2 * 3.14 * r print("Area of circle=",area) print("circumference of circle=",cf) # Area of circle= 314.0 # circumference of circle= 62.800000000000004
63248600dffaa420e3dd7250808ca8d29e88e75f
titusjan/myrepo
/myrepo/datetools.py
822
3.921875
4
""" Just some code to see pytest in action """ def is_leap_year(year): """ Returns True if the year is a leap year """ if year < 1: raise ValueError("Year must be >= 1. Actual: {}".format(year)) if year % 400 == 0: return True if year % 100 == 0: return False return ye...
08ef75da5d1e98e0a61e6c23d5c76b6a4271a7ae
keenon63/Jarvis-AI-Desktop-Voice-Assistant--Python
/jarvis-file.py
3,649
3.65625
4
""" Author - Saurabh Pal Date - 17 Sept., 2020 Purpose - Python Project for learning """ import pyttsx3 import datetime import speech_recognition as sr import wikipedia import webbrowser # for opening web browser import os import random import smtplib # To send mail from gmail engine = pyttsx3.init('sapi5') voi...
8ad376b413ad4382f10be9e634dc488836df697d
kwawrzyniak92/kurs_codeme
/Hackation_1/ksiazka_adresowa.py
1,183
3.875
4
def menu(): choice = int(input("\nŻeby wyświetlić kontakty wciśnij 1 \n\nŻeby dodać kontakt wciśnij 2\n\nŻeby usunąć kontakt wciśnij 3\n\nŻeby zamknąć program wciśnij 4\n\n")) if choice == 1: for key, value in contacts.items(): print(key,value) elif choice == 2: new_cont...
0890abdd85fd473d21b35ab93ae2448663d0d037
kwawrzyniak92/kurs_codeme
/Dzien 2/Zad 5 - Palindrom.py
184
3.65625
4
palindrom = "Kobyla ma maly bok" palindrom = palindrom.replace(" ", "") #usuniecie spacji z tekstu palindrom = palindrom.lower() print(palindrom) print(palindrom == palindrom [::-1])
2f29c6118dc6346c385c9dfe7f5bb0da569dac78
kwawrzyniak92/kurs_codeme
/Hackation_1/wisielec1.py
1,737
3.78125
4
print("----------------") print(" GRA WISIELEC ") print("----------------") print( "Gra polega na odgadnięciu hasła składającego się z liczby liter równej liczbie pól wyświetlonych na ekranie.\nMasz 10 szans na odgadnięcie hasła.\nPowodzenia! ") name = input("\nPodaj swoje imie ") password = str("programo...
450632be14a87896a983622e455c4d76d55086c4
kwawrzyniak92/kurs_codeme
/Projekt Black Jack/Black_Jack3.py
1,354
3.859375
4
class Card: RANKS = ["A","K","Q","J","10","9","8","7","6","5","4","3","2"] SUITS = ["♣", "♦","♥","♠"] def __init__(self,rank,suit): self.rank = rank self.suit = suit def __str__(self): rep = self.rank + self.suit return rep class Unprintable_Card(Card): ...
3c40edcb6143bd3a72febcac7c4e0f891e571e51
roopi7760/WebServer
/Client.py
2,797
4.125
4
''' Author: Roopesh Kumar Krishna Kumar UTA ID: 1001231753 This is the Client program which sends the request to the server and displays the response *This code is compilable only with python 3.x Naming convention: camel case Ref: https://docs.python.org/3/library/socket.html and https://docs.python.org/3/tutorial/i...
7fe0268864a53efacb6283b7c62a2a72286a8ff4
jatin7gupta/Olympic_Medals_Data_Visualization
/z5240221.py
10,836
3.734375
4
import pandas as pd import matplotlib.pyplot as matplot # function for casting string to integer def convert_int(n): if ',' in n: n = n.replace(',', '') return int(n) else: return int(n) def question_1(check_print=False): if check_print: print("--------------- question_1 ...
1b530de5791c18679d600d87de9bb6362503801a
lips-hci/ae400-realsense-sdk
/unit-tests/py/rspy/stopwatch.py
770
3.796875
4
# License: Apache 2.0. See LICENSE file in root directory. # Copyright(c) 2020 Intel Corporation. All Rights Reserved. import time # Timer that counts forward in time (vs backwards in the 'timer' class) # It supply a basic stopwatch API, reset, get elapsed time.. class Stopwatch: _start = 0 def __init__(self...
60bcd64227f8ee37987587d24478bf713e1c6356
ChrisBradLeigh/LeetCode
/Problemsets/Sort Colors.py
491
3.53125
4
class Solution: def sortColors(self, nums: List[int]) -> None: countColours = [0, 0, 0] for x in range(len(nums)): if nums[x] == 0: countColours[0] += 1 elif nums[x] == 1: countColours[1] += 1 elif nums[x] == 2: coun...
c8362723b1abf88fb98a5a14db16489316df95a2
logotip123/py_hashtable
/hashtable.py
792
3.640625
4
"""Hash module""" class HashTable: """Hash class""" def __init__(self): self.array = [] for _ in range(10): self.array.append({}) @staticmethod def hash_(key: int) -> int: """ :param key: key :return: hashes key """ return key % 10 ...
87a51c978d8891d80b1f1eafadbd0e7654e04237
viseth89/nbapython
/trial.py
1,042
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Nov 26 19:06:19 2016 @author: visethsen """ import matplotlib.pyplot as plt # Importing matplotlib general way that it is used x1 = [1,2,3] y1 = [4,7,5] x2 = [1,2,3] y2 = [10,14,12] plt.plot(x1, y1, label = "first line") plt.plot(x2, y2, label = 'se...
5d70313e59fe379784fc5748300044d3d69de1ef
LordEldak/Vampy-2017-CS
/Quiz.py
94
3.5
4
answer = input("What food do you prefer? A: Pizza B: Chicken C: Hamburgers") if answer == "A"
bc330656519ec96a211e305cc5abd9099952d649
LordEldak/Vampy-2017-CS
/CanChickinsFly.py
1,586
4.1875
4
answer = input ("Am I an object or a place? YES/NO:") if answer == "YES": answer = input("Am i bigger than a PC? YES/NO:") if answer == "YES": answer = input("Am I a building? YES/NO:") if answer == "YES": answer = input("Am I a Salon? YES/NO:") if answer == "YES": print("I am a salon") else:...
b992b29c5fc30d0817f7e5dd4967f8f8e36010ce
lcdaqua/AlgoritmsPy
/venv/Include/Classes/SimplePigLatin.py
326
3.703125
4
def pig_it(text): words = text.split(" ") for i in range (0, len(words)): if words[i] != "!" and words[i] != "?" and words[i] != "." and words[i] != ",": firstLetter = words[i][:1] words[i] = words[i][1:len(words[i])] + firstLetter + "ay" result = " ".join(words) return ...
fa330146b6d08c599cdc9d112b9b5bf2cdd61794
nimkamp/Othello
/game_logic.py
7,858
3.8125
4
# Nicholas Imkamp 62086284 class Othello: def __init__(self, rows: int, columns: int, turn: str, top_left: int, end: str): self._rows = rows self._columns = columns self._top_left = top_left[0].upper() self._board = self._create_board() self._turn = turn[0].u...
5ecb7150024ce56004919e5b0caea5b0dceeef68
JordanDoane/fileio
/write_file.py
417
3.625
4
# write_file.py import os.path from os import path file_name = "test.txt" def main(): if path.isfile("test.txt") == False: print("Opening a new file.") with open(file_name, 'w+') as file: file.writelines(""" #This is a default file. Make changes where needed device_name None device_por...
842f17e24597594de3c79b31269df1d35761547e
kyleacastillo1999/MazeGeneration
/point.py
929
4.09375
4
""" Created with Pycharm Author: Kyle Castillo Date: 02/05/2021 Contact: kylea.castillo1999@gmail.com """ """ Point class to assist with returning the path information. Stores the point itself as well as a reference to a parent node. This helps build a tree of points to be used in the maze to record the path that is t...
0e2ee1de2f24dbe063566aff173c673b08f1624f
mohit-chawla/pystride
/hackerrank-py/introduction/arithematic.py
97
3.703125
4
num1 = int(raw_input()) num2 = int(raw_input()) print num1+num2 print num1-num2 print num1*num2
54391c37977a66fb436cb3c042dbdf766b20d92f
mohit-chawla/pystride
/hackerrank-py/sets/intro_to_sets.py
454
3.984375
4
#intro to sets #botany plant problem from __future__ import division numPlants = int(raw_input()) plantHeights = map(int,raw_input().split()) numDistinctHeights = len(set(set(plantHeights))) sumDistinctHeights = 0 distinctHeights= set(set(plantHeights)) distinctHeightsList = list(distinctHeights) for i in range(0,n...
a273c999e74f39712255885b23571bda445bd592
mikejzx/py-ictcat
/a4_alpha_vals.py
1,463
3.90625
4
# -- -- -- -- -- -- -- -- -- -- -- -- -- # ICT CAT Term 4, 2019 # Category A - Problem 4: Alphabet Values (Difficulty: ****) # https://github.com/mikejzx/py-ictcat # # -- -- -- -- -- -- -- -- -- -- -- -- -- # If A = 1, B = 2, C = 3, and so on, we # can find the number value of a word. For # example “ROBOT” = 18 + 15 ...
efe28a306b0841ae0a6c6468be6391c87f3d0706
miscer/adventofcode-2019
/10/angles.py
534
3.703125
4
import math directions = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1)] def atan2(y, x): if y > 0: return -math.atan(x / y) elif y < 0 and x >= 0: return -math.pi - math.atan(x / y) elif y < 0 and x < 0: return math.pi - math.atan(x / y) elif y == 0 and...
3a8c3cfef806cb7c35eb4b0faaa1ac51376ecd73
egerber/DynamicVariableFramework
/DynamicArray/DynamicArray.py
725
3.609375
4
import numpy as np from DynamicVariable.DynamicVariable import DynamicVariable #Dynamic Array implements the same methods as DynamicVariable but holds a numpy array class DynamicArray(DynamicVariable): def __init__(self,value_array): self.value=np.array(value_array) def __getitem__(self, item): ...
4b93a00e1ca8e27e19d5c723af42b9b2604d61f4
NUbivek/PythonBootcamp
/Module6/ex1.py
1,175
4.28125
4
# Exercise 1. # Write your Binary Search function. # Start at the middle of your dataset. If the number you are searching for is lower, #stop searching the greater half of the dataset. Find the middle of the lower half #and repeat. # Similarly if it is greater, stop searching the smaller half and repeat # the proce...
09fdf09fb3393d7081c02d4fb9fbf3efb81e14b0
NUbivek/PythonBootcamp
/Module1/ex6.py
748
4.28125
4
##Exercise 6: Write Python program to construct the following pattern, using a nested for loop. def triangle(): temp_var = "" for num in range(5): temp_var += "*" print(temp_var) for num in range(5,0,-1): temp_var = "*" print(num * "*") ...
826014fdc202a68e9bd640febee1e8b886ce0bb0
NUbivek/PythonBootcamp
/Module7/sql.py
598
3.984375
4
import sqlite3 db = 'nameofdatabase.db' con = sqlite3.connect(db) c = con.cursor() ##using a connection to the database, create a cursor object (looking for things in dbase -- like crawler) #c.execute() takes in a string #you can type as much as you want using the three apestropes''' c.execute(''' CREATE TABLE ...
927ad168f5c82f35be6b850b25769dfa8edd32e8
NUbivek/PythonBootcamp
/Module5/prep1.py
2,270
3.640625
4
#user_input = str(input("Input the credit card number: ")) class Ccard(): def __init__(self, user_input): self.user_input = user_input self.card_length = len(user_input) self.card_type = None #self.card_validation = None def check_card_length(self): if self.card_length == 15 or self.card_length == 16: ...
366837fb344ba28bce72ba5ac31864760e3ca93b
Miesvanderlippe/hsl-python
/week5_2/dobbelen.py
1,026
3.546875
4
import collections from random import randint from time import time def main()-> None: t_start = time() # dictionary that counts throw_counter = collections.Counter() # length of counter changes with items in it, if it's 100 we must have every int between 1-100 while len(throw_counter) < 100: ...
5b25ff0ee144edbeac05d81c967484ed77a4e4ef
Miesvanderlippe/hsl-python
/python_classes_les/week3/dice_game.py
610
3.6875
4
from random import randint class Dice: _sides = int def __int__(self, sides: int = 6)->None: self.sides = sides self.total = 0 def roll(self): roll = randint(0, self.sides) self.total += roll return roll @property def sides(self)->int: return sel...
4dd7524abad6edbfc03729e7b1e22347910b196b
Miesvanderlippe/hsl-python
/week1/opdracht7.py
286
3.625
4
__author__ = 'Mies' miles = input('Please enter the amount of miles driven : \n') galons = input('Please enter the amount of fuel used in Galons : \n'); try: mpg = int( miles)/int( galons) print( 'MPG : ' + str( mpg)) except ValueError: print( 'Input incorrect. Retry.')
1addb4b4b7f5d5b075dad3386f4403e23a86e58c
Miesvanderlippe/hsl-python
/week2/opgave1.py
390
3.703125
4
__author__ = 'Mies' from random import randint def throw( t_sides): return randint(1, t_sides) while True: try: sides = int( input( 'Aantal kanten dobbelsteen \n')) except ValueError: print( 'Ongeldig aantal kanten') continue if sides < 2: print( 'Ongeldig aantal kan...
90c816c8f8eda770fdeaa1dab980ecb4cfd588da
abditimer/Learn-Python-the-Hard-Way
/ex44Part2.py
515
3.671875
4
class Other(object): def override(self): print "Other override1..." def implicit(self): print "other override2.." def altered(self): print "Other altered.." class Child(object): def __init__(self): self.other = Other() def implicit(self): self.other.implicit() def override(self): print "child ov...
64a5b693d74de43b1a6460c3d3d6ae58920ff32e
annabon96/Homework_2
/Homework2.py
909
3.796875
4
#Задание 1 list = ["sun", 12, 12.3, None, True] for element in list: print(type(element)) # Задание 2 n = [] num = int(input()) for i in range(num): new_element = int(input()) n.append(new_element) print(n) i = 1 while i < len(n): print(n[i], n[i - 1]) n[i], n[i - 1] = n[i - 1], n[...
33f6565aa8475d2e2ca92529b9da93ce07307ee9
rohitvernekar/stocksreport
/utils.py
370
3.796875
4
import csv def csv_to_dict(): ''' This code converts csv to dict ''' dict_details = {} reader = csv.DictReader(open('stock_list.csv', 'rb'), delimiter='|') for line in reader: keys = line.keys() vals = line.values() dict_details[vals[0]] = {keys[1]: vals[1], keys[2]: ...
082845594ae5d683451dc86f636bb2fef5b3d78a
dannieldev/Fundamentos-de-Python
/Imput.py
547
3.96875
4
nom = input("Bienvenido cual es tu nombre ") hola(nom) for x in [1,3,9,27,2]: print (x * x) print("\n") for x in range(10,20): print (x) print("\n") print("Saluda a 5 amigos") for x in range(1,6): saludar() print ("saluda de nuevo") n = input("A cuantos amigos quieres sal...
55794cba42f3ee3cb0ed69b3295e2531a02e859b
bryantvalverde/Stones-Game-Decission-Tree
/stones_game.py
4,558
3.9375
4
import random def stones_game(): # Generate a random amount of stones stones = random.randrange(20, 30) is_finished = False # Signal when game is complete player_turn = 'A' # Keep track of whos turn it is while not is_finished: # Print before we cancel loop. Prints at the ends that 1 st...
8d179b9776e0ab0fbe86c0222dbc8615a0d8bd22
CaptainPica/python-challenge
/PyParagraph/main.py
664
3.546875
4
import re with open('par.txt', 'r') as text: passage = text.read() sentences = re.split("(?<=[.!?]) +", passage) words = [sentence.split() for sentence in sentences] numberSentences = len(sentences) numberWords = sum([len(i) for i in words]) numberLetters = len(passage) - numberWords avgSent...
3fb1a53ebba315afe095f75125c1ffe8c94720e9
johnwquarles/Python-learning
/Recursive_exponentiation_for_natural_number_exponents.py
265
3.96875
4
"""Recursive exponentiation for natural number exponents""" def recurPowerNew(base, exp): if exp == 0: return 1 elif exp%2 == 0: return recurPowerNew(base*base, exp/2) elif exp%2 != 0: return base * recurPowerNew(base, exp - 1)
075507eb146a94e556b9fe135191c904a4e479ed
4320-Team-2/endDateValidator
/endDateValidator.py
1,352
4.34375
4
import datetime class dateValidator: #passing in the start date provided by user def __init__(self, startDate): self.startDate = startDate def endDate(self): #loop until user provides valid input while True: #try block to catch value errors try: ...
ecc7c56c4bb7baa12e98c54d2f811c57348f8d70
the-dominus/projeto-interdisciplinar-semestre01
/main.py
4,104
4.21875
4
# 001 - 28.04.2021 - 23h45 # 1° - Converter de decimal para binário, octal ou Hexadecimal # 2° - Pegar o decimal e dividir por 2 # 3° - Dependendo da base escolhida divdir por 2, 8 ou 16 a parte inteira e armazenar o resto while True: print("==============================================================\n") ...
0ea1925e13b74e6b10b33e251da31f01875be9bd
aploetz/python_scripts
/tokenRanges.py
1,144
3.703125
4
def readnum(prompt, min=None, max=None): while True: x = input(prompt + ' ') try: val = int(x) except ValueError: print ("%r is not an integer. Try again.\n" % (x,)) continue if min is not None and val < min: print ("The answer must be ...
236f12cfc232ffe88001501a595b0f31ce14fdd1
blueberryimps/game-wip
/static/set.py
1,920
3.625
4
from random import choice from pprint import pprint def make_cards(): colors = ['green', 'red', 'purple'] patterns = ['stripe', 'filled', 'empty'] shapes = ['triangle', 'oval', 'squiggle'] numbers = [1, 2, 3] set_cards = [[[[(a, b, c, d) for a in colors] for b in patterns] for c in...
3d86d21d93a40085977af6f9b410c08d9e23ad86
239yash/ds_lab_assignment
/Split an Array from Specified Position & Add First Part to the End/split_add.py
384
3.859375
4
size = int(input("Enter the size of the array: ")) print("Enter the elements\n") arr = [] for i in range(size): num = int(input()) arr.append(num) #print(arr) pos = int(input("Enter the position you want to spilt: ")) new_arr = arr[:pos].copy() for i in range(pos): arr.pop(0) ...
a61399c273074fe0b13ac5ef4a06cc31ea01f447
239yash/ds_lab_assignment
/calculate_sum_&_average_of_an_array/calculate_sum_&_average_of_an_array.py
236
4.0625
4
size = int(input("Enter the number of elements : ")) list1 = [] print("Enter the elements") for i in range(size): num = int(input()) list1.append(num) print("Sum: " , sum(list1)) print("Average: ",(sum(list1)/size))
f36bd04ce9d8e342f6c3aec7f5acdf55fdeae6a0
qiufeihong2018/flask-tutorial
/doc/function.py
53,086
3.9375
4
# # 一元二次方程 # import math # def quadratic(a,b,c): # x1=(-b+math.sqrt(b*b-4*a*c))/(2*a) # x2=(-b-math.sqrt(b*b-4*a*c))/(2*a) # return x1,x2 # print(quadratic(2,3,1)) # def add_end(L=[]): # L.append('end') # return L # print(add_end()) # # def add_end(L=None): # # ... if L i...
8c496858905cbaf0ba04a51c683a60e9f4e9ace7
qwerwsl/dormitymanagement
/bedroom.py
9,681
3.84375
4
'''#学生信息包括 #学号(唯一) 姓名 性别 年龄 寝室(一间寝室最多安排4人) #寝室编号 男生(100 101 102) 女生(200 201 202) #功能包括: #1. 可以录入学生信息 #2. 录入过程中可以为其分配寝室(可选自动分配或手动分配,手动分配的话如果选择的寝室人员已满,提示重新分配) #3. 可以打印各寝室人员列表(做到表格打印是加分项) #4. 可以用学号索引打印特定学生信息,可以打印所有学生信息(做到表格打印是加分项) #5. 可以为学生调整寝室(一人调整到其他寝室,两人交换寝室等,自由发挥) #6. 可以将所有信息存入文件(json格式) #7. 程序启动时,将文件中的学生信息自动导入系统...
0937f124970b8de181b896d151f3ad4a244b99ea
ksu-is/Finance-Calculator
/FinanceCalc_RachelStraiton.py
4,497
4.0625
4
#Finance Calculator by Rachel Straiton #User will be prompted with questions to figure out the NPV of a project #When user answers questions, their input will be appended to a list that will store their information #This information will be used by the calculator to calculate the NPV #Then the program will make a d...
d1ef985996be6e768a3f8fad814bab9942e8408d
Majorro/mini_projects
/check_password/main.py
1,589
3.5
4
from sys import argv import argparse import time import re def argparse_(): parser = argparse.ArgumentParser() parser.add_argument('--file', default='common_passwords.txt') parser.add_argument('--password', default='computer,science228') args = parser.parse_args(argv[1:]) return vars(args) def op...
9cda3dc324420bb542fe23d517c242cc6a8a879a
PashaBrychuk/training
/make_chocolate.py
643
3.890625
4
""" My dead end solution def make_chocolate(small, big, goal): if small+big*5>=goal: if goal%5<=small: if goal%5!=0: return goal%5 if goal == big*5: return 0 return -1 """ """def make_chocolate(small, big, goal): maxBig = goal / 5 if big >= maxBig: if small >= (goal - ma...
cc3b5d2f775c4d8f379e379c86e3a428b1808519
PashaBrychuk/training
/Insertion_Sort1.py
219
3.953125
4
def insert(list): for index in range(1, len(list)): value = list[index] i = index-1 while i>=0: if value<list[i]: list[i+1] = list[i] list[i] = value i = i-1 return list print insert([3,2,1,-176])
6927a6acdc968386d9197cb544ec6d46dd338494
PashaBrychuk/training
/select_from_sqlite.py
2,402
3.765625
4
#select_from_sqlite import sqlite3 print sqlite3.version print sqlite3.sqlite_version from sqlite3 import Error def create_connection(db_file): """ create a database connection to the SQLite database specified by the db_file :param db_file: database file :return: Connection object or None ...
6d9e5b7e53c80beb9ce555d0684702835ac843ec
PashaBrychuk/training
/Prime_factors.py
1,572
3.546875
4
"""factors = [] res = [] def find_factors(number): for i in range(1, number): if number%i ==0: factors.append(i) return factors def check_prime_factors(factors): for i in factors: print "i", i count = 0 for j in range(1, i+1): print "j", j if i % j ==0: print "smth...