blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
1bef9fdf78c7040734e7dfcf5b60f6938d63ca29 | bgmichael/Past-Projects | /Hill Climbing/Vector Hill Climbing.py | 14,630 | 3.859375 | 4 | import random
import time
import math
def generate_random_problem(n):
'''
Creates a list filled with "n" random numbers
between -10*n and 10*n.
:param n: The size of the generated list.
:return: A list.
'''
extent = 100000
problem = []
for i in range(n):
num ... |
713e953e4bf67216edc576ca835af8c8d805719e | ezair/Grading-Scripts | /grade201.py | 4,831 | 3.671875 | 4 | '''
Author: Eric Zair
File: grade.py
Description: This file grades 201 Hw Assignments.
Make sure that you give this file the proper
name for grading(as in the proper assignment
name when prompted for it).
IMPORTANT:
Make sure that this file is in the proper
folder. This script must be put ... |
68bf98a745afc9a96d78c28752e0aa81a207a14b | juliagolder/unit-4 | /quiz4.py | 540 | 3.78125 | 4 | #julia golder
#4/2/18
#quiz4.py
def count(x):
for i in range(1,x+1):
print(i)
print('BOOM!')
def excitedPrint(word):
print(word.upper() + '!!!')
def firstLetter(word2):
letter = ''
for ch in word2:
if ch not in letter:
letter = letter + ch
return(letter)... |
19828161c1e031c17ae80d7c210f55b3b64da65b | Rahul7lalani/Snake-game | /Snake file.py | 4,034 | 3.796875 | 4 | import pygame
import time
import random
# pygame window
pygame.init()
clock = pygame.time.Clock()
# Colors using RGB
blackcolor = (0,0,0)
orangecolor = (255,123,7)
redcolor = (213,50,80)
greencolor = (0,255,0)
bluecolor=(50,153,213)
# Display window
width = 620
height = 410
displayz = pygame.display.... |
b98bc5a4787ebb3f8da919299b89a7da94d6732c | tlee9595/WGWC | /Menu.py | 2,907 | 3.90625 | 4 | #Thomas Lee
#tlee319@gatech.edu
#I worked on the homework assignment alone, using on this semester's course mateials"
from Myro import*
def menu():
exit = False
while exit == False:
choice = input("1.Twerk \n2.Scaptical turning \n3.Up and Down \n4.Harry Potter \n0. Exit \nWhich dance step/song would y... |
f674dfcd2b090de093538f574d0589e9ba764174 | DovzhenkoVit/main_academy_homework | /homework_8_2.py | 2,159 | 3.8125 | 4 | class Animal:
def __init__(self, size, breed, weight):
self.size = size
self.breed = breed
self.weight = weight
def breeding(self, other):
if not isinstance(other, self.__class__):
raise RuntimeError("Species should be similar!")
size = (self.size + other.si... |
adea4daeeb75d38e606fb6c3373ca8bb4eb5e5d1 | YunaAnn/GamesInPython | /NumberGuessing/number-guessing.py | 694 | 4.09375 | 4 | import random
def number_guessing():
# computer randomly chooses a number between 1 to 100
number = random.randint(1, 100)
correct = False
# print(number)
while not correct:
try:
guess = int(input('Enter your guess! (1 - 100)'))
if number == guess:
... |
0a91c5eaff3421302e68a57c74eca320bd851ddd | stephenlin35/Algorithms_in_Python | /Chapter1/Reinforcement/r1-4.py | 446 | 4.34375 | 4 | def sum_of_squares(n):
""" Function that takes a positive integer n and returns the sum of the squares if all positive integers smaller than n. """
if n < 1:
return "Sorry, n must be a positive integer."
sum = 0
i = 1
while i < n:
i_sq = i * i
sum += i_sq
i += 1
... |
d3add473b7cbf2f36f050c3f49f643f16358981a | stephenlin35/Algorithms_in_Python | /Chapter1/Creativity/c1-22.py | 524 | 4.03125 | 4 | # Write a short program that takes two arrays a and b of length n storing int values, and returns the product of a and b in array c.
def prod_of_arrays(a, b):
c = [0] * len(a)
for i in range(len(a)):
c[i] = a[i] * b[i]
return c
def prod_of_arrays_v2(a, b):
c = []
for i, j in zip(a, b): ... |
a97b2ad3c87f867565d512312c14c6834f28d95d | stephenlin35/Algorithms_in_Python | /Chapter2/Reinforcement/r2-15.py | 1,128 | 4.34375 | 4 | # The Vector class of Section 2.3.3 provides a constructor that takes an
# integer d, and produces a d-dimensional vector with all coordinates equal
# to 0. Another convenient form for creating a new vctor would be to send
# the constructor a parameter that is some iterable type representing a
# sequence of numbers, a... |
18b416ffc8c3f5c0492201d5ccc0409e966f5505 | stephenlin35/Algorithms_in_Python | /Chapter1/Creativity/c1-24.py | 401 | 4.09375 | 4 | def count_vowels(s):
""" Function that counds the number of vowels in a given character string """
vowels = ('a', 'e', 'i', 'o', 'u')
count = 0
for i in s:
if i in vowels:
count += 1
return count
if __name__ == '__main__':
print(count_vowels('banana'))
print(co... |
5af171b891e1c60f4c33fa0827a9e00f93b99ada | totally-not-eli/Solve-zhiwehu-exercise | /Easy/ex5.py | 453 | 3.859375 | 4 | # Define a class which has at least two methods: getString: to get a string from console input printString: to print the string in upper case. Also please include simple test function to test the class methods.
class Solution:
def getString(self):
self.string = input("Please enter a string: ")
def prin... |
1c7974f34cc709da34fa6fb0df47d1b2448015f0 | tonybnya/python-cv-builder | /my_app.py | 432 | 3.9375 | 4 | class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def walk(self):
print(self.name + ' is walking...')
def speak(self):
print('Hello my name is ' + self.name +
' and I am ' + str(self.age) + ' years old.')
john = Person('John', 22)
... |
5c61111ebc2dfac081029bf3616f705bd571538b | jihuacao/research-testing-using-python | /linear_regression/plot_isotonic_regression.py | 1,932 | 3.671875 | 4 | """
===================
Isotonic Regression
===================
An illustration of the isotonic regression on generated data. The
isotonic regression finds a non-decreasing approximation of a function
while minimizing the mean squared error on the training data. The benefit
of such a model is that it does not assume a... |
5782d14b061e10a19a8c2f374c7b279a467d3556 | code4ghana/euler | /p25.py | 476 | 3.8125 | 4 | import sys
def fibDigits(digits):
prev=1
prev2=1
fib=2
curLength=1
while curLength<digits:
prev,prev2=prev2,prev+prev2
fib+=1
# print "prev ",prev,"prev2 ",prev2
curLength=len(str(prev2))
print "Fib of ",fib," has ",curLength,"digits and is ",prev2
# print prev... |
2f6b362faf4048cd13d753e8018b2f9dfdf5d1dd | code4ghana/euler | /p28.py | 379 | 3.84375 | 4 | import sys
def spiralCount(dim):
top=dim*dim
tot=1
prev=1
incr=2
while prev <top:
tot+=4*prev+10*incr
prev=prev+4*incr
incr+=2
return tot
if len(sys.argv)<2:
print "type the length of the side of the square ex:4"
exit()
found=spiralCount(int(sys.argv[1]))
print ... |
8bce48e0ae6a4784627c2a86f4e43b5a6133419f | virga42/py_exercises | /tests/test_hackerrank.py | 666 | 3.9375 | 4 | import unittest
from exercises import hackerrank
class TestDiagonalDifference(unittest.TestCase):
"""
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
https://www.hackerrank.com/challenges/diagonal-difference/problem
"""
def setUp(self):
""" Sett... |
c421381bf1fc3d0e215eb4e70d4640609aea01e6 | chankyu11/programmers | /level1/이상한 문자 만들기.py | 399 | 3.5 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/12930#
def solution(s):
answer = []
for i in s.split(" "):
tmp = ''
for j in range(len(i)):
if j % 2 == 0:
tmp += i[j].upper()
else:
tmp += i[j].lower()
... |
89c793ddec36ee14d6a6069ec9ee653e0f522bf9 | chankyu11/programmers | /level1/K번째수.py | 366 | 3.65625 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/42748
def solution(array, commands):
answer = []
for i in commands:
tmp = array[i[0]-1: i[1]]
tmp.sort()
answer.append(tmp[i[2]-1])
return answer
# pythonic
def solution(array, commands):
return list(map(lambda x:s... |
1f717f454c10c63e4063670e4ffe7de864e163ec | s145-cheeze/TrimerX | /AnsChk/AnswerManageData.py | 1,084 | 3.546875 | 4 | # -*- coding: utf-8 -*-
import csv
class AnswerManageData(object):
def __init__(self, numbers, scorings):
if len(numbers) != len(scorings):
raise ValueError("numbers and scorings must be same length")
self.numbers = numbers
self.scorings = scorings
def __len__(self):
... |
77bffd14e34c8cf1c3b296a4d663fe61a8ed4e42 | BuenasBuenasSergio/Ejercicio-Python | /Ejercicios Datos Simples/Ejercicio 04,5.py | 291 | 3.90625 | 4 | #Realizando un division introducioendo los datos en inputs,
# se castea el resultado a texto para poder mostrarlo con un mensaje
dividendo = int(input("Pon dividendo: " ))
divisor = int(input("Pon un divisor: "))
resultado = str(dividendo / divisor)
print("El resultado es: " + resultado) |
de0a5ab067d2f13e496b9a4465d3b665ff0ad04e | BuenasBuenasSergio/Ejercicio-Python | /Ejercicios Condicional/Ejercicio 06.py | 318 | 4.0625 | 4 | name = input("Como te llamas: ")
gender = input("Eres hombre o mujer(H o M) ")
if gender == "M":
if name.lower() < "m":
print("Estas en el frupo A")
else:
print("Estas en grupo B")
else:
if name.lower() < "n":
print("Estas en el grupo A")
else:
print("Estas el grupo B") |
89aa79e19ce80719d8f5c4d3126a0e84f51d6a1e | SantiagoJSG/Trabajo_Final_30_Abril | /Ejercicio25.py | 807 | 3.953125 | 4 | # Ejercicio 25
print("El programa está orientado a calcular el resultado de una venta con IVA (19%), que al ser mayor de 150.000, se le aplicara un descuento del 5%.")
iva = 0.19
venta = float(input("Digite el valor de su compra: "))
descuento = venta * 0.05
if venta > 150000:
valor = venta - descuento
... |
b69cc124249025b925d5086b03ce225b2610351e | SantiagoJSG/Trabajo_Final_30_Abril | /Ejercicio1.py | 153 | 3.6875 | 4 | # Ejercicio 1
nombre = input("Ingresa tu nombre: ")
calificativo = input("Ingresa tu calificativo: ")
print(f"Bienvenido {nombre} {calificativo}")
|
d9169f3072c6dbc0f8adcf0ed3f2cd2fec6fc091 | SantiagoJSG/Trabajo_Final_30_Abril | /Ejercicio22.py | 299 | 3.953125 | 4 | # Ejercicio 22
print("El programa está orientado a determinar si el número ingresado es par o impar (solo se aceptan números enteros).")
numero = int(input("Digite un número entero: "))
if numero % 2 == 0:
print("Ingreso un número par")
else:
print("Ingreso un número impar")
|
15e8ac97556d5514961579bb7770d554d242aa3f | SantiagoJSG/Trabajo_Final_30_Abril | /Ejercicio6.py | 431 | 3.984375 | 4 | # Ejercicio 6
print("El programa está orientado a calcular su nota final.")
n1 = float(input("Digite su nota 1: "))
n2 = float(input("Digite su nota 2: "))
n3 = float(input("Digite su nota 3: "))
n4 = float(input("Digite su nota 4: "))
n5 = float(input("Digite su nota 5: "))
definitiva = (n1 * 0.15) + (n2 * 0.... |
a92adc85da76931162a10a2458d6ace0b2cf441f | SantiagoJSG/Trabajo_Final_30_Abril | /Ejercicio2.py | 242 | 4.15625 | 4 | # Ejercicio 2
print("El programa está orientado a sacar el cuadrado del número digitado.")
numero1 = float(input("Digita un número: "))
cuadrado = numero1 ** 2
print(f"El cuadrado del número ingresado ({numero1}), es: {cuadrado}")
|
efdb1a50029d5b45a2546b43b3c03e919c58fdb6 | SantiagoJSG/Trabajo_Final_30_Abril | /Ejercicio10.py | 510 | 4.25 | 4 | # Ejercicio 10
print("El programa está orientado a calcular el promedio de 3 números ingresados (escala del 0 - 5).")
num1 = float(input("Digite su primer valor: "))
num2 = float(input("Digite su segundo valor: "))
num3 = float(input("Digite su tercer valor: "))
promedio = (num1 + num2 + num3) / 3
if 0 <= num1 ... |
af56809b3742b4a9fc39138a264a0dd6b0431f74 | khaledbnmohamed/TuringMachine | /TuringMachine.py | 4,762 | 3.5 | 4 | from collections import Counter
dict = {}
input_tape=""
Next_transition_state=-1
found_transition_function="null"
Final_Decision="Refused"
def Store_elements(type,value1,value2):
if(type==alphabets):
return int(int(value1)*int(value2))
if type =='transitions':
result = [x.strip() for x in value1.split(','... |
d0df7df9a6eee0d5f8d5ca793352a200b4af68b9 | jkelly37/Jack-kelly-portfolio | /CSCI-University of Minnesota Work/UMN-1133/Labs/think.py | 249 | 4.15625 | 4 | print("welcom to odd number sum")
num = int(input("please enter a number n:"))
i =0
sum = 0
for i in range(0,num):
print("i:",i)
if i%2 == 0:
print("even")
else:
sum = sum + i
i = i+1
print(sum)
|
72b301cb98f49d0bfca686be523f239794038135 | jkelly37/Jack-kelly-portfolio | /CSCI-University of Minnesota Work/UMN-1133/Labs/Lab2_windchill.py | 399 | 4.1875 | 4 | # Jack Kelly
# Lab 2
print('Welcome to the the windchill calculator!')
#prints welcome statement
print();
#creates blank line
wind = float(input('Enter the wind speed in miles/hour: '));
temp = float(input('Enter the temp in fahrenheit '));
if temp>=-58 and temp<41:
ans = 35.74+(0.6215*temp)-(35.75*(wind**0.1... |
3fd0f15a4a22d84c311589e16c253451a40e69cc | jkelly37/Jack-kelly-portfolio | /CSCI-University of Minnesota Work/UMN-1133/Projects/kell2425_6A.py | 2,472 | 3.609375 | 4 |
def main():
go = True
while go != False:
location = input("Enter name of input file: ").replace(" ", "")
handle = open(location, encoding = 'utf-8', errors = 'ignore')
data = sortByVal(handle)
save = input("Write list to output file:(enter 'Y' or 'y')?").lower()
if sav... |
a649015b24450e620623a3cc1e4c9f7d63a04a82 | jkelly37/Jack-kelly-portfolio | /CSCI-University of Minnesota Work/UMN-1133/Projects/kell2425_2A.py | 990 | 4.34375 | 4 | # CSci 1133 HW 2
# Jack Kelly
# HW Problem 2A
#This funtion calculates the BMI based on W and H (weight and height respectivly)
# BMI = W/H**2
#input: weight W in kilos, H height in meters
#output BMI
def get_BMI(W,H):
bmi = W/(H**2);
return bmi
#This funtion calculates the BMI Status based BMI
#input: BM... |
3bb2de71d57236b79cbef56c5d63b8ba4195f133 | jkelly37/Jack-kelly-portfolio | /CSCI-University of Minnesota Work/UMN-1133/Labs/drunkyard.py | 843 | 3.96875 | 4 | import turtle
import random
def move():
print("moveXtimes called")
i=0
x = (random.randint(20,40))
stepsCounter = 0
while i<x:
steps = random.randint(15,25)
turtle.forward(steps)
turtle.right(turn())
i=i+1
stepsCounter = stepsCounter + steps
turtle.penup()... |
c9e0c905c9eabc376aa40e72e864d425c54e9e99 | JessicaQueiroz/Exercicios | /exercicio1/exercicio1.py | 628 | 4.03125 | 4 | """
Criar variáveis para nome(str), idade(int),
altura(float) e peso(float) de uma pessoa
Criar variável com o ano atual(int)
Obter o ano do nascimento da pessoa (baseado na idade e no ano atual)
Obter o IMC da pessoa com 2 casas decimais(peso e na altura da pessoa)
Exibir um texto com todos os valores na tela usando F... |
3e4caab1d32568c0fceece9fb3987dc9ad25214e | pourso/algorithms_on_graphs | /w2_p2_toposort.py | 875 | 3.734375 | 4 | #Uses python3
import sys
def explore(adj,u,o,x):
u[x]=1
for y in adj[x]:
if u[y]==0:
explore(adj,u,o,y)
o.append(x)
return 0
def dfs(adj, used, order):
#write your code here
for x in range(len(adj)):
if used[x]==0: explore(adj,used,order,x)
return
def toposort(adj):
used ... |
8dad6d73a5375e9bcbb9751693a6548ab17e214a | CvetelinaS/pyladies | /03/hvezda.py | 362 | 3.796875 | 4 | from turtle import forward, backward, left,right, penup, pendown, exitonclick
from turtle import shape
from random import randint
shape('turtle')
#hvězda na vrsku stromu
for g in range(12):
for i in range(5):
for j in range(4):
forward(20)
left(120)
left(30)
penup()
... |
be2a7713fda28640001726de22dcadf829c4a05c | CvetelinaS/pyladies | /03/schody.py | 185 | 3.703125 | 4 | from turtle import forward, left, right, exitonclick
from turtle import shape
shape('turtle')
for i in range (10):
left (90)
forward (50)
right (90)
forward (50)
|
3cc306fd9a23aeaae36685b4c4e17501ac8dcfef | CvetelinaS/pyladies | /02/kamen_nuzky_papir.py | 569 | 4.03125 | 4 | tah_pocitace = 'kámen'
tah_cloveka = input('kámen, nůžky, nebo papír? ')
if tah_cloveka == tah_pocitace:
print("plichta")
elif tah_cloveka =='kámen' and tah_pocitace == 'nůžky' or tah_cloveka == 'nůžky' and tah_pocitace == 'papír' or tah_cloveka == 'papír' and tah_pocitace == 'kámen':
print("vyhrala jsi")
elif... |
e2982449121a6a9e3a749c10dc3be6c91b1b2464 | CvetelinaS/pyladies | /03/ctverec_zelva.py | 195 | 3.796875 | 4 | from turtle import forward, left, exitonclick
from turtle import shape
shape('turtle')
for i in range(3):
for j in range(4):
forward(50)
left(90)
left(20)
exitonclick() |
dc9c6cc51d171442a7e4d85ced44469e98f4ff52 | charlesdebarros/CodeWars | /CodeWars_Python/sandobox_python.py | 450 | 4.03125 | 4 | #!/usr/bin/env python
# When provided with a number between 0-9, return it in words.
# Input :: 1
# Output :: "One".
# Try using "Switch" statements.
def switch_it_up(number):
numbers = {0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four',
5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine'}
... |
2bebf8da61ca667e3f331638c2c476d19128527a | charlesdebarros/CodeWars | /CodeWars_Python/reversing_words_in_a_string.py | 447 | 4.59375 | 5 | #!/usr/bin/env python
# You need to write a function that reverses the words in a given string.
# A word can also fit an empty string.
def reverse(string):
return string.split(' ').reverse.join(' ')
print(reverse('I am an expert at this')) # 'this at expert an am I'
print(reverse('This is so easy')) # 'easy ... |
a33bbf361b51f779a7b844d7e436bb2067e15a71 | zhongwei/ztodo | /py/start/dict.py | 268 | 4.09375 | 4 | #!/usr/bin/env python
# encoding: utf-8
dict = {}
dict['cat'] = "This is a cat."
dict[2] = "This is a dog."
minidict = {'name': 'zhongwei', 'code': 56867, 'dept': 'gbs'}
print dict['cat']
print dict[2]
print minidict
print minidict.keys()
print minidict.values()
|
1690d6d3d02bc2545ac33351695122c8d45d018c | oobobeo/piro11 | /2주차 수요일 과제/2.py | 316 | 3.703125 | 4 | name=input('캐릭터의 이름을 입력하세요: ')
print(f'캐릭터 이름: {name}')
import random
a = random.randint(6,8)
b = random.randint(6,8)
if a>b:
j = '전사'
elif a==b:
j = '궁수'
else:
j = '법사'
print(f'캐릭터 정보: 힘({a}), 지력({b})')
print(f'캐릭터 직업: {j}')
|
ce43bf0babf90bb31552fe964ae7f5af7416167a | binthafra/Problem-solving-and-competitive-programming | /worktech/7.py | 222 | 3.78125 | 4 | n = int(input())
my_list = []
for _ in range(n):
my_list.append(float(input()))
for t in my_list:
if (t>7):
print("UP")
elif(t==7):
print("EQUAL")
else:
print("DOWN")
|
9297ab02ad1b50562ffe3b29d53b97cd41753992 | nalkpas/nonsense | /newton's method/test2.py | 274 | 3.875 | 4 | n = 12
def iterate(x):
x = float(x)
return 2 * x - n * x ** 2
result = 0.1
oldresult = -20
while (abs(result - oldresult) >= 10 ** (-10)):
oldresult = result
result = iterate(result)
print oldresult, result
print(result)
print(1.0 / n) |
2b60ca8a3479be98fcee5758638a70d7aeb3cce3 | MelvinBriant/Exercice-Python | /ex1.py | 9,200 | 3.765625 | 4 | from math import *
from itertools import permutations
"""EXERCICE 1
nom = input('Votre nom')
print('Bonjour, ' + nom)
"""
"""EXERCICE 2
a = input('Saisissez un nombre')
b = input('Saisissez un deuxième nombre')
c = int(a) + int(b)
print(c)
"""
"""EXERCICE 3
nb1 = input('Saisissez un nombre')
nb2 = i... |
f847bfd5a8622738b11d8fa296d6710ad4c41e43 | yha05223/coin | /food.py | 724 | 3.703125 | 4 | #밥 먹자
#메뉴 1,2,3 정하자
# 먹는 몌뉴 선택 메뉴 출력
import random
##아래 전체를 반복시킴##
for i in range(1, 4):
print("밥먹자")
print("메뉴는?")
# 메뉴 변수 나열
menulist = '돈가스', '떡튀순', '자장면'
print("1.학식 2.분식 3.중식 4.랜덤")
menu = input(str(i) + ".입력: ")
#만약에 사용자가 입력한 값이 1 과 같으면
if menu == '1':
print("학식")
i... |
277fa4e8aedede48825f0cab013d6c5aca5291f5 | prashant0493/playground | /sorting.py | 223 | 3.75 | 4 | def is_sorted(list1):
i=0
le=len(list1)-1
while(i<le):
if list1[i]<list1[i+1]:
pass
else:
return False
i+=1
return True
L=[1,4,3]
print(is_sorted(L))
|
71253dd2abb1bfcac5c978c99382c79c525947e9 | Charlemagnedeux/mal_dvp6_capstone_project | /dating_skeleton.py | 9,189 | 3.5 | 4 |
# coding: utf-8
# In[1]:
import pandas as pd
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn import preprocessing
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.neighbors imp... |
f6d642f4126de58a031409e21bd7689184711310 | spidermanxyz98/marcio-mourao.github.io | /Pricy.py | 1,433 | 3.5625 | 4 | #Load the Boston dataset from datasets
#This dataset contains 13 housing variables measured on 506 houses,
#with house price as the outcome.
from sklearn import datasets
import numpy as np
boston = datasets.load_boston()
#Define the training and test datasets
#The training set consists of the first 50% of t... |
b0bfa6d9531d059d1a0e0d08165777b93268dd19 | jinwen-loh482/app_crypt_project2 | /submission/zavoral_zhou_loh_barron-Darryl.py | 2,401 | 3.796875 | 4 | ''' Darryl will compute matching on non-encrypted data on query
from Alice and compare'''
import argparse
import csv
import sys
# Darryl finding Alice's query in the unencrypted data
def Darryl (category, data):
answer = list()
csvfile = 'zavoral_zhou_loh_barron-Heart.csv'
# read csvfile
with open(cs... |
7bfe5a1e65d727840249438eb2c27938c9a3a1a5 | wendyli/CS230_DL_Project | /convert_png.py | 641 | 3.875 | 4 | from PIL import Image
import os
def main():
directory = input("Choose directory of images you'd like to convert to PNG: ")
try:
os.stat(directory + '/PNGResults/')
except:
os.mkdir(directory + '/PNGResults/')
for filename in os.listdir(directory):
if filename.endswith... |
dedb793e015ea0a9db89887d1adadc81be28f4a7 | walexe99/bmi | /bmi.py | 508 | 3.828125 | 4 | vikt = float(input("Skriv vikten du har"))
längd = float(input("Skriv längden du har"))
bmi = vikt / (längd / 100)**2
print("Din vikt är:", bmi)
if (bmi > 0):
if (bmi <= 16):
print("Du är mycket underviktig")
elif(bmi <=18.5):
print("Du är underviktig")
... |
f3ac00e14f8e177209ce0d1f61af71520b58fe01 | Levalife/DSA | /sorts/selection_sort.py | 570 | 4.03125 | 4 | # -*- coding: utf-8 -*-
# Во время прохода запоминается индекс самого большого неотсортированного элемента и свапится в конец
# O(n^2) time
# O(1) space
def selection_sort(a):
for i in range(len(a)):
max = 0
for j in range(len(a) - i):
if a[j] > a[max]:
max = j
... |
5c879e39fc66b3d250e4afbfab06e136b77d2477 | Levalife/DSA | /graphs/Maze Path BFS.py | 3,734 | 3.953125 | 4 | # -*- coding: utf-8 -*-
import queue
'''
To find shortest path - use BFS (with queque)
And save every node with its prev node in a hashmap
'''
def createMaze0():
maze = []
maze.append(["#","#", "#", "#", "#", "O","#"])
maze.append(["#"," ", " ", " ", "#", " ","#"])
maze.append(["#"," ", "#", " ", ... |
347ddfbc4b53386665d828fc2bc6d0d218d82a91 | Levalife/DSA | /graphs/breadth_first_search.py | 869 | 3.859375 | 4 | # -*- coding: utf-8 -*-
def bfs(vertex, graph):
level = {vertex: 0}
parent = {vertex: None}
i = 1
frontier = [vertex]
while frontier:
next = []
for u in frontier:
for v in graph[u]:
if v not in level:
level[v] = i
... |
42fec27879cdc58b323a746cc2204bd52bc62af2 | Levalife/DSA | /tree/inorder.py | 2,482 | 3.90625 | 4 | # -*- coding: utf-8 -*-
class Tree:
def __init__(self, root=None):
self.root = root
class Node:
def __init__(self, value, parent=None, left=None, right=None):
self.value = value
self.left = left
self.right = right
self.parent = parent
def __str__(self):
... |
6fb70e99e172ed8cce53037d9c763c2d8c8cbdcd | Levalife/DSA | /heap/min_heap.py | 3,983 | 4.25 | 4 | # -*- coding: utf-8 -*-
'''
Heap is complete binary tree where every parent node greater then it's children (max heap) or every parent smaller
then it's children (min heap)
sink_up (insert node at the and and sink up)
sink_down (delete root node, move last node to root and sink down to bottom)
create_heap (add node ... |
664bc62420581d5d80cf60b42077aa6f28069a27 | Levalife/DSA | /tree/BinaryHeap.py | 2,151 | 4.375 | 4 | # -*- coding: utf-8 -*-
# Priority Queue Abstract Data Type
# Heap is a complete binary tree (complete means it's filled from left to right)
# There are two types of heap: min heap and max heap
# When see problems like "the largest of smth/ the lowest of smth immediately think of using heap"
class MinHeap:
def ... |
02ae4857f25bd79572e35998e7fa8fcef413a894 | Levalife/DSA | /tree/LevelOrderTraversal.py | 2,523 | 4.0625 | 4 | # -*- coding: utf-8 -*-
# Tree is acyclic connected graph
# While preorder, inorder and postorder are similar to DFS and use stacks
# Level order traversal is similar to BFS and uses queues
from typing import List
class Tree:
def __init__(self, root=None):
self.root = root
class Node:
def __init__... |
dcabf49510e5aa7bc29f03ff27b25f63bfe71212 | Levalife/DSA | /dynamic programming/Coin Change.py | 2,662 | 3.859375 | 4 | '''
https://leetcode.com/problems/coin-change/
https://www.youtube.com/watch?v=jgiZlGzXMBw
Problem can be solved both top-bottom (recursion + memoization) and bottom-top (from subproblems to result) ways.
Bottom-Top approach:
create result array which will contain minimum possible coin change for every amoun <= am... |
3066165a56901e40f14f949d922bf08cde7e8a51 | Levalife/DSA | /tree/avl_tree.py | 6,491 | 3.84375 | 4 | # -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
class Node:
def __init__(self, value=None, parent=None, left=None, right=None, rank=1):
self.parent = parent
self.left = left
self.right = right
self.rank = rank
self.value = value
class Tree:
def __init__(self, root=... |
6e2a005b438fd4238029abb5653307cb0c132ffb | MasterPranjal/dv.pset | /0083/Pythagorean_Triplet2.py | 503 | 4.125 | 4 | lhs = 0 #lefthandside
rhs = 0 #righthandside
a = int(input('Enter a which is one of the side of a triangle (condition to be lept in mind a<b<c) = '))
b = int(input('Enter b = '))
c = int(input('Enter c = '))
def lefthandside():
lhs=(a**2)+(b**2)
return lhs
def righthandside():
rhs=(c**2)
return rhs
... |
6aa0d7d278d135a28e1f1a0fd07b6772739ca914 | MasterPranjal/dv.pset | /0079/reverse.py | 415 | 4.28125 | 4 | #Practicing to reversing a number
actual_num = int(input("Please enter number which you want to reverse = "))
global reverse
def reverseNumber(actual_num):
reverse=0
while(actual_num > 0):
remainder = actual_num % 10
reverse = (reverse*10) + remainder
actual_num = actual_num // 10
... |
dd8a2d96dca2d57fbc5e5b0c2bc050b4fbe26cb5 | MasterPranjal/dv.pset | /0034/Is_divisible.py | 187 | 3.890625 | 4 | n=int(input("enter the upper limit"))
def is_divisable(N):
count=0
for i in range(1,N,1):
if (i%7==0):
count=count+1
return count
print(is_divisable(n))
|
ee624e83ab3a36361efb97dd9f2a4d310f44b356 | sreedevi2906/siri5042 | /storeintoavariable.py | 236 | 3.984375 | 4 | 5.Write a Python program to read a file line by line store it into a variable.
In [105]:
f1=open("test.txt","w")
f.close()
In [106]:
f1=open("test1.txt","w")
f1.write("hi")
f.close()
In [109]:
f1=open('test1.txt').readlines()
print(f1) |
93c9e99a1e40effcd14ef3d84ca0fee006461478 | bouwkast/SentimentAnalysis | /feature_extraction_tester.py | 2,651 | 3.640625 | 4 | """
The purpose of this file is to be able to quickly test different ways of extracting features
then we can implement these into our main pipeline.
"""
from nltk.stem.porter import PorterStemmer
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize, wordpunct_tokenize
import nltk
import num... |
fb6e83eb4c92a3d5374b9855655f3bf063571f72 | ItsSong/PictureLearning | /科赫曲线/KochDraw1.py | 656 | 3.796875 | 4 | #!/usr/bin/env python
#-*- coding = utf-8 -*-
#-----------------------绘制科赫曲线----------------雪花
import turtle
def koch(size,n): #曲线的长度;绘制的阶数n
if n==0:
turtle.fd(size)
else:
for angle in [0, 60, -120, 60]: #线的角度
turtle.left(angle)
koch(size/3, n-1)
def main():
turt... |
c05fe4116b6cb88e5dd656e38fe2583ebaf74d2a | mvisic/Hacktober-fest | /Python/random_birthday_generator.py | 513 | 3.703125 | 4 | import datetime
import random
def random_birthday_generator(num_names):
start = datetime.date(2011, 1, 1)
end = datetime.date(2021, 1, 1)
def random_date(start_date, end_date):
t_between = end_date - start_date
d_between = t_between.days
rand_days = random.randrange(d_between)
... |
293a6a513def8439354263875e1bb3a39d191376 | HeenakousarM/KoppalStartup | /Exercise13.py | 281 | 4.125 | 4 | """Using a list comprehension, create a new list called "newlist" out of the list "numbers", which contains only the positive numbers from the list, as integers."""
numbers = [34.6, -203.4, 44.9, 68.3, -12.2, 44.6, 12.7]
newlist = [int(x) for x in numbers if x > 0]
print(newlist) |
00e7a2e85e28bdfde67d9c1b1f2184e1fb7e39e2 | aderise2001/adedavid | /Python_Mobile _Terminal_RSLCalculator.py | 7,529 | 3.828125 | 4 | ''' Python_Project module: a module defining a number of useful
functions:
- user_locale() function : uses a uniform distribution function to get a user's location
- propagation_loss() function requires user's distance and frequency to compute Propagation losses
- fading() function
- penetration_loss() function c... |
f24161e5929b1c20d962f29cfa228f0b854ee637 | Anujay-Saraf/fsdse-python-assignment-32 | /build.py | 169 | 3.625 | 4 | def solution(list_of_ints):
sum_no = 0
for k in range(0,len(list_of_ints)):
sum_no = sum_no + list_of_ints[k]
return sum_no
print solution([5,4,6])
|
30f78a72d5ea2793c3bb06625ba28c28afa3c122 | zongxian/FeigenbaumConstants | /results/verify.py | 927 | 3.609375 | 4 |
def verify():
fname_test = raw_input("Enter the file under test (default = alpha_me.txt): ")
if (fname_test == ""):
fname_test = "alpha_me.txt"
f_test = open(fname_test, "r")
fname_ref = raw_input("Enter the reference file (default = alpha_oeis.txt): ")
if (fname_ref == ""):
fname_ref = "alpha_oei... |
2d8ddff521c5d353fc036e7168e7559b16462dc5 | sotheaYouk/bootCamp | /youksakmonysothea17/week01/projects/01_dice.py | 904 | 4.375 | 4 | import random
result = 0
intro_message = "Welcome to the dices game!"
print(intro_message)
dices = input("Enter the number of dices you want to roll: ")
check_digit = dices.isdigit()
if check_digit is False or len(dices) == 0:
print("USAGE: The number must be between 1 and 8")
dices = input("Enter the number... |
99d7b57519a0d647dbc17aee9bf39b8e023d883c | sotheaYouk/bootCamp | /youksakmonysothea17/week02/projects/test.py | 375 | 3.984375 | 4 | def one_two_pair(dictionary):
count = 0
for dict_values in dictionary.values():
if dict_values == 2:
count += 1
if count == 1:
print("One pair")
elif count == 2:
print("Two pair")
else:
print("hell no")
one_two_pair({'a': 1,
'... |
0e0a77aa6fb591319f11e203bc017869781c8b16 | sotheaYouk/bootCamp | /youksakmonysothea17/week01/ex/13_str_reverse.py | 145 | 3.6875 | 4 | str = input("Enter a string: ")
i = 1
str_temp = ""
while i <= len(str):
str_temp = str_temp + str[len(str) - i]
i += 1
print(str_temp)
|
c8ccad965e021a4a81e762d50b591a90ab1bf671 | Pari-bola/CA2020_PK | /CA2.py | 6,968 | 4.28125 | 4 | # 1. Write a program in Python to perform the following operation:
# ● If a number is divisible by 3 it should print “Consultadd” as a string
# ● If a number is divisible by 5 it should print “c” as a string
# ● If a number is divisible by both 3 and 5 its should print “Consultadd
# # Python Training” as a string
... |
b7323cf7339ef252541e4220c17b3b63c053381f | Pari-bola/CA2020_PK | /Game.py | 1,687 | 4.1875 | 4 | # Main Python program:
# Note: Here we are assuming that you have already taken size of matrix and then values in matrix(0's & 1's only) from user.
#
# As a Developer write a program for matcing following constraints:
#
# You are given a two-dimensional array (matrix) of potentially unequal height and width
# containin... |
2a19f8c0e522c5a1b054d4f970b3bd155763a6a2 | adusca/rosalind-helper | /fasta_reader.py | 519 | 3.78125 | 4 | # This will read a file with Fasta format DNA strings and return a list of tuples
def fasta_to_lst(filepath):
label = ""
dna = ""
lst = []
with open(filepath, 'r') as f:
for tmp in f.readlines():
line = tmp.rstrip()
if line[0] == ">":
if label != "":
... |
48f78fe0a313b712d510f4dc0e5ba40a4d28a682 | Humza277/sparta | /Week 3 -Python/intromaterial/sets.py | 348 | 3.703125 | 4 | # very simmilar to sets
# whats the difference
# We use {} breakets as the syntax
car_par = {"wheels", "subwoofer", "doors"}
print(car_par)
#What can we do with sets
car_par.add("seats")
car_par.discard("wheels")
print(car_par)
#Frozen set - are immuteable
# () store them in a variable first
counting = frozenset([1... |
f48e2ced2f96d02e3a8baa277393e17cef7c4e85 | Humza277/sparta | /Week 3 -Python/intromaterial/tuples.py | 298 | 4.15625 | 4 | # tuple - are immuable objects
# used to store data taht will not change
dob = ("name", "dob", "passport_number", )
#print(dob)
# cpnver the tuple into a list
# add your name into the string at 0 index
# display the list
#print(type(str(dob)))
nbob = list(dob)
nbob.insert(0, "Humza")
print(nbob) |
4897b49611425096c1bd1d44531f58a1efd8e9bf | Humza277/sparta | /Week 3 -Python/calculator/operators.py | 711 | 3.59375 | 4 | def add_values(number1, number2):
return number1 + number2
#
#
def sub_values(number1, number2):
return number1 - number2
#
#
def divide_values(number1, number2):
return number1 / number2
#
#
def modo_values(number1, number2):
if number1 % number2 == 0:
print(True)
... |
13ad71e318512da91feaefda40212c17fd3217bd | phanitejakesha/LeetCode | /Tree_Algorithms/UnivaluesTree.py | 739 | 3.828125 | 4 | #Leetcode problem Number 965
#Univalued Tree
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
value = 0
ans = True
def isUnivalTree(self, root):
"""
... |
e463af256f05e0cee7b8624731eb9797e1b33a61 | phanitejakesha/LeetCode | /Tree_Algorithms/bstToGreaterSumTree.py | 907 | 3.6875 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def bstToGst(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
self.li =... |
4db3626af50b3a208d01d7e86050f24a4b8481fe | phanitejakesha/LeetCode | /String_Problems/uniqueEmails.py | 622 | 3.515625 | 4 | #Leetcode problem Number 929
#unique email addresses
class Solution(object):
def numUniqueEmails(self, emails):
"""
:type emails: List[str]
:rtype: int
"""
d = set()
for i in range(0,len(emails)):
domainName =emails[i].split('@')[1]
userName ... |
7a9de0a026d85dfd637afeadfb453ec55634247b | phanitejakesha/LeetCode | /AvailableCapturesForRook.py | 2,032 | 3.609375 | 4 | class Solution(object):
def numRookCaptures(self, board):
"""
:type board: List[List[str]]
:rtype: int
"""
pawnLocation=self.findLoc(board)
count = 0
for i in range(pawnLocation[0],-1,-1):
if board[i][pawnLocation[1]]=='p':
count+=... |
ff20af6a346897f733073f33a8daf375c301b40a | phanitejakesha/LeetCode | /keyboardRow.py | 525 | 3.609375 | 4 | `class Solution(object):
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
fRow = set("qwertyuiop")
sRow = set("asdfghjkl")
tRow = set("zxcvbnm")
ans = []
for word in words:
if set(word.lower())<=fRow:
... |
8789880ad237b7ceea0cd4d325414bfe0e207e8a | sudo-slatin01/Python-sudo | /Python2.py | 532 | 4.25 | 4 | """
Вводится строка. Необходимо определить в ней проценты прописных (больших) и строчных (малых) букв.
"""
def percents(mstr):
uppers = lowers = 0
for i in mstr:
if i.isalpha():
if i.islower():
lowers += 1
else:
uppers += 1
y = upper... |
9e09733c4964e6a4cd3a7015da420768b9d86509 | supersum9/DataCamp | /Machine Learning with PySpark/Chapter 1 - Introduction.py | 1,756 | 4.0625 | 4 | #***************************Machine Learning & Spark**************************#
#****************************Connecting to Spark******************************#
#Creating a SparkSession#
# Import the PySpark module
from pyspark.sql import SparkSession
# Create SparkSession object
spark = SparkSession.builder \
... |
181f6a15450dad73f17d0712f542d5bde44d3155 | supersum9/DataCamp | /Building Data Engineering Pipelines in Python/Chapter 3 - Testing your data pipeline.py | 849 | 3.5 | 4 | #****************************On the importance of tests***********************#
#********************Writing unit tests for PySpark***************************#
#Creating in-memory DataFrames#
from datetime import date
from pyspark.sql import Row
Record = Row("country", "utm_campaign", "airtime_in_minutes", \
"s... |
ffe68f31ca825373e580378a7955a1a35b0e5303 | ZheLuo/python | /PythonLearning/BasicPractice_2.py | 7,566 | 4.03125 | 4 | # -*- coding: utf-8 -*-
#for循环
#基本构造:
#for 元素 in 序列:
# statement
for a in (3, 4.4, "life"):
print a
#函数range(), 帮助建立表, 从0开始一直到上限(不包括)
idx = range(5)
print idx
for a in range(10):
print a**2
#while循环
#基本结构
#while 条件:
# statement
i = 0
while i < 10:
print i
i = i + 1
#中断循环
#continue,在循环的某一次执行中,如果... |
e4235f21f25ae73c01834cff4dd3300b0dbc2d36 | Ja20019/myTest | /Udapython/p2l4.py | 1,121 | 3.734375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 21 15:30:00 2018
@author: jason
"""
"""
练习:飞行马戏团演员表
你将要为电视节目 Monty Python 飞行马戏团的演员创建一个演员表。
编写一个名为 create_cast_list 的函数,该函数将文件名作为输入,并返回一个演员姓名列表。
该函数将在文件 flying_circus_cast.txt(信息源自 imdb.com)上运行。
该文件的每一行都包含一个演员名字、一个逗号以及一些他们在节目中所扮演角色的(凌乱)相关信息。
你仅需要... |
db76d4084ebe1efaf3ee742cdf6ff49d7e009b7e | C-CCM-TC1028-111-2113/homework-4-JennyAleContreras | /assignments/17NCuadradoMayor/src/exercise.py | 218 | 3.890625 | 4 | def main():
num = int(input("Escribe un numero : "))
#escribe tu código abajo de esta línea
for N in range(num):
if (N*N)>num:
print(N)
pass
if __name__ == '__main__':
main()
|
22adf4e879e1a075ad0540fbcefd58b81ff3aafa | sarahashraf200/Classical-Ciphers | /Vigenere.py | 1,132 | 3.78125 | 4 | #implementing the key and switching between the auto and repeated mode
def create_key_repeated(key , plain):
#repeating
rep = ""
if len(plain) > len(key):
for i in range(int(len(plain) / len(key))):
rep += key
rep += key[:len(plain) % len(key)]
elif len(plain) < len (... |
c01a9a3c0c576c547c44b642688addc7a8f6241a | nicknamexiaozui/personal_celection | /huawei/diaocha.py | 807 | 3.65625 | 4 | '''
明明想在学校中请一些同学一起做一项问卷调查,为了实验的客观性,他先用计算机生成了N个1到1000之间的随机整数(N≤1000),
对于其中重复的数字,只保留一个,把其余相同的数去掉,不同的数对应着不同的学生的学号。然后再把这些数从小到大排序,按照排
好的顺序去找同学做调查。请你协助明明完成“去重”与“排序”的工作(同一个测试用例里可能会有多组数据(用于不同的调查),希望大家能正确处理)。
'''
while True:
try:
n = int(input())
set1 = set({})
for i in range(n):
set1.add... |
d8c8df95fa9ea53d094ca01f4b7a30ff91fcb5d7 | nicknamexiaozui/personal_celection | /huawei/tiqu.py | 259 | 3.515625 | 4 | '''
输入一个int型整数,按照从右向左的阅读顺序,返回一个不含重复数字的新的整数。
保证输入的整数最后一位不是0。
'''
s=input()
s=s[::-1]
y=''
for i in s:
if i not in y and i not in '0':
y=y+i
print(y) |
dfb187739303a2f41b4351f6257834bf37891d9b | C109156223/Midterm | /64.py | 197 | 3.859375 | 4 | #64 孿生質數
x=int(input("請輸入第一個要判斷的數字:"))
y=int(input("請輸入第二個要判斷的數字:"))
a=x % 2
b=y % 2
if (a==0 or b==0):
print("N")
else:
print("Y") |
dc4079fb60d884a36e70c7179d44422affa449a8 | mikgroup/sigpy | /sigpy/interp.py | 32,017 | 3.8125 | 4 | # -*- coding: utf-8 -*-
"""Interpolation functions.
"""
import numba as nb
import numpy as np
from sigpy import backend, config, util
__all__ = ["interpolate", "gridding"]
KERNELS = ["spline", "kaiser_bessel"]
def interpolate(input, coord, kernel="spline", width=2, param=1):
r"""Interpolation from array to po... |
faeeb47bf4d009f6b02bfe962e2310a5e2f16593 | 32nine/lesson1 | /types.py | 252 | 3.78125 | 4 | a = 2
b = 0.5
print(a+b)
name = input("Введите имя")
name = name.lower().replace('1', 'omfg!').capitalize()
print(f'Привет, {name}! Длина: {len(name)}')
v = input('Введите число от 1 до 10\n')
print(int(v)+10) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.