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
b1fe7b94d5da256a97234f1f5381c27d075961ac
cleanmaster/python
/GUIEx.py
1,869
3.90625
4
from tkinter import * class welcome(): def __init__(self,master): self.master=master master.geometry("600x400+100+200") master.title("welcome") Label(master,text="Welcome to wages calculator",fg="red",font=("bold",10),anchor='w').grid(row=0,column=2) Button(master,text="ok",b...
7c2b66ead088f6caef4ec688e08ef6c3d3878b6a
ajshepp/tic-tac-toe
/main.py
985
4.09375
4
print("program started") # This function makes a board and returns it def create_board(): board = [] for x in range(0, 3): board.append(["?"] * 3) return board # This function prints a board def print_board(board): print() print("----") print() for row in board: print(" "....
a409ac72b7c8b501ed6627eacc0d42c0feb26635
mbegumgit/pythoncd
/Sqlite.py
1,062
3.9375
4
import sqlite3 from Employee_class import Employee conn = sqlite3.connect(':memory:') # conn = sqlite3.connect('employee.db') c = conn.cursor() c.execute("""CREATE TABLE employees( first text, last text, pay integer )""") emp_1 = Employee('John','Doe',8000...
2fb74f8b222750856905065916e61514c03bbbd5
anhpt1993/the_two_biggest_numbers
/the_two_biggest_number.py
358
3.875
4
import random def random_number(a, b): return random.randint(min(a,b), max(a, b)) number = [] for i in range(random_number(2, 20)): number.append(random_number(0, 100)) print(number) first_biggest = max(number) number.remove(first_biggest) second_biggest = max(number) print(f"The two biggest numbers are ...
be9d7f927b82000ceeb86f8b3e517b26379b8e6e
jsong00505/Python-Studies
/1000s/pro1003.py
1,059
4
4
# define the method for the print of the result def printFibonacci(numb): # init variables firstZero = 0 firstOne = 0 secondZero = 0 secondOne = 0 resultZero = 0 resultOne = 0 # just change recursion method to 'for' statement for n in range(numb+1): if n == 0: fi...
53eee970c5c3953d63de21263d4af78e6ef47f66
truonghoangduy/Freespeak
/src/emotionsAnalysis/fileAnalysis.py
3,275
3.875
4
#import argparse import matplotlib.pyplot as plt import math from emotionsAnalysis.sentimentAnalysis import analyze from emotionsAnalysis.speechEmotionsAnalysis import custom_file import logging # -------------------------------Analyzes text emotions------------------------------- def analyze_text_emotions(file_nam...
f404398746622387007c895f4be00be321c2c2da
Nivethaselvakumar/Python-infosys-training-
/practice assignment1/employeesalary.py
464
3.578125
4
emp_id=1001 basic_sal=15000.00 allowances=6000.00 monthly_gross_salary=basic_sal+allowances if monthly_gross_salary<10000.00: income_tax=0 else: income_tax=(20*monthly_gross_salary)/100 net_salary=monthly_gross_salary-income_tax print("employee id is",emp_id) print("basic salary is:",basic_sal) print("allowance i...
bc41f3ac8617beb3afd86cba162cf81e44d6dd6b
Nivethaselvakumar/Python-infosys-training-
/practice assignment1/monthlypay.py
301
3.90625
4
number_of_hours=40 pay_rate_perhour=400 no_of_weeks=4 monthly_pay=number_of_hours*pay_rate_perhour*no_of_weeks print("number of hours worked in a week:",number_of_hours) print("pay rate per hour is:",pay_rate_perhour) print("number of weeks in a month:",no_of_weeks) print("monthly pay:",monthly_pay)
40e4738eda34abeaecaa5f22694efb815ffc21d6
cmchandan-CM/wifipass
/dayfind.py
2,421
4.09375
4
def leap(val): if(val%4==0): return True else: return False dob=input("Enter from_date in format:dd/mm/yy :") today=input("Enter to_date in format:dd/mm/yy :") dbl=dob.split('/') tdl=today.split('/') day=int(dbl[0]) mnth=int(dbl[1]) year=int(dbl[2]) tdl=today.split('/') day2=int(t...
a1444ad12fb6404e39d5fd7a33c67225136ef8db
tenenmatt/euler
/euler/problem_18.py
3,752
3.84375
4
""" By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 2...
b4784cfe43b87d7defb99966e4c1458a2ff841be
wilsonwang1996/www.wilsonweiwang.com
/projects/child_development/public/python/test.py
763
3.75
4
import pandas as pd import re # A method to figure out if a word is of unit length with no special characters in it def pure_word(word): if re.match("^\w+$", str(word)): return True return False # A method to merge file a and file b based on the column "word" def merge_files(file_a_dir, file_b_dir, ...
df039985493c09cb2ef084007a10479b7b14ded2
adiri86/AdirDevopssession6
/venv/array.py
645
3.75
4
# #switch index number 2 from 8 to 9 # import array as test # f = test.array("i",[4,6,8]) # f[2] = 9 # print(f) # #adding element to array # import array as moshe # moshe = moshe.array("i",[3,5,1]) # moshe.append(99) # print(moshe) # # #adding element to a specific idnex # import array as koko # koko = koko.array(...
579f1e44f7a26cca31c5e596516be0b34a81db6a
adiri86/AdirDevopssession6
/venv/home assignments.py
1,204
3.96875
4
# x = 5 # y = 3 # if x > y: # print("Big") # if x < y: # print("Small") # # # for num in range (5): # print(num) # # summer = 1 # if summer == 1: # print("Summer") # elif summer == 2: # print("Fall") # elif summer == 3: # print("wINTER") # elif summer == 4: # print("Spring") # 10 times #...
786bcd13b63b61078b3f9327a4651332c47721d2
StinaLue/dslr
/describe.py
7,215
3.59375
4
#!/usr/bin/env python import pandas import matplotlib.pyplot as plt import numpy as np from numbers import Number from argparse import ArgumentParser from pandas.api.types import is_numeric_dtype import math class FeatureData: """ Takes a numerical pandas Series and computes several attributes related to its ...
a44244ceefcbfacd4aa9b6f5229c854bacbd88c6
JorgeAMS/Dynamic-dictionary
/send_mail.py
912
3.625
4
import datetime as dt import time import smtplib def send_email(): SERVER = "smtp-mail.outlook.com" FROM = "jorgea-moraless@unilibre.edu.co" TO = ["jamorales516@outlook.com"] # must be a list SUBJECT = "Test" TEXT = "Hello World!" # Prepare actual message message = """From: %s\r\nTo: %s\r...
4eb0b486d070882eda74889f3896d6c9a84bb0d1
danasilver/project-euler
/31.py
434
3.59375
4
#!/usr/bin/env python3 def main(): """Return the number of ways to make 2 pounds (200p) using the eight British coins.""" coins, limit = [1, 2, 5, 10, 20, 50, 100, 200], 200 ways = [0 for i in range(limit + 1)] ways[0] = 1 for i in range(0, len(coins)): for j in range(coins[i], limit ...
d796c123ce951eed61a951fa161862d0c411207e
danasilver/project-euler
/15.py
440
4.03125
4
#!/usr/bin/env python def factorial(n): """Return n!""" if n == 0: return 1 else: return n * factorial(n - 1) def main(): """Compute the number of routes through a 20x20 grid, from top left to bottom right only moving right and down.""" n, k = 20 + 20, 20 # n C k or in th...
4321e4270a16cf74be23ab52af4331d74ab13246
armandoordonez/python_course
/list_comprehension.py
219
3.9375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 23 17:36:43 2019 @author: apple """ mylist=[] for i in "ansiedad": mylist.append(i) print (mylist) print( [i*2 for i in {3,1,2}])
2a3b14afcd735677c47ffc9962d04a4c428b2902
wuikhan/LearnPython
/ReadingAndWritingFiles.py
385
4.09375
4
#Read and write files using the built-in Python files methods def main(): #open a file for writing and create it if it does not exist f = open("txtfile.txt","w+") #write some lines of data to the file for i in range(10): f.write("This is line %d\r\n" % (i+1)) #close the file w...
9155360a2f33bc6e5e83c2a8c1f11bb23acb3fed
uttayandeb/Fraud-Check-using-Random-Forest
/Fraud_Data_Random_Forest.py
3,991
3.703125
4
############################################################################## ####################### R A N D O M F O R E S T ########################### ############################################################################## #### Importing packages and loading dataset ############ import pandas as p...
1ee8122aac186f918b32b0d4b0bf1c2e6bac2988
mageshrocky/python_django_projects
/calculator/get_input.py
1,866
3.984375
4
def cgpa1(): while True: try: c = int(input('how many subjects you want to calculate CGPA:')) return c except ValueError: print('Invalid number') def cgpa2(): while True: try: m = int(input(f'enter your mark in subject:')) ret...
47334b9cdf6c82a6f6e182473e8ab59d1c56800c
cuongcb/LPyTHW
/ex36/ex36.py
1,299
3.84375
4
# Ex36 from LPyTHW - Designing and Debugging """Rule for If-Statements 1. Every if-statement must have an else 2. If this else should never run because it doesn't make sense, then you must use a die function in the else that prints out an error message and dies, just like we did in the last exercise. 3. Never nest ...
04981f8f4cbfdfe8ffae78fb3e157905117c049d
MolSSI-Education/mm_2019_sss_3
/mcpy/particles.py
2,434
3.90625
4
""" particles.py A python package for the MolSSI Software Summer School. Contains Particles class """ import numpy as np from mcpy.box import * class Particles(): '''Holds all the information of the particles. Parameters ---------- coordinates : np.array The numpy.array that holds the coordin...
08d9bfd12207e8f5ece46aa8bb0b08812523ae3b
CodecoolBP20161/python-pair-programming-exercises-2nd-tw-adam_david
/years/years_module.py
430
3.90625
4
import datetime def years(age): now = datetime.datetime.now() difference = 100 - age result = now.year + difference return result def main(): name = input("Enter your name: ") age = int(input("Enter your age: ")) repeat = int(input("Enter a number: ")) for i in range(repeat): ...
a836c740813a8a4b99f644d9a0b889c134f172af
panxiufeng/panxftest
/python-test/base_test/ch14_struct03_set.py
574
4.15625
4
basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'} print(basket) # 删除重复的 print("orange" in basket) # 两个集合间的运算 a = set('abracadabra') b = set('alacazam') print(a) print(b) print(a - b) # a和b的差集 print(a | b) # a和b的并集 print(a & b) # a和b的交集 print(a ^ b) # a和b中不同时存在的元素...
0efc2e80426f7e553442765462dfec8f4415ea67
panxiufeng/panxftest
/python-test/base_test/ch12_iter.py
1,711
4.1875
4
# 字符串,列表或元组对象都可用于创建迭代器: list=[1,2,3,4] it = iter(list) # 创建迭代器对象 print (next(it)) # 输出迭代器的下一个元素 print (next(it)) print ("---------") # 迭代器对象可以使用常规for语句进行遍历 list=[1,2,3,4] it = iter(list) # 创建迭代器对象 for x in it: print (x, end=" ") print() print ("---------") # 也可以使用 next() 函数: # import sys # 引入 sys...
31fe430e4a2ae497408fb9e910a70eb736580657
shen1994/board_check
/calibration/utf8_to_unicode.py
521
3.75
4
# -*- coding: utf-8 -* def to_unicode(string): ret = '' for v in string: ret = ret + hex(ord(v)).upper().replace('0X', '\\u') return ret if __name__ == "__main__": #print(to_unicode("往左来点"), len(to_unicode("往左来点"))) #print(to_unicode("往右来点")) #print(to_unicode("往上来点")) #print(to_unicode(...
9126aa5dc7676c9c74bb109fc15dfa6e7b8ca9f3
phongcoiydbg99/toolMergeDict
/moest.py
728
3.5
4
import pandas as pd data = { "calories": [420, 380, 3], "f": [0,0,0], "duration": [4, 5, 3], "type": ["duration","calories", "duration"] } def get(s): if s == "duration": return 3 return 5 #load data into a DataFrame object: df = pd.DataFrame(data) filter_chan = df['calories'] % 2 == 0...
2958561f8a9ff117963365eaecbca31e0fc17d03
rahamanankit/Word-Scrambling
/scrambled.py
752
3.96875
4
import random fh = open("MyFile.txt") fh1 = open("MyFileScrambled.txt","w") def shuffles(word): # get your word as a list word = list(word) # perform the shuffle operation random.shuffle(word) # return the list as a string word = ''.join(word) return word for line in fh: line = line.sp...
daf1d6dbf6973985f3ceed4ef5fff0edfcf03922
mawu01/mentorship_repo
/code.py
109
3.921875
4
name = input('Enter your name: ') age = input('What is your age: ') print(f'Welcome, {name}. Age is {age}')
cbd751e555b6c5eb22e003937b5a3973501d506a
bryan-truong99/JARVIS
/main.py
3,521
3.640625
4
import pyttsx3 import speech_recognition as sr import datetime import wikipedia import webbrowser import os import smtplib import requests from bs4 import BeautifulSoup user = "Bryan" # Setting up text-to-speech voice and speaking rate engine = pyttsx3.init() voices = engine.getProperty("voices") rate = engine.getPro...
7256344ff7b510500a0333f3903979dd46f8877a
WhattaSkilL/Python
/Tiny/odniBukvi.py
1,710
3.6875
4
def OdinBukvi(): #Функция сравнения букв stroka = input("Введите предложение: ") # Ввод строки listStroka = stroka.split() # разбиение строки на элементы списка lowListStroka = stroka.lower().split() #разбиенеи строки на элементы списка с одинаковым регистром rightSlova = [] # список с рабочими словами nomer...
dfb884e7c36df817718e26a8ad5af6cc50627fc7
TheEnjoy/Hyperskill
/Python/Problems/The last digit of a number/task.py
59
3.53125
4
num = int(input()) last_digit = num % 10 print(last_digit)
2324810db703edf759fe4e7c9becb272d61e76a3
TheEnjoy/Hyperskill
/Python/Problems/Divide nuts equally between squirrels/task.py
96
3.515625
4
# put your python code here N, K = (int(input()) for i in range(2)) each = (K // N) print(each)
b740f71a9ff140a6181b2284ce6c78451287e6ba
TheEnjoy/Hyperskill
/Python/Problems/Small scale/task.py
220
3.984375
4
numbers = [] while True: x = input() if x != '.': # input x while x is not '.' numbers.append(float(x)) # and add x to the end of the list else: break # Prints the Min print(min(numbers))
419703e053709f84994a9394f361b9943ed10d20
TheEnjoy/Hyperskill
/Python/Problems/Guessing game/task.py
125
3.609375
4
set_number = 6557 a, b = (int(input()) for i in range(2)) if a * b == set_number: print('True') else: print('False')
4faf24dbb13b3cfdd95a853e4cb7b4a56d3aa338
arossbrian/my_short_scripts
/poetry.py
1,014
3.75
4
import random Nouns = ["fossil", "horse", "aardvark", "judge", "chef", "mango", "extrovert", "gorilla"] Verbs = ["kicks", "jingles", "bounces", "slurps", "meows", "explodes", "curdles"] Adjectives = ["furry", "balding", "incredulous", "fragrant", "exuberant", "glistening"] Prepositions = ["against", "after", "into"...
50e60053be06ad98d06b643fcd718e3a7c7b0561
arossbrian/my_short_scripts
/whileLoop.py
170
3.984375
4
#This is a simple while loop script n= 2 #we create a variable "n" and assign it a value 1 while (n < 5): print ("n ="), n n = n + 1 print("loop Finished")
06fa3566bbafae0cce0bbba966803eb76b674b92
arossbrian/my_short_scripts
/trials.py
820
3.84375
4
##from random import randint ##for trials in range(0,10): ## print(randint(0,10)) ## trials = trials + 1 ## #name = input() ####spam = 0 ## ##print ("My name is ") ##for i in range(5): ## print ("Jimmy Five Times" + str((i) + 1)) ## ##n = 5 ##while n == 5: ## print("n -", str(n+1)) ...
4f67a41d6a13cdbb5bec602c12cc880c00224634
arossbrian/my_short_scripts
/Regexes/intro.py
866
3.859375
4
import re import string # text_to_search = [ascii_lowercase, ascii_uppercase, ] text_to_search = ''' abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 Ha HaHa metaCharacters (Need to be escaped): > ^ $ * + ? { } [] \ | ( ) coreyms.com 321-555-4321 123.555.1234 Mr. Schafer ...
327d89760aca774d4cf1019eda5c88cadc469502
arossbrian/my_short_scripts
/multiplier.py
405
4.15625
4
##This is a multiply function #takes two figures as inputs and multiples them together def multiply(num1, num2): multiplier = num1 * num2 return multiplier input_num1 = input("Please enter the first value: ") input_num2 = input("Enter the Second Value: ") ##input_num1 = int(input_num1) ##input_num2 = ...
f8b914676da0c034a908c3e440313e6633264068
arossbrian/my_short_scripts
/shoppingbasketDICTIONARIES.py
492
4.15625
4
print (""" Shopping Basket OPtions --------------------------- 1: Add item 2: Remove item 3: View basket 0: Exit Program """) shopping_basket = {} option = int(input("Enter an Option: ")) while option != 0: if option == 1: item = input("Add an Item :") qnty = int(input("Enter the quan...
36ec1104b30f90707920614405bc83cd5a2f7e40
yeonsu100/PracFolder
/NewPackage01/LambdaExample.py
601
4.5
4
# Python program to test map, filter and lambda # Function to test map def cube(x): return x ** 2 # Driver to test above function # Program for working of map print "MAP EXAMPLES" cubes = map(cube, range(10)) print cubes print "LAMBDA EXAMPLES" # first parentheses contains a lambda form, that is # a squaring ...
a33c19dfb0b96705eecdc44ca0cc64aec3097e85
CSPR07/pythonProject
/main.py
783
3.859375
4
antwoord = input("Wil je het spel spelen? (ja/nee) ") if antwoord.lower().strip() == "ja": antwoord = input("Je komt een pad tegen wil je naar links of naar rechts toe? (links/rechts) ").lower().strip() if antwoord == "links": antwoord = input("Boe! je komt een monster tegen. Wat doe je ren je of val...
2a809af0bec5ff06895807913153c26997cf30a0
deeptivenugopal/Python_Projects
/AddressBook_Tkinter.py
3,630
4.3125
4
#Creating Address Book using Tkinter GUI ''' These are the step to build a contact book python project: Importing module Initializing window Define buttons Define functions ''' #1. Importing module from tkinter import* from tkinter import messagebox #2. Initializing window root = Tk() #Use x for...
c30cd41b41234884aea693d3d0893f2889bd5f1d
deeptivenugopal/Python_Projects
/edabit/simple_oop_calculator.py
605
4.125
4
''' Simple OOP Calculator Create methods for the Calculator class that can do the following: Add two numbers. Subtract two numbers. Multiply two numbers. Divide two numbers. https://edabit.com/challenge/ta8GBizBNbRGo5iC6 ''' class Calculator: def add(self,a,b): return a + b def subtract(sel...
6598f0f714711ea063ef0f160e65847cc9dfa295
fiberBadger/portfolio
/python/collatzSequence.py
564
4.15625
4
def collatz(number): if number % 2 == 0: print(number // 2) return number // 2 else: print(3 * number + 1) return 3 * number + 1 def app(): inputNumber = 0 print('Enter a number for the collatz functon!') try: inputNumber = int(input()) except (Val...
f416c4993cfc11e8ca6105d48168d42952f55aa3
fiberBadger/portfolio
/python/stringStuff.py
813
4.125
4
message = 'This is a very long message' greeting = 'Hello' print(message); print('This is the same message missing every other word!'); print(message[0:5] + message[8:9] + ' ' + message[15:19]); print('The length of this string is: ' + str(len(message)) + 'chars long'); print('This is the message in all lower case ' ...
f867edf91db301a809fdf070c47b589e25fb5adc
zzghost/MachineLearning
/NewtonsMethod/newtonsmethodinLR.py
2,141
3.6875
4
# -*- coding:utf-8 -*- ''' implement newton's method in logistic regression ''' import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt def data(): dataX = pd.read_csv("./logistic_x.txt", header=None, sep="\s+") dataY = pd.read_csv("./logistic_y.txt", header=None, sep="\s+"...
948ea9bebee4007a96b9866469e4d7e06a39d327
Junhyeok1015/Codeup
/Basic/1066_16616969(AC).py
102
3.734375
4
a = list(map(int,input().split(" "))) [print("even") if x % 2 == 0 else print("odd") for x in a]
532e0929506cf6b8ca15218320c207e0ba358ecf
BoZhao0817/IS590PZ
/HW2/Hold_that_Line.py
6,001
4.15625
4
# data structure: # maps is a 2-D list of size height*width. Each maps[i][j] contains a Point (a class defined below) # line is a 3-D list of current line. For example[[[0,0],[2,1]],[[2,1],[2,2]]] represent there are two line # in the maps which is (0,0),(2,1) and (2,1),(2,2) # IMPORTANT!!! For a lineA, lineA[0] should...
271757b107ab2369e831073348d31273716a11fc
Demorneau/python-challenge
/PyBank/main.py
3,119
3.828125
4
# PyBank -budget_data.csv analysis of minimum value, maximun value, sum total, and average. #importing sub-routines for path and csv reader and writer files. import os import csv # Establishing dictionary Bank for data information, and setting counters in zero value. dictionary_bank = {} min_pl = 0 max_pl = 0 average_p...
e16a267612443612a5b460d1d04609f391629ca6
eileen-b/pcc_2e
/chapter_02/Try it yourself/personal message.py
344
3.859375
4
'''2-3. Personal Message: Use a variable to represent a person’s name, and print a message to that person. Your message should be simple, such as, “Hello Eric, would you like to learn some Python today?” pg 25''' fname = "desmond" msg = f"Hi {fname.title()}, hope your day was great! \nJust a little Python Zen." print(...
59fe6a88db022f0be7d22bea71c42192eacb8548
alictai/euler
/problem1.py
98
3.78125
4
sum = 0 for i in range(1000): if (((i%3) == 0) or ((i%5) == 0)): print i sum += i print sum
c3aff5e58dfbe155a6ed4fd0ad59a012734f7237
kryman0/school
/python/sort/test.py
2,603
3.625
4
""" Module Test """ import unittest from unorderedlist import UnorderedList from errors import IndexOutOfRangeError, ValueExistentError import sort class TestUnorderedList(unittest.TestCase): """ Test class for UnorderedList. """ def setUp(self): """ Setup the objects. """ self.ulist = Unord...
ef01dd238ba02b1974fff155216cdfc6e9a47f36
kryman0/school
/python/spellchecker/spellchecker.py
7,361
3.765625
4
""" Module SpellChecker. """ import string from node import Node from trie import Trie class SpellChecker: """ SpellChecker class. """ def __init__(self): """ Ctor. """ self.trie = Trie() self.node_list = [] self.menus = { "1": self.check_w...
de6d6ce936509cdfab20b9fe9cfd5ac947a14bc2
sbuckner6/piano-player
/app/music/oscillator.py
2,068
3.75
4
from random import randint, random class Oscillator: UP = 0 DOWN = 1 def __init__(self): self.direction = self.UP if randint(0, 1) == 0 else self.DOWN def update(self, tick): pass class BasicUpDownOscillator(Oscillator): def __init__(self, length): self.length = lengt...
56eea43b8582cb89f83ee3dfcddbb7ab33e090b1
joao0710/primeiro-repo
/pythoncollections/iterator.py
183
3.578125
4
#IMPRIMIR UMA PALAVRA INSERIDA INVERTIDAMENTE if __name__ == "__main__": palavra = input() for index in range(len(palavra) - 1, -1, -1): print(palavra[index], end='')
6282c39cd427c50bbb59343f3b44fc7436d79ac0
LordAldi/machine-learning-a-z
/2. regression/1. simple linear/linear-regression.py
1,299
3.84375
4
# -*- coding: utf-8 -*- """ Created on Thu Feb 11 12:59:24 2021 Simple Linear regression @author: User """ # importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #import dataset dataset = pd.read_csv("Salary_Data.csv") X = dataset.iloc[:, :-1].values y = datase...
dde5b47d54f35e1d3ccbc11322831edf21cd55cc
zkbt/illumination
/illumination/sequences/Array_Sequence.py
2,407
3.515625
4
''' Define a generic sequence of images. ''' from .Image_Sequence import * class Array_Sequence(Image_Sequence): def __init__(self, initial, name='array', time=None, temporal={}, spatial={}, **kwargs): ''' Initialize a Sequence from 2D or 3D numpy array. Parameters ---------- ...
c4acbc2cc9cbbe534af749af6b6ceb44ee854b6f
kcthogiti/ThinkPython
/Dice.py
352
4.1875
4
import random loop_control = "Yes" Min_num = int(raw_input("Enter the min number on the dice: ")) Max_num = int(raw_input("Enter the Max number on the dice: ")) def print_rand(): return random.randrange(Min_num, Max_num) while loop_control == "Yes": print print_rand() loop_control = raw_input("Do you want to c...
e717309b5e4397d68510f8fd97931a17128a7d97
kittykatcode/Automate-The-Boring-Stuff-With-Python
/Chapters_ABSWP/inventory.py
734
3.625
4
import pprint stuff = {'rope':1, 'torch': 6, 'gold coin': 42, 'dagger' :1, 'arrow' :12 } def displayinventory(inventory): print("Inventory : ") item_total = 0 for k, v in inventory.items(): item_total += v print((k.ljust(10) + ': ' + str(v).rjust(10))) print(pprint.pformat("total nu...
997b652db916280d604483ce73aa6324c0b5f6d4
yuukou3333/study-python
/55knock_py/knock_20.py
249
3.90625
4
# リスト(forによる捜査) # 変数に[1,2,3,4,5]の5つの要素を持つリストを格納して,偶数の要素だけ出力してください.出力形式は問いません. l = [1,2,3,4,5] for i in l: if i%2 == 0: print(i)
d8da2f3fe23acf33367543f0655f03b3dc71e9ce
yuukou3333/study-python
/55knock_py/knock_29.py
852
4.21875
4
# 辞書(キーの存在確認,get) d = {'apple':10, 'grape':20, 'orange':30} # if 'apple' in list(d.keys()): # .get(キー)は辞書にキーが存在するかどうかを判断し、存在する場合はキーに対応する値、存在しない場合はNoneを返す # .get(キー, 値)は辞書にキーが存在するかどうかを判断し、存在する場合はキーに対応する値、存在しない場合は第二引数で指定した値を返す # 例 # d.get('pine') # => None # 辞書に指定した値を反映させたい時は、 # d['pineapple'] = d.get('pineappl...
cfb1af2a6e06d88811b8b90ceab57c8cb2fda3f1
yuukou3333/study-python
/55knock_py/knock_12.py
325
3.671875
4
# 文字列(lower) # 自分の回答(間違い)==================================== s = "This Is A Sentence ." # s = s.lower print(s) # => <built-in method lower of str object at 0x7f926da6a300> # 模範解答 ==================================== s = s.lower() # メソッドの後に『()』をつける。 print(s)
611091381de21716115bf1104d7c6493f815a640
yuukou3333/study-python
/55knock_py/knock_14.py
298
3.703125
4
# 文字列(文字数) s = "How many characters?" print(len(s)) # 頻繁に使用する汎用的なメソッド。リストの長さを得るときにも使う # 参考) # Pythonのlen関数で様々な型のオブジェクトのサイズを取得 https://note.nkmk.me/python-len-usage/
f31055339f0b50d51f73e89c831d66fde7cfa2b1
yuukou3333/study-python
/55knock_py/knock_07.py
260
4.09375
4
# 比較演算子、bool a = 5 if a % 2 == 0: print(True) else: print(False) # 比較演算子(==, !=, <, >, >=, <=)はbool型と呼ばれるTrueかFalseのいずれかを返す. # 模範解答 ==================================== print(a%2 == 0)
d8384b37334d8f11840d4785f5c3ebb740fe06a6
meltemarsl/uvadlc_practicals_2016
/practical_3/convnet.py
4,918
3.71875
4
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf import numpy as np class ConvNet(object): """ This class implements a convolutional neural network in TensorFlow. It incorporates a certain graph model to be trained and to ...
4fb1c11f72c165f881348a2145b6130346c15bcc
L200184134/Praktikum-Algopro
/Activity 4. Data Type (shell).py
2,307
4.125
4
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> Nama = "Mahardhika Bathiarto Dim Zarita" >>> NIM = 134 >>> Tinggi = 1.68 >>> Berat = 57 >>> TahunLahir = 2000 >>> Aku = (TahunLahir, Berat, Tinggi, NIM...
0956ae560a6614d8867c0d009fdd61df44013cf3
pgresham/CIDR-Calc
/cidr.py
3,009
3.890625
4
#!usr/bin/python3 # This is a short program to 'calculate' subnet # masks from CIDR notation. Operation is pretty # straightforward, enter a number between 1 and # 32 and it will return the subnet mask. Typing # 00 exits the script. import os import time def clear(): os.system('clear') def title(): clear(...
f48e0539fff87005e7bf9714de61b1fd1708b62a
csvenja/LeetCode
/Sort Colors.py
527
3.53125
4
class Solution: # @param A a list of integers # @return nothing, sort in place def sortColors(self, A): current = 0 for i in xrange(len(A)): if A[current] == 0: del A[current] A.insert(0, 0) current += 1 elif A[current] ...
864af346b189de2e8ad34c7e1cfdb97c977e3723
ompraka158/pythonData
/classConcept2.py
659
3.796875
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 2 09:52:28 2018 @author: ompra """ class Employee: empCount=0 #variable which will hold number of objects def __init__(self,name,salary): self.salary=salary self.name=name Employee.empCount+=1 #Class reference used so the...
a921a761fc8c723872a7c5ce4ba17eb547cca6c7
SailorTheMan/rostishka_UG
/db_to_csv.py
487
3.53125
4
import csv import sqlite3 # TODO в русские буквы не может conn = sqlite3.connect('sim_data.sqlite') cursor = conn.cursor() cursor.execute("select * from id_factory;") with open("copy_db.csv", "w", newline='') as csv_file: # Python 3 version #with open("out.csv", "wb") as csv_file: # Python 2 version...
da5093d6a5aa0effa3bc5477f7f4a8ed370ddbd7
yamasampo/bseq
/bseq/alignment.py
22,414
3.703125
4
# -*- coding: utf-8 -*- """Data structure models for biological alignments. This module contains the classes that describe representations of nucleic acid, protein, and codon alignments. An Alignment is a list of sequences that have been aligned such that characters in the same alignment column are evolutionary relat...
6275eae9107c2d92a9df5f2c8749389434917a82
SDrag/weekly-exercises
/exercise1and2.py
1,450
4.375
4
################### ### Exercise 1: ### ################### def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i # Test the function with the following value. x = 18 ans = fib(x) print("Fibonac...
2fbdf1272451b9116c8336e70b21d58a98486a1a
harishtalanki/HackerRankSolutions
/SwapCase.py
176
4.0625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT n = raw_input() newString = [i.lower() if i.isupper() else i.upper() for i in n] print "".join(newString)
c93fc51cd78902514408e9146f2a144f253e7a7d
tomholmes19/Minimum-Enclosing-Balls-with-Outliers
/src/meb/geometry.py
4,755
3.84375
4
import numpy as np def find_furthest(p,data, core_set=None, return_index=False, find_closest=False) -> np.array: """ Finds the furthest or closest point in data from p (l2 norm) that isn't in the core set if specified Input: p (array like): initial point data (array like): list of points t...
8f5157697fe47f9be87c9769cf51957afda55b29
tomholmes19/Minimum-Enclosing-Balls-with-Outliers
/src/data/loading.py
1,643
4.0625
4
import numpy as np import pandas as pd def to_csv(data, filename) -> None: """ Converts a dataset from np.array to pd.DataFrame then writes to a .csv file Input: data (np.array): data to be written to csv filename (str): filename/path of csv to be written to Return: None ...
b4a9d5d00fb985408709e3cd94affeab96354e08
PrestigiousP/SpaceGame
/EventInterface.py
579
3.625
4
from abc import abstractmethod, ABC import EventHandlerInterface class EventInterface(ABC): """ Trigger events """ @abstractmethod def attach(self, observer: EventHandlerInterface): """ Add an observer to the subject """ pass @abstractmethod def detach(sel...
da66cd026542da7dc6f3c8fa6e591dd787fa7932
Hikari1149/thread-process-python-example
/barriers/matrix_multiply_single.py
1,051
3.5625
4
import time from random import Random matrix_size = 200 # matrix_a = [ # [3,1,-4], # [2,-3,1], # [5,-2,0] # ] # # matrix_b = [ # [1,-2,-1], # [0,5,4], # [-1,-2,3] # ] random = Random() matrix_a = [[0]*matrix_size for r in range(matrix_size)] matrix_b = [[0]*matrix_size for r in range(matrix_...
9b874d450830678c6ac27f7ebc304f08c6fd1f88
ZdenekBrydl/CollegePractice
/First_semester/Practice/3/CV3.py
1,432
3.875
4
#Print sum of all natural numbers smaller or equal import def sum(n): print(int(n*(n+1)/2)) #Print factorial of import def factorial(n): a= 1 for i in range(1, n+1): a= a*i print(a) #Print digit sum of import def digit_sum(n): n= str(n) a= 0 for i in range(len(n)): ...
4545259ed896f6fac36c050b15127ce3be8b0de0
rramdehol/python_101
/pygame_shooter/hero.py
1,419
3.8125
4
# Duh import pygame; # THis will get the Sprite class from pygame.sprite # Our hero will be a sprite from pygame.sprite import Sprite; class Hero(Sprite): # initialize class properties def __init__(self, screen): super(Hero,self).__init__(); self.image = pygame.image.load('hero.png') self.screen = screen; #...
ca59fa6abd548f47cbabe477adb2db510843d6f5
fyndiq/py-moneyed
/src/moneyed/classes.py
18,821
3.84375
4
# -*- coding: utf-8 -*- from __future__ import division from __future__ import unicode_literals from decimal import Decimal, ROUND_DOWN # Default, non-existent, currency DEFAULT_CURRENCY_CODE = 'XYZ' class Currency(object): """ A Currency represents a form of money issued by governments, and used in one...
2d94305898adc3a1227bc7790f1d769c4da93426
gautam06/Python
/py5_StdDataTypes.py
2,933
4.21875
4
#Python Standard DataTypes print "Numbers String List Tuple Dictionary" print "Numbers -> int (-1,786,-0x260,0x69), float(15.20,-25.1,-32.3e100), complex(3.14j, .876j, 4.53e-7j)" print "" #Number Examples print ("\n-------------------------------------") print ("Number Exaples"); print ("------------------------...
c4770cee138dcac6f6b8f0e749b7004bd0499032
gautam06/Python
/py17_FileObj.py
5,942
4.09375
4
#file object = open(file_name [, access_mode][, buffering]) #file_name: name of the file that you want to access #access_mode: i.e., read, write, append, etc. default mode is read (r). #buffering: 0 = no buffering, 1 = line buffering. #if buffering > 1, then buffering action is performed with the indicated buffer s...
5eb43489aae91a4b9b58cd6c39dc4982ec60b27f
XanderEagle/unit11
/breakout.py
6,651
3.796875
4
# Xander Eagle # January 24, 2020 # This program makes a star wars themed breakout game (YOU HAVE TO USE THE FORCE BECAUSE THE BALL IS HARD TO SEE) import pygame, sys from pygame.locals import * import brick import paddle import ball def main(): # Constants that will be used in the program application_width...
9102b4f2c9f13509a6171f3a4ad0a73cd2b353e7
njmikkelsen/machinelearning2018
/Project3/programs/progress_bar.py
829
3.734375
4
import sys class progress_bar(object): """ A command-line progress bar for use in large loops (as a sanity check). Initialization arguments: N | number of loops add_space | whether to print an empty line before & after progress bar Usage: ----------------------------- sanity = progress_bar...
a9116755c5a55fecdd662e83437e60a1dd7a5f2e
bruno-zaccariello/LP2_2s2017
/Lista_dicionarios/Ex03/Ex03.py
415
3.609375
4
nome = '_init_' nota_alunos = {} while nome != '' : nome = str(input('Insira o nome do aluno')) if nome == '' : break nota_alunos[nome] = [float(input('Insira a primeira nota')), float(input('Insira a segunda nota'))] print(nota_alunos) nome = str(input('Insira o nome do aluno a buscar')) ...
e7978691d83f36e1268e2fd943e9fbfb19c1ad08
l3aalteshuva/shellcode-tools
/reverse-string.py
565
3.9375
4
import sys if len(sys.argv) <= 1: print "[] - Add your string as the first argument." print "[] - Example: python reverse-string.py MyString " sys.exit(0) input = sys.argv[1] print 'String length: ' + str(len(input)) stringList = [input[i:i+4] for i in range(0, len(input),4)] for item in stringList...
f119fa584b0359aba2f35e1b29c7c55338f114e9
wfaithfull/Projects
/python/projects/projects/text/palindrome.py
285
3.8125
4
def ispalindrome(s): # D.R.Y. from reverse import reverse return s == reverse(s) def main(args): if ispalindrome(args[1]): print 'is a palindrome' else: print 'is not a palindrome' if __name__ == '__main__': import sys main(sys.argv)
4124348e44c46398f56341c6f96d6fbd16cdf8dd
wfaithfull/Projects
/python/projects/projects/number/tiles.py
427
3.890625
4
def tilecost(price, width, height): return (width * height) * price; if __name__ == '__main__': from decimal import Decimal import sys import locale locale.setlocale(locale.LC_ALL, 'uk') price = Decimal(sys.argv[1]) width = int(sys.argv[2]) if sys.argv.count == 3: height == i...
e4a599afaf6a7a8066331e4482da913514a1ec78
sahibseehra/Python-and-its-Applications
/Python+data sciences+sql+API/1.py
81
3.59375
4
a=input("enter no") a=int(a) b=input("enter no") b=float(b) c=a+b print(c)
106a25dde373fb9d64f016803a4638a71058e654
sahibseehra/Python-and-its-Applications
/Python+data sciences+sql+API/file handling.py
184
3.671875
4
myfile=open("D:\\demo.txt","r") #str=myfile.read() str=myfile.readline() c=0 while(str!=""): print(str) str=myfile.readline() c=c+1 print("total no. of lines:",c)
41a907c8a5062f01e3a671521178e70de9a91ad5
sahibseehra/Python-and-its-Applications
/Python+data sciences+sql+API/7.py
237
4.15625
4
#declaring list: l=[] n=input("enter no of students") n=int(n) for i in range(0,n): name=input("enter student name=") l.append(name)#if there is no list , then elements are appended on the next memory location print(l)
48c843a3bb0ebbea2325c4cf1ac2b88f891294f6
sahibseehra/Python-and-its-Applications
/Python+data sciences+sql+API/5.py
80
3.53125
4
a=10.00 b=20 if(a==10): print("python") else: print("java")
071fc367d145c4c3d371b28f04fbadf8501da0bf
sahibseehra/Python-and-its-Applications
/Python+data sciences+sql+API/cometohome1.py
148
3.5625
4
name=input("enter any name") l=len(name) if l%2==0: s=(name[1:l:2]+name[0:l-1:2]) else: s=(name[1:l-1:2]+name[0:l:2]) print(s)
10174f8a42406e8f1216b7cd02a054a8d993147f
kburr6/Python-Projects
/Python Basics/Tuples_Dictionaries_Sets/dict_comprehensions.py
187
4.15625
4
words = input('Enter words to transform to uppercase here. Separate them with spaces:') s = words.split(' ') result = {value: value.upper() for idx, value in enumerate(s) } print(result)
0fa5ad12cd25202d70e1a2e06a6bccb2d62e1f97
kburr6/Python-Projects
/Python Basics/Strings and Lists/append_first_to_last.py
252
4.15625
4
# Input series of comma-separated strings s = input('Please enter a series of comma-separated strings: ') # Split on comma+space to create the list l = s.split(', ') # Append the first element to list l and then print the list l.append(l[0]) print(l)
91cad9a7f2bc9c5680e9b18d38df530a15d2b2f4
kburr6/Python-Projects
/Python Basics/Numpy_Examples/numpy_boolean_indexing.py
405
4.125
4
import numpy as np def elements_twice_min(arr): """ Return all elements of array arr that are greater than or equal to 2 times the minimum element of arr. Parameters ---------- arr: NumPy array (n, m) Returns ------- NumPy Array, a vector of size between: 0 and (n * m) - 1 """...
40adcc5c09bed49f610cde520c3b3e789ac13a62
yangbin112/yangbin112
/第一次个人编程作业最终版.py
6,846
3.5
4
import re # 导入模块 class Stack(object): # 初始化栈为列表 def __init__(self): self.stack = [] # 判断栈是否为空 def isEmpty(self): return self.stack == [] # 返回栈顶元素 def peek(self): return self.stack[-1] def peek1(self): return self.stack[-2] # 返回栈的大...