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
95dd4da434beae64e290402848a3372c6c07ddf2
XXQ2/CrawlAndScrape
/chapter_2/17.save_json.py
797
3.765625
4
# ==Json形式の文字列に変換する== import json cities = [ {'rank': 1, 'city': 'Shanghai', 'population': 24150000}, {'rank': 2, 'city': 'Karachi', 'population': 23500000}, {'rank': 3, 'city': 'Beijing', 'population': 21516000} ] # json.dumps()で引数のobjをJSON形式のstrオブジェクトに直列化します。 # json.dump()だと引数のobjをJSON形式のfp(.write()がサ...
0815bab35075b6852d0f2dd87dfa0ec087dac539
DeepeshYadav/AutomationMarch2020
/PythonPractice/Interview/incedo2.py
1,521
3.71875
4
""" def decorator(func): def new_function(): print("Extra Functionality") func() return new_function @decorator def initial_function(): print("This is first functionality") #initial_function() def read_file(filename): with open(filename, 'r+') as file: data = file.read(5) ...
1a960f7012360b250780c8a9ea4a4e2f269065b4
DeepeshYadav/AutomationMarch2020
/PythonPractice/DataStructure/SinglyLinkedList2.py
3,169
3.96875
4
class Node: def __init__(self, data): self.item = data self.ref = None class LinkList: def __init__(self): self.head = None def travers_list(self): if self.head is None: print("No Element in the list") return else: n = self.head ...
ff5436431c464cd15ab32dc07fa3f4797be442aa
DeepeshYadav/AutomationMarch2020
/PythonPractice/Lambda_function/practice/method_decorator.py
590
3.71875
4
######## Method Decorator ######## def method_decor(method): def inner(name_refer): if name_refer.name == "Deepesh": print("This is the same name we were expecting") else: method(name_refer) return inner class Printing: def __init__(self, name): self.name = ...
668093da9a48d1e47e4e10a2ee3c8453b2043678
DeepeshYadav/AutomationMarch2020
/PythonPractice/RegEx/RegXPractice.py
1,949
4.09375
4
# Website for testing regx : https://www.regextester.com/ import re # Example 1 global inputstr inputstr = "Create a class with three methods which give complete detail of a carresult." def findall_example(): # Findall method return list of matching string # Either return empty list result = re.findall("...
c19ee39d113ba175d1501c4b21d332a94d4df209
DeepeshYadav/AutomationMarch2020
/PythonPractice/RegEx/RegExPractice2.py
2,429
3.90625
4
""" import re findall : Returns a list containing all matches search : Returns a Match object if there is a match anywhere in the string split : Returns a list where the string has been split at each match sub : Replaces one or many matches with a string [] A set of characters "[a-m]" \ Signals a special sequence...
f0caa0dc61e92f7468067e57c49163b8d357272d
DeepeshYadav/AutomationMarch2020
/PythonPractice/DataStructure/DoublyLinkList.py
2,245
4.09375
4
class Node: def __init__(self, item): self.item = item self.prev = None self.next = None class DoubleLinkList: def __init__(self): self.head = None self.tail = None def inser_from_front(self, data): if self.head is None: new_node = Node(data) ...
a0ee9db42b6a9cc7f4a423e2281a718a1789981f
DeepeshYadav/AutomationMarch2020
/PythonPractice/Lambda_function/practice/Decorator Introdcution.py
740
4.3125
4
""" Decorators 1. Need to take a function as parameters 2. Add Functionality to the function. 3. Function need to return another function. -> In general language a decorator means , the person who does decoration job. to make things more presentable. for examples i want to given gift to my friend like watch 1 -> I ...
a53438a66dc0fdfc81a368630bb642152d2e807b
DeepeshYadav/AutomationMarch2020
/PythonPractice/PythonTrainingMarch2020/string_test.py
228
3.9375
4
input_str="Hello CoronaHowAreYou,please go away" input_word="CoronaHowAreYou" dict={ } for str in input_word: print (str) if str in dict: dict[str] +=1 else: dict[str]=1 print ("result:",dict)
cde40dccf5ea9938c8572de56bb6de3a9f8d131e
DeepeshYadav/AutomationMarch2020
/PythonPractice/Decorators/property_decor_example1.py
544
4.28125
4
# In this class will how to set values using setter # and next example2 will explain how achieve this using @propert decorator class Student: def __init__(self, name, grade): self.name = name self.grade = grade def msg(self): return self.name +" got the grade "+self.grade def set...
a95f6e8d82c147400a9e747284498d8bcd304642
DeepeshYadav/AutomationMarch2020
/PythonPractice/OOPS/overloading.py
301
3.859375
4
a = 20 b = 30 b = 30 str1 = 'abc' str2 = 'xyz' #print(a + b) print(a-b) #print(str1 + str1) #print(str1 + a) #print(int.__add__(a, b)) #print(str.__add__(str1, str2)) print(int.__sub__(a, b)) print(int.__mul__(a, b)) print(int.__eq__(a, b)) # For string there is no sub method available print()
41550a6c4aaa98c0918d86e27216d8ebd0175d74
DeepeshYadav/AutomationMarch2020
/PythonPractice/Lambda_function/practice/class_decorator.py
226
3.5
4
class Decorator: def __init__(self, func): self.func = func def __call__(self): str1 = self.func() return str1.upper() @Decorator def gritting(): return "good morning" print(gritting())
a80af9c17779e8c2463de713bd46db645456a566
kimdahyun0402/dao
/파이썬/5주차 2번.py
1,065
3.75
4
print("ax^2 + bx + c=0 에 대한 실수해를 구하는 프로그램입니다.") a=int(input("a의 값:")) #a,b,c의 값을 정수로 입력받는다. b=int(input("b의 값:")) c=int(input("c의 값:")) import math D = b*b - 4*a*c #이차방정식 해를 판별하기 위한 판별식 if D>0: #판별식이 0보다 클 경우 이차방정식의 해가 2개이다. x1=(-b + math.sqrt(b*b-4*a*c))/(2*a) #x1과 x2의 값을 구한다 x2=(-b - math....
39abae45c414ed02af0c6f17b176b006779aeb0d
kimdahyun0402/dao
/파이썬/5주차 4번.py
970
3.703125
4
a=int(input("100미만 양의 정수 복권번호를 입력하세요:")) #복권번호 입력받음 import random computer_choice = random.randint(1,100) #당첨번호를 랜덤으로 설정한다. b= computer_choice #당첨번호를 b로 놓는다 user_choice = a print("당첨번호는 %d입니다!"%(b)) if a==b : #당첨번호와 복권번호가 같을경우 상금 100만 print("상금: 100만원") elif ((a//10 == b//10) or (a%1...
eb28fa13c1b84600de00929da0c4116b51e33a25
shellmay/JZ-offer
/offer-25-复杂链表的复制.py
1,230
3.875
4
# -*- coding:utf-8 -*- """ 从头结点 head 开始拷贝; 由于一个结点可能被多个指针指到,因此如果该结点已被拷贝,则不需要重复拷贝; 如果还没拷贝该结点,则创建一个新的结点进行拷贝,并将拷贝过的结点保存在哈希表中; 使用递归拷贝所有的 next 结点,再递归拷贝所有的 random 结点。 """ class RandomListNode: def __init__(self, x): self.label = x self.next = None self.random = None class Solution: #深...
645ace2b507c4bbd30504f4e1d65f91f0d8dacb5
shellmay/JZ-offer
/offer-17-树的子结构.py
1,272
3.875
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None #判断树是都匹配时: #这道题要清楚终止条件 #1、tree2被匹配完,return True #2、tree1被匹配完tree2没有匹配完,return False #3、节点值不同,return False #返回值: #左右子树是否匹配 #临界点为两树有一为空,则 return False #递归时: # ...
2533afb57729a5910a4cbe07f999a864dd2166b8
shellmay/JZ-offer
/offer-22-从上往下打印二叉树.py
720
3.8125
4
# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None import collections #利用一个双向列表来操作,先进先出 class Solution: # 返回从上到下每个节点值列表,例:[1,2,3] def PrintFromTopToBottom(self, root): # write code here i...
cf542d105b35a3c446403c832fcd2588a9d4d643
shellmay/JZ-offer
/offer-21-栈的压入弹出序列.py
643
3.53125
4
# -*- coding:utf-8 -*- class Solution: def IsPopOrder(self, pushV, popV): # write code here a=[] while popV: tmp=popV.pop(0) if tmp in pushV: a.extend(pushV[:pushV.index(tmp)]) pushV=pushV[pushV.index(tmp)+1:] else...
b406738ed7b0ee5da3016206578b96bd400abe72
shellmay/JZ-offer
/offer-50-数组中重复的数字.py
708
3.703125
4
# -*- coding:utf-8 -*- class Solution: # 这里要特别注意~找到任意重复的一个值并赋值到duplication[0] # 函数返回True/False def duplicate(self, numbers, duplication): # write code here if numbers==None and len(numbers)==0: return False for i in numbers: if i <0 or i>len(numbers):...
da36fef5857babd8a8f5493b9bd7163740b6fffb
weezybusy/AtBSwP
/8/mad_libs.py
601
3.75
4
''' mad_libs.py -- reads in text file and lets the user add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB appears. ''' import re with open('src.txt') as original: text = original.read() blanks_list = re.findall(r'ADJECTIVE|ADVERB|NOUN|VERB', text) for blank_type in blanks_list: ...
6f3efe009ca41f626f6f109bcf7560414bcd7eb6
weezybusy/AtBSwP
/5/add_to_inventory.py
773
3.921875
4
''' add_to_inventory.py -- takes dictionary with player's inventory and list with the new items as arguments and returns dictionary with updated inventory. ''' def display_inventory(inventory): print('Inventory:') print('-' * 10) item_total = 0 for k, v in inventory.items(): print(str(v) + ' ' ...
faccf22c60f4255b29123df6d7dab82dd0e57df7
AlexMckey/P4E_Python
/Assignements/assign-3-3.py
381
4.0625
4
inp = raw_input("Enter float number between 0.0 and 1.0: ") num = float(inp) if num < 0.0: print "Error => The number must be greater or equal than 0.0" elif num < 0.6: print "F" elif num < 0.7: print "D" elif num < 0.8: print "C" elif num < 0.9: print "B" elif num <= 1.0: print "A" else: pr...
7c59504e8cbf8f7bc7883711ff404612aafc65ff
TimDaviesATCO/03-simple-predictions
/notebooks/munging.py
509
3.5625
4
import pandas as pd def load_data(data_file, sht_name, file_type): excel_filetypes = ['Excel', 'xls', 'XLS', 'xlsx'] csv_filetypes = ['CSV' or 'csv'] if file_type in excel_filetypes try: df = pd.read_excel(io=data_file, sheet_name = sht_name) except: print ("Err...
bd2503409c6cce97e9067ce733788a696dbaabca
zhangshengyue/text
/crawler/simple1.py
217
3.5
4
import urllib.request,urllib date={'word':'zhang'} url = "http://www.baidu.com/?" date_url=urllib.parse.urlencode(date) full_url=url+date_url a = urllib.request.urlopen(full_url).read() a = a.decode('UTF-8') print(a)
2fe318cddf13e6c498857998beede343a62ef92a
lbalmelli/network-python
/applications/microblog/app/routes.py
389
3.59375
4
""" View function: handler for the route """ from app import app # the @app.route decorator creates an association between the URL given as an # argument and the function. # These decorators associate the URLs / and /index to this function. @app.route('/') @app.route('/index') def index(): """ This view functi...
88b9d71d5b6cf65c264257326ce6fd53e7e6909f
prezentini/estudo_python
/d003.py
342
3.59375
4
def tautograma(frase): listap = frase.split() pl = (listap [0][0]).lower() contador = 0 while contador < len(listap): if (listap[contador][0]).lower() != pl: return 'N' contador += 1 return 'Y' palavra = (input()) if len(palavra) > 50: print('Erro') else: print(...
9a60630843c19d4c098cebf6203e675f5a2138a7
v0lb1nary/Lab_Zone
/Set_data/sets_minutos.py
1,165
3.90625
4
import time def inputInt(x): ''' Loop para o teclado numerico ''' E = True while E: try: ic = int(input(str(x)+": ")) if x == "Hora" and ic > 24: raise print("Isso não é uma hora possivel") elif x == "Minutos" and ic > 59: raise print("Isso não é um minuto suportavel") ...
9a0860a758daf3674acf74568832d1bcf28f752d
gil9red/price_of_games
/third_party/shorten.py
641
3.703125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'ipetrash' def shorten(text: str, length=30) -> str: if not text: return text if len(text) > length: text = text[:length] + '...' return text if __name__ == '__main__': text = '1234' * 20 new_text = shorten(text) a...
3963296709302dc7253f4a7b4564ef9f145af01b
Eduardo-Armiliato/teste-
/aula 26.py
348
3.90625
4
salario = float(input('digite o o salario do funcionário:')) salarinc = salario print('o salario inicial é de ',salarinc) if salario >= 1200: salario = (salario * 0.10) + salario else: salario = (salario * 0.15) + salario print('o salario atual é de ',salario) aumento = salario * 0.1 print('o aumento...
00a207e43a51d8b89cb21f690e3312ceaf5a1bd6
Wellingtonfernando/Urionline
/1024.py
554
4.0625
4
texto = str(input("digite o texto: ")) chave = 3 CARACTERES = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' convertido = '' texto1 = texto.upper() for caractere in texto1: if caractere in CARACTERES: num = CARACTERES.find(caractere) num = num + chave if num >= len(CARACTERES): num = num - len(C...
2f574e237b5dd535fd9ddac22459729a0ea655c5
Wellingtonfernando/Urionline
/1002.py
67
3.6875
4
X = float(input()) area = 3.14159 * (X**2) print('A=%.4f'%area)
57fbcb1b3551fb1d36e2d2828a0bcf81c561361c
Mattie432/Teaching-Computer-Science-2014
/Exercise 3/Exercise3_Quiz.py
5,120
3.984375
4
#Imports from random import randint from operator import add, sub, mul import random #Globals numOfQuestions = 10 pupilsClass = "" pupilsName = "" def generateQuestion(questionNumber): #generate two random numbers between min & max minNum = 1 maxNum = 12 randNum1 = randint(minNum,maxNum) randNum2 ...
926fc7bfe6d651b2e79443a2a9b45cf79c6a20ef
mikolajkrzyminski/kelnerAI
/src/algorithms/AStar/Node.py
1,127
3.96875
4
from math import sqrt class Node: def __init__(self, parent, x, y, distance): self.parent = parent self.x = x self.y = y self.distance = distance self.estimated = distance # returns distance from the object to other node def getDistanceTo(self, other): dx ...
0248a047a97752eb6028adf81022ad57b765e5e2
ahmed-t-7/Programming-Foundations-Fundamentals
/3. Variables and Data Types/Challenge_What_is_The_output.py
496
4.40625
4
print("Challenge 1:") # A message for the user message = "This is going to be tricky ;)" Message = "Very tricky!" print(message) # show the message on the screen this statement will print the first message variable # Perform mathematical operations result = 2**3 print("2**3 =", result) result = 5 - 3 #Change the v...
471876081dfdb7601f522bea2dfa199c1275b423
WertheimKhon/CompMatSciTools
/Create_Graphene_Sheet/angles.py
1,025
3.8125
4
#!/usr/bin/env python # Program written by Benjamin Jensen # Revision 1.0 # January 7th 2013 # Michigan Technological University # 1400 Townsend Dr. # Houghton, MI 49913 def angles(bonds): # returns a set of tuples print("Determining angles... ") angle_set = set([]) count = 1 for atom1, atom2 in bon...
5235303ceb3e54695ebebe35e39281bd918d55ea
danilohuera/ProSoftware
/teoremaPitagoras.py
352
3.984375
4
print (" Teorema de Pitagoras") print (" Al ingresar los valores de los catetos") cata= float(input(" Ingrese cateto a: ")) catb= float(input(" Ingrese cateto b: ")) hipc= (cata**2 + catb**2)**0.5 print(" Se aplica la formula de teorema de Pitagoras para \n obtener la Hipotenusa c") print ( "el valor de la hipo...
c764977b13b7b14cba39855b5c4c820904875107
CaseyInHaengsin/datastructuresandalgorithms
/array_sequences/anagram_challenge.py
249
3.65625
4
def main(): # Example Challenge print(anagram('aa','bb')) def anagram(s, t): _s1 = sorted(list(s.replace(' ', '').lower())) _t1 = sorted(list(t.replace(' ', '').lower())) return _s1 == _t1 if __name__ == '__main__': main()
8bcdc627379f686bbc937d6c6c756cadd1d9cc75
JeffreyAsuncion/Study-Guides
/Unit_3_Sprint_2/study_part1.py
2,472
4.28125
4
import os import sqlite3 """ ## Starting From Scratch Create a file named `study_part1.py` and complete the exercise below. The only library you should need to import is `sqlite3`. Don't forget to be PEP8 compliant! 1. Create a new database file call `study_part1.sqlite3` """ DB_FILEPATH = os.path.join(os.path.dirna...
ef3c8260e4906b34cc204288cbe038839ccd4341
moredatarequired/rl-course
/ucl-compm050/easy21/monte-carlo.py
1,628
3.71875
4
""" Monte-Carlo control for Easy21. Instructions: Initialise the value function to zero. Use a time-varying scalar step-size of α_t = 1/N(s_t, a_t) and an ε-greedy exploration strategy with ε_t = N_0/(N_0 + N(s_t)), where N_0 = 100 is a constant, N(s) is the number of times that state s has been visited, and N(s, a) ...
12f1f980d7ed2f4bf8333064405ae38fca31ff5d
blackplusy/weekend0303
/例子-0310-02.列表操作.py
454
3.796875
4
#coding=utf-8 l=[1,2,3,4] l2=[1,'kobe',2,'rose'] l3=[1,2,[3,4]] l=[1,2,3,4,5] print(l) for i in l: print(i) if 1 in l: print('1 is here!') l=['james','rose','kobe','no.3'] print(l[0]) print(l[-3]) #print(l[6]) print(l[1:]) print(l[:-1]) print(l[2:3]) l1=[1,2,3] l2=['heygor','ladeng'] print(l1+l2) print('*******')...
477c7d36fe3fa854b19c948ed68803ab11fad4f7
blackplusy/weekend0303
/例子-0324-02.函数的常用格式.py
297
3.59375
4
#coding=utf-8 #无参数,无返回值 def hello(): print('im your baba!') hello() #无参数,有返回值 def sleep(): return 'sleep' s=sleep() print(s) #有参数无返回值 def sub(x,y): print(x+y) sub(2,3) #有参数有返回值 def sub(x,y): return x+y s=sub(10,20) print(s)
d6e06b10b543e59a0b85759348c34de84f33e493
blackplusy/weekend0303
/例子-0324-06.函数的递归.py
517
3.921875
4
#coding=utf-8 #嵌套函数 ''' def t1(): print('im t1') def t2(): t1() print('im t2') def t3(): t2() print('im t3') t3() ''' ''' #例子:阶乘 n!=1*2*3.... def func(n): if n==1: return n elif n>1: return n*func(n-1) else: return '请传递大于0的参数' print(func(5)) ==(5) ===(5*func(4)) ==(4*func(3)) ''' #盗梦空间 def func(n)...
576bdf169a6d07ddb9910b568936db7fc8cc878e
vilaj46/ad1-ad2-briefs
/extraResources/electron-backend/utils/misc/find_white_space.py
224
3.734375
4
def find_white_space(number, text): count = 0 for index in range(len(text)): if count == number: return index - 1 if text[index] == ' ': count = count + 1 return len(text)
26159ad985c08b3e372e2f71952d018dab610f1e
vslotema/kattis
/python/AboveAverage.py
463
3.6875
4
c = int(input()) def getAVG( someA, div ): sum = 0 for i in someA[1:]: sum += int(i) return sum/div def getPercentage(someA,avg,div): count = 0 for i in someA[1:]: x = float(i) if x > avg: count += 1 return count/div while c > 0: A = input().split(" ") ...
5bac844967545312fa3dec6342774af5957f73ce
tristandres/hello-world
/triangle.py
209
3.578125
4
import turtle painter = turtle.Turtle() for _ in range(3): painter.forward(100) painter.left(3) for _ in range(20): painter.forward(100) painter.left(100) turtle.done() print('hello worla')
b6eeceedf3718b53884ac45c66735a56c34351b4
infantinoalex/AI-Final-Project
/Source/Word.py
760
3.828125
4
""" Contains the Word class. A Word represents a playable letter and is associated score in the game """ class Word : def __init__(self, word=None) : self.tiles = word self.string = '' self.score = 0 self.primeNumber = 1 if not self.tiles == None: for til...
852c9c8b42a9aca6d27892bb5afbad6862f86354
geroalonso/octopus
/num_to_cur.py
239
3.59375
4
from num2words import num2words def num_to_cur (number): string = num2words(number, to='currency') song = 'cold, cold heart' # replacing 'euros' with 'dollars' string = string.title().replace('Euro,', 'Dollars, with') return string
ef02da83464aaa8d89d459639ebdda829b6a38ef
mayamithra/python-programming-
/prime no two integers.py
112
3.5
4
a=10 b=100 for num in range (a,b+1): if (num>1): for i in range (2,num): if (num %i==0): break else: print(num)
223b6e68740e9411f390b37869df3125c8fe49c0
usamarabbani/Algorithms
/squareRoot.py
996
4.15625
4
'''take user input number = int(input("Enter a number to find the square root : ")) #end case where user enter less than 0 number if number < 0 : print("Please enter a valid number.") else : sq_root = number ** 0.5 print("Square root of {} is {} ".format(number,sq_root))''' def floorSqrt(x): # Base cases ...
a90307f0e77fa8b274f44c1a619c6fe8f6131c43
usamarabbani/Algorithms
/linked_list1.py
2,945
4.03125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.next def ...
f3e397a744558c935850f18001b4a5bf14e56ec6
usamarabbani/Algorithms
/mergeTwoSortedList.py
2,189
4.46875
4
# Defining class which will create nodes for our linked lists class Node: def __init__(self, data): self.data = data self.next = None # Defining class which will create our linked list and also defining some methods class LinkedList: def __init__(self): self.head = None def printLi...
2643bd8a29459423a0d4a717a73c39abc877ce62
basicpail/StudyPython
/Chap4_4.py
137
3.65625
4
array3 = ["사과", "자두","초콜릿","바나나","체리"] output = [fruit for fruit in array3 if fruit != "초콜릿"] print(output)
2a63e76283c46ebb29ef73b6c117d1443937c19c
luress/my_first_projects
/LinkedList.py
5,160
4.34375
4
""" Create CustomList – the linked list of values of random type, which size changes dynamically and has an ability to index elements. The task requires implementation of the following functionality: • Create the empty user list and the one based on enumeration of values separated by commas. The elements are stored in...
caf1789b2c9fd900fdcad4201d704fbc12bb2602
C3vin/codeforces-1
/102501.py
9,242
3.546875
4
""" 2019-2020 ICPC Southwestern European Regional Programming Contest (SWERC 2019-20) https://codeforces.com/gym/102501 """ def ProblemA(): """ https://codeforces.com/gym/102501/problem/A не решил - не правильный результат на тесте 5 """ def Dist(a, b): """ Вычисл...
ea1fba38cce57ef6fbbb5b1d8c94f74eb59c10c8
sachiel-x/Python-Daily-Challenge
/NINE.py
519
3.6875
4
# Given a string, add or subtract numbers and return the answer. # Example: # Input: 1plus2plus3minus4 # Output: 2 # Input: 2minus6plus4plus7 # Output: 7 import re x="2minus6plus4plus7" l1=[] x1="" for c, i in enumerate(x): if i.isnumeric(): l1.append(int(i)) for i in x: if i.isnumeric()...
157be94688095679f0f0cb03420226bdc7c41314
chandnibhatia/Simple-CRUD-in-Django
/project/client_test/templates/client_test/temp.py
993
3.59375
4
import os def sort_large_file(file_path): try: if os.path.exists(getFile): with open(getFile, 'r') as fp: #print(fp.readline()) for lines in fp.readlines(): #print(lines) listdata.append(int(lines)) print(list...
970f23ef1afa5d5c2ae538b25c9c9fbc191745f9
BigThighDude/SNS
/Week3/Ch5_Ex2.py
1,133
4.34375
4
num = int(input("Enter integer to perform factorial operation:\n")) #prompt user to enter number, converts string to interger. program doesnt work if float is entered def fact_iter(num): #define iterative function product = 1 # define product before it is used for i in range(1,num+1): #count up from 1 (w...
5f0e8f997fd3d5e52fb78abbe86d70bb4e1ca125
LevchenkoNG/21411Python
/Общие наработки/task1.py
405
3.890625
4
#Программа считывает размеры команд (два положительных целых числа a и b, каждое в отдельной строке) и выводит наименьшее число d, которое делится на оба этих числа без остатка a = int(input()) b = int(input()) d = 1 while(d%a != 0 or d%b != 0): d+=1 print(d)
37df2be145eedf6be551bec7905960825a0961fa
mohamedsahadkp/machine-learning
/neural-networks/simple-neural-networks.py
208
3.53125
4
import numpy as np input = np.array([0.2, -0.3]) weight = np.array([0.01, 0.02]) bais = 0.01 def sigmoid(x): return (1 / (1 + np.exp(-x))) output = sigmoid(np.dot(input, weight) + bais) print output
58a21925b83d8e8cb2f4b770c3877d6f0af54def
Wagui13/ProjetoBancos
/BancoPY/banco-blue.py
2,151
3.84375
4
import operacoesBanco import menus menus.bemVinde() # mensagem de bem vindo # menu que pega os dados do usuário name = input(f"+{'-'*54}+\n Digite o seu nome -> ") psword = input(f"+{'-'*54}+\n Sua senha ---------> ") while (len(psword) < 6): print(" Inválido! A senha precisa ter 6 ou mais caracteres") ps...
083d2e149bb44c30ebdc1e7038f9622ce202bac1
Cyufei87/LeetCode_Solutions
/Algorithms/1-50/p_20.py
554
3.734375
4
# Valid Parentheses class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ from collections import deque q = deque() for ss in s: if len(q) >= 1: if (ss == ")" and q[-1] == "(") or (ss == "]" and q[-1] == "[...
3ddb3e2499c36a15d0269aac926fec373f5c0efe
Cyufei87/LeetCode_Solutions
/Algorithms/1-50/p_19.py
771
3.828125
4
# Remove Nth Node From End of List # 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...
2169d48ff2a68ca3ff9735bf2505542c2929d7da
Cyufei87/LeetCode_Solutions
/Algorithms/1-50/p_44.py
697
3.515625
4
# Wildcard Matching class Solution(object): def isMatch(self, s, p): """ :type s: str :type p: str :rtype: bool """ s_len = len(s) p_len = len(p) dp = [[False for _ in range(p_len + 1)] for _ in range(s_len + 1)] dp[0][0] = True i = 0 ...
d9ea412762debf8916cc11fe900782dc6d0d4059
Cyufei87/LeetCode_Solutions
/Algorithms/1-50/p_26.py
404
3.59375
4
# Remove Duplicates from Sorted Array class Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ last = None r = 0 for i in range(len(nums)-1, -1, -1): num = nums[i] if num != last: ...
949bc6786062b8b82f00933b0ec93d2df8bd9444
Cyufei87/LeetCode_Solutions
/Algorithms/1-50/p_02.py
803
3.796875
4
# Add Two Numbers # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ ...
01592df3e01cf0fff04f4e327e568b4b22155cab
kishan811/ACM-ICPC-Algorithms
/DP/Fibonacci/Fibonacci.py
294
3.921875
4
''' Bottom up Approach for Fibonacci series ''' N = int(input()) def fib(n): if(n == 0): return 0 elif(n == 1): return 1 else: fib = [0, 1] for i in range(2,n+1): fib.append(fib[i-2] + fib[i-1]) return fib[i] print(fib(N))
b6ee4a00c1105109f284388e8e8c9b8993dcca32
zhang-huijie/My_job
/my_own_code/strint_to_arrlist.py
624
3.59375
4
#输入型号的 string类型转变成输出的二维数组 matrix =input() arr = int(matrix.count(']')-1) matrix = matrix.split(',') res = [] for i in range(len(matrix)): m = matrix[i] s = "" for j in range(len(m)): if m[j] ==']' or m[j] =='[': continue else: s = s+str(m[j]) res.append(int(...
441f73ecee45ff51ab7d7d32f185a22fb3da65e1
joses29/menu-main
/menu.py
11,743
3.75
4
from calculadora import * from operacionnumeros import * from listas import * from cadenas import * import os class Menu: def __init__(self, titulo='', opciones=[]): self.titulo = titulo self.opciones = opciones def menu(self): print(self.titulo) for opcion in self.opciones: ...
30cc081bb035c097712ec17cd5073adc5cf5f143
mithunnandi/Selenium_Pytest_Basics
/PythonBasics/Basics.py
748
3.640625
4
#Counter from collections import Counter a=[1,1,2,3,4,5,6,7,8] c=Counter(a) print(c) print(list(c.elements())) #Array pop import array as arr a=arr.array('i',[10,20,40]) print(a.pop()) print(a.pop(1)) a.remove(10) print(a) #Nested Dictionaries emp_details={'Employee':{'Dave':{'ID':12345,'Salary':10000,'Designation':'...
5d2db6cb426037568a8ce378f7d7f37e16bc01ef
mithunnandi/Selenium_Pytest_Basics
/PythonBasics/childbaseconcept.py
263
3.515625
4
class Base(object): pass #Empty class class Child(Base): pass class Child1(): pass print(issubclass(Child,Base)) print(issubclass(Base,Child)) print(issubclass(Child1,Base)) b=Base() c=Child() print(isinstance(b,Base)) print(isinstance(c,Child))
1eacb152f36f1ca0ee1045602de67c8732edfe27
code-in-the-schools/four_loops_Jayla
/main.py
150
4.09375
4
soda = ["pineapple soda" , "strawberry soda" , "coke soda"] for x in soda : print (x) if x == "pineapple soda" : continue print (6)
058f990afbab4b46c8b539fa23f80df850c7ad1e
qdonnellan/random_questions
/questions/arrays_and_strings/strings/haha_replace_test.py
591
3.5625
4
import unittest from haha_replace import haha_replace_function class test_implementation_of_haha_replace_function(unittest.TestCase): def test_simple_case(self): ''' test that a sentence with "the" gets it replaced with "HAHA" ''' sentence = "the world is dark" expected = "HAHA world is dark" ...
d1ef54fbb683fe2e9f5cdcf8343d37fb3f522a29
qdonnellan/random_questions
/questions/trees_and_graphs/stack_test.py
423
3.53125
4
import unittest from stack import Stack class test_simple_implementaiton_of_stack(unittest.TestCase): def test_stack_push(self): '''make sure simple push works''' s = Stack() self.assertIsNotNone(s) s.push(3) self.assertEqual(s.head.value, 3) def test_stack_push_pop(self): '''make sure pu...
1f9f32a6031bb1c9adecc2db77d1d4015bf83788
qdonnellan/random_questions
/questions/recursion/telephone_word_combos_test.py
1,600
3.84375
4
import unittest from telephone_word_combos import telephone_word_combos class TelephoneWordCombosTest(unittest.TestCase): """ test the implementation of telephone_word_combos """ def test_case_with_three_numbers(self): """ test the case with the number 111 there is only one com...
9216d28094f7e12e471ae327de4ba1be8b222e5b
qdonnellan/random_questions
/questions/linked_lists/stack_test.py
1,626
3.984375
4
import unittest from stack import stack class test_stack_implementation(unittest.TestCase): def test_stack_initialization(self): ''' make sure a new stack is not None! ''' new_stack = stack() self.assertIsNotNone(new_stack) def test_push_method(self): ''' make sure the push method wor...
cae2c0cefa82cb8a8b1ae36506d4f53118e12a14
ozmaws/Chapter-5
/CH4P6.py
870
3.953125
4
text = input("Enter name of the file to encrypt: ") target = open(text, "r") encrypt = open("encrypted.txt", "w") dist = 1 for x in target: for i in x: bit = "" value = ord(i) cipherValue = value + dist if i == ' ': encrypt.write('s') continue elif i == '\n': encrypt...
78482d507822ef15a97684b695b73d08ad69a4e0
ozmaws/Chapter-5
/CH5P4.py
1,303
3.875
4
import random def getWords(filename): input_file = open(filename, "r") wordList = [] for line in input_file: for word in line.split(): wordList.append(word) input_file.close() return tuple(wordList) adjectives = getWords("adjectives.txt") articles = getWords("articles.txt") conjunction = ...
f2d8c16fb5246bbfc3a4ddaa2af8c825f5a2a13a
ozmaws/Chapter-5
/CH4P2.py
365
4.09375
4
text = input("Enter message to decrypt: ") dist = int(input("Enter ciphers distance: ")) decrypt = "" for i in text: value = ord(i) cipherValue = value - dist if i == ' ': decrypt += ' ' continue if cipherValue < ord('!'): cipherValue = (ord('~') - (dist + (ord('!') - value - 1))) decry...
5d3e305a9041b72286584e2526ebe366bc6fc781
yellowsimulator/Algorithms-and-Data-Structures-in-Python
/Merge_sort.py
448
4.09375
4
def merge_sort(lst): """Merge sort an input list""" if len(lst) < 2: return list # choose a pivot index mid = int( len(lst) / 2) lst1 = merge_sort(lst[:mid]) # O(n) lst2 = merge_sort(lst[mid:]) return make_merge(lst1, lst2) def make_merge(lst1, lst2): """ Merge lists """ ...
90c8f8c20710cbf5f4cc7bb2423bc7c73c1f9d36
Arrownaut/cs325-Homework1
/Homework_1/mergesort.py
3,261
3.953125
4
# Author: Kento Woolery # Class: CS325 - Analysis of Algorithms # Homework 1, Problem 4, Merge Sort # Description: Reads inputs from a file called 'data.txt' where the first value of each line is the number of integers # that need to be sorted, followed by the integers. # Example values for data.txt: # 4 19 2...
ffa0989fddab13d8220973f19a7e48a63c05a999
liviu-gheorghe/FMI-Materials
/Calcul Numeric/Teme/Tema 4/Temă 4 - Nu complet.py
5,677
3.640625
4
import numpy as np import matplotlib.pyplot as plt # Datele Problemei n = 20 def liniar(x): return x def exponential(x): return np.exp(x + 2) def patratic(x): return x ** 2 # Funcții Auxiliare # Metoda Substituției Descendente (Funcție Auxiliară pt implementarea Metodei Gauss) ...
bcf8b9de227ca5cb2ad63179fa4af3c69a7c51d1
BobbySinclusto/CS362-in-class-4
/unittest_palindrome.py
684
3.515625
4
import unittest import palindrome class TestCasePalindrome(unittest.TestCase): def test_palindrome_good(self): self.assertEqual(palindrome.is_palindrome('testing'), False) self.assertEqual(palindrome.is_palindrome('bob'), True) self.assertEqual(palindrome.is_palindrome('racecar'), True) ...
4f32d050d1e1dd969c981f8606769c758a394121
Farubegum/santa
/evvv.py
85
3.578125
4
s,d=input().split() s=int(s) d=int(d) for x in range(s+1,d): if(x%2!=0): print(x)
e98f73174b70622f05f8c20bf43f4fa80f65e995
elmasbusenur/Python
/transforming_data.py
707
3.609375
4
# -*- coding: utf-8 -*- """ Created on Wed Nov 20 21:32:13 2019 @author: PC """ import numpy as np import pandas as pd dictionary={"Name":["Ali","Buse","Selma","Hakan","Bülent","Yağmur","Ahmet"], "Age":[18,45,12,36,40,18,63], "Maas":[100,200,400,500,740,963,123]} dataFrame1=pd....
df59fc80eed96be39b8cc34919b91e2a4129c77a
waltermblair/CSCI-220
/calc.py
194
3.9375
4
print("This program will perform whatever calculation you wish, within reason") for i in range(100): x = eval(input("Please type the calculation you wish to perform\n")) print(x)
be8a5925b8c4a40c907ae272b7080cb1e7c59756
waltermblair/CSCI-220
/quiz_grade.py
356
3.765625
4
print("This program tells you how shitty your kids are.") score=eval(input("Quiz score out of 5: ")) grades=["F", "F", "D", "C", "B", "A"] print("Your shitty kid made a {0}".format(grades[score])) test=eval(input("Test score out of 100: ")) test_grades=("F"*60+"D"*10+"C"*10+"B"*10+"A"*10) print("Your shitty kid mad...
a6af63be177ccfdece511ddb04a2051b9a762f01
waltermblair/CSCI-220
/bullseye.py
1,328
3.765625
4
from graphics import * def drawTarget(): win=GraphWin(320,240) win.setCoords(0,0,200,200) center=Point(100,100) white=Circle(center,100) white.setFill("white") black=Circle(center,80) black.setFill("black") blue=Circle(center,60) blue.setFill("blue") blue.setOutline("blue") ...
96e14857244d2eca4346894518f7fb72a2573240
waltermblair/CSCI-220
/gpa.py
1,389
3.9375
4
"""Program to find the student(s) with highest GPA from a tab-delimited file of Name Hours QPoints.""" class Student: "Creates a student with given name, hours, qpoints from file" def __init__(self, name, hours, qpoints): self.name=name self.hours=float(hours) self.qpoints=float(qpoints...
381824856aa8e62495f557a4ef0f60201bb9d58c
waltermblair/CSCI-220
/regression.py
1,844
4
4
from graphics import * print("This program calculates linear regression from several data points.") class Regression: def __init__(self): self.count=0 self.xsum=0 self.ysum=0 self.xysum=0 self.xsqsum=0 def addPoint(self, win): while True: p=win.get...
a6d695dc7f5458c32a2d6786c734bce2f63da4f8
waltermblair/CSCI-220
/encoder.py
149
4.1875
4
print("This program encodes messages into unicode!") message=input("Type your secret message below\n") for chr in message: print(ord(chr)," ")
59367641bfd30e48e5d18b80b386a518d30b627a
waltermblair/CSCI-220
/hydrocarbon.py
263
4.125
4
print("This program calculates the molecular weight of a hydrocarbon") h=eval(input("How many hydrogen atoms?")) c=eval(input("How many carbon atoms?")) o=eval(input("How many oxygen atoms?")) w=h*1.0079+c*12.011+o*15.9994 print("The weight is ",w," grams/mole")
7b3282a1fa97a3069e075441e35901c06260ed16
waltermblair/CSCI-220
/ch4.py
416
3.546875
4
from graphics import * def main(): win=GraphWin() shape = Rectangle(Point(50,50),Point(75,75)) shape.setOutline("red") shape.setFill("red") shape.draw(win) for i in range(10): p=win.getMouse() c=shape.getCenter() dx=p.getX()-c.getX() dy=p.getY()-c.getY() ...
dce29aacbef5e86574b300659dd52c9edb4868f5
waltermblair/CSCI-220
/random_walk.py
723
4.28125
4
from random import randrange def printIntro(): print("This program calculates your random walk of n steps.") def getInput(): n=eval(input("How many steps will you take? ")) return n def simulate(n): x=0 y=0 for i in range(n): direction=randrange(1,5) if direction==1: ...
b523d255c751e3f3a2c118cc8a2e5340b76067a1
waltermblair/CSCI-220
/ants_marching.py
810
3.625
4
def ants(n): print("The ants go marching {0} by {0}, hurrah! hurrah!".format(n)) def marching(stops_to, n): print("The ants go marching {0} by {0},".format(n)) print("The little one stops to {0},".format(stops_to)) print("And they all go marching down...") print("In the ground...\nTo get out...\nOf...
bfed4746d1b8c77e4529fd3ebc5260e7602a9f81
waltermblair/CSCI-220
/GCD.py
177
4.21875
4
print("This program find the greatest common divisor of two values") m, n = eval(input("Enter two integers separated by a comma: ")) while m != 0: n, m = m, n%m print(n)
60bf88909cf62031fdd72108af8c95c3e905b442
waltermblair/CSCI-220
/convert_graph.py
647
3.734375
4
from graphics import * #Draw interface win=GraphWin("Temperature Converter",400,400) win.setCoords(0,0,100,100) Text(Point(30,90), "Temperature in Celsius: ").draw(win) Text(Point(30,20), "Temperature in Fahrenheit: ").draw(win) input=Entry(Point(75,90),10) input.setText("0.0") input.draw(win) output=Text(Point(75,20)...
da041491ca0bc9cad4637af41a2be78f692595b2
waltermblair/CSCI-220
/blackjack_start_value.py
1,471
3.953125
4
from random import randrange def printIntro(): print("This program simulates n games of blackjack and calculates" \ "the probability that the dealer will bust.") def getInput(): n = eval(input("How many games do you want to simulate? ")) print("--"*20) return n def draw(): card=randrang...
ddb747b2b03438b099c0cf14b7320473be16888b
waltermblair/CSCI-220
/word_count_batch.py
404
4.28125
4
print("This program counts the number of words in your file") myfileName=input("Type your stupid ass file name below\n") myfile=open(myfileName,"r") mystring=myfile.read() mylist=mystring.split() word_count=len(mylist) char_count=len(mystring) line_count=mystring.count("\n") print("Words: {0}".format(word_count))...
e73755b5312fb5c9b56c69e60a327873845547d1
waltermblair/CSCI-220
/adder2.py
180
4.125
4
print("This program sums a series of numbers") n=eval(input("How many numbers do you want to add?")) x=0 for i in range(n): x=x+eval(input("Type a number: ")) print("Sum: ",x)
bf94281e4f175a9f83c62fccb0df97ed08cb755d
TsaiHUNGYU/PythonMidTerm
/14.py
89
3.671875
4
s = input("輸入一字串為 :") sum = len(s) print("There are "+str(sum)+" characters")