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
85eb2ffc8676179e4c6f23062f20a19e0d0a1906
HATIMj/MyPythonProblems
/Divisor.py
1,138
4.125
4
#DIVISOR OR NOT try: #trying the below inputs n=int(input("Enter the total number of apples:--"))#Taking an input of number of apples mn=int(input("Enter the minimum no. of students:--")) #Taking the input of minimum number of students mx=int(i...
cf51027b0e5206824cb0c05446701e973c4e7e25
muhammadmehranbinazam/Encryption-and-decryption
/encrypt.py
1,473
3.796875
4
#!/usr/bin/python class Solution: def __init__(self): self.key = '' self.plainText = '' self.decry=[] self.string=[] self.ci_key=[] def decrypt(self, cipherText): # //write your logic to decrypt the given cipherText #dictionary keys={'a':'a', 'b':...
d86c5759e787449b4615d0bce90305d3f96a8002
biceps94/Component-Testing-1.0
/QA - Component Testing 1.0.py
793
3.875
4
def componenttesting(motorinput=0, tempinput=0): if motorinput < 150 and tempinput < 120: print("Try Again") return True elif motorinput > 150 and tempinput > 120: print("Game over") return False def motor_and_temperature(): try: motorinput = int(in...
8ef76a34722e35eab5d0c8bdc79124a661bb684d
myh1000/character-song-id
/main.py
925
3.578125
4
import urllib2 import pafy from bs4 import BeautifulSoup url = "https://en.wikipedia.org/wiki/List_of_Touhou_Project_characters" page = urllib2.urlopen(url) soup = BeautifulSoup(page, 'html.parser') name_box = soup.findAll('dt') touhou_names = [] for name in name_box: name = str(name) name = name.split('<') rea...
23f99ef8bd383e7022f7dfa4ae5d846bcf0cd000
SamKirkiles/reinforcement-learning
/Bandit/nonstationary.py
1,054
3.6875
4
import gym import numpy as np import gym_bandits import matplotlib.pyplot as plt # A k-bandit algorithm to maximize reward from a series of 10 slot machines #BanditTenArmedGaussian-v0 #BanditTenArmedRandomFixed-v0 #BanditTenArmedRandomRandom-v0 env = gym.make('BanditTenArmedGaussian-v0') env.reset() k = 10 epsilon ...
85d564366aedac62c9706d78ccb01cb8ab78f8b1
EthioCompSciClub/basic_data_science_tutotrial
/data.py
2,731
4
4
import pandas as pd # used to manupulate data and tables from matplotlib import pyplot as plt #used to plot data or tables import itertools #to sort data before plotting import datetime from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange from numpy import arange import random #simple plotting...
e1b50fa6f175072297cef823a13f387b8e2aa945
damkh/gb_py_alg_2020-07
/les3/les_3_task_7.py
770
4.0625
4
""" 7. В одномерном массиве целых чисел определить два наименьших элемента. Они могут быть как равны между собой (оба минимальны), так и различаться. """ import random init_list = [random.randint(1, 10) for _ in range(0, 10)] print(f'Начальный массив: {init_list}') n = 2 min_list = [] for i in range(0, n): min_e...
511ed45e3a1096278ebfada4c401b0e1c0bca4d6
damkh/gb_py_alg_2020-07
/les3/les_3_task_9.py
881
4.03125
4
""" 9. Найти максимальный элемент среди минимальных элементов столбцов матрицы. """ import random rows = 5 columns = 4 arr = [[random.randint(1, 10) for _ in range(0, columns)] for _ in range(0, rows)] for row in arr: for el in row: print(f'{el:>5}', end='') print() max_min = None flag = True for co...
22bb794c7925515c882c409514166bdbbcf7f9a9
damkh/gb_py_alg_2020-07
/les_8/dz_8/les_8_task_1.py
1,129
4.09375
4
""" 1. На улице встретились N друзей. Каждый пожал руку всем остальным друзьям (по одному разу). Сколько рукопожатий было? Примечание. Решите задачу при помощи построения графа. Для данной задачи неориентированный граф будет заполнен единицами везде, кроме главной диагонали. Количесвто рукопожатий будет равно сумме вс...
bb6a12f23977e3ccd61d074a193b27bb4091f113
jaycoskey/AdventOfCode
/2020/03_python/sol03.py
1,907
3.75
4
#!/usr/bin/env python3 DATA_DIR = '../03_data' INPUT_FILE = 'input.txt' WIDTH = 31 def print_chart(chart): for line in chart: line = ''.join(line) assert(len(line) == WIDTH) print(line) # print() def is_tree(chart, row_num, col_num): # print(f'row={row_num}, col={col_num}') ...
204875aad5488beb58a1b987397a3ad8452f22b1
pratyushmb/Prat_Python_Repo
/W3Schools/w3_schools_1.py
883
4.0625
4
if 5 > 3: print("yes! 5 > 3") x_y = "hello" # variable can start with _ , cannot start with number, no other # special character allowed. print(x_y) x, y, z = "a", "b", "c" # x = y = z = "same" print(x) print(y) print(z) x = 5 y = "abc" print(str(x) + y) # 5abc # this is a comment """ this is multi line comme...
15da41ac63d1c424b8f18924593efe8ab64c15e9
pratyushmb/Prat_Python_Repo
/Ineuron/Basics.py
265
3.890625
4
True and False # Bool output as False True or False # Output: True True is False # Output: False x = 5 print(x) numbers = [1, 2, 3] i = 0 for i in numbers: if i == 2: break print(i) else: print("done") print("the number: " + str(i))
ef953085648ad000470656586143e2cefd242470
pratyushmb/Prat_Python_Repo
/W3Schools/tuples.py
525
4.40625
4
myTuple = ("a", "b", "c") print(myTuple) print(myTuple[1]) print(myTuple[-1]) print(myTuple[1:2]) # change tuple value though its unchangable myList = list(myTuple) myList[1] = "change" myTuple = tuple(myList) print(myTuple) # iterate thru tuple: need to verify for x in myTuple: print(x) if "change" in myTuple: ...
5273225e4f7f4f0eb510dcbcda5c7637feeb94cb
pratyushmb/Prat_Python_Repo
/Ineuron/Assignment_2.py
3,232
3.828125
4
# 1.1 create your own reduce function in python def myreduce(fun, lst): a = lst[0] # storing the first value of list to be used in function for i in range(1, len(lst)): a = fun(a, lst[i]) return a def to_add(p, q): return p + q def to_mul(p, q): return p * q my_lst = [1, 2, 3, 4] prin...
a7c4c0fe4a970202ca85be51bdd61248c423e240
pratyushmb/Prat_Python_Repo
/W3Schools/lambda.py
267
3.953125
4
x = lambda a: a + 10 print(x(6)) y = lambda a, b: a * b # can take any number of arguments. print(y(2, 3)) def my_function(a): return lambda b: a * b mydoubler = my_function(2) mytripler = my_function(3) print(mydoubler(11)) # 22 print(mytripler(11)) # 33
9403a5bd6ed8c75da0733ddaaf1ac09aa2ac58c8
isaac-aryan/Backup
/password.py
256
3.59375
4
idb=False pwb=False while(idb==False): id=input("Enter your valid ID") if id.isalnum()==True: iwb=True break while(pwb==False): password=input("Enter your valid password") if password.isdecimal()==True and len(password)<=10: pwb=True break
d9b1b1ce164c4dc2a0fc3f8aa6287ade95be6114
isaac-aryan/Backup
/Python/Conditionals_in_Python.py
265
4.03125
4
a=10 b=20 c,d=20,10 if(a>b): if(c>d): print("a and c are greater than b and d") else: print("a is greater than b but c is not greater than d") elif(c>d): print("c is greater than d but a is not greater than b") else: print("a and c are less than b and d")
2d74a1de222374e9d93ced094685c8c6fd5683b6
isaac-aryan/Backup
/How to think Like a programmer/task_8.py
142
4.21875
4
while(1): i=int(input("Enter a positive number..")) print("Your input is ",i) if i<0: print("The number ",i," is not positive.") break
56179fbb248d9fe07334511ff59dca71e88495c0
isaac-aryan/Backup
/How to think Like a programmer/max_and_min.py
232
3.9375
4
list1=[100,10,23,48,7,54] maxi=list1[0] for i in list1: if maxi>=i: continue else: maxi=i print(maxi," is the largest value.") mini=list1[0] for j in list1: if j<=mini: mini=j print(mini," is the minimum value.")
d79052d2b19e901735753e14eb690051025f2e89
isaac-aryan/Backup
/github/PathFinder-With-AStar/pathfinding.py
5,657
3.5
4
#IMPORTED STUFF import os,math,sys import pygame from tkinter import * #import project modules try: import configs as cfg except: print("1 or more project modules are missing.") openSet=[] closedSet=[] cameFrom=[] #CREATE 2D ARRAY grid = [ [0 for i in range(cfg.row)] for i in range(cfg.cols)] st=input("E...
28f4f58d9ecf0fb84ea85a2fdec5b444b945c2cd
isaac-aryan/Backup
/Python/Functions_in_python.py
173
3.609375
4
#function declaration def add(): a=10 b=20 print(a+b) #Function call add() def add(a,b): print(a+b) add(60,42.6) def add(a,b,c): return a+b*c print(add(10,30,59))
53dab86b4a7509ec7b3b852026e25d72dcc56fdb
isaac-aryan/Backup
/How to think Like a programmer/first_n_prime_nos.py
407
4.03125
4
num=int(input("Enter the number...")) limit=num/2 i=2 ctr=0 while i<=num: isPrime=True for j in range(2,int(i**0.5)+1): if i%j==0: isPrime=False break if isPrime==True: print(i," is a prime number.") ctr+=1 i+=1 print("The total count of prime numbers is ",ctr) #Code for finding first n prime numb...
e44eb29f3393b428dc1d285a8d9e070b2c08f881
isaac-aryan/Backup
/How to think Like a programmer/display.py
182
3.65625
4
name=input("Please enter your name.. ") age=input("Please enter your age.. ") gender=input("Please enter your gender..") print("Name: ",name,"\n\nAge: ",age,"\n\nGender: ",gender)
019e226b07c989501022cab92f0ed54379108038
vancuicide/JianZhiOffer
/2.Replace_Space.py
895
4
4
# -*-coding:utf-8-*- # 题目描述 (P51) # 请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 # 思路 # 针对一个定长数组,如果从头到尾挨个替换的话,会涉及很多字符的移动,所以想法是从后往前,遍历到空格就替换,但是对于python其实不用这么讲究 class Solution: # s 源字符串 def replaceSpace(self, s): res = '' for ele in s: if ele.strip...
8a7bc34e60b610d8c83d7f71f91dcecf16374011
emmanuelnyach/python_basics
/dict.py
757
3.84375
4
# this_dict={ # "name":"emmanuel", # "hobbies":["coding", 'reading'], # 'age': 10, # 'parents': { # 'mother':'jane' # } # } # print(this_dict['parents']['mother']) # dict = { 'name':'emmanuel', 'primary_schools':{ 'primary1':{ 'name':'st.teresa', 'tot...
6ea2887ac7d1679ca5663d773c288bbfc38b40cf
emmanuelnyach/python_basics
/algo.py
818
4.25
4
# num1 = input('enter first number: ') # num2 = input('enter second number: ') # # sum = float(num1) + float(num2) # # print('the sum of {} and {} is {}'.format(num1, num2, sum)) # finding the largest num in three # # a = 8 # b = 4 # c = 6 # # if (a>b) and (a>c): # largest=a # elif (b>a) and (b>c): # l...
e9f3f6fb6bc017d64265bac68b4b5b6cc11f8b60
lolmrpana22/calulators
/distancetimecalu.py
1,060
3.703125
4
try: distance = int(float(input(f'\u001b[34;1mWhat is the distance of miles? \u001b[35m'))) rate = int(float(input(f'\u001b[34;1mHow many miles per hour are your going? \u001b[35m'))) time = (distance / rate) hours = (time // 1) convert_decimals_time = (time % 1 * 60) seconds = (round(convert_de...
9315b94f9e076276f034d51cb172845a3aa60763
pppk520/scope_workflow_visualizer
/util/parse_util.py
751
3.6875
4
from pyparsing import * class ParseUtil(object): @staticmethod def is_extend_str_cat(the_str): ''' Check if it's string concat with numbers inside the first item must be string :param the_str: the string :return: True/False ''' item = quotedString | Word(nums)...
67f3e2641b970745dc61861d9e43825a8da1d3a4
ofirbarak/self-learnining-courses
/cs231n/assignment1/cs231n/classifiers/softmax.py
4,015
3.875
4
import numpy as np from random import shuffle def softmax_loss_naive(W, X, y, reg): """ Softmax loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples. Inputs: - W: A numpy array of shape (D, C) containing wei...
364fe4c0d1127a6613a6a566e2bd53394a71130e
VladPetrov19/Lessons
/lesson12.py
556
3.796875
4
# Список def range_number(num): return num % 3 == 0 or num % 5 == 0 range_numbers = list(range(1,1001)) print( list( filter( range_number, range_numbers ) ) ) # Квадраты списка def range_number(num): return num % 3 == 0 or num % 5 == 0 range_numbers = list(ra...
599b88945616e39bebb24245231adba8e7550db7
VladPetrov19/Lessons
/venv/lib/example.py
328
3.828125
4
class Student: Dog: str last_name: str age: int def __init__(self, dog, last_name, age): self.dog = dog self.last_name = last_name self.age = age def __str__(self): return self.dog + ' ' + self.last_name + ', ' + str(self.age) s = Student('Ivan', 'Ivanov', 21) ...
26d083191f7d9a06da742fcee90b8c338dab7145
challakarthikreddy/project_euler
/10001_prime_number.py
229
3.578125
4
count = 1 for num in range(2,10000000): prime = True for i in range(2,num): if (num%i==0): prime = False if prime: count = count +1 print str(num) + '-----' + str(count) +'st prime'
a958021525ed187fd2a7ea1dd3183c404ad75d2a
koby-ettdgy/Real-Python
/debuggig/pdb_ex.py
439
3.953125
4
import sys from random import choice import pdb random1 = [1,2,3,4,5,6,7,8,9,10,11,12] random2 = [1,2,3,4,5,6,7,8,9,10,11,12] while True: print ("To exit this game type 'exit'") num1 = choice(random2) num2= choice(random1) answer = input("What is {} times {}?".format(num1, num2)) # if answer == "exit": prin...
287ac9c40820562e71d1d3297c212fa8ff1ebfb3
koby-ettdgy/Real-Python
/SQL/sql-exercise4.py
376
3.546875
4
import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() c.execute("UPDATE invantory SET Quantity = 60000 WHERE Model = 'Civic'") c.execute("UPDATE invantory SET Quantity = 70000 WHERE Model = 'Fiest'") print ("\nNEW DATA:\n") c.execute("SELECT * FROM invantory") rows = c.fetchal...
b3c8b121c0559b7b11c070f102ecd971f7eb28fd
noyonict/Number-conversion-in-Python-3
/decimal_to_binary.py
324
4.25
4
# Convert Decimal number to Binary Number def dec_to_bin(dec_num): """Convert Decimal Number dec_num to Binary Number""" bin_num = 0 power = 0 while dec_num > 0: bin_num += 10 ** power * (dec_num % 2) dec_num //= 2 power += 1 return bin_num print(dec_to_bin(46...
3fb3185a1997ea0c23573ad963e5f5a1d5308119
elementbound/jamk-script-programming
/week 5/worker.py
1,236
3.875
4
# Exercise 5-2: Inheritance # # Create a Worker class which inherits a Person class. # Worker has two own properties: # * contractType: FullTime or PartTime # * salary: amount of monthly salary # + all properties from the Person base class (see Exercise I) from person import Person class ContractTypeError(Exception):...
03d5fa4ff4dece6cb4e00d200257353e66ce478d
elementbound/jamk-script-programming
/week 4/listsum.py
738
4.125
4
# 4-3) list calculation with type detection # # calculate sum and average of elements in the list # ignore all values in the list that are not numbers # # initializing the list with the following values # # list = [1,2,3,4,5,6,7,8,9,20,30, "aa", "bee", 11, "test", 51, 63] def is_int(val): try: val = int(va...
c7d30937119b900ae41e34a0d5be61ae7a083b8c
janellecueto/HackerRank
/Python/Itertools/IterablesAndIterators.py
441
3.609375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import combinations N = int(input()) l = input().split() K = int(input()) perms = combinations(l, K) #all combinations in l of size k count = 0 size = 0 for p in perms: size += 1 #this is really just len(pe...
4df715c5ef5e345e885b2d7d572dd6beaabe8afc
janellecueto/HackerRank
/Python/Math/TriangleQuest.py
450
3.828125
4
for i in range(1,int(input())): #More than 2 lines will result in 0 score. Do not leave a blank line also print((10**i//9)*i) # this is just plain math. '//' is floor division: # ex. (i=2) (10**2//9)*2 = (100//9)*2 = 11*2 = 22 # (i=5) (10**5//9)*5 = ...
9fa3f3a66a5774e2d01ace15e4c328caefab31b7
janellecueto/HackerRank
/Python/Collections/CollectionsOrderedDict.py
343
3.859375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT from collections import OrderedDict items = OrderedDict() for _ in range(int(input())): item = input().rpartition(" ") #rpartition - breaks string by last occurence items[item[0]] = items.get(item[0],0) + int(item[-1]) for i, q in items.it...
552f8637c1f336084b4abd16b419d9d74a698013
janellecueto/HackerRank
/Security/EncryptionScheme.py
125
3.734375
4
# Enter your code here. Read input from STDIN. Print output to STDOUT import math n = int(input()) print(math.factorial(n))
cb6346b01a59464f5afcea74c23d8693ba5fe0c5
janellecueto/HackerRank
/Python/Strings/MergeTheTools.py
493
3.59375
4
def merge_the_tools(string, k): # your code goes here l = [] for i in range(0, len(string), k): #string= AABCAAADA l.append(string[i:i+k]) #l = [AAB, CAA, ADA] for j in l: c = '' for a in range(k): if j[a] not in c: #to...
3569fdc19d592128cda6f27c7293c15c4f1ca58a
janellecueto/HackerRank
/Python/Strings/StringFormatting.py
395
3.921875
4
def print_formatted(number): # your code goes here offset = len(str(bin(number))[2:]) for i in range(1, number+1): b = str(bin(i))[2:] o = str(oct(i))[2:] h = str(hex(i))[2:] print(str(i).rjust(offset)+" "+o.rjust(offset)+" "+h.upper().rjust(offset)+" "+b.rjust(offset)) ...
83221890454fe712c7b95bd40f6bff92e0f21b27
JasonAnx/machine-learning
/Part 2 - Regression/Section 5 - Multiple Linear Regression/data_preprocessing_template.py
2,755
3.890625
4
# Data Preprocessing Template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('50_Startups.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 4].values # encode categorical data -------------------------------------...
833a11b5aa0bac7d3d22dc32b02dab6f2890139a
qwerty0981/advent-of-code
/day2_COMPLETE/day2_part1.py
485
3.90625
4
#!/usr/bin/python3 def parseLine(line): two = False three = False while line is not "": letter = line[0] c = line.count(letter) if c is 2: two = True elif c is 3: three = True line = line.replace(letter, "") if two and three: break return two, three data = [line.rstrip("\n") for line in open...
fb696f26298eb56983d32c46284b6a673542f897
mamin3118/automationProjects
/wangmen/personDemo.py
614
3.640625
4
class Person: def __init__(self,name,age): self._name= name self._age= age @property #属性 def name(self): return self._name # def get_name(self): # return self._name def rename(self,new_name): self._name = new_name p = Person('wong',12) p.name # 不用加() # prin...
0f540cb9aaabb93486b7b08488a6393d1bbabe83
wesfox/intro-to-pytest
/18_the_mocker_fixture.py
1,874
4.0625
4
""" Mock are objects used for testing in Python. It allows you to replace parts of your system under test with objects which make assertions about how they have been used. Assuming that my_mock is a mock, you can call my_mock() without any error, it will return a mock, also callable. You may also retrieve attributes : ...
c8ea3f473cb86f722a9c352cd7084174a3828e38
ecobost/featurevis
/featurevis/utils.py
2,669
3.75
4
import torch def varargin(f): """ Decorator to make a function able to ignore named parameters not declared in its definition. Arguments: f (function): Original function. Usage: @varargin def my_f(x): # ... is equivalent to def my_...
bb510d0b1d3e9b30af489969971b3702c03eaf25
Steven-Chavez/self-study
/python/introduction/numbers.py
848
4.28125
4
# Author: Steven Chavez # Email: steven@stevenscode.com # Date: 9/4/2017 # File: numbers.py ''' Expression is used like most other languages. you are able to use the operators +, -, *, and / like you would normally use them. You can also group the expressions with parentheses ()''' # addition, subtraction, multipli...
179222c8597bea4c6b35e1824ac7a1507b68737f
Steven-Chavez/self-study
/python/control-flow/for.py
562
4.09375
4
# Author: Steven Chavez # Email: steven@stevenscode.com # Date: 9/4/2017 # File: for.py # Resource: https://docs.python.org/3/tutorial/controlflow.html # The Python for statement is not the same as a for loop # The for statement reminds of the PHP and C# foreach statement # Create a list to iterate through animals = ...
d0aa2e2d247b419e477b0401033143a571beabe9
Steven-Chavez/self-study
/python/data-structures/del.py
554
3.96875
4
# Author: Steven Chavez # Email: steven@stevenscode.com # Date: 9/16/17 # File: del.py # del statement '''Unlike the pop() method the del statement does not return a value. It simply deletes the item at the given index or slice expression''' # initialize list for testing using list comprehension test = [x**2 for x in...
b909f3f7a25f8050f6a5c13ca3e042df3615be5b
amadhabib-ds/BikeShare-DataAnalytics
/bikeshare_2.py
8,311
3.84375
4
import time import pandas as pd import numpy as np from collections import defaultdict pd.set_option('display.max_columns', 30) CITY_DATA = { 'Chicago': 'chicago.csv', 'New York City': 'new_york_city.csv', 'Washington': 'washington.csv' } def get_filters(): """ Asks user to specif...
e5fe717cb01dc21004c670e19045287438a189cc
JerryAa/ProjectSophia
/perfect.py
697
3.75
4
def perfect(number): divisors = list() half = number//2 for idx in range(1, half + 1 ): if number % idx == 0: divisors.append(idx) # print('Divisors for {0} are {1} and their sums is {2}'.format(number, divisors, sum(divisors))) return True if sum(divisors) == number el...
c0efe733dca038cf3b22bae8ddb368a4cca817a5
Jogas12/PR-CTICAS-PYTH-N
/condicionales.py
133
3.875
4
a = 5 if (a > 10): print("a es mayor a 10") elif (a < 0): print("el número es negativo") else: print("el número es menor a 10")
0bc0f0e4cbdf12cfd4a15f1f5f2e272a917f5fbe
rakesh0180/PythonPracties
/classMethod.py
236
3.734375
4
class Point: def __init__(self, x, y): self.x = x self.y = y def draw(self): print(f"{self.x} and {self.y}") @classmethod def zero(cls): return cls(1, 3) abc = Point.zero() abc.draw()
7fb4ede2dbd7ba97c78af7fa5cedcef8fcbf7baf
rakesh0180/PythonPracties
/TupleEx.py
506
4.21875
4
items = [ ("p1", 4), ("p2", 2), ("p3", 5) ] # def sort_item(item): # return item[1] # print(item.sort(key=sort_item)) # print(item) # using lambada we avoid above two statement items.sort(key=lambda item: item[1]) print(items) # map x = list(map(lambda item: item[1], items)) print("map", x) # fil...
98629b4dbea4d216033ef5fc5d73ae79a8562107
sabujdaas/crypto
/Leet_Label_02.py
5,756
3.65625
4
# (a to m) a b c d e f g h i j k l m item_5 = ["4", "8", "(", "δ", "3", "}", "9", "#", "!", "]", "X", "1", "ψ"] # (n to z) n o p q r s t u v w x y z item_6 = ["~", "0", "?", "σ", "2", "5", "7", "μ", "√", "≜", "*", "λ", "%"] while True: ...
351d0ea4da6594b318e8ca1319bd92c24ce413cc
shanidoger/Python-Practice-Projetcs
/writeNumeric.py
463
4.0625
4
''' write your pay program using try and except so that your program handles non-numeric input gracefully. Enter Hours: 20 Enter Rate: nine Error, please enter numeric input Enter Hours: forty Error, please enter numeric input ''' def GrossPay(): hours = int(input("Enter Hours: ")) rate = int(input("Enter Rate...
e143f989122e98cebf3dd9fb0445406c8b4786d5
bernard30653/comp_programming
/single_cycle.py
594
3.59375
4
# This is a question from algoexpert Single Cycle Check # Given an array where each element represent the number of jumps(i.e. 2 means 2 indices forward # and -4 means 4 indices backward # Check if an input array is such that there is a single cycle def hasSingleCycle(array): # Write your code here. arrLen = le...
e2f846697e1453763c8c021cf7a327d1e8f8b63a
hhj0325/pystock
/com/hhj/pystock/ml/__init__.py
1,441
3.90625
4
""" 关于朴素贝叶斯 朴素贝叶斯算法是一个直观的方法,使用每个属性归属于某个类的概率来做预测。你可以使用这种监督性学习方法,对一个预测性建模问题进行概率建模。 给定一个类,朴素贝叶斯假设每个属性归属于此类的概率独立于其余所有属性,从而简化了概率的计算。这种强假定产生了一个快速、有效的方法。 给定一个属性值,其属于某个类的概率叫做条件概率。对于一个给定的类值,将每个属性的条件概率相乘,便得到一个数据样本属于某个类的概率。 我们可以通过计算样本归属于每个类的概率,然后选择具有最高概率的类来做预测。 通常,我们使用分类数据来描述朴素贝叶斯,因为这样容易通过比率来描述、计算。一个符合我们目的、比较有用的算法需要支持数值属性,同时假设每一个...
7ae40c0747cfa2b71e0ea3ece49fe1d2076395da
hhj0325/pystock
/com/hhj/simplecode/demo6.py
1,652
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys """a test module """ __author__ = 'Michael Liao' def func1(): args = sys.argv print(args) if len(args) == 1: print('Hello, world!') elif len(args) == 2: print('Hello, %s!' % args[1]) else: print('Too many arguments...
7d1d9a1997ec0ad4df02b524784e424cd8a31d95
devcybiko/DataVizClass
/Week3/RockPaperScissors.py
812
4.125
4
import random while True: options = ["r", "p", "s"] winning_combinations = ["rs", "sp", "pr"] ### for rock, paper, scissors, lizard, spock... # options = ["r", "p", "s", "l", "x"] # winning_combinations = ["sp", "pr", "rl", "lx", "xs", "sl", "lp", "px", "xr", "rs"] user_choice = input(options) ...
2eb1b66b3eaf7fb12b3e32ae3b1680a09e4da4c4
lohasle/webSpider
/thread/demo1.py
597
3.84375
4
import threading import time def writing(): while True: print('thread %s is writing...' %threading.current_thread().name) time.sleep(5) def painting(): while True: print('thread %s is painting...' %threading.current_thread().name) time.sleep(5) def main(): # 通过threading模块配...
28dc9491680f0487e992277f1bedf98dbbcf4b8f
lohasle/webSpider
/thread/demo2.py
595
4.03125
4
import threading import time # 从 threading.Thread 继承创建一个新的子类,并实例化后调用 start() 方法启动新线程,即它调用了线程的 run() 方法: class Writing(threading.Thread): def run(self): for x in range(1,5): print('%s is writing' % threading.current_thread()) class Painting(threading.Thread): def run(self): for x in...
f906d946bbff1eb8a8431c4711f9e1292b46a12a
lohasle/webSpider
/csv/demo2.py
523
3.65625
4
import csv # 将python中字典数据保存为csv文件 headers = ['class','name','sex'] rows = [ {'class': 1,'name':'jack','sex':'male'}, {'class': 2,'name':'lucy','sex':'female'}, {'class': 3,'name':'lily','sex':'female'} ] with open('2.csv','w',encoding='utf-8') as fp: # 创建一个DictWriter对象,参数为一个文件对象fp,一个表头headers wri...
62e75902fa73c4b3cf3c0efbbeff4e928cb80119
BENLINB/Practice-assignment-for-Visual-Studio
/Generate username.py
536
4.125
4
#Problem2 #writing programm that would prompt the username in the format Domain Name-Username. print("#######################################") print("WELCOME TO DBS CONSOLE") print("#######################################") #asking the user to input his credentials student=input("enter username") index= s...
ffa0ff5ec747288ef1eb88fa742810f6d57977b1
gopalakrishna/eulers-python-gopal
/2.py
1,677
3.859375
4
""" This file is part of the set of solutions to Project Euler # Copyright (C) 2011 Gopalakrishna Bhat A <gopalakbhat@gmail.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; ei...
3b6ff7d431fd0c19b3946f7bf6aea64d496be738
gopalakrishna/eulers-python-gopal
/1.py
1,722
3.765625
4
""" This file is part of the set of solutions to Project Euler # Copyright (C) 2011 Gopalakrishna Bhat A <gopalakbhat@gmail.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; ei...
db48caea82b3ac1e70b11a992488d297a0da80ba
prince5609/Leet_Code
/Decimal_Binary.py
434
3.65625
4
def decimal(a): i = 0 sums = 0 while a != 0: rem = a % 10 sums += rem * pow(2, i) i += 1 a = a // 10 return sums print(decimal(11001)) def binary(num): d = num // 2 rem = num % 2 sums = rem while d != 1: rem = d % 2 d = d // 2 s...
599ecf8e936096c23c02615562f20d5eaf8a2b0e
prince5609/Leet_Code
/Max_Deapth_Binary_Tree.py
579
4.15625
4
# Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes # along the longest path from the root node down to the farthest leaf node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left sel...
1ecb239ec7b4cf8244f81b4d9cf4ad0cf3e45a9c
mzntaka0/ocra
/ocra/typedocs/basedoc.py
500
3.53125
4
# -*- coding: utf-8 -*- """ """ from abc import abstractmethod, ABCMeta class Basedoc(object, metaclass=ABCMeta): """ Args: """ @abstractmethod def read_lines(self): """ This method have to have the features below. - load document from document_Path - reco...
f72a6650ad5c110b15b2e6e7632fdfda37cd9b95
AntoineKhoury/DeepLearningVisionChip
/Sequential CNN Keras/Basic_Sequential_CNN.py
2,207
3.671875
4
# Multiple libraries required to import, visualize and treat the data import matplotlib.pyplot as plt from keras.utils import to_categorical from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Conv2D, Flatten #already splitted in train and test (x_train, y_train), (x_t...
a0d4f9f823847403700707ce540fa1b6e7aef386
Nitin-K-1999/Python_script
/Sample Script 1.py
504
4.34375
4
# A list of cricket team is given below. Print the number of possible matches between each of them. Also print each possible match in the format team1 vs team2. team_list = ['CSK','RCB','Sun Risers','Deccan Chargers','Mumbai Indians'] matches = [] for index in range(len(team_list)) : for team in team_list[i...
54a2f9db559f9735c4c5c120c55290f81b5741af
dib-lab/msu-cse491-2013
/day9/try5.py
216
3.59375
4
class Klassy(object): def __init__(self, n): self.n = n def val(self): def g(m): return 3 * self.n + m return g k = Klassy(4) fn = k.val() k.n = 8 print fn(4)
a65b1e857a1c0ff05952b42a12eef83aceffe684
jaikishanEngg/GeeksForGeeks
/Closest_Number.py
708
3.59375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 22 22:55:41 2019 @author: v-jaimo """ ''' Closest number print the closest number to N which is also divisible by M ''' def closest(n,m): q = int(n/m) if((n*m) > 0): v2 = m * (q + 1) else: v2 = m * (q - 1) v1 = m * q #whichever c...
43235a7fd0d901b600ffc7572daf71babc62da7d
jaikishanEngg/GeeksForGeeks
/Binary_to_Decimal.py
419
3.734375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 22 04:33:33 2019 @author: v-jaimo """ '''Binary number to decimal number''' output = [] # read testcases T T = int(input()) if((T > 1) & (T < 100)): #iterate through the each test case for i in range(T): #read the number in binary using the para...
4297bebbf2560a5de889b32cb66e79c7ed2ade70
jaikishanEngg/GeeksForGeeks
/list.py
667
3.5
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 6 02:12:11 2019 @author: v-jaimo """ N = int(input()) li = [] output = [] for line in range(N): cmd, *values = input().split() if(cmd == 'insert'): i = int(values[0]) v = int(values[1]) li.insert(i,v) if(cmd == 'print'): outpu...
7aef3df62352c285f3a57aad1be1a3288ec3330e
eduaga/farm
/main.py
2,485
3.828125
4
class Animal: hungry = True name = '' color = '' weight = 0 can_eat = 0 animal_name = '' sound = '' def __init__(self, name, color, weight): self.color = color self.name = name self.weight = weight def feed(self): self.hungry = False self.weight += self.can_eat return 'Not hu...
8bd65ffebd51ac1fe051969e9dc0f5600273219c
hannahmknerr/learnpython
/threecard.py
1,150
3.96875
4
from random import * def main(): end = 0 round = 1 while end == 0: print("Round", round) pick = getPick() print("You chose: %s" % (pick)) options = 'A', 'B', 'C' queen = choice(options) if queen == pick: print("You win!") print("It onl...
154f031f13b28e9bdece5b3a58a7776c6a34b440
WytheLi/data_structures_and_algorithms
/sorting_algorithms/insertion_sort.py
573
4.03125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Author : willi # @Email : willi168@163.com # @Description: 插入排序 def insert_sort(alist): # 从第二个位置,即下标为1的元素开始向前插入 for i in range(1, len(alist)): # 从第i个元素开始向前比较,如果小于前一个元素,交换位置 for j in range(i, 0, -1): if alist[j] < alist[j-1]: ...
00a2572f560cb1d72bb1362ea3dfc98912c11103
WytheLi/data_structures_and_algorithms
/linked_list/__init__.py
1,013
3.984375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Author : willi # @Email : willi168@163.com # @Description: class LinkedListBase(object): def __init__(self): self._head = None # 头节点 def is_empty(self): return self._head is None def length(self): cur = self._head count = 0 ...
8c06e095ad162dd530d353d095ce8ff6124296c9
csking0/adventuretext
/adventureText.py
16,610
3.5
4
import sys import time from threading import Timer import random import traceback class Game: def __init__(self): self.win = False self.room = 1 self.firstTime = True self.playerHealth = 100 self.minotaurHealth = 100 self.roomSixTurnCounter = 0 def exit(self)...
8b9caaad0681b417281c819f7938f09aea8976e1
dinghenc/AlgorithmBasis
/4_1_DC.py
607
3.671875
4
def divide_land(height, width): # 大者为width, 小者为height if height > width: temp = height height = width width = temp if width % height == 0: # 基线条件, 可以完整的分成正方形 return height else: # 递归条件, 分而治之 return divide_land(width % height, height) def sum_...
441a4abef21f430ae4b9fccd320d76a5e14ccb94
sprinfall/study
/code/py/is_ascii.py
1,628
3.640625
4
# -*- coding: utf-8 -*- """ -------------------------------------------------------------------------------- is_ascii.py 2009-06-15, adam gu <sprinfall@gmail.com> check if a given file is encoded in ASCII. only support checking for the following file types: - .h, .hpp, .c, .cpp, .cc, .cxx usage: $ is_ascii.py...
d195d539706595e79ed187db6038c07d2623925b
NeuralNetworksUSB/Adaline
/GradientDescent.py
1,048
3.53125
4
# GradientDescent.py """ Autor: Arturo Toro Carnet: 12-10796 Carrera: Ingenieria en computacion - USB """ import numpy as np # W(n+1) = W(n) - lr*dE(W)/dW # Descenso de gradiente: Cauchy def LMS(X, d, f, alfa): """ En la actualizacion continua se presenta un dato a la vez y se actualizan los pesos. # Consideracion...
e8cc98c7c911fbb3975762e9866af060c786d219
sayohnahilan/PathfindingVisualisations
/SearchAlgorithms/depthFirst.py
1,153
3.671875
4
import queue from colours import * from SearchAlgorithms.backTrack import backtrack def depthFirst(self): # a queue to store nodes to check / travel to next myQueue = queue.LifoQueue() myQueue.put(self.start) # for every node in queue while not myQueue.empty() and self.atEndNode == False: ...
8410c98c7fddcb1239a339d23fe20cf7cdbd6c9e
Sudhanshu277/python
/input2.py
513
3.859375
4
a = int(input("Enter the 1st number :")) b = int(input("Enter the 1st number :")) add = a+b ; print("add = " ,add) c = int(input("Enter the 1st number :")) d = int(input("Enter the 1st number :")) rim = c%d print("remainder", rim) e = int(input("Enter the 1st number :")) f= int(input("Enter the 1st number :")) av...
ba64da4d1691696c38c761e66914063023afbdbc
Sudhanshu277/python
/comparsion.py
90
3.640625
4
a= 5 b = 3 x= 4 y=4 print(a==b) print(a>b) print(a<b) print( x!=y) print(x>=y) print(x<=y)
fa8017713c3454e582a3ce5f19b345fa1f203ca5
Sudhanshu277/python
/ifelifpractice.py
413
3.90625
4
a = input("Enter you location:\n") b = int(input("Enter you distance(km) from your college:\n")) if(b<10 and a=="gwalior"): print("you can submit your sheet in your college") elif(b>10 and a=="gwalior"): print("your nearest college are : \n 1.mulsimbord 2. agra college") elif(b>=20 and b<=20 and a=="gwalior")...
43b0db75da79025886538baecc850cae9866ee8f
Sudhanshu277/python
/list(if).py
413
3.984375
4
# names = ["ram","vikas","rohit"] # a = input("enter your name") # if a in names: # print("yes your name is ther") # else: # print("no") marks = int(input("Enter Your Marks\n")) if marks>=90: grade = "A++" elif marks>=80: grade = "A+" elif marks>=70: grade = "B+" elif marks>=60: grade = "B...
163c1341d241a08c00d2ba7297ac4eb5798799c1
Sudhanshu277/python
/letter.py
589
4.09375
4
# letter = ''' dear <|NAME|>, # You are selected ! # Have a great day ahead! # thanks and regards, # pninfosys # DATE : <|DATE|> # ''' # name = input("enter your name\n") # date = input("enter date\n") #letter = letter.replace("<|NAME|>" , name) # letter = letter.replace("<|DATE|>" , date) # print(letter) # s = "pni...
9550534f45044d9b5ee3c3cf3543b39fc2d123b6
Sudhanshu277/python
/list.py
373
4.21875
4
# crete a list using [] a = [1, 3, 4,5,6,"pninfosys"] #index 0 start print(a) #access using index using a[0] , a[1] print(a[2]) #change the value of list using a[0] = 40 print(a) #we can crete a list with items of different types c = ["pnifosys" , 12,False,7.5] print(c) #list slicing pn = ["vikas" , "ram" , "rohan"...
ed2a09190f7a0140eccc63ae25a2c73fcca33a0d
prashanthr11/HackerRank
/Problem Solving/Implementations/Repeated String.py
512
3.796875
4
#!/bin/python3 import math import os import random import re import sys def repeatedString(s, n): if len(s) < n: cnt = s.count('a') * (n // len (s)) return cnt + repeatedString(s, n % len(s)) else: s = s[:n] return s.count('a') if __name__ == '__main_...
0289340834c28ba7154df4a3fc754231ade9834f
prashanthr11/HackerRank
/Problem Solving/Trees/Is This a Binary Search Tree?.py
488
3.75
4
""" Node is defined as class node: def __init__(self, data): self.data = data self.left = None self.right = None """ def isbst(root, mini = -98798798797, maxi = 9797979797979): if not root: return True if root.data <= mini or root.data >= maxi: return False lft ...
8c803bd9c5b99c02e2ca681c97821843f7941fdd
prashanthr11/HackerRank
/Sparse Arrays.py
205
3.65625
4
n = int(input()) l = list() for i in range(n): s = input() l.append(s) n2 = int(input()) l2 = list() for i in range(n2): s = input() l2.append(l.count(s)) for i in l2: print(i)
a7fa0c065804d31a0a25174d5612f911dd960578
fraidaL/SF_DAT_15_WORK
/hw2.py
3,986
3.5625
4
##### Part 1 ##### import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression from sklearn.cross_validation import train_test_split from sklearn import metrics import statsmodels.formula.api as smf import seaborn as sns import matplotlib.pyplot as plt # 1. read in the yelp dataset yelp = ...
f3c84049aeee00c14ad02c6e181fa81d13cedbe0
tiantian-li/pythonstudy
/lesson02/zhishu.py
261
3.5625
4
print('100以内的质数为:') count=0 s=0 for i in range(1,101): for j in range(2,i): if i%j == 0: s=1 break if s==0: print(i) count+=1 s=0 print ('一共有质数%d个:'%count)
f7863021e85446a96430e0e20e4c45e2da26a585
rituteval/problem-set-1
/Q10.py
328
3.515625
4
import numpy import matplotlib.pyplot #x axes x = numpy.array([0, 1, 2, 3, 4]) #y axes y = numpy.array([0, 1, 2, 3, 4]) # RO is X matplotlib.pyplot.plot(x,y, 'r-') # BO is X^2 matplotlib.pyplot.plot(numpy.square(x), y, 'b-') # YO is 2^X matplotlib.pyplot.plot(2**x, y, 'y-') matplotlib.pyplot.sho...
6131421913914723fbdf9fdda188a7897f5447a7
ABPande/MyPythonRepo
/Python/Basics/py_R3/NumpyArray.py
1,344
3.609375
4
mylist = [1,2,3] listoflists= [[1,2,3],[4,5,6],[7,8,9]] import numpy as np arr = np.array(mylist) print (arr) matarr = np.array(listoflists) print (matarr) nprangearr = np.arange (0,11,2) print (nprangearr) npzerosarr = np.zeros(3) print (npzerosarr) npmatzeros = np.zeros((2,3)) print (npmatzeros) evenlyspacedarr = np....
75465c207416d737acba4da872be18039e1508a2
ABPande/MyPythonRepo
/Python/Basics/py_R1/test.py
371
3.515625
4
import random print(random.randint (1,52)) l1 = [1,2] l2 = [3,4] l1.append(l2) print (l1) print (list(range(1,53))) l1 = [[x,int((x-1)/13)+1,False,x] for x in range(1,53)] for item in l1: modRes = item[0]%13 if modRes >= 2 and modRes <=10: item[3] = modRes if modRes == 1: item[3] = 11 if (modRes > 10 and modRes...