blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
beaf525e63162d3622dc2a92539f5d9c06aa55cb
slamdunk0414/python
/3.字符串列表数组/9.for循环中的else.py
85
3.671875
4
nums = [11,22,33,44] for num in nums: print(num) else: print('循环完毕')
b7497c0e6ed896dbd94591d97ccbc2e3a91069a3
slamdunk0414/python
/4.元祖函数/5.函数的嵌套调用.py
301
3.6875
4
def test1(): print('test1') test2() def test2(): print('test2') test1() def input_num(): return int(input('请输入一个数字')) def add(): total = 0 num1 = input_num() num2 = input_num() num3 = input_num() total = num1 + num2 + num3 print(total) add()
db5eeb28857a086ed10ac3bbc93db809f18806d4
slamdunk0414/python
/7.面向对象/10.类属性.py
277
3.96875
4
class Tool(object): num = 0 def __init__(self,new_name): self.name = new_name Tool.num += 1 self.num2 = 0 self.num2 += 2 t1 = Tool('t1') t2 = Tool('t2') t3 = Tool('t3') print(Tool.num) print(t1.num2) print(t2.num2) print(t3.num2)
90d2b350864993b362c197cd6d13dc7b577a2f62
Arsher123/Wizualizacja-danych-BartoszN
/lab6/zad7.py
362
3.53125
4
import numpy as np def funkcja(n): macierz=np.zeros((n,n)) #tworzymy przekatne for i in range(n): macierz=macierz+np.diag(np.linspace(2*(i+1),2*(i+1),n-i),i) if (i!=0): macierz=macierz+np.diag(np.linspace(2*(i+1),2*(i+1),n-i),-i) return macierz n=input("podaj rozmi...
3f2e50cc26a76b1ef4f4595b12ccecf4417960da
Arsher123/Wizualizacja-danych-BartoszN
/lab7/zadanie2.py
480
3.703125
4
import numpy as np a=np.array([9,5,1,4,6,2,7,3,5]).reshape(3,3) b=np.array([1,6,8,4,11,16,9,5,14,10,15,2,13,3,12,7]).reshape(4,4) print("Pierwsza tablica: ") print(a) print("Najmniejsze wartosci kazdego rzedu: ") print(a.min(axis=1)) print("Najmniejsza wartosc kazdej kolumy: ") print(a.min(axis=0)) print("Drug...
e7a9c53e005411ab69f183ea2fa4c448aa5afb40
Arsher123/Wizualizacja-danych-BartoszN
/Zadania cw3/zadanie 4.py
286
3.703125
4
import math print("funkcja y=ax+b") a=input("podaj liczbe a: ") a=int(a) if a > 0: print("a jest wieksze od 0 zatem funkcja jest rosnaca ") if a < 0: print("a jest mniejsze od 0 zatem funkcja jest malejaca") if a==0: print("a jest rowne 0 zatem funkcja jest stala")
9600558ef3ed872f6644678992de0fb77206298b
yookie-bui/Rock-Paper-Scissor-game
/rps-Gui.py
1,464
3.53125
4
from tkinter import* import random class rpsGui: def __init__(self, parent): self.name_label = Label(parent, text='Rock Paper Scissor') self.name_label.grid(row=0,column=0,columnspan=2, pady=10) self.user_entry = Entry(parent, width=12) self.user_entry.grid(row=1,column=0,padx=5) ...
ff1a9b191b3bf4ec35cefa1e2ef63485b684b4ef
danielcaballero88/dc_Multiscale-Nanofibers-2_gitlab-bu
/ejemplo_1d.py
2,150
3.65625
4
""" Este ejemplo es una simulacion de un caso de 1d resuelto aparte son dos barras de longitudes l1=5 y l2=7. La barra 1 esta anclada en x=0, en x=5 están conectadas (nodo) y el extremo de x=12 se lleva hasta x=20 Entonces se encuentra un nuevo punto de equilibrio El resultado es completamente acorde a la simulacion 1...
65dcc7f9b80d722f12c01381dbe6b5d4473c681c
kiukin/codewars-katas
/7_kyu/Reversing_fun.py
906
4.09375
4
# Kata: Reversing Fun # https://www.codewars.com/kata/566efcfbf521a3cfd2000056 # You are going to be given a string. # Your job is to return that string in a certain order that I will explain below: # Let's say you start with this: 012345 # The first thing you do is reverse it:543210 # Then you will take the string...
7144bc7f17c0fd35a31e83a3bb8dd245a90ef61d
kiukin/codewars-katas
/7_kyu/Simple_string_characters.py
752
4.03125
4
# Kata: Simple string characters # https://www.codewars.com/kata/5a29a0898f27f2d9c9000058 # In this Kata, you will be given a string and your task will be to # return a list of ints detailing the count of uppercase letters, lowercase, # numbers and special characters, as follows. # solve("*'&ABCDabcde12345") = [4,5...
7424e3d1c91b4052176e86aeedc9261a86490a14
kiukin/codewars-katas
/7_kyu/Descending_order.py
546
4.125
4
# Kata: Descending Order # https://www.codewars.com/kata/5467e4d82edf8bbf40000155/train/python # Your task is to make a function that can take any non-negative integer as a argument and # return it with its digits in descending order. Essentially, rearrange the digits to # create the highest possible number. # Exam...
61f43a56471e46893f9fe07227ea44161256a5d8
kiukin/codewars-katas
/7_kyu/Counting_array_elements.py
331
3.828125
4
# Kata: Counting Array Elements # https://www.codewars.com/kata/5569b10074fe4a6715000054 # Write a function that takes an array and counts the number of each unique element present. # count(['james', 'james', 'john']) # #=> { 'james' => 2, 'john' => 1} from collections import Counter def count(array): return Cou...
d2e683c7666f55bd51ca159822307bfc0136a253
aces8492/py_edu
/applications/vgood.py
514
3.515625
4
import sys vsize = int(input()) if (vsize % 2 == 0) or (vsize > 100): print("invalid") sys.exit() for i in range(vsize,0,-1): for j in range(1,vsize+1): if i == 1: if j == (vsize+1)/2: print("v",end="") else: print(".",end="") else: ...
79ce2fe95e1a8ccba8095daa0db9d57168192e71
aces8492/py_edu
/basics/slice.py
597
3.953125
4
score_lists = [40,50,60,70,100] score_tuple = (40,50,60,70,100) print("Value and this num") for i,score in enumerate(score_lists): print("{0}:{1}".format(i,score)) print("specify start and end point of value 1 to 4") print("list : {0}".format(score_lists[1:4])) print("tuple : {0}\n".format(score_tuple[1:4])) pri...
e4c63508ac697f87c6934b2520666027a15ee894
aces8492/py_edu
/basics/Comprehension_notation.py
815
3.9375
4
#comprehension notation (C_N) #range() is iterable print([i for i in range(10)]) #generate range object print(range(10)) #making list from iterable (range object) print(list(range(10))) #using C_N map like usage print([i*3 for i in range(10)]) #same processing using map print(list(map(lambda x:x*3,range(10)))) #usi...
cd583aca69c3e7153884032017e2cb6a336f6e24
aces8492/py_edu
/basics/multi_inferitance.py
417
3.75
4
#class A,B -> C class A: def say_a(self): print("in A") def say_hi(self): print("hi A") class B: def say_b(self): print("in B") def say_hi(self): print("hi B") class C(B,A): pass instance_c = C() instance_c.say_a() instance_c.say_b() ''' if exist same instance nam...
8fd9dc373ee53a51250597f8d07b0075c868c011
kabirs/python
/99.py
200
3.84375
4
#!/usr/bin/env python3.3 basevalue=15 for a in range(1,basevalue): for b in range(1,basevalue) : if a>=b : print(repr(b).ljust(1)+"x"+repr(a).ljust(1)+"="+repr(b*a).ljust(3),end=' ') print('')
dc15053c612f0828e00738b1b5b22fcab47f8fab
MelanieArzola/AprendiendoPython
/Tabla.py
287
4.03125
4
# Melanie Arzola 16/09/2019 #Pides el numero que quieren tabla= int(input("Dame un numero del 1 al 9: ")) if tabla >9 or tabla <1: print("Este valor no es permitido") else: for i in range(1,11): salida= "{} x {} = {}" print(salida.format(tabla,i,i*tabla))
9059e5a2b1d99f12c4437e30cef9358a14fe4cf1
ersujalsharma/PythonPractice
/14_Swap_Two_Numbers_Common.py
81
3.5625
4
a= int(input()) b= int(input()) temp = a a = b b = temp print("a",a) print("b",b)
c78659011ed28a9d2c37a2e42214107ee317c31a
ersujalsharma/PythonPractice
/24_Quiz3.py
190
4.0625
4
while True: a = int(input("Enter a Number")) if a>100: print("COngrats You Have Enter Greater Than 100") break else: print("Wrong Input") continue
89c8905424a8b6d9f5d346b3f2fe82e1bf715636
ersujalsharma/PythonPractice
/47_args_and_kargs.py
301
4.03125
4
list = [] def function_add(*args): sum=0 for i in args: sum=sum+i return sum print("Enter numbers you want to add Enter c for REsult") while(1): number = input() if(number == 'c'): break list.append(int(number)) summation = function_add(*list) print(summation)
044c6ad5e47e02265d8c5af88460935dd4b80c5d
ersujalsharma/PythonPractice
/32_FileWritingOperation.py
109
3.53125
4
f = open("Hello.txt","w") f.write("HEy Pagla") print(f) f = open("Hello.txt","a") a = f.write("Sujal sharma") print(a)
33472ccb0008747c75097fd980344f2e7839f692
J100130098/Functional-Turtle-Art-Gallery
/FunctionalTurtleArtGallery.py
933
3.640625
4
import turtle Roger=turtle def hexagon(): for i in range(6): Roger.forward(150) Roger.right(60) def octagon(): for i in range(8): Roger.forward(50) Roger.left(45) def octagonLoop(): for i in range(80): octagon() Roger.right(5) def dodecagon(): ...
cbe5f99c9a95a4e3c2ed8ef05b7fbfff8a52380a
Yuhsuant1994/leetcode_history
/solutions/1_linkedlist.py
2,252
3.5625
4
class ListNode(object): def __init__(self, val=0, next=None): self.val=val self.next=next class Solution(object): def maxDepth(self, root): """ :type root: TreeNode :rtype: int """ level, current_max=0,0 check_later=list() if root: ...
1e3515ec7e6cda2d5edda61a283debeae79049fa
Yuhsuant1994/leetcode_history
/solutions/median_string_toint.py
2,719
3.828125
4
""" Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function). The algorithm for myAtoi(string s) is as follows: Read in and ignore any leading whitespace. Check if the next character (if not already at the end of the string) is '-' or '+'. Read thi...
781fb17c04ac87a118aca8853e7a58837a61942d
Yuhsuant1994/leetcode_history
/solutions/average_levels_in_binary_tree.py
1,428
4.03125
4
""" Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 11] Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. Hence return [3, 14.5, 11]...
fd4e7f629a05d36875bbe8f3ee9e6d5ecab1d8e3
Asabeneh/Fundamentals-of-python-august-2021
/week5/list-comprehension.py
508
3.875
4
countries = ['Finland','Sweden','Denmark','Norway','Iceland'] nums = [1, 2, 3, 4, 5] # [1, 4, 9, 16, 25] new_nums = [n ** 2 for n in nums] print(new_nums) country_codes = [c.upper()[:3] for c in countries] print(country_codes) countries_with_land = [c for c in countries if 'land' in c] print(countries_with_land) count...
36a0cb1db271953430c191c321286014bc97ed6d
Asabeneh/Fundamentals-of-python-august-2021
/week-2/conditionals.py
997
4.40625
4
is_raining = False if is_raining: print('I have to have my umbrella with me') else: print('Go out freely') a = -5 if a > 0: print('The value is positive') elif a == 0: print('The value is zero') elif a < 0: print('This is a negative number') else: print('It is something else') # weather = in...
27b0269da0ce0d4c3723623a4058f4f2bfa31fa7
Asabeneh/Fundamentals-of-python-august-2021
/week4/revision.py
1,146
3.703125
4
countries = ['Finland','Sweden','Denmark','Norway','Iceland'] print(len(countries)) print(countries[0]) print(countries[1]) print(countries[-1]) print(countries[-2]) # append, extend, pop, remove, del, insert etc nums = [1, 2, 3, 4, 5] # [1, 4, 9, 16, 25] new_nums = [] for i in nums: new_nums.append(i * i) print...
8d58e8c62c213af074d36c67a413cf4212f13eec
djdd01/CS50-2020
/pset6/credit/credit.py
2,221
3.984375
4
from sys import exit from cs50 import get_int # ok so first of all creating a long variable to get a card number as an input card = get_int("What is your credit card number? \n") temp = card # creating another variable temp to utilize instead of making changes in card alt = 0 # alternate digits adj = 0 # alt altern...
2e1146369916a05e2abed687a431935a3f7788e5
salehas222/Dataquest_Data_Analyst_In_Python
/Step_2_Intermediate_Python_and_Pandas/6_Data_Cleaning_Project_Walkthrough/Challenge_ Cleaning Data-102.py
1,839
3.671875
4
## 4. Filtering Out Bad Data ## import matplotlib.pyplot as plt true_avengers = pd.DataFrame() #avengers['Year'].hist() true_avengers = avengers[avengers["Year"] > 1960] true_avengers['Year'].hist() ## 5. Consolidating Deaths ## col_death = ["Death1","Death2","Death3","Death4","Death5"] #for col in col_death: # ...
e765080b8821dd0cf37aee8298468cdaf08c320c
salehas222/Dataquest_Data_Analyst_In_Python
/step_5_Probability_and_Statistics/2_statistics_intermediate/Measures of Variability-308.py
5,705
3.8125
4
## 1. The Range ## import pandas as pd houses = pd.read_table('AmesHousing_1.txt') houses.head() def find_range(array): return max(array) - min(array) years = houses['Yr Sold'].unique() years range_by_year = {} for year in years: range_by_year[year] = find_range(houses[houses['Yr Sold'] == year]['SalePrice']...
313b4139cb12025d115123870bf769d8368091b9
verito-stanger/PythonPractice
/Conditions.py
1,357
3.84375
4
#----Conditions---- # Operators #Variables Integer = 0 Float = 0 String = "Mikey" Boolean = True Array = [1, 3, 4, 8, 76] Dictionary = {'Papagayo':'objeto', 'Patilla':'fruta'} Tuple = (12,25) Array2 =[] #validation = type(Tuple) """if (Integer <= 10): print("Si es menor a 10") if (Boolean): pri...
d6e5435f634beb7a11f6095bb3f697fbeb426fb8
hossein-askari83/python-course
/28 = bult in functions.py
898
4.25
4
number = [0, 9, 6, 5, 4, 3, -7, 1, 2.6] print("-----------") # all , any print(any(number)) # if just one of values was true it show : true (1 and other numbers is true) print(all(number)) # if just one of values was false it show : false (0 is false) print("-----------") # min , max print(max(number)) # show m...
e1dbf5bf24acd79b8f81ee414ec7b9fd815285d3
hossein-askari83/python-course
/39 = decorator.py
912
3.828125
4
class user : def normalFunction(self): print("this is normal function") print(self) # print("--------------------------------------------------") @classmethod def functionWithDecorator(cls): print("this is function with decorator") print(cls) example = user() example.normalFuncti...
f6380219eed1fb33a23997c9c6952693edf37a51
hossein-askari83/python-course
/38 = login example.py
1,099
3.890625
4
class users : activeUsersCount = 0 activeUsersList = [] allowedUsers = ["ali", "hossein" , "iman" , "javad" , "sara"] def __init__(self , userName , userFamily): self.name = userName self.family = userFamily def login(self): if self.name not in users.allowedUsers : ...
58ddeb4812eda53fd74c23fb258479449194869e
hossein-askari83/python-course
/9 = condision.py
314
4.03125
4
# condition logic = true or false # we whant giva medals to sporters print("please enter youre rank ") rank = int(input()) if rank == 1 : print("you got the GOLD medal ") elif rank == 2 : print("you got the SILVER madal ") elif rank == 3 : print("you got the BRONZE medal ") else : print("ridi")
6031ee42849ca64aafd9ae7829f83c207e0966af
ashleyjohnson590/CS162Python-Project7
/LinkedList1.py
6,229
4.25
4
#Author: Ashley Johnson #Date: 5/7/2021 #Description: Program adds and removes a node to the linked list, searches the linked list for a #value, inserts a node into the linked list at a specific value, reverses the linked list, and returns #the linked list as a regular python list, and returns the node object that ...
4b77591a779a29ea29cad5805a335ee7b5b9da5f
rintukutum/functional-gene-annotation
/fact_function.py
205
4.15625
4
def factorial (n): f = 1 while (n >0 ): f = f * n n = n - 1 return f print("Input your number") n= int(input()) print ("factorial of your input number:", factorial(n))
a0e243a830e5b91d7f4081784700dee2ed58289b
Victoria-DR/codecademy
/computer-science/veneer/script.py
2,340
3.578125
4
import datetime class Art: def __init__(self, artist, title, year, medium, owner): self.artist = artist self.title = title self.year = year self.medium = medium self.owner = owner def __repr__(self): return f"{self.artist}. \"{self.title}\". {self.year}, {self.medium}. {self.owner.name}, {...
f7df70c87749177fdb0473207659ba0ee49741c0
beyzakilickol/week1Wednesaday
/palindrome.py
591
4.15625
4
word = input('Enter the word: ') arr = list(word) second_word = [] for index in range(len(arr)-1, -1 , -1): second_word.append(arr[index]) print(second_word) reversed = ''.join(second_word) print(reversed) def is_palindrome(): if(word == reversed): return True else: return False print(i...
c86ab1fe4371066a37d70f6d5b4459325e54ed90
beepboop271/programming-contest-stuff
/CCC-03-J1.py
156
3.578125
4
t = input() s = input() h = input() for i in range(t): print '*'+(' '*s)+'*'+(' '*s)+'*' print '*'*(3+(2*s)) for i in range(h): print ' '*(s+1)+'*'
24f522cdedbbbe2c80fb94ba468f366102de7d06
beepboop271/programming-contest-stuff
/CCC-15-J1.py
248
4.125
4
month = input() day = input() if month < 2: output = "Before" elif month > 2: output = "After" else: if day < 18: output = "Before" elif day > 18: output = "After" else: output = "Special" print output
58da502d8cb88dd2e406c8715e1256977240583a
beepboop271/programming-contest-stuff
/CCC-13-S1.py
213
3.859375
4
year = input() valid = False while not valid: year += 1 yearList = list(str(year)) valid = True for letter in yearList: if yearList.count(letter) > 1: valid = False print year
1238f6ef46f90f7e0ad22ba5a1062f6a5a0d94fc
crashb/AoC-2017
/Solutions/Day17.py
1,014
3.90625
4
# solution to http://adventofcode.com/2017/day/17 # fills a buffer of length steps+1 with numbers according to part 1 # returns the buffer (list of int) def fillBuffer(stepLength, steps): buffer = [0] currentPos = 0 for i in range(1, steps + 1): currentPos = (currentPos + stepLength) % len(buffer) currentPos +=...
0d6256b911b8e8dc665f2e52d1bd3ba3bdc83498
crashb/AoC-2017
/Solutions/Day11.py
2,151
4.09375
4
# solution to http://adventofcode.com/2017/day/11 # part 1: follow a path and find the shortest distance to its destination. # takes a list of directional strings: "n", "s", "ne", "sw", "nw", and "se". # the y-axis runs from n-s, while the x-axis runs from ne-sw. there is a third # axis, the z-axis, which runs from n...
7b3dce9551aa9acce445a765ca847dc956d1f375
rymo90/100DaysOfCodeChallenge
/numberfun.py
506
3.75
4
n= int(input()) svar="" for i in range(n): c= input() c= c.split() product= int(c[len(c)-1]) c = c[0:len(c)-1] c.sort(reverse = True, key= int) # print(c) if (int(c[0]) + int(c[1])) == product: svar="Possible" elif (int(c[0]) / int(c[1])) == product: svar="Possible" e...
143cfbbbc0413e448fb78767e3876dda66cba6f7
iver56/it3105
/module1/base_node.py
1,321
3.625
4
class BaseNode(object): """ This class represents the state of a node along with its score (f, g, h) and expand function This is the class that should be replaced or subclassed to implement other A* problems """ ARC_COST_MULTIPLIER = 1 def __init__(self, **kwargs): self.parent = kwargs....
a826bd5b814dc947ed4a8ac67312654f46eef3a7
iver56/it3105
/module1/nav_node.py
1,551
3.84375
4
from point import Point from base_node import BaseNode class NavNode(BaseNode): """ This is a Node implementation that is specific to the "find shortest path" problem """ H_MULTIPLIER = 1 board = None def __init__(self, position, g=None, h=None, parent=None): super(NavNode, self).__in...
b004d77b2b1d156f22d74ce2cde2557dcec7055a
guohuahua2012/samples
/Test/CHEME_APP/get_csvfile.py
1,239
3.765625
4
#coding=utf-8 import os import csv ''' 读取文件夹下的csv文件 ''' def readAllFiles(filePath): file_list = [] fileList = os.listdir(filePath) for file in fileList: path = os.path.join(filePath, file) if os.path.isfile(path): file = open(path, 'r' , encoding='utf-8') file_li...
b707c3f7f4ebc050b4f9b97502c8505a35acb690
guohuahua2012/samples
/OOP/study_class.py
1,305
4.15625
4
#coding=utf-8 ''' author:chunhua ''' ''' 对象的绑定方法 在类中,没有被任何装饰器的方法就是绑定的到对象到的方法,这类方法专门为对象定制 ''' class People1: country = 'China' def __init__(self, name): self.name = name def eat(self): print("%s is eating--1" %self.name) people1 = People1('nick') print(people1.eat()) ''' 类的绑定方法 @classm...
7211b7d8835f37b292b93756a2deb5f64ee62d4b
andrew-kulikov/crypto
/el_gamal/crypto.py
827
3.65625
4
import random def encrypt_bit(number, p, g, y): k = random.randint(2, p - 2) a = pow(g, k, p) b = number * pow(y, k, p) % p return a, b # crypto pair def decrypt_bit(crypto_pair, public_key, private_key): p, _, _ = public_key x = private_key a, b = crypto_pair decrypted = (b * a **...
e1695f2e4c4e00256d83d9c35091a628f04060a1
antonpols/Algorithms-Coursera
/Exercise_1.py
4,057
4
4
import math import random def karatsuba_multiplication(int1, int2): """Karatsuba implementation of integer multiplication.""" if isinstance(int1, int): int1 = str(int1) if isinstance(int2, int): int2 = str(int2) n_int1 = len(int1) n_int2 = len(int2) highest_pow_2 = max(2**ma...
dfcfc4edb4647d193e708b7dbaf99e5c04e7ce86
lyh71709/AS_Area_Perimeter
/08_calc_history_v1.py
6,017
4.15625
4
# Component 8 - Making a calculation history and print it at the end of the program # Only put in triangles and rectangles import math # number checker function goes here # Checks that it is not 0 and is a number def number_checker(question, error, num_type): valid = False while not valid: try: ...
0e4a586b1bfb3a97d3311b61d8653e0041c42eb0
sinceresiva/DSBC-Python4and5
/areaOfCone.py
499
4.3125
4
''' Write a python program which creates a class named Cone and write a function calculate_area which calculates the area of the Cone. ''' import math class ConeArea: def __init__(self): pass def getArea(self, r, h): #SA=πr(r+sqrt(h**2+r**2)) return math.pi*r*(r+math.sqrt(h**2+r**2)) con...
e484ba88e6d1587778d87a9831e30652ba9210ba
sinceresiva/DSBC-Python4and5
/replaceWordsWithLength.py
340
3.671875
4
class ReplaceWordsWithLength: def __init__(self): pass def getNewList(self, words): newList=[str(len(w)) for w in words] return newList replacer=ReplaceWordsWithLength() newList=replacer.getNewList(['A','Dark','Horse','Rode','Through','The','Mountain']) print("The new list is given belo...
bf5b6d876ce86fa04d0c53ed77a221c087d63741
Introduction-to-Programming-OSOWSKI/1-2-wordsmash-Kaleb-Aguirre03
/main.py
329
3.828125
4
#Define Function wordSmash def wordSmash (a, b): #return two variables as one combined return a + b #print the function to create CatDog print (wordSmash ("Cat", "Dog")) #print the function to create Redblue print (wordSmash ("Red", "blue")) #print the function to create qqqqqwwwww print (wordSmash ("qqqqq", ...
d1d9571a3ef48f6e25a8894baa0d5f4ad233a587
amir734jj/algorithm-practice
/regex/valid_number.py
534
3.703125
4
# https://leetcode.com/problems/valid-number/ import re def is_valid_number(token): return bool(re.fullmatch(r"\s*([+-]?((\d*\.)?\d+))(e[+-]?\d+)?\s*", token)) table = { "0": True, " 0.1 ": True, "abc": False, "1 a": False, "2e10": True, " -90e3 ": True, " 1e": False, "e3": Fal...
b9d7374e9022ed8a3c3c5ceeef7999c88bb20596
tonytamsf/python-learning
/names.py
342
3.703125
4
def count_arara(n): names = ['anane', 'adak'] name = '' if n == 1: return names[0] if n == 2: return names[1] if n % 2 == 0: for i in range(1,n,2): name = name + ' ' + names[1] else: name = count_arara(n - 1) + ' ' + names[0] return name.lstrip() ...
a3367d1f2af874ec507fa053fc19cd65f0699522
tonytamsf/python-learning
/cracking-coding-interview/linklistnode.py
965
3.875
4
#!/usr/bin/env python from testy import test class linklistnode: def __init__(self, d): self.data = d self.next = None def insert(self, d): n = linklistnode(self.data) self.data = d n.next = self.next self.next = n def append(self, d): n = ...
8f6776c26746a6f291ba188d0402280ebd702cb0
beetee17/week_4_suffix_array
/kmp/kmp.py
1,216
3.96875
4
# python3 import sys def find_pattern_fast(pattern, text): """ Find all the occurrences of the pattern in the text and return a list of all positions in the text where the pattern starts in the text. """ s = pattern + '$' + text borders = prefix_function(s) matches = [] for i in range(len(patter...
41f15ccbd2a2d053731579db1caa8c2796d5e64f
mrvecka/Python-Projects
/ML tests/House_price_prediction.py
4,047
4
4
# # house price prediction.py # # this is very simple prediction of house prices based on house size, implemented in tensorflow. This code is part of Pluralsight's coourse # # import tensorflow as tf import numpy as np import math import matplotlib.pyplot as plt import matplotlib.animation as animation # generate ho...
432cace0d237b5a415897de321f3ef36d29c16d4
trevorgokey/drug-computing
/uci-pharmsci/assignments/solubility/tools.py
1,386
3.65625
4
from numpy import * def rmserr( set1, set2 ): """Compute and return RMS error for two sets of equal length involving the same set of samples.""" tot = 0. for i in range(len(set1)): tot+= (set1[i] - set2[i])**2 return sqrt(tot/float(len(set1))) def correl(x,y ): """For two data sets x and ...
405c0566fcd647b110e84736b9728303519cfd45
raymag/binary-search-tree-sketches
/py/node.py
1,894
3.9375
4
class Node(): def __init__(self, value): self.value = value self.left = None self.right = None def addNode(self, node): if node.value < self.value: if self.left == None: ...
64f53a10971a8d012868cee0abbf380ff58dda59
palhiman/Lab-Practices
/python3/algorithms/sorting.py
542
3.59375
4
from random import randint from timeit import repeat def run_sorting_algorithm(algorithm, array): setup_code = f"from __main__ import {algorithm}" \ if algorithm != "sorted" else "" stmt = f"{algorithm}({array})" times = repeat(setup_code, stmt=stmt, repeat=3, number=10) print(f"Algorithm:{a...
45ffab46f36cc0fe42fd1d36eb72f2a94fb6730e
rbastardo13/ie_mbdbl2018_rbastardo_2
/__init__.py
1,168
3.890625
4
# -*- coding: utf-8 -*- """ Created on Thu Aug 30 09:45:16 2018 @author: Rafael Bastardo """ def linear_congruences_random_generator(X0=3,a=22695477,b=1,m=2**32,throws=1): """Function generates a list of random numbers using linear congruences equation X1=(a*X0+b) mod(m) Default values: a=22695477,b=1,m=2**32 ...
a6655d68d7d4d84709cea71f8e99229b86f05c0e
kostyafarber/info1110-scripts
/scripts/hailstones.py
343
3.90625
4
n = int(input("Starting Number: ")) num_list = [n] for i in num_list: if 1 in num_list: print("".join(str(num_list).strip("[]"))) elif i % 2 == 0: num_list.append(int(i / 2)) else: num_list.append(int(i * 3 + 1)) # Very useful function .strip to take the brackets out of a list if ...
009a177a0aea16ed8c9df0fa980e75d7412de480
kostyafarber/info1110-scripts
/scripts/integer.py
262
4.03125
4
while True: num = int(input("Integer: ")) if num == 0: print("Bye") break if num % 2 == 0 and num in range(20,201) or num % 2 != 0 and num < 0: print(num, "passes the test!") else: print(num, "fails the test :(")
928d5d403a69cd99e6c9ae579a6fc34b87965c1c
kostyafarber/info1110-scripts
/scripts/rain.py
468
4.125
4
rain = input("Is it currently raining? ") if rain == "Yes": print("You should take the bus.") elif rain == "No": travel = int(input("How far in km do you need to travel? ")) if travel > 10: print("You should take the bus.") elif travel in range(2, 11): print("You should ride your bike....
cfc8958512e750232c5441f55d7df0e79893053d
tschutter/skilz
/2010-12-06/compound_a.py
1,627
4.03125
4
#!/usr/bin/python # # Find all the two-word compound words in a dictionary. A two-word # compound word is a word in the dictionary that is the concatenation # of exactly two other words in the dictionary. Assume input will be a # number of lowercase words, one per line, in alphabetical order, # numbering around, say, 1...
a2d0a7288f4fc9ce22f9f1447e1e70046b80b30b
tschutter/skilz
/2011-01-14/count_bits_a.py
733
4.125
4
#!/usr/bin/python # # Given an integer number (say, a 32 bit integer number), write code # to count the number of bits set (1s) that comprise the number. For # instance: 87338 (decimal) = 10101010100101010 (binary) in which # there are 8 bits set. No twists this time and as before, there is # no language restriction....
31d75fd3b23a68c0573b13b60ea7033b815e9661
tschutter/skilz
/2014-04-14/base_convert_b.py
3,101
4.09375
4
#!/usr/bin/env python3 """ Convert values from one base to another. Changed from original spec to specify output base in the input stream rather than the command line. This makes demonstration easier. """ import decimal import re import string import sys DEBUG = True def baseString(base): """Return a Unicode ...
31313ead59605c9aa557b4387d1a88284f22ce8e
taylorfio/pygames
/pizza hunt.py
17,857
3.734375
4
""" backstory: In this game you are papa john, the previous king of the major pizza corporation and have recently been dethroned by your own disciples to be replaced by shaquille o'neal. You need to fight your way through the hoards of pizza minions sent by shaq himself to confront him in a final battle to reclaim your...
1e00f9bada478a3c0643d3eb3ff11e3c6aa2ec38
tkmckenzie/pan
/PE/33.py
2,379
3.671875
4
import fractions def without(iterable, remove_indices): """ Returns an iterable for a collection or iterable, which returns all items except the specified indices. """ if not hasattr(remove_indices, '__iter__'): remove_indices = {remove_indices} else: remove_indices = set(remove_ind...
fc3b101a2259c5fec7fde2b27a942244aaaa68dc
kimaya2/RSA
/RSA.py
1,037
3.8125
4
''' Created on Feb 24, 2020 @author: ccoew ''' p = input("Enter value of p:") q =input("Enter value of q:") mes = input("Enter message:") def computeGCD(x, y): while(y): x, y = y, x % y return x def findn(x,y): return x*y def findEulerQuotient(x,y): return (x-1)*(y-1) def finde(euler):...
20d8e34261de4ea02a84699336eb618a3441c96d
WenHui-Zhou/weekly-code-STCA
/top100_frequency/top100/19.py
1,352
3.6875
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode dummy = ...
e691de9fd1594e0e684da46b8055f525d99a4a2c
WenHui-Zhou/weekly-code-STCA
/top100_frequency/thrid/98.py
1,214
3.8125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isValidBST(self, root): """ :type root: TreeNode :rtype: bool if root == Non...
2d0fe3fc1b1b688cc166b7674df3fac6cf9dd495
WenHui-Zhou/weekly-code-STCA
/week10-11/493.py
1,348
3.5625
4
class Solution(object): def reversePairs(self, nums): """ :type nums: List[int] :rtype: int """ def merge(nums,left,mid,right): res = [] start = left end = mid + 1 while start <=mid and end <= right: if nums[star...
db5a8740b561ebf41daf9468ce6a1dd824a23f8e
WenHui-Zhou/weekly-code-STCA
/top100_frequency/fifth/baidu1.py
504
3.8125
4
# 输入两个整数 n 和 m,从数列1,2,3,.......,n 中随意取几个数, # 使其和等于 m ,要求将其中所有的可能组合列出来。 # 用动态规划的思想来做,对节点,从右到左遍历 n = 10 m = 8 def getList(n,m,lists,ans): if m == 0: ans.append(lists[::]) return if m < 0 or n <=0: return getList(n-1,m,lists,ans) lists.append(n) getList(n-1,m-n,lists,ans) ...
8741b37b87b2f0f7490c1297f6e8e2317f3f50aa
jw3030/git
/python/python_crawler/27_four_operation.py
374
3.734375
4
# plus minus multiple divide 을 return하는 함수 def getFourOperations(val1, val2): plusResult = val1 + val2 minusResult = val1 - val2 multipleResult = val1 * val2 divideResult = val1 / val2 return {"plus":plusResult, "minus":minusResult, "multiple":multipleResult, "divide":divideResult} res...
33a159573bd04a0a6200561a6a33d3e8eac12c6e
Highcourtdurai/Deep-learning
/RNN.py
3,021
3.765625
4
#Google Stock Market Prediction #Importing Libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt #Importing the training set dataset_train=pd.read_csv("Google_Stock_Price_Train.csv") training_set=dataset_train.iloc[:,1:2].values #Feature Scaling from sklearn.preprocessing impor...
3984fed0a2026179870161f6c7d8edab7ec65f9e
spartakummaximus1/py_files
/union.py
90
4.03125
4
a=[1,3,4,2,4,5,4] b=[3,5,3,5,6,4,3] def union(a,b): return a+b or b+a print(union(a,b))
e382fdcfff2ad071794defd4b9baf013175b33aa
bencheng0904/python200817
/m&e.py
449
3.96875
4
E = int(input("輸入英文成績:")) M = int(input("輸入數學成績:")) if E >= 0 and M >= 0 and E <= 100 and M <= 100: if E >=90 and M >=90: print("幹的好,有獎品!") elif E <=60 and M <=60: print("幹的好,有處罰!!!") elif M <=60 or E <=60: print("幹的好,再加油!!") else: print("隨便啦,沒獎品喇") els...
1d48da6a7114922b7e861afa93ddc03984815b0c
iZwag/IN1000
/oblig3/matplan.py
477
4.21875
4
# Food plan for three residents matplan = { "Kari Nordmann": ["brod", "egg", "polser"], "Magda Syversen": ["frokostblanding", "nudler", "burger"], "Marco Polo": ["oatmeal", "bacon", "taco"]} # Requests a name to check food plan for person = input("Inquire the food plan for a resident, by typi...
b3c5c76c0e7a77453da596bb4b615f00570b4ec9
iZwag/IN1000
/oblig4/reiseplan.py
1,385
4.03125
4
# Oppg 4.1 # Make an empty list called called "steder" elements = 5 steder = [] for i in range(0, elements): steder.append(input("Please enter a travel destination and hit ENTER: ")) # Oppg. 4.2 klesplagg = [] avreisedatoer = [] # NOTE: I am only making separate for-loops for the sake of the task. # I'd conside...
914134c3475f4618fa39fbbde917a4ada837968f
iZwag/IN1000
/oblig5/regnefunksjoner.py
1,933
4.125
4
# 1.1 # Function that takes two parameters and returns the sum def addisjon(number1, number2): return number1 + number2 # 1.2 # Function that subtracts the second number from the first one def subtraksjon(number1, number2): return number1 - number2 # 1.2 # Function that divides the first argument by the sec...
08e71694bd2f54c8b3131912cab43b11156d41ae
keithkay/python
/python_crash_course/modulo.py
128
3.875
4
num_1 = input("First number: ") num_2 = input("Second number: ") result = int(num_1) % int(num_2) print("The result is", result)
67b284c3f8dcaed9bdde75429d81c7c96f31847c
keithkay/python
/python_crash_course/functions.py
2,432
4.78125
5
# Python Crash Course # # Chapter 8 Functions # functions are defined using 'def' def greeting(name): """Display a simple greeting""" # this is an example of a docstring print("Hello, " + name.title() + "!") user_name = input("What's your name?: ") greeting(user_name) # in addition to the normal positional ...
ef7d7c152439de6ccfcb9d3206f9d38fe14102b8
keithkay/python
/python_crash_course/test_name_function.py
729
3.921875
4
# Python Crash Course # # Chapter 11 - Testing # # This is the unit test to test name_function.py import unittest from name_function import format_this_name class NamesTestCase(unittest.TestCase): """Tests for 'name_function.py'.""" # each test must be named test_... def test_first_last_name(self): ...
d7b69396e0fd909f1db82de9606f6241d6499c4c
keithkay/python
/python_crash_course/scratch.py
196
3.59375
4
############################################################################### import kay_func as kf new_list = ['one', 'two', 'three'] print_list = kf.format_list(new_list) print(print_list)
03ec200798e7dfd44352b6997e3b6f2804648732
keithkay/python
/python_crash_course/classes.py
776
4.5
4
# Python Crash Course # # Chapter 9 OOP # In order to work with an object in Python, we first need to # define a class for that object class Dog(): """A simple class example""" def __init__(self, name, age): """Initializes name and age attributes.""" self.name = name self.age = age ...
effe6b249e0b89c55a92a0d13b790fe0a87bd06c
keithkay/python
/sandbox/json_tests.py
1,522
3.609375
4
# json_tests.py # # This program works out how to handle different states you may encounter # loading a json file that contains a dictionary of settings. # # by: Keith Kay import json filename = 'testing.json' my_dict = {} # first open the the file and determine if it is empty try: with open(filename, 'r') as fi...
165a331029d73afbe5e10d39bf1948d613d816fe
abhi1p/Undo_Redo
/Undo_Redo/__init__.py
1,237
3.515625
4
from collections import deque class UndoRedo: def __init__(self): self._stack = deque() self._index = -1 def append(self, num): self.pop() self._stack.append(num) self._index += 1 def pop(self): l = len(self._stack) for i in reversed(range(self._in...
d0fac3ca0f27e050d676c38ddc11f27afb017826
AeroX2/tree-distance-proof
/proof.py
3,081
3.5
4
from random import randint from collections import deque uuid = 0 class Node: def __init__(self, parent): global uuid uuid += 1 self.uuid = uuid self.parent = parent self.children = {} def drop(self): if (not self.parent): return self.add_child(self.pa...
7d287d26b6229506f59ac51080d93b0c4bb508c0
pala9999/python
/week1/zipCode.py
531
4.03125
4
# zipCode = "12345" # print(zipCode) zipCode=input("Enter zipCode:\n") #print(zipCode.isnumeric()) if len(zipCode) != 5: print("Invalid Zip: " + zipCode + "\t...expecting 5 digit zip") exit() elif (zipCode.isnumeric()) == False: print("Invalid zip: " + zipCode + "\t...expecting numbers only") ...
287f72721a917cd83e34efdd7856741b6c214565
pala9999/python
/week3/week3_utils.py
2,468
4.0625
4
## Q1. Create a function named custom_function . def custom_function(n): for i in range(1,11): #print(n,"*",i,"=",n*i) return n , i, n*i x,y,z = custom_function(5) ################################################################################ # Q2. Write the function call with 2 arguments fname...
d5f27265bbc922c31c7268b3395cde1f17d8bfb7
Kodamayuto2001/NumPyTest01
/test10.py
2,331
3.90625
4
import numpy as np from PIL import Image l_2d = [[0,1,2],[3,4,5]] print(l_2d) print(type(l_2d)) arr = np.array([[0,1,2],[3,4,5]]) print(arr) print(type(arr)) arr = np.arange(6) print(arr) arr = np.arange(6).reshape((2,3)) print(arr) print("-----Numpy Matrix-----") mat = np.matrix([[0,1,2],[3,4,5]]) print(mat) prin...
46206896c2b33cfa6d851e34c5a6938d27e306b5
minhhoangho/Machine-learning-algorithms
/Linear-regression/linear-regression_v2.py
1,064
3.578125
4
# Source: https://machinelearningcoban.com/2016/12/28/linearregression/ import numpy as np import matplotlib.pyplot as plt import pandas as pd data = pd.read_csv('data/Advertising.csv') # mẫu số liệu (x :Chiều cao, y: Cân nặng) # height (cm) X = np.array([[147, 150, 153, 158, 163, 165, 168, 170, 173, 175, 178,...
06f48c859b796a65a874bb4a487dc29449bf0336
minhhoangho/Machine-learning-algorithms
/K-means/K-means2.py
2,497
3.59375
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np # Euclidian: (x1, y1) , (x2, y2) => (x1-x2) **2 + (y1-y2)**2 # # Manhattan: (x1, y1) , (x2, y2) => abs(x1-x2) + abs(y1-y2) # # trọng số, # # Minkowski: (x1, y1) , (x2, y2) => abs(x1-x2) + abs(y1-y2) def load_dataset(path): data = pd.read_cs...
8899317ae6c5039dcbe7698db43bdf048062ade3
nickmoop/Pool
/Board.py
1,199
3.546875
4
class Board: def __init__(self, canvas=None): self.wide = 355 self.height = 710 self.g = 9.809 self.item = None self.canvas = canvas self.loss = 0.55 def paint(self, root): if self.canvas is None: return board = self.canvas(root, bg='...