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 |
|---|---|---|---|---|---|---|
881b2cce11a176a01451bb19f208470f6798d9e2 | manovidhi/python-the-hard-way | /ex5.py | 420 | 3.78125 | 4 |
name = "Amit Sinha"
age = 40 #real age
height = 160 # in cm
weight = 170 # in kg
eyes = "black"
color = "brown"
print("lets talk about %r." % name)
print("he is %s inch tall." % ( round(height/2.54, 2)))
print("He is %r kg heavy." % weight)
print("Ohh, He is too heavy")
print("He is got %r eyes and %r color." % (eye... |
4ed6cf981fd362e21ff59c9abbf24035f2e765a3 | manovidhi/python-the-hard-way | /ex13.py | 650 | 4.25 | 4 | # we pass the arguments at the runtime here. we import argument to define it here.
from sys import argv
script, first, second, third = argv
#print("this is script", argv.script)
print( "The script is called:", script ) # this is what i learnt from hard way
print ("Your first variable is:", first)
print ("Your se... |
85af7b903ced77cfddd9c5d8fedac47dc21bbe67 | SlyCodePanda/AdvancedPython-Udemy | /SocketProgramming/FileServer.py | 1,069 | 3.703125 | 4 | import socket
host = 'localhost'
port = 8080
# Create socket using internet version 4 (socket.AF_INET), using a TCP connection (socket.SOCK_STREAM).
# You can also pass nothing in the socket function and it will do the same thing. These are set by default.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Bin... |
460d89bb752a57f2b19613fd12ac05ee947c6f5d | SlyCodePanda/AdvancedPython-Udemy | /SocketProgramming/Server.py | 899 | 3.78125 | 4 | import socket
host = 'localhost'
port = 8080
# Create socket using internet version 4 (socket.AF_INET), using a TCP connection (socket.SOCK_STREAM).
# You can also pass nothing in the socket function and it will do the same thing. These are set by default.
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Bin... |
19ff95e26004878f007aeba1740e1967610dd4c4 | SlyCodePanda/AdvancedPython-Udemy | /MagicFunctions/formatting_example.py | 1,022 | 3.84375 | 4 | # Converting to metres (m)
class LengthConversion:
value = {"mm": 0.001, "cm": 0.01, "m": 1, "km": 1000, "inch": 0.0254,
"ft": 0.3048, "yd": 0.9144, "mi": 1609.344}
def convertToMetres(self):
return self.x * LengthConversion.value[self.valueUnit]
def __init__(self, x, valueUnit="m"):
... |
591396f0a8790e2e64bbd285bbd082cad1053e12 | thebiwall/pythonpracticecode | /removeKfromList.py | 294 | 3.65625 | 4 | def removeKFromList(l, k):
i = 0
j = 0
b = []
print(l)
while i < len(l):
if l[i] == k:
b.append(i)
i = i + 1
while j < len(b):
del l[b[j]]
j = j + 1
return l
l = [3, 1, 2, 3, 4, 5]
k = 3
removeKFromList(l, k) |
8b642d1247ae703da0bf02c7eb464f8ce3efad4b | MustafaHaddara/google-code-jam-2021 | /qual/moons.py | 863 | 3.578125 | 4 | def find_min_cost(x, y, s):
# x = cost for CJ
# y = cost for JC
# we want to minimize flips
cost = 0
prev = ''
start = 0
for i in range(0, len(s)):
if s[i] != '?':
start = i
prev = s[i]
break
for i in range(start+1, len(s)):
current =... |
d4acbec572bd02a4cda1c6a8d7da786ece8b3ae4 | ArghyaDS/TestPy | /Basics/AssertPy.py | 281 | 4 | 4 | #AssertionError handling in simple operation
div=int(input("Enter dividend: "))
divs=int(input("Enter divisor: "))
try:
assert divs!=0, "You can not divide by zero"
quo=div/divs
print(f"Result: {quo}")
except:
print("You should not try to divide by zero")
|
6abc2703cad15b402398e5a795b761a5e5d8506a | nicolasmartinez1993/Python-hacking-multi-tool | /ataque_dos.py | 715 | 3.53125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
ATAQUE DOS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
from scapy.all import *
src = raw_input("Introduce la IP a... |
fd4c8a3f8de296ae8df949979ffd8c3602b97369 | wong2/PyOthello | /src/network.py | 1,292 | 3.75 | 4 | '''
network.py
This module defines class Server and Client. They are used in network games.
'''
import socket, sys, os
class Server:
def __init__(self):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 5543
self.socket.bind(('', port))
self.socke... |
6e98b66fbafb140f34594dc5be52c9aa03ceca44 | chaerui7967/K_Digital_Training | /Python_KD_basic/Module/module/calculator.py | 269 | 3.75 | 4 | #계산기 함수 : add(x,y),sub(x,y),mul(x,y),div(x,y)
def add(x,y):
return x+y
def sub(x,y):
return x-y
def mul(x,y):
return x*y
def div(x,y):
return x/y
print('123456789','-'*10)
#__name__main()__
if __name__ == '__main__':
print('calculator')
|
2b67bdd9e57a980076099105048e8f936a9adec4 | chaerui7967/K_Digital_Training | /Python_KD_basic/HW/1_채길호_0527_3.py | 1,990 | 3.53125 | 4 | #회원명단을 입력받아 저장,출력,종료 프로그램 작성
def input_member(input_file):
while True:
inName = input('멤버를 입력하세요.(종료는 q) : ')
if inName.lower() == 'q':
break
else:
with open(input_file, 'a', encoding='utf-8') as i: i.write(inName+'\n')
print('저장되었습니다.')
def output_member(output... |
a497471f2cd6acca5a95394afb05ee7e9e1cffc3 | chaerui7967/K_Digital_Training | /Python_KD_basic/while/while_1.py | 304 | 3.609375 | 4 | #1~10 정수 출력
a = 1
while a <= 10:
print(a,end='\t')
a += 1
#continue
x=0
while x<10:
x+=1
if x % 2 ==0:
continue
print(x)
#무한 loop
while True:
print('반복시작')
answer = input('끝내려면 x')
if answer == 'x':
break
print('반복종료') |
c13c563831e0bb18f5ba7767b1b4eae6fb72013f | chaerui7967/K_Digital_Training | /Python_KD_basic/for/for_1.py | 513 | 3.75 | 4 | for name in ['홍길동', '이몽룡', '성춘향', '변학도']:
print(name)
for i in range(0, 10): # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(i, end="\t")
# range(start[시작값,생략가능 기본 0], stop, 간격) range(11)= 0~10
for i in range(10, 100, 20):
print(i, end=", ")
# 1~10 사이 숫자합
sum = 0
for i in range(101):
sum += i
print("1 ~ 100 ... |
087631e0f764310b40cd2db61d102de65025e5c6 | chaerui7967/K_Digital_Training | /Python_KD_basic/02_datatype/tye_conversion.py | 248 | 3.828125 | 4 | #타입변환
a=1234
print('나의 나이는 '+str(a)+'이다!')
num=input('숫자? ')
print(int(num)+100)
print(float(num)+100)
print(int('123',8)) #8진수 123 print시 10진수로 변환되서 출력
print(int('123',16))
print(int('111',2)) |
4693ddf9763efa81badf356343831b203f436d0a | chaerui7967/K_Digital_Training | /Python_KD_basic/14_module/module3/gbbGame.py | 856 | 3.71875 | 4 | #gbb game
from random import randint
def gbb_game(you_n):
com_n = randint(1,3)
if com_n-you_n ==1 or com_n-you_n ==-2:
result = 1 #1인경우 com win
elif com_n-you_n == 0:
result = 2 #2인경우 비김
elif you_n>3 or you_n<0:
print('다시입력')
return
else:
result = 3 #3인경우 my ... |
1ad2cd819e2b9ca0e38435955fdea7a29211eb75 | chaerui7967/K_Digital_Training | /Python_KD_basic/List/list_3.py | 277 | 4.3125 | 4 | #리스트 내용 일치
list1 = [1,2,3]
list2 = [1,2,3]
# == , !=, <, >
print(list1 == list2)
# 2차원 리스트
list3 = [[1,2,3],[4,5,6],[7,8,9]]
#행렬 형식으로 출력
for i in list3:
print(i)
for i in list3:
for j in i:
print(j, end="")
print() |
f4865aa087e05df368a73af8c17105bc4854e6d0 | chaerui7967/K_Digital_Training | /Python_KD_basic/if/condition.py | 297 | 3.875 | 4 | #키보드로 입력받은 정수가 짝수 인지 아닌지 확인
aa= int(input("정수 입력 : "))
bb= aa%2
cc= bb!=1
print('짝수?'+str(cc))
#조건문 if elif else
if(aa % 2 == 0):
print('짝수')
else:
print('홀수') #pass 아무것도 수행하지 않음
#반복문 for, while
|
c01b4306131f6fa4bd8a59f7b68ec758e2b16a5c | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter5/wordLength.py | 708 | 4.40625 | 4 | # Average Words Length
# wordLength.py
# Get a sentence, remove the trailing spaces.
# Count the length of a sentence.
# Count the number of words.
# Calculate the spaces = the number of words - 1
# The average = (the length - the spaces) / the number of words
def main():
# Introduction
print('The program cal... |
2afa7c968a716fcca6cdb879880091093f1d22fc | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter11/sidewalk.py | 510 | 4.125 | 4 | # sidewalk.py
from random import randrange
def main():
print('This program simulates random walk inside a side walk')
n = int(input('How long is the side walk? '))
squares = [0]*n
results = doTheWalk(squares)
print(squares)
def doTheWalk(squares):
# Random walk inside the Sidewalk
n = len... |
6a4583c2981af50718518b39db6859cc5154952f | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter11/removeDup.py | 174 | 3.5625 | 4 | # removeDup.py
def main(aList):
newList = []
for i in range(len(aList)):
if aList[i] not in newList:
newList.append(aList[i])
return newList
|
f4e6850526192481d46c2e8cff4d0c667d7622bd | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter11/stats.py | 862 | 3.90625 | 4 | # stats.py
from math import sqrt
def main():
print('This program computes mean, median and standard deviations.')
data = getNumbers()
xbar = mean(data)
std = stdDev(data, xbar)
med = median(data)
print('\nThe mean is', xbar)
print('The standard deviaton is', std)
print('The median is... |
9afa0ebe9146bd1996081846c0b594423653a84f | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter11/cardSort.py | 2,461 | 3.96875 | 4 | # cardSort.py
# Group cards by suits and sort by rank
def main():
print('This program sorts a list of cards by rank and suit')
filename = input('Enter a file name: ')
listOfCards = sortCards(filename)
score = checkScore(listOfCards)
print(score)
def sortCards(filename):
infile = open(filename,... |
393e027c2e80d8a2ca901ef0104ac59c6887770d | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter3/distance.py | 467 | 4.21875 | 4 | # Distance Calculation
# distance.py
import math
def main():
# Instruction
print('The program calculates the distance between two points.')
# Get two points
x1, y1, x2, y2 = eval(input('Enter two points x1, y1, x2, y2:'\
'(separate by commas) '))
# Calculate the dis... |
ca66d5fae8f505075ecd044b6e5931935caac234 | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter4/archery.py | 755 | 3.828125 | 4 | # Archery Target
# archery.py
from graphics import *
def main():
# Instruction
print('The program draws a archery target.')
# Draw a graphics window
win = GraphWin('Archery Window', 400, 400)
# Draw the circle from out to inside
blue = Circle(Point(200, 200), 100)
blue.setFill('blue')
... |
0a2723e8901b90d51b3944dda5e52940f5631c85 | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter3/fibonacci.py | 396 | 4.09375 | 4 | # Fibonacci
# fibonacci.py
def main():
# Instruction
print('The program calculates Fibonacci number.')
# Get the n number
n = eval(input('How many numbers do you want?(>2) '))
# Calculate fibonacci
f1 = 1
f2 = 1
for i in range(2, n):
fibo = f1 + f2
f1 = f2
f2 = f... |
5be7c7b7aa9bf5e2d666fee28bf26eaad9766840 | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter4/studentScore.py | 1,258 | 4 | 4 | # Draw Student Scores Bar
# studentScore.py
from graphics import *
def main():
# Instruction
print('The program draws the bar chart with Student Name and')
print('Score in horizontal.')
# Get Input from a file
fileName = input('Give the file name: ')
inFile = open(fileName, 'r')
# First lin... |
2133dc25dcb652326883afe21d3a6f3a9c8c0837 | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter5/caesar.py | 1,529 | 4 | 4 | # Caesar Cipher
# caesar.py
# A-Z: 65-90
# a-z: 97-122, the difference is 32
# For upper case: (num + key) % 91 + (num + key) // 91 * 65
# For lower case: (num + key) % 123 + (num + key) // 123 * 97
# For both: (num + key) % (91 + num // 97 * 32) +
# (num + key) // (91 + num // 97 * 32) * (65 + num // 97 * 32)
de... |
bd874c01e0597151bb1b8383b00b254277436772 | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter11/gpasort.py | 2,441 | 3.53125 | 4 | # gpasort.py
from graphics import *
from gpa import Student, makeStudent
from button import Button
def main():
win = GraphWin('Students Sort', 400, 400)
win.setCoords(0, 0, 4, 5)
input1, input2, bList = drawInterface(win)
while True:
p = win.getMouse()
for b in bList:
if b.... |
39c742637396b520ad65097e4a6ac7fc92b16af4 | quynguyen2303/python_programming_introduction_to_computer_science | /Chapter8/syracuse.py | 447 | 4.125 | 4 | # syracuse.py
# Return a sequence of Syracuse number
def main():
# Introduction
print('The program returns a sequence of Syracuse number from the first input.')
# Get the input
x = int(input('Enter your number: '))
# Loop until it comes to 1
while x != 1:
if x % 2 == 0:
x = ... |
5dd5876363aa431cb73871182406d6da8cef8503 | MakeRafa/CS10-poetry_slam | /main.py | 1,376 | 4.25 | 4 |
# This is a new python file
# random library
import random
filename = "poem.txt"
# gets the filename poem.txt and moves it here
def get_file_lines(filename):
read_poem = open(filename, 'r')
# reads the poem.txt file
return read_poem.readlines()
def lines_printed_backwards(lines_list):
lines_list = lines... |
fdbb84be2145f66814f4b429ffa18319356184f4 | samfishman/crimsononline-assignments | /assignment1/question5.py | 380 | 3.765625 | 4 | from pprint import pprint
class HashableList(list):
def __hash__(self):
return hash(tuple(self[i] for i in range(0, len(self))))
#==TEST CODE==
arr = HashableList([1, 2, 3])
it = {}
it[arr] = 7
it[HashableList([1, 5])] = 3
print "it[HashableList([1, 5])] => ",
pprint(it[HashableList([1, 5])])
print "it[Hashab... |
0ecc954c08459398a9c3900e3bef55260f986e15 | BriskYunus/yunus_b_shahfazlollahi_n_FIP | /assets/traa_graphs/TRAA_data_viz_rainbow_eggs.py | 1,206 | 3.609375 | 4 | import numpy as np
import matplotlib.pyplot as plt
N = 5
eggs_received = (100000, 150000, 100000, 50000, 150000)
year = (2014, 2015, 2016, 2017, 2018)
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(ind, eggs_received... |
7cd321c3e25afc95416c31a9868cfe4d1a0d53fb | millmill/scrabblegame | /Dictionary.py | 980 | 3.703125 | 4 | class Dictionary:
def __init__(self):
self.dictionary = {}
with open("./dictionaries/english_words_94k.txt", "rb") as eng_words:
for word in eng_words:
try:
self.dictionary[word.decode("utf-8").strip()] = True
except UnicodeDecodeE... |
f91cb3f042204645f5bc28f8ac2e87d52c61841f | iluxonchik/webscraping-with-python-book | /Chapter_6/csv.py | 350 | 3.59375 | 4 | from urllib.request import urlopen
from io import StringIO
import csv
data = urlopen("http://pythonscraping.com/files/MontyPythonAlbums.csv").read().decode("ascii", "ignore")
dataFile = StringIO(data) # treat sring as a file
csvReader = csv.reader(dataFile)
for row in csvReader:
print("The album is: " + row[0] + ... |
6bc7a09f1f0b9ae19e3c8c00140e57aa02843bfc | priyankakushi/pythonLearnning | /function1.py | 1,536 | 4.03125 | 4 | # create a function
# def MyFunction():
# print("hello from function")
# # Calling a Function
# MyFunction()
# passing parameters
# def myFunction1(fname,):
# print("Hello",fname)
# myFunction1("Rani")
# # return value
# def myFunction2(num):
# return 4 * num
# x=myFunction2(5)
# prin... |
a4e8145ae4241ebde9e9a4240647fd280cac1110 | ujjwalll/Codeforces | /HQ9.py | 116 | 3.734375 | 4 | b = input()
count = 0
k = 0
for i in b:
if i == "H" or i == "Q" or i == "9":
print("YES")
exit()
print("NO")
|
b9fbe6a2e8791ccbb9b4315aef33bd97fd1aa8a5 | jiakechong1991/search | /query_correct/utils/common.py | 3,597 | 3.734375 | 4 | # coding: utf8
from lang_conf import *
def in_range(c, ranges):
for cur_range in ranges:
if c >= cur_range[0] and c <= cur_range[1]:
return True
return False
def not_in_range(c, ranges):
return not in_range(c, ranges)
def all_in_range(chars, ranges):
""" chars里所有的字符都在ranges里 """
... |
6e5ec4961de30d568666b590ffbbbb6f5e6011d3 | SurajB/resource_allocator | /resource_allocator.py | 5,033 | 3.578125 | 4 |
from operator import itemgetter
#Intialization
sorted_lst_west = []
sorted_lst_east = []
west_server_lst = []
east_server_lst = []
output_lst = []
server_dict = {
"large": 1,
"xlarge": 2,
"2xlarge": 4,
"4xlarge": 8,
"8xlarge": 16,
"10xlarge": 32
}
def get_costs(instances, hours = 0, cpus = 0, price = 0):
#Finding... |
198f794713f011457d34745f16b32e6057e02ec5 | Sairaj9604/Alphabet-pattern-using-python | /j.py | 406 | 3.890625 | 4 | print("I")
for row in range(7):
for col in range(5):
if (row ==0):
print("*", end=" ")
elif (row in {1,2,3,4}) and (col ==2):
print("*", end=" ")
elif (row ==5) and (col in{0,2}):
print("*", end=" ")
elif (row ==6) and (col ==1):
... |
3bd1002ef0377f38e5d98d1e163c721a5c66e8b4 | soham0511/Python-Programs | /PYTHON PROGRAMS/conditional.py | 171 | 4.25 | 4 | a=45
if(a>3):
print("Value of a is greater than 3")
elif(a>6):
print("Value of a is greater than 7")
else:
print("Value of a is not greater than 3 or 7") |
22dc36de5686070bc61a6dcea0cb43d2612c0b2c | soham0511/Python-Programs | /PYTHON PROGRAMS/04vardtypes.py | 329 | 3.96875 | 4 | a="Soham"#string
b="42"#integer
c=4081.12#floating point integer
print(a)
print(b)
print(c)
#print(a+" "+b+" "+c) error integer c cannot be concatenated to string because unlike java string
#is not the default datatype
print(a+" "+b)#no problem since 42 is a string
print(type(c)) #printing the datatype
print... |
8db11a8c475c03280d69d97b8a6538300a5be654 | tatendafmukaro/heart_rate | /heart_rate.py | 801 | 3.921875 | 4 | """
When you physically exercise to strengthen your heart, you
should maintain your heart rate within a range for at least 20
minutes. To find that range, subtract your age from 220. This
difference is your maximum heart rate per minute. Your heart
simply will not beat faster than this maximum (220 - age).
When e... |
16438c5bf345d608ff8416edc5289ea7272ec016 | StevenGhow/For_Junyi | /2_multiple.py | 211 | 3.734375 | 4 | num = int(input("input:"))
result = []
for ii in range(1, num+1):
if ii % 5 == 0 and ii % 3 == 0:
result.append(ii)
elif ii % 5 != 0 and ii % 3 != 0:
result.append(ii)
print(len(result)) |
2e0d104b9aaf7b2c3dd993db7f548731ba4179e5 | vesche/juc2 | /examples/example_06.py | 784 | 3.578125 | 4 | #!/usr/bin/env python
"""
juc2/examples/example_06.py
Draw a bunch of rectangles and move them around at random. ^_^
"""
import random
from juc2 import art, Stage
HEIGHT = 40
WIDTH = 100
stage = Stage(height=HEIGHT, width=WIDTH)
rectangles = list()
for i in range(30):
d, x, y = random.randint(3, 8), random.r... |
81525e42c8fa2cd5d7dc6b5f2aab5e7370d9bc5f | palashsharma891/Algorithms-in-Python | /2. Trees/3. Special Techniques/lca.py | 907 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 21 12:22:57 2021
@author: palash
"""
def get_path_from_root(root, val):
def dfs(root, val, path):
if root is None:
return
else:
path.append(root) # add to path
if root.val == val
... |
2aab194aba65b1e511a7b9d2d29ccd016edaae70 | palashsharma891/Algorithms-in-Python | /6. Searching and Sorting/countingSort.py | 518 | 3.953125 | 4 | def countingSort(array):
size = len(array)
output = [0] * size
count = [0] * 10
for i in range(size):
count[array[i]] += 1
for i in range(1, 10):
count[i] += count[i-1]
i = size - 1
while i >= 0:
output[count[array[i]] - 1] = array[i]
... |
c16a74d047966190473065d6b9d16e619dec7814 | palashsharma891/Algorithms-in-Python | /2. Trees/3. Special Techniques/existsInTree.py | 356 | 3.859375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 21 11:43:34 2021
@author: palash
"""
def existsInTree(root, value):
if root is None:
return False
else:
leftExist = existsInTree(root.left, value)
rightExist = existsInTree(root.right, value)
return root.dat... |
72e84ca9b62056459a760f02f775cd5b59d0d801 | palashsharma891/Algorithms-in-Python | /6. Searching and Sorting/bubbleSort.py | 309 | 4.34375 | 4 | def bubbleSort(array):
for i in range(len(array)):
for j in range(0, len(array) - i - 1):
if array[j] > array[j+1]:
(array[j], array[j+1]) = (array[j+1], array[j])
data = [-2, 45, 0, 11, -9]
bubbleSort(data)
print("Sorted array is: ")
print(data)
|
5ebe70d52484369c71fda2eab422b34274ce05d5 | sanrenyimu/identifying-critical-nodes | /algrtm2.py | 3,035 | 3.5 | 4 | import copy, math
# Reads the Graph from file
Vertices = int(input('enter Number of Vertices: '))
k_bound = int(input('enter k_bound or enter 0: '))
if k_bound == 0:
k_bound = math.ceil(0.36 * Vertices)
# file_name = input("enter data file name (e: file_name.txt): ")
my_file = list(open("graph_sample.txt", 'r'))... |
e0f739400b81672043e5dc2a56457b1e808b4b09 | YangXiaozhou/IE5202-Project-1 | /util_formula.py | 8,189 | 3.65625 | 4 | import statsmodels.formula.api as smf
import statsmodels.api as sm
import pandas as pd
import numpy as np
from sklearn.cross_validation import KFold
import itertools
"""
The function obtain the model fitting results
feature_set: is the collection of input predictors used in the model
data: is the dataframe c... |
a2cf46db68ef3b309185e0e7802714fe37cbf10a | ju-c-lopes/Logica-de-programacao | /Python/mediaidades.py | 273 | 3.8125 | 4 |
print("Digite as idades")
idade = int(input())
soma = 0
cont = 0
if idade < 0:
print("IMPOSSIVEL CALCULAR")
else:
while idade > 0:
soma = soma + idade
cont = cont + 1
idade = int(input())
media = soma / cont
print(f"Media = {media:.2f}") |
efa5c33af7feb138defc048e2db956e558f4d4af | ju-c-lopes/Logica-de-programacao | /Python/variavel_for_teste.py | 69 | 3.65625 | 4 | x: int
y: int
i: int
x = 0
y = 5
for i in range(x,y):
print(i)
|
7021ceb11212b0da3e5e8af79d315ce60dc58cc9 | MarkJasonE/LandingSitesOnMars | /elevation_profile.py | 1,424 | 3.5625 | 4 | """ A side view from west to east through Olympus Mons. This will allow to extract meaningful insights regarding the smoothness of a surface and visualize its topography."""
from PIL import Image, ImageDraw
import matplotlib.pyplot as plt
from utils import save_fig
#Get x and z val along the horizontal profile, parall... |
5cd68fffc941d9c770a1b944052c4f08f69069f2 | xmichelle26x/pairprogramming_tennis | /functions.py | 1,186 | 3.53125 | 4 | points = 0
playerOne = 0
playerTwo = 0
point = [0, 15, 30, 40]
playerOne = {
"zero": 0,
"fifteen": 15,
"thirty": 30,
"forty": 40,
"name": "playerOne"
}
class Player:
def __init__(self, score):
self.score = score
def setear_score(self, score):
self.score = score
playerOne... |
6c2730d080f8c443030873e79131619df41f93c4 | dbaleeds/DataPrep | /Thresholds/thresholdsCSV.py | 748 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thursday Dec 11 15:19:00 2018
@author: dbaleeds
A script to render data to acceptable thresholds for output
"""
import pandas as pd
import csv
import re
#set the threshold
threshold = 5
#set what the value should show if it falls below the threshold
placeholder = '<5'
#set the ... |
83bb60faab926793651b498c42a3dbe47059b64a | sushvk/manipulating-data-with-numpy-code-along | /code.py | 2,052 | 3.78125 | 4 | # --------------
import numpy as np
# Not every data format will be in csv there are other file formats also.
# This exercise will help you deal with other file formats and how toa read it.
data_ipl =np.genfromtxt(path,delimiter =',',dtype='str',skip_header=True)
#data_ipl[1:5,:]
matches = data_ipl[:,0]
print(len(set(m... |
768546b334da56514b948f5ad6da2e9fd69fa74b | ljjhpu/untitled | /521.py | 1,046 | 3.78125 | 4 | # class Solution:
# def jumpFloor(self, number):
# # write code here
# if number == 1:
# return 1
# elif number == 2:
# return 2
# else :
# res = self.jumpFloor(number - 1) + self.jumpFloor(number - 2)
# return res
# 实现斐波那契数列
"""
1,2,... |
0e90bcaea3c896ad3727d5a1eee3bd67e2adbf5b | phvash/NPCore | /phvash/problem sets/xtreme11/quipy1.py | 2,017 | 3.71875 | 4 | # Case N == D return 1
# Case N is prime and not a factor of D, return 2
# Case N is not prime and not a factor of D, return length of
# list containing factors of N
# Case N
# def factors(n):
# return set(x for tup in ([i, n//i]
# for i in range(1, int(n**0.5)+1) if n % i == 0) for x in... |
e2e9694cd6916afb6541d608f340a88579221dba | khiner/simple_matrix | /matrix.py | 10,142 | 3.859375 | 4 | class Matrix:
def __init__(self, n_rows_or_list = 0, n_columns = 0):
if isinstance(n_rows_or_list, list):
self.n_rows = len(n_rows_or_list)
if self.n_rows > 0 and isinstance(n_rows_or_list[0], list):
self.n_columns = len(n_rows_or_list[0])
else:
self.n_columns = 1
else:
... |
2655a0529c8ce4d2c8a0e536f38bfb68c97df453 | ranji2612/Algorithms | /dp/01knapsack.py | 339 | 3.796875 | 4 | def knapsackProblem(weight, value, capacity):
# As we Iterate through each item, we two choices, take it or leave it
# So the choice should be the one which maximizes the value
# Can be done in both Recursion(DP with Memoization) & Iterative DP
#Iterative Solution
maxWt = [ [0 for x in range(weight)] for x in ... |
aaee1e60838c453cef553cd125152c699bd3b126 | ranji2612/Algorithms | /sorts/insertionSort.py | 258 | 3.953125 | 4 | def insertionSort(A, printSteps = False):
l = len(A)
#Iterate from second element to Last
for j in range(1,l):
k = j
val = A[k]
while k>0 and A[k-1] > val:
A[k] = A[k-1]
k-=1
A[k] = val
if printSteps:
print 'Iter '+str(j),A
return A
|
c37aba3b14d6af7204c909b623f1de8563dabf35 | Abdelrahmanrezk/Sentiment-Behind-Reviews | /Sentiment_behind_reviews/file_handles/handle_combind_shuffle_reviews.py | 7,966 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Reviews Handling
# based on the problems of Sentimen Classifcation some of reviews file have muliple columns like:
# - 'reviews.dateAdded'
# - 'reviews.dateSeen'
# - others columns
#
# but we just interset in two columns the text review and the rate of each review.
#
# So h... |
5b4161986fe4af26d3a588ecd8a28347212aecbf | lexboom/Testfinal | /Studentexempt.py | 2,121 | 4.375 | 4 | #Prompt the user to enter the student's average.
stu_avg = float(input("Please enter student's average: "))
#Validate the input by using a while loop till the value
#entered by the user is out of range 0 and 100.
while(stu_avg < 0 or stu_avg > 100):
#Display an appropriate message and again, prompt
... |
3196064e2211728cc382913d1f6c6a0b019364c4 | micajank/python_challenges | /exercieses/05factorial.py | 365 | 4.40625 | 4 | # Write a method to compute the `factorial` of a number.
# Given a whole number n, a factorial is the product of all
# whole numbers from 1 to n.
# 5! = 5 * 4 * 3 * 2 * 1
#
# Example method call
#
# factorial(5)
#
# > 120
#
def factorial(num):
result = 1
for i in range(result, (num + 1)):
result = resu... |
99002ac30ecbeeeebb743872620e223b9d058a8b | dmunozbarras/Practica-7-Python | /Ej7-1.py | 380 | 4.03125 | 4 | # -*- coding: cp1252 -*-
"""DAVID MUÑOZ BARRAS - 1º DAW - PRACTICA 7 - EJERCICIO 1
Escribe un programa que pida un texto por pantalla, este texto lo pase como parámetro a un
procedimiento, y éste lo imprima primero todo en minúsculas y luego todo en mayúsculas.
"""
def cambio(x):
print x.lower()
print ... |
7b1452a65bd7777187678c2bc483988e78cfa982 | kanaud/Any-GuI-API- | /anygtk.py | 10,889 | 3.734375 | 4 | import gtk # importing the module gtk
now_position=[10,10] # defining a global variable now_position
def default_position(x,y): # writing a method to assign default positions to widgets
now_position[0]=now_position[0]+x
now_position[1]=now_position[1]+y
return now_po... |
aad38dd193cdab0a22db9054c667eead9df005df | imsazzad/programming-contest | /uva/Dark_Roads.py | 623 | 3.5625 | 4 | import operator
while True:
node, edge = input().strip().split(' '); # python 2 raw input
node, edge = [int(node), int(edge)];
if (node == 0 and edge == 0):
break;
sorted_edge = {};
for i in range(edge):
x, y, z = input().strip().split(' ');
x, y, z = [int(x), int(y), int(z... |
21cb794219fb722cba5e2c369d23522b60421b8f | abouchan01/EDA-2019-2 | /Practice_11.py | 5,123 | 3.953125 | 4 | #En este documento se encuentran ordenados del primero al octavo de los codigos fuente de la practica 11.
from string import ascii_letters, digits
from itertools import product
#concatenar letras y dífitos en una sola cadena
caracteres= ascii_letters+digits
def buscador (con):
#archivo con todas las combinaciones ... |
e8e951c5c2e452264db382daffe4d31032e0811d | abouchan01/EDA-2019-2 | /Practice_11_4.py | 978 | 3.875 | 4 | #Top-down
memoria = {1:0,2:1,3:1} #Memoria inicial
import pickle #Carga la biblioteca
archivo = open('memoria.p','wb') #Se abre el archivo para escribir en modo binario
pickle.dump(memoria, archivo) #Se guarda la variable memoria que es un diccionario
archivo.close() #Se cierra el archivo
archivo = open('memoria.p','rb... |
e7fdfdedde1c8c315f6a7743dcd65d0d60569845 | bernardbrandao/Python2019_1 | /aula3_5.py | 863 | 3.9375 | 4 | import math
def IMC(massa,altura):
imc = float(massa) / ((float(altura))**2)
print('o indice de massa corporal e ', "%.2f" % imc)
altura = input("Digite a altura da pessoa: ")
massa = input("Digite a massa da pessoa: ")
IMC(massa,altura)
def calc_vol(r):## em metros cubicos
Volume = (4/3)*(math.pi)* floa... |
81fae3ee5bef718c6e7c8a6d7e8379341e8a374a | bernardbrandao/Python2019_1 | /Aula6_1_A.py | 242 | 3.5625 | 4 | import turtle
t= turtle.Turtle()
def square(t):
jn = turtle.Screen() # Configurar a janela e seus atributos
jn.bgcolor("lightyellow")
jn.title("Quadrado")
for i in range (4):
t.forward(50)
t.left(90)
square(t)
|
a86756685311b1144178feeb59cf3b6df704bc2d | bernardbrandao/Python2019_1 | /aula9_01B.py | 471 | 3.828125 | 4 | class clone:
def nova_lista(uma_lista):
""" Essa funcao faz uma copia da lista dada e modifica a copia dobrando os valores dos seus elementos.
"""
clone_lista = uma_lista[:]
for (i, valor) in enumerate(clone_lista):
novo_elem = 2 * valor
clone_lista[i] = novo... |
45d01c8faa0aaaca7e666166ebea2c612fe80239 | drunkwater/leetcode | /medium/python3/c0300_647_palindromic-substrings/00_leetcode_0300.py | 809 | 3.828125 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#647. Palindromic Substrings
#Given a string, your task is to count how many palindromic substrings in this string.
#The substrings with different start i... |
a0df7dbbc3139b4a37db898b5d7e850d4f7f8906 | drunkwater/leetcode | /hard/python3/c0101_552_student-attendance-record-ii/00_leetcode_0101.py | 1,084 | 3.625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#552. Student Attendance Record II
#Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded... |
9c9fb00c316199447af33e79a78359efcc6b08d9 | drunkwater/leetcode | /medium/python/c0075_142_linked-list-cycle-ii/00_leetcode_0075.py | 691 | 3.5 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#142. Linked List Cycle II
#Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
#Note: Do not modify the linke... |
11ed38a411b99db38585b56de9fc0fba749f2652 | drunkwater/leetcode | /hard/python3/c0141_761_special-binary-string/00_leetcode_0141.py | 1,223 | 3.671875 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#761. Special Binary String
#Special binary strings are binary strings with the following two properties:
#The number of 0's is equal to the number of 1's... |
0e073b114f501d4e46eeeded78b6e59da37714a0 | drunkwater/leetcode | /medium/python/c0259_526_beautiful-arrangement/00_leetcode_0259.py | 1,208 | 3.6875 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#526. Beautiful Arrangement
#Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers... |
d819ea63f5685a96e3c720248df41dfc2c79a874 | drunkwater/leetcode | /medium/python/c0285_583_delete-operation-for-two-strings/00_leetcode_0285.py | 814 | 3.75 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#583. Delete Operation for Two Strings
#Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where... |
bdf6ddc95d5103135345a7a752f16c558df76205 | drunkwater/leetcode | /medium/python3/c0240_481_magical-string/00_leetcode_0240.py | 1,160 | 3.84375 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#481. Magical String
#A magical string S consists of only '1' and '2' and obeys the following rules:
#The string S is magical because concatenating the nu... |
a1b41adcda2d3b3522744e954cf8ae2f901c6b01 | drunkwater/leetcode | /medium/python3/c0099_209_minimum-size-subarray-sum/00_leetcode_0099.py | 798 | 3.546875 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#209. Minimum Size Subarray Sum
#Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which... |
6f206aae6b5c1f54376ab0272a29df549f558c7a | drunkwater/leetcode | /medium/python/c0356_779_k-th-symbol-in-grammar/00_leetcode_0356.py | 945 | 3.515625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#779. K-th Symbol in Grammar
#On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 wi... |
cff345e92a42dd91bdda6ec354b4f6da7959d52e | drunkwater/leetcode | /easy/python/c0100_409_longest-palindrome/00_leetcode_0100.py | 762 | 3.515625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#409. Longest Palindrome
#Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built wi... |
51f20d548cb8c6c0df7895a1b98cbf08e44d4a70 | drunkwater/leetcode | /medium/python3/c0252_513_find-bottom-left-tree-value/00_leetcode_0252.py | 841 | 3.78125 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#513. Find Bottom Left Tree Value
#Given a binary tree, find the leftmost value in the last row of the tree.
#Example 1:
#Input:
# 2
# / \
# 1 3
#... |
6de2173a736994fd14b1b7582390244b95bb0782 | drunkwater/leetcode | /medium/python/c0039_75_sort-colors/00_leetcode_0039.py | 1,111 | 3.625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#75. Sort Colors
#Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the co... |
25db5937814b9cad78b5a6a96c34f942be58b6b5 | drunkwater/leetcode | /easy/python/c0019_88_merge-sorted-array/00_leetcode_0019.py | 894 | 3.671875 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#88. Merge Sorted Array
#Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
#Note:
#The number of elements initi... |
dff1f2a45dd7db365f0eb4dfb2cae29e11ab4132 | drunkwater/leetcode | /medium/python/c0003_6_zigzag-conversion/00_leetcode_0003.py | 976 | 3.90625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#6. ZigZag Conversion
#The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this patte... |
9ed6c9f4d5a63da916f992358efca0e942e2dd65 | drunkwater/leetcode | /easy/python/c0084_345_reverse-vowels-of-a-string/00_leetcode_0084.py | 586 | 3.671875 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#345. Reverse Vowels of a String
#Write a function that takes a string as input and reverse only the vowels of a string.
#Example 1:
#Given s = "hello", r... |
65f317170c57b948dfb1d458b7464fd2135a4cb8 | drunkwater/leetcode | /easy/python/c0181_747_largest-number-at-least-twice-of-others/00_leetcode_0181.py | 1,090 | 3.671875 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#747. Largest Number At Least Twice of Others
#In a given integer array nums, there is always exactly one largest element.
#Find whether the largest eleme... |
6a58e4a32ff7c0a37569f1975131d2f0250a8472 | drunkwater/leetcode | /medium/python/c0104_216_combination-sum-iii/00_leetcode_0104.py | 768 | 3.625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#216. Combination Sum III
#Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each... |
459e08a0443040c7e3b9dbbef45c683ffb2277e4 | drunkwater/leetcode | /medium/python3/c0313_667_beautiful-arrangement-ii/00_leetcode_0313.py | 1,164 | 3.828125 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#667. Beautiful Arrangement II
#Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n ... |
736fa511a3435e9cfd403b4bfe687cc86cd434c2 | drunkwater/leetcode | /medium/python/c0211_406_queue-reconstruction-by-height/00_leetcode_0211.py | 847 | 3.5 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#406. Queue Reconstruction by Height
#Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k),... |
0f41b47bd2e12204d5304a5c86e346602a44173a | drunkwater/leetcode | /medium/python/c0154_313_super-ugly-number/00_leetcode_0154.py | 1,039 | 3.90625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#313. Super Ugly Number
#Write a program to find the nth super ugly number.
#Super ugly numbers are positive numbers whose all prime factors are in the gi... |
0b62f5917ed5c69ec3b72d36878ae688496d2433 | drunkwater/leetcode | /medium/python/c0258_525_contiguous-array/00_leetcode_0258.py | 774 | 3.703125 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#525. Contiguous Array
#Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.
#Example 1:
#Input: [0,1]
#Ou... |
5be735a231521a1d207591384ac2222b39a2df7b | drunkwater/leetcode | /medium/python/c0317_676_implement-magic-dictionary/00_leetcode_0317.py | 1,855 | 3.828125 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#676. Implement Magic Dictionary
#Implement a magic directory with buildDict, and search methods.
#For the method buildDict, you'll be given a list of non... |
4c48b068be3fd43c9f9a6602e8e6d2ed217d2da7 | drunkwater/leetcode | /medium/python3/c0150_307_range-sum-query-mutable/00_leetcode_0150.py | 1,142 | 3.5625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#307. Range Sum Query - Mutable
#Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.
#The update(i, val)... |
66826010a2c0e37b1d15937105c84e7240fd7b2a | drunkwater/leetcode | /easy/python/c0121_485_max-consecutive-ones/00_leetcode_0121.py | 739 | 3.5 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#485. Max Consecutive Ones
#Given a binary array, find the maximum number of consecutive 1s in this array.
#Example 1:
#Input: [1,1,0,1,1,1]
#Output: 3
#E... |
769521c7ccab6a8ca1bdcf0c7f2b2bfd8fd64a0a | drunkwater/leetcode | /easy/python/c0038_167_two-sum-ii-input-array-is-sorted/00_leetcode_0038.py | 942 | 3.59375 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#167. Two Sum II - Input array is sorted
#Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to ... |
453f8a8af6b0f4b0ef3eb5847cc0dfa635bfe548 | drunkwater/leetcode | /hard/python3/c0136_745_prefix-and-suffix-search/00_leetcode_0136.py | 1,226 | 3.765625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#745. Prefix and Suffix Search
#Given many words, words[i] has weight i.
#Design a class WordFilter that supports one function, WordFilter.f(String prefix... |
29dcda207100679ff05ad1f9ab153b816adb0af8 | drunkwater/leetcode | /easy/python3/c0169_693_binary-number-with-alternating-bits/00_leetcode_0169.py | 852 | 3.90625 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#693. Binary Number with Alternating Bits
#Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.