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 |
|---|---|---|---|---|---|---|
8470c24e0ab592450635588d1529b155da7ef55e | drishyatm/Codecademy | /page_objects/codecademy_login_page_object.py | 2,528 | 3.515625 | 4 | """
This class models the form on the Codecademy Login page
The form consists of some input fields username and password
"""
import conf.locators_conf as locators
import conf.test_codecademy_conf as conf
from utils.Wrapit import Wrapit
class Codecademy_Login_Page_Object:
"Page object for the Login Page"
# lo... |
225f55af87c32ed1bb0e1471af4ec4cce0a6c65f | FanchenBao/GAME_Alien_Invasion | /reward_stats.py | 2,503 | 3.6875 | 4 | '''
Author: Fanchen Bao
Date: 02/17/2018
Description:
RewardStats class, handle the statistics related to rewards from hitting alien.
Note that at different level of the game, the probability for different rewards are different.
'''
from random import randint
class RewardStats():
''' a class to represent stats for ... |
6e954ee0e789eaad7fb38949d990124fcf5a39e3 | h0oper/DojoAssignments | /Python/Python/ComparingLists/server.py | 611 | 3.859375 | 4 | # list_one = [1,2,5,6,2]
# list_two = [1,2,5,6,2]
# list_one = [1,2,5,6,5]
# list_two = [1,2,5,6,5,3]
# list_one = [1,2,5,6,5,16]
# list_two = [1,2,5,6,5]
list_one = ['celery','carrots','bread','milk']
list_two = ['celery','carrots','bread','cream']
def server (list_one, list_two):
count = 0
if len(list_one) == l... |
5ca0e9fec9b1cc737130a10bb31a46ec82f8ccd6 | h0oper/DojoAssignments | /Python/Python/TypeList/Stars/server.py | 338 | 3.546875 | 4 | def draw_stars(lis):
for z in lis:
if type(z) == int or type(z) == float:
newstr = ""
for v in range(0,z):
newstr += "*"
print newstr
if type(z) == str:
newstr = ""
for v in range(0,len(z)):
newstr += z[0].lower()
print newstr
x = [4, "Tom", 1, "Michael", 5, 7, "Jimmy Smith"]
y = [4,6,1,... |
f1766a33179e812727ebad52ccff3ed3bbc80c01 | h0oper/DojoAssignments | /Python/Python/TypeList/server.py | 890 | 3.90625 | 4 | a = ['magical unicorns',19,'hello',98.98,'world']
b = [2,3,1,7,4,12]
c = ['magical','unicorns']
def server(p):
total = 0
sentence = ""
intcount = 0
strcount = 0
for element in p: #iterating through array for elements
if type(element) == int or type(element) == float:
intcount = intcount + 1 #check number of ... |
a81acb8892bdb89c2c61ed08a67c2cfbf82b8bbc | h0oper/DojoAssignments | /Python/Python/Fundamentals/group3.py | 774 | 3.859375 | 4 | '''
def number1():
greeting = "hello"
name = "dojo"
print name + greeting
number1()
'''
'''
def number2(li):
for i in li:
print i
number2(["wish", "mop", "bleet", "march", "jerk"])
'''
'''
def number3(num):
li =[]
for i in range(0,25):
num*=2
li.append(num)
print li... |
fef3ba62f6495c7de96680119717794cb06ea513 | NikMunigela/Recommendation-System | /Error Measures/measures.py | 569 | 3.921875 | 4 | import numpy as np
def rmse(M, M_p):
"""
This function is used to compute the Root Mean Square Error.
"""
x_len = M.shape[0]
y_len = M.shape[1]
error = 0
N = x_len * y_len
for x in range(x_len):
for y in range(y_len):
error += ((M[x][y] - M_p[x][y]) ** 2) / N
e... |
29a4a6573f9c27772fce6549d219ffdb147b0d21 | jgeng98/fcc-scientific-computing-python-polygon-area-calculator | /shape_calculator.py | 1,585 | 3.765625 | 4 | class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def __str__(self):
if isinstance(self, Square):
return "Square(side={side_length})".format(side_length=self.width)
else:
return "Rectangle(width={width}, height={h... |
870584ac512971e7b83b510160036437227417f9 | Apoorva-K-N/Online-courses | /Day 12/coding/prog1(Day 12).py | 280 | 4.125 | 4 | 1.Python Program for Sum of squares of first n natural numbers
def squaresum(n):
return (n * (n + 1) / 2) * (2 * n + 1) / 3
n=int(input("Enter number"))
print("Sum of squares n numbers : ",squaresum(n));
output:
Enter number5
Sum of squares n numbers : 55.0 |
d84901935f5ebe0122a4de43dda9133e287b4d16 | facinettoure/referral | /main.py | 797 | 3.75 | 4 | if __name__ == '__main__':
reference= []
balance = {}
price=5
buy=[]
print('Product List')
print('product 1 ---> 5$ Price')
while True:
print('\n')
name= input('whats your name:')
ref_num = int(input('How many people u want to refer:'))
data = []
for ... |
8b3047ed94e8d2c6402ec37a0b9ac0c4eb22f878 | shanyt/xss_fuzzing_scraper | /fuzzing_scraper/t1.py | 154 | 3.96875 | 4 | n = 5
while n > 0:
age = int(raw_input("Plz input your age"))
n = n - 1
if age >= 18:
print 'adult'
else:
print 'teenager' |
1ced156b8bad36c94f49d1c51483611eba47754d | Deepomatic/challenge | /ai.py | 2,709 | 4.125 | 4 | import random
def allowed_moves(board, color):
"""
This is the first function you need to implement.
Arguments:
- board: The content of the board, represented as a list of strings.
The length of strings are the same as the length of the list,
which represe... |
f6cb3a0ddc22aaa93e121407412d677c9892459a | jaho901/SWEA_coding_practice | /1001/p1/p1.py | 601 | 3.515625 | 4 | arr = [5, 2, 7, 1, 3, 4, 9, 8, 7, 2]
for i in range(len(arr)):
min_idx = i
for j in range(i+1, len(arr)):
if arr[j] < arr[min_idx]:
min_idx = j
arr[i], arr[min_idx] = arr[min_idx], arr[i]
print(arr)
arr = [5, 2, 7, 1, 3, 4, 9, 8, 7, 2]
def selectionSort(start, end):
min_idx = sta... |
b023d5d28ddd6c98f89d46444265d066813248a9 | jaho901/SWEA_coding_practice | /0812/4839_binary_search/p3.py | 691 | 3.59375 | 4 | import sys
sys.stdin = open('input.txt')
# binary_search를 하는 함수를 만들자
def binary_search(last_page, goal):
cnt = 1
l, r = 1, last_page
c = (1 + r)//2
while c != goal:
if c < goal:
l = c
c = (l + r)//2
elif c > goal:
r = c
c = (l + r)//2
... |
4d15f968ac09a8610a06948fb44c4395d343cea9 | junaidfiaz143/Weapon-API | /data_model.py | 328 | 3.765625 | 4 | from dataclasses import dataclass
@dataclass
class Data:
name: str = ""
age: int = 0
number: int = 0
def getName(self):
return self.name
def getAge(self):
return self.age
def getNumber(self):
return self.number
d = Data("JD", 1, 2)
print(d.getName())
print(d.getAge())
print(d.getN... |
aa7c27b5f5a83953acaba3e7c707bea72493c170 | emilIftekhar/contact_strategies | /contact_counter.py | 883 | 3.6875 | 4 |
class Contact_Counter:
def __init__(self, population_IDs):
self.contact_counts = {}
for ID in population_IDs:
self.contact_counts[ID] = 0
def count_contacts(self, person1_ID, person2_ID):
self.contact_counts[person1_ID] += 1
self.contact_counts[person2_ID] += 1
... |
e1aebc8fd45cdee10f05c3811cf4ef973930971d | Qlogin/python | /challanges.py | 27,083 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 24 13:56:12 2015
@author: q-login
"""
import re
import itertools
xrange = range
###############################################################################
def PermutationStep(num):
"""
Return the next number greater than 'num' using the same digits.
F... |
40168e8454f98da604ad266c6e862f5a64117df3 | deepak-mane/cracking-the-coding-interview | /python_solutions/chapter_01_arrays_and_strings/problem_01_01_is_unique.py | 198 | 3.84375 | 4 | def is_unique(input):
dict = [False]*128
for letter in input:
index = ord(letter)
if dict[index] == True:
return False
dict[index] = True
return True
|
d6c33cb465705f1c7a9b5719fe9dc54b883d1582 | Nawaf1409/MIYE | /Miye_Summer2016/Miye/SD.py | 7,847 | 3.890625 | 4 | import csv
import time
import pandas as pd
import datetime
import copy
def convertListToDf(inputList):
"""
Converts an list object to a DataFrame
"""
newInputList = inputList[:]
header = newInputList[0]
newInputList.remove(header)
inputList_df = pd.DataFrame(newInputList,columns = header)
return inputList_df... |
59bdb38f9ef75b24a6c4ab114d6fcb3d04be9df1 | pmazgaj/SerialApp | /modules/file_parser.py | 975 | 3.609375 | 4 | """
Module to parse .*csv files into list of values.
Possible - line by line (yield) and all_data.
"""
import csv
from settings_files.program_settings import *
__author__ = "Przemek"
class FileHandler:
@staticmethod
def get_data_line_by_line(file) -> list:
"""Parse data to list, from given file, step... |
c705cd6c2c07fab452bc83550ca83116952bc2b9 | shnehna/python_study | /string.py | 238 | 4.21875 | 4 | num_str = "Hello world "
# print(num_str.isdecimal())
# print(num_str.isdigit())
# print(num_str.isnumeric())
print(num_str.startswith("H"))
print(num_str.endswith("d"))
print(num_str.find(" "))
print(num_str.replace("world", "python"))
|
26b6f6c94f7cd5a01f804b4c409e76aef864692a | alcmenem/numerical-analysis-projects-uni- | /aran_project_7.py | 3,036 | 3.96875 | 4 | #
#Αριθμητική Ανάλυση - υποχρεωτική εργασία 2017-2018 - 7η εκφώνηση
import numpy as np
def least_squares_method(x_list,y_list, degree, input):
# create A
#print("Creating A matrix...")
n = len(x_list)
A = np.zeros(shape=(n, degree+1))
b = np.zeros(shape=(n, 1))
# fill in b matrix wi... |
b6aa6c29e3b5c46a54a3dd7725f99df7742cf06e | sola1121/references_of_machine_learning | /Python Machine Learning CookBook/数据预处理/数据预处理sklearn.preprocessing-归一化(Normalization).py | 693 | 3.625 | 4 | import numpy as np
from sklearn import preprocessing
data = np.array([
[3, -1.5, 2, 5.4],
[0, 4, -0.3, 2.1],
[1, 3.3, -1.9, -4.3],
])
# 归一化(Normalization)
# 数据归一化用于需要对特征向量的值进行调整时, 以保证每个特征向量的值都缩放到相同的数值范围.
# 机器学习中最常用的归一化形式就是将特征向量调整为L1泛数, 使特征向量的数值之和为1.
data_normalized = preprocessing.normalize(data, norm=... |
38a4524825587ad4c8d39ee9398d37ae760d8950 | cceniam/BaiduNetdiskDownload | /python/python系统性学习/2020_04_18/list_learn.py | 2,360 | 4.125 | 4 | """
类似于 int float 这种类型,没有可以访问的内部结构
类似于 字符串 (str) 是结构化非标量类型 有一系列的属性方法
今天学习 list 列表 :
"""
# list 有序 每个值可通过索引标识
import sys
list1 = [1, 2, 3, 4, 5, 6]
print(list1)
# 乘号表示重复的次数
list2 = ['hello'] * 3
print(list2)
list3 = list1 * 3
print(list3)
# len() 计算list长度
print(len(list3))
# 通过enumerate函数处理列表之后再遍历可以同时获得元素索引和值
for w... |
86f6c4269a18a3f175f67e1e76d6e2df175d375b | cceniam/BaiduNetdiskDownload | /python/python系统性学习/2020_04_20/文件和异常.py | 383 | 3.921875 | 4 | """
文件的读写操作
"""
def main():
try:
f = open('test.txt', 'r', encoding='utf-8')
print(f.read())
except FileNotFoundError:
print("file not exist")
except LookupError:
print("unknown encoding")
except UnicodeDecodeError:
print("encoding error")
finally:
f... |
6b54f7894bb938078efb1b00f98d8965285049df | wxy1031/hi | /hi.py | 140 | 3.5625 | 4 | name = input('請輸入名字: ')
height = input('請輸入身高: ')
weight = input('請輸入體重: ')
print('嗨', name, height, weight) |
5e1e2e536787176e984cd8c7ad63169371361fb9 | anokhramesh/Calculate-Area-Diameter-and-Circumference | /calculate_area_diametre_Circumference_of_a_circle.py | 466 | 4.5625 | 5 | print("A program for calculate the Area,Diameter and Circumference of a circle if Radius is known")
print("******************************************************************************************")
while True:
pi = 3.14
r = float(input("\nEnter the Radius\n"))
a = float(pi*r)*r
d = (2*r)
c ... |
b7560159501ff4a9aa8034fe5e654c52ee856d2c | yawzyag/holbertonschool-interview | /0x0C-nqueens/0-nqueens.py | 1,907 | 3.734375 | 4 | #!/usr/bin/python3
"""
[find n posible queens]
"""
from sys import argv, exit
def ln(x):
"""[logaritm implementation]
Args:
x ([int]): [number to find logaritm]
Returns:
[int]: [lograit value]
"""
n = 1000.0
return n * ((x ** (1/n)) - 1)
def solveBoard(list_items, row, row... |
17e647bab2f04410dad20c71703b358ac50a23dc | tunielmegor/Random-Stufff | /media.py | 541 | 3.515625 | 4 | cantidad = int(input("Tamaño de la muestra: "))
total = 0
lista = []
nro_menos_mediaacum = 0
for i in range(cantidad):
nro = float(input("Ingrese valores uno a uno "))
lista.append(nro)
total = total + nro
#total += float(nro)
media=total/cantidad
print("media = "media)
for i in range(c... |
b0f171588a69286bc1aaba953e45b712a23ffb66 | ggrossvi/core-problem-set-recursion | /part-1.py | 1,130 | 4.3125 | 4 | # There are comments with the names of
# the required functions to build.
# Please paste your solution underneath
# the appropriate comment.
# factorial
def factorial(num):
# base case
if num < 0:
raise ValueError("num is less than 0")
elif num == 0:
# print("num is 0")
return 1
... |
afe1218c973cdb531798955d0c7167c8e8c80f9a | NeroSH/python-beginner | /Module 1/Unit_1-2/2/Исправь ошибки 1/2.py | 428 | 4 | 4 | # Программа должна считать сумму чисел.
# Из-за кавычек программа объединяет строки и печатает "123456".
# Убери кавычки, чтобы значениями переменных были числа 123 и 456,
# результатом работы программы должна стать их сумма!
a = "123"
b = "456"
print(a + b)
|
568b10f43910994019c5a58b705b088deb391f3b | Spider-shi/python_learning | /PythonEX/userpw.py | 1,500 | 3.96875 | 4 | #! /usr/lib/python
#Filename : userpw.py
useroperator = '''
\'1\':userapply,
\'2\':userlogin,
\'q\':userexit
'''
userpw = {}
def userapply():
while True:
username = raw_input('Please input the account:')
if username in userpw.keys():
print 'The accout is exists'
print 'Enter the \'q\' exit'
continue
... |
22cc81922d9143d2039aab3b35e2620c0520a154 | Spider-shi/python_learning | /LPTHW/ex03.py | 436 | 4 | 4 |
print "I will now count my chickens:"
print "Hens",25 + 30/6
print "Roosters",100-25*3%4
print "Now I will count the eggs:"
print 3+2+1-5+4%2-1/4+6
print "Is it true that 3+2 < 5 -7"
print 3+2< 5-7
print "What it 3+2?", 3+2
print "Whai is 5-7?", 5-7
print "Oh, that'is why it's False."
print "How about some more.... |
5ccf3ce275e4dd79e826ff510a3b37692ba4cefb | Spider-shi/python_learning | /Simple/Simple_script_150227.py | 2,386 | 3.734375 | 4 | #-*-coding:utf-8-*-
#简明python教程 第十章 脚本
print '01'
print '-' * 15
#脚本的第一个版本
import os
import time
'''
#1.The files and directories to be backed up are specified in a list
source = ['/home/bob/unix', '/home/bob/code']
#2. The back up must be stored in a main backup directory
target_dir = '/mnt/backup/'
#3. The files... |
9fac772da04545d0f4450eb78e3f8c05762fbc20 | yasserhussain1110/grokking-algo-solutions | /SubsetSum/sub_sum_dynamic.py | 1,380 | 3.515625 | 4 | def merge_list(l1, l2):
soln = []
for s1 in l1:
for s2 in l2:
if set(s1).isdisjoint(set(s2)):
soln.append(s1 + s2)
return soln
def add_solutions(sol1, sol2):
for v in sol2:
present = False
for a in sol1:
if set(a) == set(v):
... |
6ec7f502110f4ecb577c7648599caad920e4827e | edwaitingforyou/cs1114python | /rec08.py | 6,406 | 3.921875 | 4 | import givePrize
KEY_WORD = "startrun"
SEVN_STAMP_AMOUNT = 100
THREE_STAMP_AMOUNT = 100
SIX_STAMP_AMOUNT = 100
DOLLARS_COIN = 100
QUARTERS_COIN = 100
DIMES_COIN = 100
NICKLES_COIN = 100
PENNIES_COIN = 100
def welcomeState():
'''
This function prints the welcome screen
'''
print '''
--------------... |
fe7a5d017d9b0806d0c83585f59b89c6a0cc27d5 | edwaitingforyou/cs1114python | /sentinel.py | 553 | 3.828125 | 4 | STOP_VAL = "QUIT"
def getAvgOfUserInputs():
sumOfItems = 0
numOfItems = 0
dataItems = raw_input("Enter first value or QUIT to quit:")
while dataItems.upper() != STOP_VAL:
sumOfItems += int(dataItems)
numOfItems += 1
dataItems = raw_input("Enter next value or QUIT to quit:")
i... |
ac0fa6045e5022501773eb660d86f9b633af02b6 | edwaitingforyou/cs1114python | /hw00.py | 1,200 | 3.5 | 4 | #!C:\Python26\python.exe
#cs1114
#Submission: hw00
#Programmer: Beihong Chen
#Username: bchen13
#e of program:
#This program answered the questions of hw00.
#Constratints:
#The output is always displayed from left to right and from top to bottom.
import os
print "This program is written by Beihong Chen for hw00 in... |
91d9761b6dcc5f048f05a6c81f57f4c4ef41f615 | edwaitingforyou/cs1114python | /hw08/hw08111.py | 5,760 | 3.875 | 4 | #!C:\Python27\python.exe
def openTheFile():
'''
This function open files that cotains summary data
extracted from a file of data about world population change.
'''
openFile = open("statistics.txt","r")
oneLine = openFile.readline()
oneLine = openFile.readline()
return openFile,oneLine
... |
e891798609b01a936369909f47df7bc1d8d61202 | gtarciso/Estudos-Maratona | /URI/Ad-Hoc/1140.py | 228 | 3.609375 | 4 | while 1:
st = input()
if st == '*':
break
taut = st.split(' ')
flag = 0
letter = taut[0][0].lower()
for obj in taut:
if obj[0].lower() != letter:
flag = 1
break
if flag == 0:
print('Y')
else:
print('N')
|
67a391932743121af7197a0a92d8a429898dca7a | gtarciso/Estudos-Maratona | /URI/DataStructures/1259.py | 257 | 3.84375 | 4 | n = int(input())
even = []
odd = []
for i in range(n):
x = int(input())
if x % 2 == 0:
even.append(x)
else:
odd.append(x)
even.sort()
odd.sort(reverse = True)
for i in range(len(even)):
print(even[i])
for i in range(len(odd)):
print(odd[i]) |
b6fc424cae1cffb20f1bb4d72d6282e451ee86b3 | layerwise/training | /0_numpy_lineare_algebra/assignments/learntools/challenges/challenge1.py | 8,435 | 4.125 | 4 | import pandas as pd
import os
from learntools.core import *
class FruitDfCreation(EqualityCheckProblem):
_var = 'fruits'
_expected = (
pd.DataFrame([[30, 21]], columns=['Apples', 'Bananas']),
)
# TODO: This is a case where it would be nice to have a helper for creating
# a solution wi... |
004ffdaae97c0a34d7484857e0f7dc2c62977e23 | lauracastillo325/LCE_Final | /ejercicio 5.py | 521 | 3.96875 | 4 | mensaje = "hola"
mensaje += " "
mensaje += "Ernesto"
print (mensaje)
print("concatenacion:")
mensaje = "hola"
espacio = " "
nombre = "Ernesto"
print(mensaje + espacio + nombre)
numero_uno = 4
numero_dos = 6
resultado = numero_uno + numero_dos
resultado = str(resultado)
print("el resultado de la suma es: " + resultad... |
9fb1fb28df63db67bcc4fb3dbdbd0401816a35f0 | tecWang/knowledges-for-cv | /剑指offer/Codes/17_不用加减乘除做加法_进制转换.py | 414 | 3.78125 | 4 | # -*- coding:utf-8 -*-
class Solution:
def Add(self, num1, num2):
# write code here
while(num2 != 0):
s1 = num1^num2
s2 = (num1&num2)<<1
num1 = s1 & 0xFFFFFFFF
num2 = s2
print(s1, s2, num1, num2)
return num1 if num1 >> 31... |
9c07b470a7dfa671f44891c5285632306d63560c | tecWang/knowledges-for-cv | /剑指offer/Codes/37_heapq.py | 743 | 3.515625 | 4 | import heapq
nums = [-132, -23, -54, -1, -5, -3, -2, 2, 3, 5, 1, 54, 23, 132]
heap = []
heap2 = []
for n in nums:
heapq.heappush(heap, n)
print(heap) # [-132, -23, -54, -1, -5, -3, -2, 2, 3, 5, 1, 54, 23, 132]
while heap:
print(heapq.heappop(heap), end=", ")
# -132, -54, -23, -5, -3, -2, -1... |
328674b4396b5d23edab7000950b5d508c87e774 | tecWang/knowledges-for-cv | /剑指offer/Codes/01_神奇的数字-双指针.py | 799 | 3.609375 | 4 | #
#
# @param number string字符串
# @return string字符串
#
class Solution:
def change(self , number ):
# write code here
start = 0
end = len(number) - 1
number = list(number)
while start < end:
# 偶数位,对调
print(start, end)
if int(num... |
8a8679d1c945322632cdd9885dfcabdbe5db0ecc | tecWang/knowledges-for-cv | /剑指offer/Codes/35_DFS参数传递测试.py | 1,342 | 3.796875 | 4 | # -*- coding:utf-8 -*-
import copy
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# 返回二维列表,内部每个列表表示找到的路径
def FindPath(self, root, expectNumber):
# write code here
# DFS
def dfs(root, targe... |
676c9f399bf122739b3b5a2fde15257cee388a08 | LeeMellon/python_work | /figuring_out_classes.py | 1,572 | 3.578125 | 4 | """solving class inhertance questions I've had. Practicing via
RPG character sheet model of Classes"""
import random
class CharacterSheet:
def __init__(self, name):
self.name = name
self.cha = 0
self.intl = 0
self.strg = 0
self.make_me = self.creat_char( name )
sel... |
ae6384d266c0a962a2921048b678ef7bd64f98f1 | LeeMellon/python_work | /CodeMachineMk1.py | 3,115 | 3.78125 | 4 | # def clean_number():
# num = input("what is the number you want to format?: ")
# ara = num[0:3]
# pre = num[3:6]
# suf = num[6:10]
# print("({})-{}-{}".format(ara, pre, suf))
class Code:
def __init__(self): #Bring my creation to LIFE!!
# self.name = name
se... |
f5319c7951e6c846d95d563533f7e8562dd0c66f | Burseylj/ProjectEuler | /P16.py | 144 | 3.578125 | 4 | import time
def sumDigits(no):
return 0 if no == 0 else int(no%10) + sumDigits(int(no/10))
print "answer is {}".format(sumDigits(2**1000))
|
83a5e7c23a3fd45086712653ea85246a2db788a6 | bendourthe/3d-transformations-toolbox | /Python/transformation-functions/helical_axis.py | 827 | 3.65625 | 4 | # LIBRARIES IMPORT
import numpy as np
# FUNCTION
def helical_axis(T):
'''
Calculate the components of the vector along which a solid translates and around which it rotates (i.e. helical axis, or screw axis).
Based of the work of Spoor and Veldpaus (1980): equations [31] and [32].
Input:
T: 4x... |
1be9a89c5edc52c684a62dcefcdd417a418ef797 | aayishaa/aayisha | /factorialss.py | 213 | 4.1875 | 4 |
no=int(input())
factorial = 1
if no < 0:
print("Factorrial does not exist for negative numbers")
elif no== 0:
print("1")
else:
for i in range(1,no+ 1):
factorial = factorial*i
print(factorial)
|
de6b241ac73edc70adbbc86cf00f74f4a9e484e3 | dby/leetcode_ | /007/reverseInteger.py | 211 | 4.03125 | 4 | #!/usr/bin/python
def reverse(x):
res = 0
ll = 1
if x < 0:
ll = -1
x = x * -1
while x:
res = res * 10 + x%10
x = x/10
return res*ll
x = 300
print reverse(x)
|
bb236d47d6d4abd1772314d07e5ac46ecc6897b3 | yataOrg/study_course | /python_basic_knowledge/review/code_06_19.py | 2,456 | 3.890625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author: yata
# @Date: 2019-06-19 10:24:45
# @Last Modified by: yata
# @Last Modified time: 2019-06-19 11:48:38
'''必需参数
关键字参数
默认参数
不定长参数
'''
# 没有参数
'''
def onePlay():
a = 1
return a+1
myMethod()
'''
# 普通有参数
'''
def onePlay(doing):
print(doing, " ball")
ret... |
f0bb6c9ce738180b8c1fa1f4f5724675b83359e0 | emilioramirezeguia/cs-sprint-challenge-hash-tables | /hashtables/ex1/ex1.py | 1,544 | 3.6875 | 4 | def get_indices_of_item_weights(weights, length, limit):
"""
YOUR CODE HERE
"""
dictionary = {}
# if there's only 1 weight, return None
if length == 1:
return None
# otherwise, loop through the weights and populate
# the dictionary with the weight as the key and the index
#... |
e8b2cf20a5466d21ca204bf592827820ac4cd579 | MiParekh/python-challenge | /PyBank/main.py | 3,173 | 4 | 4 | #PyBank Homework Assignment - Mitesh Parekh
#Import Budget Data File
import os
import csv
#Data File Name and Path to Open: C:\Users\mites\OneDrive\Documents\RU Data Science Bootcamp\python-challenge\PyBank\budget_data.csv
#Read CSV File, identify comma delimiter, and print csvreader
csvpath = "budget_data.... |
aca21cdf688c99428106d4e1cd0c798775be531a | ShawnBatson/cs-module-project-hash-tables | /lecture/lectureP3.py | 3,955 | 3.953125 | 4 | import math
d = {
"foo": 12,
"bar": 17,
"qux": 2
}
# print(d.get("foo"))
# print(d["foo"])
records = [
("Alice", "Engineering"),
("Bob", "Sales"),
("Carol", "Sales"),
("Sarah", "Sales"),
("Pranjal", "Sales"),
("Dave", "Engineering"),
("Erin", "Engineering"),
("Frank", "Engi... |
f5b66a34392b2c61a65771fdda36a9cbed624626 | JuanPyV/Python | /ListaAnidada/Matriz_A00368753.py | 3,390 | 3.6875 | 4 | listaX = [[1, 5, 8, 9, -11],
[-1, 5, 7, -8, 6],
[5, 4, -3, 10, 5]]
# nxn con -1 en cada posicion
def creaMatriz1(n):
lista1 = []
for i in range(n):
lista_1 = []
for num in range(n):
lista_1.append(-1)
lista1.append(lista_1)
return lista1
print(crea... |
ff032f652c58ed51959a345becc934a301e2a3d2 | JuanPyV/Python | /Funciones/5funciones_menu.py | 1,798 | 4 | 4 | import math
import os
import msvcrt
# Autor: Juan Pablo Velazco Velasquez
# Programa para calcular area del circulo, cuadrado, triangulo, rectangulo y rombo
def triangulo (b, h):
a = (b*h)/2
print("\n El area del tiangulo es: %.2f \n" % a)
def cuadrado (l):
a = l*l
print("\n El area del cuadrado es: %... |
feec2f79dbb735123eb5e33b9ce0ae455088aae9 | JuanPyV/Python | /For/Puebas.py | 449 | 3.625 | 4 | resp = "si"
suma = 0
while resp != "no":
nom = input("Ingresa el nombre del alumno: ")
ncal = int(input("Cuantas calificaciones: "))
for i in range(1, ncal+1):
cal = float(input("Ingresa la calificacion: "))
suma = suma + cal
prom = suma / ncal
if prom >= 70:
print("El al... |
19839a9ccb9fb048dd8a03255080f10234f0fcf7 | JuanPyV/Python | /while/W5_A00368753.py | 152 | 3.65625 | 4 |
n = int(input("¿Hasta que numero? "))
c = 0
g = 0
while c < n:
g = g + 3.785
c = c + 1
print("%d gal. equivale a %.3f lts" % (c, g))
|
c99d88921af53108f0d239dadffcff342278ee07 | JuanPyV/Python | /LecturaDeArchivo/Aeropuerto/Test.py | 1,906 | 3.53125 | 4 | from math import sin, cos, sqrt, atan2
def latitud(ciudad):
try:
archivo=open("airports.txt","r",encoding="UTF-8")
except:
print("No se puede abrir el archivo")
else:
lista2=[]
for linea in archivo:
lista=linea.split(",")
lista[2]=lista[2].strip(' " ')... |
e1b943845c810187483e2f2fe61e0197574c9f59 | JuanPyV/Python | /For/For 2 ppp.py | 110 | 3.640625 | 4 | c = 0
n = int(input("Tabla del: "))
for x in range (1,11):
c = n * x
print("%d*%d = %d" % (n, x, c))
|
10e78fc0ad4dadbeea99be2da4d2f432a315ba65 | JuanPyV/Python | /For/for.py | 104 | 3.5625 | 4 |
x = 5
for nombre in ["mayra", x, "daniel", "adolfo"]:
print("bienvenido a mi clase %s" % (nombre)) |
92c2b81347dea4b4cf4d4e5bf54fb30e3e794194 | JuanPyV/Python | /LecturaDeArchivo/Aeropuerto/airlineHackV0.5.py | 1,417 | 3.609375 | 4 | aero = input("Nombre del aeropuerto: ")
def Aeropuertos_de_un_pais(aero):
try:
aeropuerto = open("airports.txt", "r", encoding='UTF8')
lineas = []
for linea in aeropuerto:
lineaP = linea.strip()
lin = lineaP.split(",")
if lin[1].strip('"') == aero:
... |
25249c79dc0f0cc92e7cc350fef637ce40fefcac | santiagoparaella/ADM-HW3 | /main.py | 694 | 3.921875 | 4 | import utils as u
if __name__ == "__main__":
al, vocab=u.load_urls_and_vocab()
choice_done = True
while choice_done:
which_engine = input("Choose with which Search Engine you want to do your research: \n1 - Engine 1 \n2 - Engine 2 \n3 - Engine 3 \nq - Quit \n\n")
if which_engine == "1"... |
8000aea6632fad1e6f754cff06f88ffd36249290 | toster2099/Python_course | /lesson3/lesson3_hw03.py | 3,530 | 3.90625 | 4 | #2. Написать скрипт, который генерируем два случайных дробных числа,
# находит их произведение и выводит на печать результирующее число,
# затем результирующее число, округленное но 4-х знаков и затем до 2х знаков
import random
second_value = random.uniform(1.00,100.00)
first_value = random.uniform(1.00,100.00)
resu... |
557db6014ade0a2fc318b675bdc3fbf6aa9b3d30 | JonasJR/zacco | /task-1.py | 311 | 4.15625 | 4 | str = "Hello, My name is Jonas"
def reverseString(word):
#Lets try this without using the easy methods like
#word[::-1]
#"".join(reversed(word))
reversed = []
i = len(word)
while i:
i -= 1
reversed.append(word[i])
return "".join(reversed)
print reverseString(str)
|
ddcd92fbfdca7e580f3b0a6545db8b13424bae40 | brunacorreia/100-days-of-python | /Day 4/exercise1-head-or-tails.py | 560 | 3.9375 | 4 | import random
def start_game():
random_side = random.randint(0, 1)
print(random_side)
my_choice = int(input("Choose '0' for HEADS or '1' for TAILS\n"))
if my_choice == random_side:
restart_game = input("You got it CORRECT! Would you like to try again? 'Y' or 'N'?").lower()
if restart_ga... |
bd8613e29770b94258700f6f60362336da92ef29 | brunacorreia/100-days-of-python | /Day 1/exercise1-printing.py | 241 | 4.09375 | 4 | # Write a program in main.py that prints the some notes from the previous lesson using what you have learnt about the Python print function.
print("Day 1 - Python Print Function\nThe function is declared like this:\nprint('what to print')") |
e1cdeb27240a29c721298c5e69193576da556861 | brunacorreia/100-days-of-python | /Day 1/finalproject-band-generator.py | 565 | 4.5 | 4 | # Concatenating variables and strings to create a Band Name
#1. Create a greeting for your program.
name = input("Hello, welcome to the Band Generator! Please, inform us your name.\n")
#2. Ask the user for the city that they grew up in.
city = input("Nice to meet you, " + name + "! Now please, tell us the city you gr... |
702afec3facc5253ed05fff2002582d85a9314e7 | CSA-DJH/CompPro1DJH | /slicelist.py | 395 | 3.890625 | 4 | #daniel Hebowy
import os
os.system('clear')
def slice():
slicelist=['a','b','c','d','e','f','g'] #defines the letters
print(slicelist[2]) #prints the third letter
print(slicelist[ :4]) #prints the first 4 letters
slicelist[-1]='z' #replaces last letter
slicelist[-2]='y' #replaces f
slice... |
857eb52b715c3619a8850ff87950befee8514753 | CSA-DJH/CompPro1DJH | /review4.py | 567 | 3.640625 | 4 | import os, time
os.system("clear")
def adding():
x=0
for i in range(500):
if x>=500:
print(str(x)+' is the total.')
break
nums=input("pick a number between 1 and 100. ")
nums=int(nums)
x+=nums
print('x='+str(x))
if nums>100:
... |
4b9dd8833d46361824dd09955cf4951ada8321cb | CSA-DJH/CompPro1DJH | /cubes1.py | 600 | 3.8125 | 4 | import os, time
os.system('clear')
def cubes(n):
print("n", '\t', "result") #prints the result
print("---", '\t', "------")
x = 1
while x <= n:
equation = x**3 #runs the equation as many times as asked
print (x,'\t', equation)
x += 1
def check():
x=int(input('Enter ... |
ce062d3da84554c34030f29d74dcb5ecf717f5af | CSA-DJH/CompPro1DJH | /house1.py | 1,269 | 3.96875 | 4 | #daniel herbowy
import os, random
os.system('clear')
def house(): #makes a function
num1=input("what is your name?") #asks for a name
x=num1.title() #capitalizes the make
print("hi"+x) #prints a greeting
num2=input("what price do you want to pay for the house in between 100 and 500? in the thousan... |
d71bec31ccd344b10eac95776a71e6be35b0963e | CSA-DJH/CompPro1DJH | /mylist1.py | 606 | 3.671875 | 4 | #daniel Herbowy
import os
os.system("clear")
def mylist(): #makes a function
num1=[76]
num2=['92.3']
num3=["hello"] #defines all variables to add
num4=[True]
num5=[4]
num6=[76]
mylist=[] #makes an empty list
num7=mylist+num1 #adds the first variable
... |
c8ffda838ff6b52e4b66944de9b763b035c4fa22 | AshishGhotekar/Springboard-DSTC | /unit05_bruteForceSearch.py | 456 | 3.984375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 18 19:36:30 2021
@author: aghotekar
"""
def search(numbers, query_number):
found_number = False
for number in numbers:
if number == query_number:
found_number = True
break
return found_n... |
a82e6ac3d46335e2ecb73df5f657eebed146515f | MBWalter/Orientation_Week | /variables_1.py | 223 | 3.703125 | 4 | import math
weight_apple = input("How much apple do you want to buy? ")
cost_apple = input("How much does 1 kg apple cost? ")
price = int(weight_apple) * int(cost_apple)
print( "It will cost you" , abs(price) , "korona.")
|
deb7c48c129f8d82ff4b10a185357462ba0489dc | MBWalter/Orientation_Week | /variables_6.py | 561 | 3.921875 | 4 | total = input("How much money you want to cover to coins: ")
money = int(total)
ten_coins = money // 10
five_coins = (money - (ten_coins * 10)) // 5
two_coins = (money -( ten_coins * 10 + five_coins * 5)) // 2
one_coins = (money -( ten_coins * 10 + five_coins * 5)) % 2
print("Least ammount of coins you can pay with: ")... |
f1843443c331d4c5c063af1da427959041a0c28e | MBWalter/Orientation_Week | /string_3.py | 194 | 3.6875 | 4 | sentence_original = input("The sentence: ")
sentence_copy = ""
for i in range(len(sentence_original)):
sentence_copy += sentence_original[(len(sentence_original)-i)-1]
print(sentence_copy)
|
557e4d43a305b7ddcfe16e6151d7523468417278 | axxypatel/Project_Euler | /stack_implementation_using_python_list.py | 1,550 | 4.4375 | 4 | # Implement stack data structure using list collection of python language
class Stack:
def __init__(self):
self.item_list = []
def push(self, item):
self.item_list.append(item)
def pop(self):
self.item_list.pop()
def isempty(self):
return self.item_list == []
de... |
1cc216118fb425aa5559af85dce913495c58f293 | axxypatel/Project_Euler | /46_Goldbach's_other_conjecture.py | 1,562 | 4 | 4 | # It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square.
# 9 = 7 + 2×1^2
# 15 = 7 + 2×2^2
# 21 = 3 + 2×3^2
# 25 = 7 + 2×3^2
# 27 = 19 + 2×2^2
# 33 = 31 + 2×1^2
# It turns out that the conjecture was false.
# What is the smallest odd composite that ... |
6686d6c3b01ca9f6d04005fa931fc05392fc9ecd | axxypatel/Project_Euler | /32_Pandigital_products.py | 1,493 | 3.71875 | 4 | # We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital.
# The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.
# Fi... |
f51db9de2049eca877c433615b0f9291d4216dfd | axxypatel/Project_Euler | /sorting_algorithm_using_python.py | 6,833 | 4.4375 | 4 | # Sorting algorithm using python
un_order_list = [5, 7, 1, 3, 2, 90, 45, 87, 23, 87, 65, 34, 78, 94, 88, 82, 10, 33, 54]
temp_list = [3, 4, 7, 1, 2]
# order_list = [1, 2, 3, 5, 7, 10, 23, 33, 34, 45, 54, 65, 78, 82, 87, 87, 88, 90, 94]
class SortingAlgorithms:
def __init__(self):
pass
@staticmethod
... |
fc89443767db0289e461f62bbddda3f8f46c7a54 | axxypatel/Project_Euler | /24_Lexicographic_permutations.py | 2,298 | 4 | 4 | # A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4.
# If all of the permutations are listed numerically or alphabetically, we call it lexicographic order.
# The lexicographic permutations of 0, 1 and 2 are: 012 021 102 120 201 210
#... |
675a7b5aa3aa67a76c27267eaad74d92eba9ca93 | SeyramDiaba/pythonLoopsMedical-InsuranceProject | /pythonLoopsMedical-InsuranceProject.py | 1,790 | 4.09375 | 4 | names = ["Judith", "Abel", "Tyson", "Martha", "Beverley", "David", "Anabel"]
estimated_insurance_costs = [1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 6000.0, 7000.0]
actual_insurance_costs = [1100.0, 2200.0, 3300.0, 4400.0, 5500.0, 6600.0, 7700.0]
########################################
#Original first loop# ... |
b6a1f99661506c8614be233105f165ea8fdaca36 | sklvskiy/Group-Project-Code | /Classification/Utilities.py | 3,536 | 3.9375 | 4 | import pandas as pd
import numpy as np
import tensorflow as tf
import math
import neural_network_steps as nn
"""
The following code was adapted from a Coursera Deep Learning Specialization
which I used to prepare myself to do classification part of the project
"""
#Loads the datasets from the csv files specified by ... |
f1269857066eeb9e0eaacda64e7a10ac1544f53f | kirillov-n/cs102 | /homework07/week_1.py | 5,861 | 3.640625 | 4 | import psycopg2.extras
import psycopg2
from pprint import pprint as pp
from tabulate import tabulate
conn = psycopg2.connect("host=localhost port=5433 dbname=odscourse user=postgres password=secret")
cursor = conn.cursor() # cursor_factory=psycopg2.extras.DictCursor)
def fetch_all(cursor):
colnames = [desc[0] ... |
d97b6caaec9ce4bba67d0078a3e8d5c904947b41 | Strijov/Multiscale | /python-code/LoadAndSaveData/get_iot_data.py | 5,065 | 3.609375 | 4 | # coding: utf-8
"""
Created on 30 September 2016
@author: Parantapa Goswami, Yagmur Gizem Cinar
"""
import os
import pandas as pd
import linecache
from collections import defaultdict
'''
get_data: method to read certain metrics from the data file.
@param: FILE_NAME is the path to the data file
@param: line_indices is... |
40dada3d23c773fb43420fb0000f73d83e98dbbf | yuksom/pyimagesearch | /detect_color/detect_color.py | 1,563 | 3.703125 | 4 | # PyImageSearch: Color detection in an image
# Reference: https://www.pyimagesearch.com/2014/08/04/opencv-python-color-detection/
import numpy as np
import argparse
import cv2
import imutils
# construct argument parser
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help = "path to the... |
a280c65a81f7700e5d069094951c5fc111f444b7 | San4ez-13/python | /lib.py | 492 | 3.96875 | 4 | def check_input(user_input: str, allowed_values: list, user_message: str = 'Попробуй ещё:\n') -> str:
while user_input not in allowed_values:
allowed_str = ''
for item in allowed_values[:-1]:
allowed_str += f'{item}, '
allowed_str = allowed_str[:-2]
allowed_str = f... |
951e51086b66dad2b6ec49bbee176e7de462c6ab | San4ez-13/python | /21.py | 2,430 | 3.921875 | 4 | from random import shuffle
#функция возвращает перемешанную колоду
def get_deck():
deck = []
for suit in ('черви','пики','бубны','трефы'):
for card in range(2,11):
deck.append(f'{card} {suit}')
for card in ('валет', 'дама', 'король', 'туз'):
deck.append(f'{card} {suit}... |
44ca92f1cadfc2429b16c3ddb2ff9a9194774a4c | UtkarshDpk/tree-models | /classifier-evaluation.py | 5,553 | 4.09375 | 4 | #!/usr/bin/env python
# coding: utf-8
#
# ## Evaluation BEFORE and AFTER building a Machine Learning model
#
# This basic Notebook explores methods for evaluation BEFORE and AFTER building a model. Evaluation of data and evaluation of model performance are key to any successful Machine Learning implementation so hop... |
b7aee2e0edeb2897e566ea7b3ff2c8dbf1a5eb58 | jsmith312/EMR-Job1 | /reducer.py | 714 | 3.953125 | 4 | #!/usr/bin/python
import sys
import re
from collections import defaultdict
def main(argv):
# create a dictionary to hold the count of each word
counts = defaultdict(int)
# read the line in stdin
for line in sys.stdin:
# check to see whether the line starts with
# the string LongValueSum
... |
c2a31d1744d9164068c23b9729c759d7080b9055 | snehasharma12/Assignment-4 | /time.py | 130 | 3.65625 | 4 | import time
import datetime
time = datetime.datetime.now()
current_time = time.strftime("%H:%M:%S")
print("Time: ", current_time)
|
451147f2a30e3ff334a8a23ea6ce348225c76c5b | jonatanjmissora/TKINTER_CALCULADORA | /calc7.py | 5,680 | 4.0625 | 4 | from tkinter import *
#================================================================
# Calculadora simple para manejar conceptos de Python y Tkinter
#================================================================
#RESUELTAS
# comienza con un 0 en pantalla
# no ceros a la izquierda
# no doble coma
# numeros negat... |
ed16d51907433405f06402bff946b63fc38a78dc | julianhyde/seb | /python_work/factor.py | 1,678 | 4.125 | 4 | #
#
# We want to print:
#
# a c e
# ---- + ---- = ----
# b d f
#
# For example, given (3, 4, 1, 10), we should print
#
# 3 1 17
# ---- + ---- = ----
# 4 10 20
#
def add_fractions(a, b, c, d):
(e, f) = (c * b + a * d, b * d)
# print(f"e={e},f={f}")
g... |
4bc3dced7001619e9582fec50c59f8d373025893 | minari1505/AlgorithmForH-M | /Class2/9012.py | 324 | 3.640625 | 4 | n = int(input())
for i in range(n):
line = input()
answer = 0
for a in line:
if a == "(":
answer +=1
elif a == ")":
answer -=1
if answer <0:
print("NO")
break
if answer > 0:
print("NO")
elif answer ==0:
print("Y... |
9db551d5593978349f7aa46aca3b0a351fe4ccd6 | minari1505/AlgorithmForH-M | /Class2/4949/minari-4949.py | 798 | 3.96875 | 4 | # 균형잡힌세상
```python
while True:
a = input()
if a == ".":
break
stack = []
answer = True
for j in a:
if j == "(" or j == "[":
stack.append(j)
elif j == ")":
if len(stack) == 0:
answer = False
break
... |
2179c16f178c592d0aa2a5fa3465bbce9c2a8554 | minari1505/AlgorithmForH-M | /Class2/11650/minari - 11650.py | 875 | 3.859375 | 4 | # 좌표 정렬하기
```python
#2차원 배열
#1. 2차원 배열로 입력받기
#2. lst[i][1]을 오름차순으로 정렬
#3. if lst[i][1] == lst[i+1][1] , lst[][1]을 오름차순으로 정렬
N = int(input())
#1.
lst = []
for i in range(N):
x,y = map(int,input().split())
lst.append([x,y])
#2,3
lst.sort()
for i in range(len(lst)):
print("{0} {1}".format(lst[i][0],lst[i][1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.