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
d904f6ae14f31c7b284e39329a22a1e0a8ec91bf
green-fox-academy/Angela93-Shi
/week-02/day-7/oop/sharpie.py
806
3.9375
4
# Create Sharpie class # We should know about each sharpie their color (which should be a string), # width (which will be a floating point number), ink_amount (another floating point number) # When creating one, we need to specify the color and the width # Every sharpie is created with a default 100 as ink_amount # W...
0ff0c13459c83929d90c57a453cb8fdf5736af28
green-fox-academy/Angela93-Shi
/week-01/day-3/python/print_even.py
122
3.921875
4
# Create a program that prints all the even numbers between 0 and 500 for i in range(500): if i%2==0: print(i)
12562fa1658d275e15075f71cff3fac681c119ab
green-fox-academy/Angela93-Shi
/week-01/day-4/data_structures/data_structures/product_database.py
715
4.34375
4
map={'Eggs':200,'Milk':200,'Fish':400,'Apples':150,'Bread':50,'Chicken':550} # Create an application which solves the following problems. # How much is the fish? print(map['Fish']) # What is the most expensive product? print(max(map,key=map.get)) # What is the average price? total=0 for key in map: total=total+map...
fca1600839df5efa93b7f515b6323c1a32c9e2ce
green-fox-academy/Angela93-Shi
/week-01/day-4/function/summing.py
238
4.03125
4
# Write a function called `sum` that returns the sum of numbers from zero to the given parameter given_num=10 def sum(num): global given_num for i in range(num+1): given_num=i+given_num print(given_num) sum(given_num)
c525397178d3cfa51ee9163724db2d8131c8601f
green-fox-academy/Angela93-Shi
/week-02/day-7/inheritance/student.py
904
3.90625
4
from person import Person class Student(Person): def __init__(self,name='Jane Doe',age=30,gender='female',previous_organization='The School of life',skipped_days=0): Person.__init__(self,name='Jane Doe',age=30,gender='female') self.previous_organization = previous_organization self.skipped_...
587a7726500b091aea4511e4036f8750c229ecaa
green-fox-academy/Angela93-Shi
/week-05/day-01/all_positive.py
319
4.3125
4
# Given a list with the following items: 1, 3, -2, -4, -7, -3, -8, 12, 19, 6, 9, 10, 14 # Determine whether every number is positive or not using all(). original_list=[1, 3, -2, -4, -7, -3, -8, 12, 19, 6, 9, 10, 14] def positive_num(nums): return all([num > 0 for num in nums]) print(positive_num(original_list))
7e84399b0ae345beb15e19b1e44663d4bc062138
green-fox-academy/Angela93-Shi
/week-02/day-7/oop/petrol_station.py
718
3.796875
4
# Create Station and Car classes # Station # gas_amount # refill(car) -> decreases the gasAmount by the capacity of the car and increases the cars gas_amount # Car # gas_amount # capacity # create constructor for Car where: # initialize gas_amount -> 0 # initialize capacity -> 100 class Station(): def __init__(...
8fcf16851182307c41d9c5dd77e8d42b783628c7
green-fox-academy/Angela93-Shi
/week-01/day-4/function/factorial.py
409
4.375
4
# - Create a function called `factorio` # that returns it's input's factorial num = int(input("Please input one number: ")) def factorial(num): factorial=1 for i in range(1,num + 1): factorial = factorial*i print("%d 's factorial is %d" %(num,factorial)) if num < 0: print("抱歉,负数没有阶乘") elif nu...
c5d9cfe8cdda4d4fdc98f77221c15bb23da5e100
green-fox-academy/Angela93-Shi
/week-01/day-4/data_structures/data_structures/telephone_book.py
478
4.1875
4
#Create a map with the following key-value pairs. map={'William A. Lathan':'405-709-1865','John K. Miller':'402-247-8568','Hortensia E. Foster':'606-481-6467','Amanda D. Newland‬':'319-243-5613','Brooke P. Askew':'307-687-2982'} print(map['John K. Miller']) #Whose phone number is 307-687-2982? for key,value in map.item...
f0871075ce0fef62569e4ce443389d1c8c592480
sajal203/dice-simulator
/dicesimulator.py
641
3.84375
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 5 20:26:46 2020 @author: sajal """ '''dice simulator''' import random import time user_inp = 'yes' while user_inp == 'yes' or user_inp == 'y': print('dice is rolling...') time.sleep(1) dice1 = random.randint(1, 6) dice2 = ran...
6f5f64793115b2302e947c9f8ce5be419d5740e1
johnrick10234/hello-world
/Homework-4/Homework_4_12.7.py
484
3.921875
4
#John Rick Santillan #1910045 def get_age(): age=int(input()) if age<18 or age>75: raise ValueError('Invalid age.') return age def fat_burning_heart_rate(age): h_rate=(220-age)*.70 return h_rate if __name__=='__main__': try: age=get_age() print('Fat burning heart rate ...
cc78b79ef9732173ad7066b7c0474ce639bbe480
Joseane772/exercicios_python
/pratice/B.py
844
3.71875
4
na = int(input('what is the total number of students?')) NV = 0 Lx = 0 Lz = 0 EB = 0 EM = 0 Vb = 0 for n in range(0, na): v = str(input('which list will you vote for(X or Z)')) NE = str(input('what is your level of education (B or S)?')) if v == 'x': Lx = Lx + 1 elif v == 'z': Lz = Lz +...
b68d019707668a3a3a47b556afa389154e403274
mnusicallity/Py-Pong
/Pong/paddle.py
1,855
3.78125
4
import pygame from pygame.sprite import Sprite class Paddle(Sprite): def __init__(self, screen, ai_settings, player_paddle): super(Paddle, self).__init__() self.ai_settings = ai_settings self.color = ai_settings.paddle_color self.paddle_position = 400 self.paddle_s...
31c2c7901dd994dea44ce68dea458bf8675926d3
MAWA-Taka/SelfTaughtPgmr
/p156_apple.py
291
3.703125
4
class Apple: def __init__(self, k, s, w, c): self.kind = k self. size = s self.weight = w self.color =c a = Apple("ふじ", "L", 200, "yellow") print("品種:{}、サイズ:{}、重さ:{}、色合い:{}".format(a.kind, a.size, a.weight, a.color))
856e1fe1bffc794ff217365ce83f1bfab6d9e094
misssoft/Fan.PythonExercise
/src/assessment/estimate/binary_search_distribution.py
724
4
4
""" Distribute a depth value into the right bin by binary search """ def binary_search_distribution(boundaries, depth, lower, upper): """ :param boundaries: a list containing the boundary values of different bins in ascending order :param depth: the depth value of a pixel :param lower: position of lowe...
5a48b2cc0ad944fafff7215e755a6af233ead39e
KrishnaAgarwal16/May-Leetcode-Challenge-2020
/Week-1/MajorityElement.py
419
3.671875
4
#Problem Link: https://leetcode.com/explore/challenge/card/may-leetcoding-challenge/534/week-1-may-1st-may-7th/3321/ class Solution: def majorityElement(self, nums: List[int]) -> int: d = set(nums) n = len(nums) for i in d: if nums.count(i)>(n/2): return i ...
3f3d0582c711859aae5b2999bf057b6cba2b88fd
LiamBrem/PythonProjects
/PassGen/main.py
577
3.8125
4
import random import pyperclip def generatePassword(chars, charList): password = [] for i in range(chars): nextChar = characterList[random.randint(0, len(charList))] password.append(nextChar) return ''.join(password) def copyToClipBoard(copy): pyperclip.copy(copy) if __name__ == "_...
6ca4a43e77389bcdec965fc1b9ced177f785c1a8
rajes95/intensive_fundamentals_of_computer_science
/binary_search/binary_search_tree_Tests.py
3,526
4.125
4
# Author: Rajesh Sakhamuru # Version: 3/28/2019 import unittest import binary_search_tree class Binary_Search_Tree_Tests(unittest.TestCase): def testBinarySearchTreeAdd(self): """ # Purpose: This method adds a specified value to the binary tree in the expected location. Lower...
1b42ac0ff1735b7c01b53715a78feb9d6d525700
rajes95/intensive_fundamentals_of_computer_science
/more_shapes_with_loops/moreShapes.py
3,979
4.4375
4
# Author: Rajesh Sakhamuru # Version: 2/10/2019 def printLowerRight(size): """ This function prints a right-aligned triangle with an incrementing number of "*" in each row until it reaches the specified size. A Lower Right triangle of size 6 would look like this: * ** *** ...
5a094fde4286a2b7776be503ad866871330454bf
rajes95/intensive_fundamentals_of_computer_science
/repeating_shapes/repeatingShapesDriver.py
2,088
4.03125
4
# Author: Maria Jump # Version: 2019-02-15 import repeatingShapes def readInteger(prompt, error="Value must be a positive integer"): """ Read and return a positive integer from keyboard """ value = -1 while(value == -1): entered = input(prompt) try: value = int(entered) ...
c60df7c6d2aa3eaecdc1c95bc7bba9a96eff1add
kasemodz/RaspberryPiClass1
/LED_on_off.py
831
4.125
4
# The purpose of this code is to turn the led off and on. # The LED is connected to GPIO pin 25 via a 220 ohm resistor. # See Readme file for necessary components #! /usr/bin/python #We are importing the sleep from the time module. from time import sleep #We are importing GPIO subclass from the class RPi. We are ref...
99f64a174783c4a4f8a4a304672a096b0fe04ccc
Poter0222/poter
/PYTHON/03.04/string.py
697
4.1875
4
#coding=UTF-8 # 03 # 字串運算 # 字串會對內部的字元編號(索引),從 0 開始 s="hello\"o" # \ 在雙引號前面打入,代表跳脫(跟外面雙引號作區隔) 去避免你打的字串中有跟外面符號衝突的問題 print(s) # 字串的串接 s="hello"+"world" print(s) s="hello" "world" # 同 x="hello"+"world" print(s) # 字串換行 s="hello\nworld" # /n代表換行 print(s) s=""" hello world""" # 前後加入“”“可將字串具體空出你空的行數 print(s) s="hello"*3+"w...
e799fbff3d6be502d48b68fb1094b6dd4bcc4079
yihangx/Heart_Rate_Sentinel_Server
/validate_heart_rate.py
901
4.25
4
def validate_heart_rate(age, heart_rate): """ Validate the average of heart rate, and return the patient's status. Args: age(int): patient'age heart_rate(int): measured heart rates Returns: status(string): average heart rate """ status = "" if age < 1: tachyca...
59af5bd8671e37f88a8d870dafb252a31d19feb8
julminen/aoc-2020
/day_15.py
1,095
3.59375
4
#!/usr/bin/python3 from collections import namedtuple def read_file(day: str): with open(f"input/day_{day}.txt") as file: lines = [line.strip() for line in file] numbers = [int(n) for n in lines[0].split(",")] return numbers def play(input, until): # A bit slow print(f"Initial: ...
214209cf95f808f20e613ff30529a04a4c0d1094
julminen/aoc-2020
/day_23.py
8,448
3.609375
4
#!/usr/bin/python3 # Tried different variations for phase 2, none which is especially fast from typing import List from collections import namedtuple Cup = namedtuple('Cup', ['value', 'next']) class ListNode: def __init__(self, node_id: int): self.node_id = node_id self.next_node = None ...
83bba9ae93acb35a1789d734cdf7acc0349a08d4
JamesKing9/NewHeart-NewLife
/Study/Python/JCP027.py
273
3.734375
4
#!/usr/bin/python # -*-coding: UTF-8-*- ''' 需求: ''' def palin(n): next = 0 if n <= 1: next = input() print print next else: next = input() palin(n-1) print next i = 5 palin(i) print
7d0799241a47e78342643a0ed708ae9e5ff4c777
nabilahap/Labpy03
/Latihan1.py
187
3.53125
4
from random import random n = int(input("Masukan Nilai N: ")) for i in range(n): while 1: n = random() if n < 0.5: break print("dara ke: ",i, '==>', n)
519f6444488b6478ac2c09ded5f689c63ba21dd7
SifatIbna/codeforces-problems
/Boboniu Plays Chess/main.py
1,096
3.65625
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press ...
76db64ba5a47301aeaae345e43b6e528037e369c
yanigisawa/python-morsels
/format_fixed_width.py
3,630
3.90625
4
# This week I'd like you to write a function, format_fixed_width, that accepts rows of columns (as a list of lists) # and returns a fixed-width formatted string representing the given rows. # For example: # >>> print(format_fixed_width([['green', 'red'], ['blue', 'purple']])) # green red # blue purple # The paddin...
e56c47a35358601f048e68397fa45658523a1469
TechKrowd/sesion1python_03062020
/operadores/06.py
465
4.09375
4
""" Pedir dos datos numéricos reales al usuario y calcular la suma, resta, producto y división de los mismos. """ n1 = float(input("Introduce un número real:")) n2 = float(input("Introduce otro número real:")) suma = n1 + n2 resta = n1 - n2 producto = n1 * n2 division = n1 / n2 print("La suma es {:.2f}".format(suma...
fe0364c9796f13da242bb31a99cd74ed21ca33c8
TechKrowd/sesion1python_03062020
/operadores/05.py
201
4.0625
4
""" Pedir un número entero por teclado y calcular su cuadrado. """ n = int(input("Introduce un número: ")) #cuadrado = n ** 2 cuadrado = pow(n,2) print("El cuadrado de {} es {}".format(n,cuadrado))
08edecc297ce651d8e7178941aa00e01de2b8ef7
halfozone007/repoA
/PythonProjects/RegularExpressions/1Regex.py
420
3.796875
4
#Regular Expressions are a very powerful method of matching patterns in a text import re def main(): fh = open('raven.txt') for line in fh.readlines(): if re.search('(Neverm|Len)ore', line): print(line, end = '') for line in fh.readlines(): match = re.search('(Neverm|Len)ore', ...
112fcd917a53cbc7da8ce27c1055bfa577b93458
halfozone007/repoA
/PythonProjects/Loops/enumerate.py
151
3.5625
4
def main(): string = "this is a string" for i, c in enumerate(string): print(i, c) if __name__ == '__main__': main()
5b014f4393fb6048c8f2d7546fe03a3d5625b28d
halfozone007/repoA
/PythonProjects/VariablesObjectAndValues/2UsingString.py
232
3.796875
4
def main(): n = 24 s = "This is a {} string".format(n) print(s) s1 = ''' Hello hello1 hello2 ''' #Print strings on different lines print(s1) if __name__ == '__main__':main()
8604414ab76375a1977f0b49929df80184b2fb9c
sagarnil1989/DemoProjects
/Customer Churn for Bank Customer/Classification_Solution_Sagarnil.py
2,586
4.03125
4
#Evaluating, Improving, Tuning Artificial Neural Network # Part 1 - Data Preprocessing # Import libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #Set working directory & import data dataset = pd.read_csv("Churn_Modelling.csv") X=dataset.iloc[:,3:13].values Y=dataset.iloc[:,13].values ...
cb9c3f9e12220ab7a64692d3d4a2fa22860152c6
zxy1013/creat_mode
/creat_mode/factory.py
1,234
4
4
# 简单工厂模式 from abc import ABCMeta, abstractmethod # 抽象产品角色 class Payment(metaclass=ABCMeta): @abstractmethod def pay(self, money): pass # 具体产品角色 class Alipay(Payment): def __init__(self, use_huabei=False): self.use_huabei = use_huabei def pay(self, money): if self.use_huabei: ...
c45a016425d84fc6eda59d6d82c359b0eb3d49a6
iayushbhartiya/iayushbhartiya
/Guessing the number.py
739
3.96875
4
#Guessing the number nam = input('Enter your name: ') print('Welcome to guessing game', nam) num = 18 i = 0 while(True): count = 9 - i if count<0: print('Game over') break i += 1 val = int(input('Enter a number: ')) if val>18: if val>30: print('You...
4b4076ce66e3a70a7c36bc4c5aa87699a9f30995
Bayaz/flasktaskr
/project/db_create.py
780
3.625
4
#project/db_create.py import sqlite3 from _config import DATABASE_PATH with sqlite3.connect(DATABASE_PATH) as connection: #get cursor object to execute SQL commands c = connection.cursor() #create table c.execute("""CREATE TABLE tasks(\ task_id INTEGER PRIMARY KEY AUTOINCREMENT, \ n...
4f7f761819b008ab5a09eb51272fcfaeb974c12f
Ad0rian/Python-Voice-input-test
/venv/app.py
2,076
3.75
4
""" Este pequeño programa tiene el objetivo de probar el servicio de voz que permite usar python, en concreto este pequeño programa te permite realizar dos funciones, la primera es la de apagar tu equipo si le dices 'Apagar' y la otra funcion es la de buscar en internet, para activar esta funcion le tienes que decir 's...
85dcf64aed58d3d0f44bf12a86430788e684838e
Jayem-11/machine-learning-scratch
/machine_learning/neural_network/ann/perceptron/multiclass_perceptron.py
5,428
3.828125
4
import itertools import numpy as np from sklearn.datasets import make_classification import matplotlib.pyplot as plt from sklearn.metrics import f1_score from sklearn.model_selection import train_test_split from sklearn.linear_model import Perceptron as sklearn_perceptron class multiClassPerceptron: """ Perce...
43382e8fe8fac375b8bdbbda97a67d853a5a7e19
eleanorpark/Python-Dec-2018-CrashCourse
/areaofcircle.py
348
4.125
4
def area_of_circle(radius): 3.14*radius*radius radius=2 area = 3.14*radius*radius area_of_circle(radius) print('area of circle of radius {} is:{}'.format(radius,area)) def area_of_circle(radius): 3.14*radius*radius radius=10 area = 3.14*radius*radius area_of_circle(radius) print('area of circle of radius {} ...
6f89741abdec32b48b49bb52fa494c944e2ad541
mugiritsu/deepl-tr-pyppeteer
/deepl_tr_pp/browse_filename.py
972
3.578125
4
r"""Browse for a filename. https://pythonspot.com/tk-file-dialogs/ filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes=(("jpeg files","*.jpg"),("all files","*.*"))) """ # import sys from pathlib import Path import tkinter from tkinter import filedialog # fmt: off def browse_filename( ...
d84ff4475eee0708a755242c6019a381a1aa7c5f
carinapetcu/University-Projects
/Fundamentals of Programming/Game of Life/Validator/Validate.py
673
3.640625
4
import math from Exceptions.Exceptions import ValidatorError class Validate: def __init__(self): pass @staticmethod def validateBoards(board, boardWithPattern, row, column): dimension = int(len(boardWithPattern)) for index1 in range(dimension): for index2 in range(dim...
6832c702badf29d98eed86d234df1ba0183f9f4f
Deepak995/python
/bacic_exception.py
501
3.8125
4
class division: def divi(self, a,b): try: # a=int(input("enter the value of a ")) #b=int(input("enter the value of b")) c=a/b except ArithmeticError : print("enter the right value of b") else: return c print("this is a free stateme...
4add69787b4ad852eb7511ddbcdf5664ea1b2917
Deepak995/python
/iterator.py
173
3.796875
4
a=[1,2,2,3,2,'eraju','baju'] """for i in a: print (i)""" b=iter(a) print(b) print(next(b)) print(next(b)) print(next(b)) print(next(b)) print(next(b)) print(next(b))
137bcdcadc480592f4a3c50240146b6fe9126313
Deepak995/python
/ansss.py
1,287
3.59375
4
###P- Replace somthing from given input # s1 = 'how are you' # s1 = s1.replace('how', 'who') # print(s1) # # list = ['where are you'] # list = list[0].replace('where','who') # print(list) ###################################################### ###P- output should be ----->[4, 5, 6, 1, 2, 3] # input = [1,2,3,4,...
16e7156b501609938163fcdc287b256589830413
nilloc95/Graphing-with-python
/d_graph.py
11,906
4.09375
4
# Course: CS261 - Data Structures # Author: Collin Gilmore # Assignment: 6 # Description: This file contains a class for an directed graph using a matrix to store links between nodes # along with the weight. It also has methods to add vertices, edges, remove edges, # find out if a path is v...
0f7cfefeb124d76ef25dc904500246c9e843658d
xg04tx/number_game2
/guessing_game.py
2,282
4.125
4
def main(): while True: try: num = int( input("Please, think of a number between 1 and 1000. I am about to try to guess it in 10 tries: ")) if num < 1 or num > 1000: print("Must be in range [1, 100]") else: computer_guess...
76b9e0167bf76c50015b4359665b33f495e85c81
echo-1234/code-complete-MIT60001
/assignments/ps0/ps0.py
191
3.953125
4
## input ## data type ## numerical operation import numpy x = int(input("Enter a number x: ")) y = int(input("Enter a number y: ")) print("x**y = ", x**y) print("log(x) = ", numpy.log2(x))
3beab522b6c62c0302f7a436bd2da893889d87d4
rickmansfield/U5.2-M3
/U5-2-M3-Homework/Task4b.py
799
3.734375
4
def csWordPattern(pattern, a): # print(a.split()) words = a.split() # print("words split", words) if len(words) != len(pattern): return False char_to_word = dict() for i in range(len(pattern)): char = pattern[i] word = words[i] if char in char_...
3d2acafdebab21cb2ff8c5b0b08e26ba47ed8b44
vtheno/zuse_sim
/MainMenu.py
4,269
3.796875
4
import Tkinter as Tk import App class MainMenu(object): def __init__(self, master): self.master = master self.width = master.winfo_width() self.height = master.winfo_height() f_text = Tk.Frame(master, bg = 'white', width = self.width, height = self.height / 6,bd=1) f_text.gr...
d3030ce858b421aa3b7d4f86874063ed0d862890
akshayjoshii/LeetCode_Coding_Interview
/Pos_Neg_Array.py
942
3.578125
4
import numpy as np import timeit #O(n^2) - Simple solution def pos_neg_simple(arr): t = [] #2 for loops for i in range(len(arr)): for j in range(i+1, len(arr)): if(abs(arr[i]) == abs(arr[j])): t.append(abs(arr[i])) if(len(t)==0): return "No Positive/Negative ...
4659470dc6b39f197e43b358b5bd8f196157dec1
Parkhomets/Python
/Stepic/2/DateAndTime.py
208
3.765625
4
import datetime x = input().split(" ") for i in range(3): x[i] = int(x[i]) data = datetime.date(x[0], x[1], x[2]) data = data + datetime.timedelta(int(input())) print(data.year, data.month, data.day)
1c1b4cd1dda92e6aef9fe38236a45a856776f082
ConorMB93/Python1
/AirportDistance/Airports.py
635
3.734375
4
''' Airports by Conor Byrne ''' class Airports: def __init__(self, airport_code, name, city, country, lat, long): self.airport_code = airport_code self.name = name self.country = country self.city = city self.lat = float(lat) self.long = float(long) def __str...
d8d59642182dbba4388cdfd81ab97e99efa92cc5
rchaskar/PycharmWork
/Functions.py
742
4.0625
4
'''def average(a,b): return (a+b/2) print(average(20,10)) ''' '''def calculate(a,b): x=a+b y=a-b z=a*b r=a/b return x,y,z,r print(calculate(10,20)) ''' #function inside another function ''' def message(name): def gretting(): return "How are u " return gretting() + name prin...
98f3f92f67791def2251246bccb8770c73320dae
rchaskar/PycharmWork
/assignment1.py
117
3.5625
4
Name = "Rahul Chaskar" City = "Pune" Age = 26 height = 179 Weight = 80 print("Name is" + Name , "City:" +City, Age, Weight)
6c111511875ad1fd6eb2c23a7206122a73f23e76
kexinxin/Defect
/genetic-hyperopt/mahakil/Distance.py
348
3.578125
4
class Distance: def __init__(self,distance,label): self.__distance__ = distance self.__label__= label def get_distance(self): return self.__distance__ def get_label(self): return self.__label__ def __str__(self): return str("distance:{} label:{} ".format(self.__...
dc0b326cbbd52603b780b087d8f2fe9ab7e3c63a
kexinxin/Defect
/SoftwarePrediction/OverSampleAlgorithm/smote.py
3,030
3.5625
4
from sklearn.neighbors import NearestNeighbors import random import numpy as np class Smote: """ Implement SMOTE, synthetic minority oversampling technique. Parameters ----------- sample 2D (numpy)array class samples N Integer amount of SMOTE N%...
760e2277fae9977374f73331293fb6efd1d7cddd
kexinxin/Defect
/SoftwarePrediction/OverSampleAlgorithm/BorderlineOverSamplling.py
4,098
3.5625
4
import random from sklearn.neighbors import NearestNeighbors import numpy as np class BorderlineOverSampling: """ RandomOverSampler Parameters ----------- X 2D array feature space X Y array label, y is either 0 or 1 b float in...
4092786eb3254dc3dcddd09bbe6892d5a0ccb717
cksrb1616/Algorithm_past_papers
/DFSBFS/DFSBFS_5-5_factorial.py
265
3.921875
4
#반복적으로 구현한 n! def factorial_iterative(n): result=1 for i in range(1,n+1) result *= i return result #재귀적으로 구현한 n! def factorial_reculsive(n): if n<=1: return 1 return n*factorial_reculsive(n-1)
513540cee31c1fbd3c2dbb95ffb4ed2bf3473b2c
TanyaGerenko/T.Gerenko
/Ex4.py
555
3.8125
4
#ДЗ-4 #N-школьников делят k-яблок поровну, неделящийся остаток остается в корзинке. #Сколько яблок достанется каждому, сколько останется в корзинке? k = int(input("Сколько всего яблок? ")) n= int(input("Сколько всего школьников? ")) print("Каждому школьнику достанется ", k//n, "яблок") print("В корзинке останет...
6eae59d3f1e4f73b5563fc1979024d0cbd612705
TanyaGerenko/T.Gerenko
/Ex6.py
636
3.859375
4
#ДЗ-6 #Дано целое, положительное, ТРЁХЗНАЧНОЕ число. #Например: 123, 867, 374. Необходимо его перевернуть. #Например, если ввели число 123, то должно получиться на выходе ЧИСЛО 321. #ВАЖНО! Работать только с числами. #Строки, оператор IF и циклы использовать НЕЛЬЗЯ! n = int(input("Ввести целое, положительное, ТРЁ...
66c3ffce7cface103349ba9d972521cbe57c883c
MateusValasques/AlgoritmosPython
/Ordenação/Quase ordenados.py
11,576
3.8125
4
from array import * import time import random cont_selection = 0 cont_insertion = 0 cont_shell = 0 cont_quicksort = 0 cont_heap = 0 cont_merge = 0 def selection_sort(array): global cont_selection for index in range(0, len(array)): min_index = index for right in range(index + 1, len(array)): ...
0bd28c58aec4f2d5ebb0428cb3da2929239206b7
zhangxingxing12138/web-pycharm
/pycharm/改版.py
737
3.90625
4
from collections import Iterable class MyList(object): def __init__(self): self.items = [] self.index = 0 def add(self, name): self.items.append(name) self.index = 0 def __iter__(self):#加这个方法变成了可迭代对象(iterable) return self #返回一个迭代器(MyIterator(self)) def __next__...
2e3b067497ab8a8005abecbcea9606bb56d43493
licebmi/extra-projects
/number-printer.py
1,416
4.0625
4
#!/usr/bin/env python3 import argparse import random def parse_arguments(): parser = argparse.ArgumentParser(description="Generate a range of random integers") parser.add_argument( "-o", "--ordered", action="store_true", dest="ordered", help="Returns an ordered range", ...
4280e622f18a3eac097f5773902f30ba2c8cb6d3
uva-sp2021-cs5010-g6/finalproject
/project01/question3.py
7,685
3.796875
4
""" This module provides the functions and code in support of answering the question "How do popular food categories fare with corn syrup?" The `main()` function provides the pythonic driver, however this can be run directly using python3 -m project01.question3 after the files have been fetched from the USDA (see `pro...
4deedfe0dea559088f4d2652dfe71479fce81762
saman-rahbar/in_depth_programming_definitions
/errorhandling.py
965
4.15625
4
# error handling is really important in coding. # we have syntax error and exceptions # syntax error happens due to the typos, etc. and usually programming languages can help alot with those # exceptions, however, is harder to figure and more fatal. So in order to have a robust code you should # handle the errors and ...
1e922122a376fe94be19ce450289691680dfc55a
MuraliSarvepalli/Squeezing-reptile
/my_func_ex3.py
176
3.984375
4
def myfunc3(a,b): if (a+b)==20 or a==20 or b==20: return True else: return False a=input('Enter a') b=input('Enter b') r=myfunc3(a,b) print(r)
dce7935bd17f8f27baf4cda9a2eb2f0db19c00b7
MuraliSarvepalli/Squeezing-reptile
/my_func_ex_7.py
370
3.9375
4
#Given a list of ints, return True if the array contains a 3 next to a 3 somewhere def three_conseq(ls): count=0 while count<len(ls): if ls[count]==3 and ls[count+1]==3: return True count+=1 ls=[] for i in range(0,5): num=int(input('Enter the values')) ls.append(n...
55f4fc114333b02e47285ac8d06aac4889ae403a
MuraliSarvepalli/Squeezing-reptile
/try_except_fianlly.py
245
3.84375
4
#try except finally def ask(): while True: try: n=int(input("Enter the number")) except: print("Whoops! Thats not a number") else: break return n**2 print(ask())
d5d16ef90534d51086eb9966710e794b39265ef7
MuraliSarvepalli/Squeezing-reptile
/my_func_ex_19.py
171
4.15625
4
#palindrome def palindrome(st): if st[::]==st[::-1]: return True else: return False st=input('Enter the string') print(palindrome(st))
a21b9e2173759cf993bcc77f445b4c2fedc10348
MuraliSarvepalli/Squeezing-reptile
/my_func_ex_17.py
225
4.03125
4
#Write a Python function that takes a list and returns a new list with unique elements of the first list. def unique(mylist): un_list=set(mylist) return un_list print(unique([1,1,1,1,3,3,5,4,9,5,6,7,8,7,2]))
f545e77bc882b7dacb6ba522f354531b8a3206ad
zdrasteenastya/utils
/patterns/strategy.py
1,443
3.71875
4
import types # Option 1 class Strategy: def __init__(self, func=None): self.name = 'Patter Strategy 1' if func is not None: self.execute = types.MethodType(func, self) def execute(self): print(self.name) def execute_replacement1(self): print(self.name + 'replace wit...
483f62eacc57d12e1542ef8bf8265896ef921323
zdrasteenastya/utils
/requests_to_db.py
1,821
3.6875
4
# coding: utf-8 import sqlite3 import psycopg2 conn = sqlite3.connect('Chinook_Sqlite.sqlite') cursor = conn.cursor() # Read cursor.execute('SELECT Name FROM Artist ORDER BY Name LIMIT 3') results = cursor.fetchall() results2 = cursor.fetchall() print results # [(u'A Cor Do Som',), (u'AC/DC',), (u'Aaron Copland ...
21fb03593c46ab3dee1bbfc36bf93698a0d87286
returnpointer/trainsim
/user_interface/menu_sim.py
1,826
3.5
4
""" Simulation Menu """ from PyInquirer import prompt from user_interface.menu_questions import style, sim_questions1, sim_questions2 from sim_engine.simulation import sim_run def sim_menu(railway, graph): """Simulation Menu""" if not railway['stations'] or \ not railway['tracks'] or \ ...
6c0b90765de1de097e3da9a5434649929ee01b7a
newpheeraphat/banana
/Algorithms/String/T_ReverseStringInList.py
147
3.609375
4
class Solution: def reverseWords(self, s: str) -> str: s3 = s.split() res = [i[::-1] for i in s3] return " ".join(res)
a9a4f9e454711353a969c827b8c3a6226ced3bf9
newpheeraphat/banana
/Algorithms/List/T_ChangeValuesInList.py
340
3.546875
4
def check_score(s): import itertools # Transpose 2D to 1D res = list(itertools.chain.from_iterable(s)) for key, i in enumerate(res): if i == '#': res[key] = 5 elif i == '!!!': res[key] = -5 elif i == '!!': res[key] = -3 elif i == '!': res[key] = -1 elif i == 'O': res[key] = 3 elif i == '...
aee829e9b7b2796c39884a76f4dc1a8fe0b6aca7
newpheeraphat/banana
/Algorithms/Integer/Prime/10001st_prime.py
311
4
4
def nth_prime(nums): counter =2 for i in range(3, nums**2, 2): j = 1 while j*j < i: j += 2 if i % j == 0: break else: counter += 1 if counter == nums: return i int1 = int(input()) print(nth_prime(int1))
a61fb10a9c8b3dc6244a01c7296a2de90fde246a
newpheeraphat/banana
/Algorithms/Map-FIlter/T_Zip.py
307
3.640625
4
class Solution: def convert_cartesian(self, x : list, y : list) -> list: res = [[i, j] for i, j in zip(x, y)] return res if __name__ == '__main__': print(Solution().convert_cartesian([1, 5, 3, 3, 4], [5, 8, 9, 1, 0]) ) print(Solution().convert_cartesian([9, 8, 3], [1, 1, 1]) )
41ff3ef5de93046c9836bfb2ea81435539244849
newpheeraphat/banana
/Algorithms/Dictionary/T_FindMax.py
308
3.84375
4
country = ['Brazil', 'China', 'Germany', 'United States'] dict1 = {} my_list = [] _max = 0 for i in country: int1 = int(input()) my_list.append(int1) dict1[i] = int1 if _max < int1: _max = int1 print(dict1) for key in dict1: if dict1[key] == _max: print(key, dict1[key])
339523698a51d97b56c9419d2f2a7ac90231edfb
bajca/pyladies
/Import_piskvorky/piskvorky.py
1,392
3.71875
4
def tah(herni_pole, cislo_policka, symbol): return herni_pole[:cislo_policka] + symbol + herni_pole[cislo_policka + 1:] def tah_pocitace(herni_pole): while True: cislo_policka = random.randrange(len(herni_pole)) if herni_pole[cislo_policka] == "-": return tah(herni_pole, ci...
fa1354ec7e81123f76e33054103be26e6d644e6d
bormanjo/Basic-Scrabble-Word-Aid
/Main.py
3,199
3.71875
4
scrabbleScores = [ ["a", 1], ["b", 3], ["c", 3], ["d", 2], ["e", 1], ["f", 4], ["g", 2], ["h", 4], ["i", 1], ["j", 8], ["k", 5], ["l", 1], ["m", 3], ["n", 1], ["o", 1], ["p", 3], ["q", 10], ["r", 1], ["s", 1], ["t", 1], ["u", 1], ["v", 4], ["w", 4], ["x", 8], ["y", 4], ["z", 10] ] def letterScore(letter, scorelist): ...
0b2de788f6be653826240f287578a86d2070893d
Donovan1905/Ants-colony-search-algorithm
/ants.py
3,237
3.78125
4
from AntsAlgo.const import ALPHA, BETA, RHO, CUL import random class Ant: # the ant class def __init__(self): # initialize visited and to visit cities lists as well as the time self.visited = list() self.toVisit = list() self.time = 0 """[summary] Function to choose the next c...
ef9848abae877105114ff60a86f33f40a7fc5a6a
Scottycags/Scott-Cagnard---Assignment-2
/Scott.Cagnard---Assignment.2.py
4,508
4.3125
4
#Scott Cagnard #Assignment 2 #2.1 practice str = "hello, i am a string" #Create any certain string x = str.find("am") #Set x to find the position of "am" in str print(x) #Print the location of "am" print(str.replace("i", "me")) #Replace "i" with "me" in the string and pr...
218cd58e485e9a4dee468613d738c5c84613ffc1
gopiselvi30/Python
/to find common elements in two elements.py
315
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 29 22:46:58 2016 @author: gopi-selvi """ list1= range(1,100) list2= range(50,150) list3=[] for a in list1: if a in list1: list3.append(a) for b in list2: if b not in list1: list3.append(b) print(list3)
227510fcca18ea1c2a74af631cb1ba532ea3522b
oamole/Projects
/Iocane.py
9,848
3.796875
4
#!/usr/bin/env python # coding: utf-8 # # Iocane Powder # # ## Overview # # > Man in Black: All right. Where is the poison? The battle of wits has begun. It ends when you decide and we both drink, and find out who is right... and who is dead. # # The line above is from the perennial favorite 1980s movie adaptation...
b595630701a103250cb67649b0182040c982d1cf
Prink0054/Assignment-Python
/practice/practice.py
708
4.03125
4
""" #Question-1 a = int(input("Enter year to check it is leap year or not")) if((a%4) == 0): { print("Yes it is leap year") } else: { print("no it is not a leap year") } """ """ #Question-2 a = int(input("Enter Length of box")) b = int(input("Enter Width of box")) if(a == b): p...
a202ac88914984267b1065b58c388b2a69e4af2e
Prink0054/Assignment-Python
/Assignment11/Assignment11.py
1,346
3.96875
4
#Question1 import threading from threading import Thread import time class Th(threading.Thread): def __init__(self,i): threading.Thread.__init__(self) self.h = i def run(self): time.sleep(5) print("hello i am running",self.h) obj1 = Th(1) obj1.start() obj2 = Th(2) obj2.start() ...
0a8a9a0a4c6ca24fde6c09886c52d1d5c7817a24
Trietptm-on-Coding-Algorithms/Learn_Python_the_Hard_Way
/ex40b.py
974
4.53125
5
cities = {'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville'} cities['NY'] = 'New York' cities['OR'] = 'Portland' def find_city(themap, state): if state in themap: return themap[state] else: return "Not found." # ok pay attention! cities ['_find'] = find_city while True: print "State? (ENTER to qui...
5892f0c1c6cb36853a85e541cb6b3259346546e9
Trietptm-on-Coding-Algorithms/Learn_Python_the_Hard_Way
/ex06.py
898
4.1875
4
# Feed data directly into the formatting, without variable. x = "There are %d types of people." % 10 binary = "binary" do_not = "don't" #Referenced and formatted variables, within a variable. y = "Those who know %s and those who %s." % (binary, do_not) print x print y #r puts quotes around string print "I said: %r."...
15eb6a39ec8e85689d6dc60f8bed506d68955634
pellertson/scripts
/bin/fenparser
1,712
3.5625
4
#!/usr/bin/python3 # parser for printing properly formatted chess boards from a FEN record # assumes piped input from json2tsv(2) import fileinput import sys # uppercase letters are white; lowercase letters are black def parse_square(sq): if sq == 'k': return '♚' elif sq == 'K': return '♔' elif sq == 'q': re...
b67a4bd391591382eeadec48c55e5db6e9417f1f
samyumobiMSIT/ads-2
/practise/m3/Bonus _ Hamilton Path/Hamilton Path/HamiltonianPath.py
1,684
3.71875
4
from __future__ import print_function from data_structures.adjacency_list_graph import construct_graph class HamiltonianPath(object): '''Find the hamiltonian path in a graph''' def __init__(self, graph): self.graph = graph self.vertices = self.graph.adjacency_dict.keys() self.hamiltonia...
59c54a778af80dc495ed27f83006893f36e9a9e7
saurabhslsu560/myrespository
/oop3.py
1,028
4.15625
4
class bank: bank_name="union bank of india" def __init__(self,bank_bal,acc_no,name): self.bank_bal=bank_bal self.acc_no=acc_no self.name=name return def display(self): print("bank name is :",bank.bank_name) print("account holder name is:",self.name) ...
31ebe8918dd39a56be55d7d73315ea3a1e0e292b
ftuyama/AIproblems
/Lab5/DiffEvolution.py
7,634
3.703125
4
# -*- coding: utf-8 -*- # !/usr/bin/env python """Algoritmo das N-Rainhas.""" from random import randint from copy import deepcopy from graphics import * import timeit def print_board(board): u"""Desenha o grafo de rotas a partir do mapa lido.""" win = GraphWin('N-Rainhas', 850, 650) win.setBackground(col...
5d14097892b10f631944b82dbe03262a26d84021
dariokl/firebase-flask-ponzi
/ponzi.py
2,355
3.546875
4
""" PONZI. A pyramid scheme you can trust YOU HAVE UNLIMTED TRIES THE 4 DIGITS IN THE NUMBER DONT REPEAT THERE IS NO LEADING ZERO YOUR GUESS CANNOT HAVE REPEATING NUMBERS THE FASTER YOU ARE DONE THE BEST THE RETURNS ARE ALLOCATED ACCORDING TO YOU ABILITY TO SCAPE THE PYRAMID FROM THE TOP KILLED MEANS THE NUMBER IS PR...
263c7fb994dca4aeb198f87793683ef6630b267a
kdolder79/maze_game
/rooms/room10.py
3,951
3.5
4
import adventure_game.my_utils as utils from colorama import Fore, Style # # # # # # ROOM 10 # # Serves as a good template for blank rooms room10_description = ''' . . . 10th room ... This looks like another hallway. Not much is in this room. ''' room8_state = { 'door locked': Fal...
b42c601cfb574a4d8f6f4f5c37b117385bd350ee
KevinBorah/Python_for_Absolute_Beginners
/Python_Code/RPS_Game-v1.py
1,614
4.09375
4
print("----------------------------") print(" Rock Paper Scissors v1") print("----------------------------") print() player_1 = input("Enter Player 1's name: ") player_2 = input("Enter Player 2's name: ") rolls = ['rock', 'paper', 'scissors'] roll1 = input(f"{player_1} what is your roll? {rolls}: ") rol...
638ba2a42c0aae6fa5a250d6aeaac2a81c264180
szerem/pySolve100Exercises
/45.py
201
3.546875
4
import os, string if not os.path.exists("letters"): os.makedirs("letters") for letter in string.ascii_lowercase: with open("letters/{}.txt".format(letter), "w") as f: f.write(letter)
3fe58aa1750f43479050a19efe175cbffcf60d9a
szerem/pySolve100Exercises
/79.py
293
3.796875
4
import platform import string print(platform.python_version()) while True: psw = input('--> ') if any( i.isdigit() for i in psw) and any( i.isupper() for i in psw) and len(psw) >= 5: print("Password is fine") break else: print("Password is not fine")
02a81d00904de7e79c311d05919ad55012d903af
CHENHERNGSHYUE/pythonTest
/tkinter/tkinter_09_messagebox.py
1,260
3.71875
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 10 12:00:12 2019 @author: chenmth """ import tkinter as tk window = tk.Tk() window.title('messagebox test') window.geometry('600x300') def answer(): print(input('')) def messageBoxShowing(): tk.messagebox.showinfo(title='info box', message='一般顯示') tk.messag...