blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
b1953a6b8652ea8744c6ca9c935a7ec9d04ac4b6 | MikeCullimore/project-euler | /project_euler_problem_0001.py | 2,131 | 4.3125 | 4 | """
project_euler_problem_0001.py
Worked solution to problem 1 from Project Euler:
https://projecteuler.net/problem=1
Problem title: Multiples of 3 and 5
Problem: if we list all the natural numbers below 10 that are multiples of 3 or
5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the... |
1d4031a8e37b67b10156c1af1cbdb5e5bf3fb1ae | wunote/noob | /note/py3/word_count.py | 319 | 3.9375 | 4 | src = raw_input('Please into a string:')
strs = 0
ints = 0
space = 0
other = 0
for char in src:
if char.isalpha():
strs+=1
elif char.isdigit():
ints+=1
elif char.isspace():
space+=1
else:
other+=1
print("strs=%s ints=%s space=%s other=%s" %(strs, ints, space, other))
|
138c8a513a004fad86677b6a11248f9813028cf9 | Arkini123/210CT-Algorithms | /Week 3 ( Task 6 ) Reverse sentence.py | 221 | 3.6875 | 4 | sentence = "Everything is awesome"
#('how','are','you'] are registered in 'first'
first = sentence.split()
# ['you','are','how] are registered in 'final'
final = first[::-1]
''.join(final)
print (final)
|
33bb92c777e1c41df9e4d705ce8bb17cc5633809 | Grnd0s/envwriter | /envwriter.py | 1,890 | 3.53125 | 4 | #!/usr/bin/env python3
import sys, getopt
def getEnvString(envFilename):
envString = ""
try:
envFile = open(envFilename, "r");
except IOError:
print("Error: " + envFilename + " not found.")
sys.exit(2)
envLines = envFile.readlines();
envFile.close()
for line in e... |
256b3cf6e6919388e85f3e16fd025c4fc1c3b688 | suspectpart/misc | /cellular_automaton/cellular_automaton.py | 1,787 | 4.28125 | 4 | #!/usr/bin/python
'''
Implementation of the Elementary Cellular Automaton
For an explanation of the Elementary Cellular Automaton, read here:
http://mathworld.wolfram.com/ElementaryCellularAutomaton.html
The script takes three parameters:
- A generation zero as a starting pattern, e.g. 1 or 101 or 1110111
- A rul... |
d51eb511d6682cd9cb71d87d46502fea1c88b4a4 | AntonioDiazCarmona/CSE | /notes/Antonio-Diaz-Items.py | 16,308 | 3.6875 | 4 | debug = True
if debug:
delay = 0.01
else:
delay = 1
class Item(object):
def __init__(self, name, weight):
self.name = name
self.weight = weight
class Axe(Item):
def __init__(self, name, weight, blade, damage, durability):
super(Axe, self).__init__(name, weight)
self.h... |
fc64caf53dcb65240becb48766df2a4a97e3a396 | AntonioDiazCarmona/CSE | /notes/Antonio Diaz-Hang Man.py | 1,291 | 4.0625 | 4 | import random
import string
words = ["tomatoes", "superman", "chair", "chicken", "math", "noodle", "pepperoni", "computer", "pycharm", "video", ]
the_word = random.choice(words)
# the_word = "CAPITAL LETTERS!!!"
# print(the_word)
letters = list(string.ascii_letters)
turns_left = 10
failed = 0
letters_used = []
hidden_... |
e87af5e8761542f7b7dba5d46ffb1e8ad7dface0 | ehnryx/acm | /ecpc-2013-cf100283/i.py | 170 | 3.890625 | 4 | def gcd(a,b):
while b != 0:
a,b = b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
res = 1
for i in range(2,13+1):
res = lcm(res,i)
print(res)
|
dc40e2bb0c34c8da3d101bc531335d6445507fff | ehnryx/acm | /na-2021-practice-3/jointattack.py | 213 | 3.546875 | 4 | from fractions import Fraction
n = int(input())
a = [int(x) for x in input().split()]
ans = Fraction(a[-1])
for x in reversed(a[:-1]):
ans = x + 1 / ans
print("{}/{}".format(ans.numerator, ans.denominator))
|
3c1c6b8edb7d78ade079413850a1669bd1a0e519 | ehnryx/acm | /pacnw2014-d2/t.py | 409 | 3.5 | 4 | import re
number = "(0|[-]?[1-9][0-9]*)"
pattern = re.compile("^" + number + "[-+*]" + number + "=" + number + "$")
T = int(input())
while T:
T -= 1
line = input()
for d in range(10):
if str(d) in line:
continue
check = line.replace('?', str(d))
left, right = check.split('=')
if pattern.mat... |
81d6052746b8b82c9cf42cc906fc5794259e9daf | anaruzz/holbertonschool-machine_learning | /unsupervised_learning/0x01-clustering/4-initialize.py | 713 | 3.625 | 4 | #!/usr/bin/env python3
"""
Function that initializes variables for a
Gaussian Mixture Model
"""
import numpy as np
kmeans = __import__('1-kmeans').kmeans
def initialize(X, k):
"""
Returns: pi, m, S, or None, None, None on failure
pi is a numpy.ndarray of shape (k,)
m is a numpy.ndarray of shape (k, d... |
04d86a64fe0b3c892205757f70a9cb532538d09e | anaruzz/holbertonschool-machine_learning | /math/0x00-linear_algebra/2-size_me_please.py | 319 | 3.796875 | 4 | #!/usr/bin/env python3
""" Script that calculates the shape of a matrix"""
def matrix_shape(matrix):
"""
Function that calculates the shape
of a matrix
"""
size = [len(matrix)]
while type(matrix[0]) is list:
size.append(len(matrix[0]))
matrix[0] = matrix[0][0]
return size
|
86cf4cb652c0c62011f157bfd98259d7a092d005 | anaruzz/holbertonschool-machine_learning | /math/0x06-multivariate_prob/0-mean_cov.py | 564 | 4.125 | 4 | #!/usr/bin/env python3
"""
A function that calculates the mean and covariance of a data set
"""
import numpy as np
def mean_cov(X):
"""
Returns mean of the data set
and covariance matrix of the data set
"""
if type(X) is not np.ndarray or len(X.shape) != 2:
raise TypeError("X must be a 2D ... |
3a904d372a32c4d10dbf04e2e0f8653bf6c0d995 | anaruzz/holbertonschool-machine_learning | /math/0x00-linear_algebra/3-flip_me_over.py | 398 | 4.15625 | 4 | #!/usr/bin/env python3
"""
Script that returns the transpose of a 2D matrix
"""
def matrix_transpose(matrix):
"""
function that returns
the transpose of a 2D matrix,
"""
i = 0
new = [[0 for i in range(len(matrix))] for j in range(len(matrix[i]))]
for i in range(len(matrix)):
for j ... |
18e2ae39a668380a3a3d959bdd5f139dc2c278eb | anaruzz/holbertonschool-machine_learning | /math/0x03-probability/binomial.py | 1,721 | 4.09375 | 4 | #!/usr/bin/env python3
"""
Script that represents binomial distribution
"""
class Binomial():
"""
class binomial
"""
def __init__(self, data=None, n=1, p=0.5):
"""
class constructor
"""
if data is None:
if n <= 0:
raise ValueError('n must be ... |
98d8aeea94709eb56cab0307e0224d41b0b74ec2 | anaruzz/holbertonschool-machine_learning | /math/0x07-bayesian_prob/100-continuous.py | 1,101 | 3.703125 | 4 | #!/usr/bin/env python3
"""
that calculates the posterior probability that the
probability of developing severe side effects falls
within a specific range given the data
"""
import numpy as np
from scipy import math, special
def posterior(x, n, p1, p2):
"""
Returns the posterior probability that p is within
... |
ec6d7ad32c46a8c45d905a51020583cda99fb478 | anaruzz/holbertonschool-machine_learning | /math/0x06-multivariate_prob/multinormal.py | 1,304 | 3.921875 | 4 | #!/usr/bin/env python3
"""
A class that represents a Multivariate Normal distribution
"""
import numpy as np
mean_cov = __import__('0-mean_cov').mean_cov
class MultiNormal():
"""
Class that represents a Multivariate
normal distribution
"""
def __init__(self, data):
"""
class constr... |
0e6e899d797e0fd3242b703986337fffff10f970 | anaruzz/holbertonschool-machine_learning | /supervised_learning/0x0D-RNNs/2-gru_cell.py | 1,340 | 3.78125 | 4 | #!/usr/bin/env python3
"""
Script that represents a gated recurrent unit
"""
import numpy as np
class GRUCell():
"""
Class that represents a gated recurrent unit
"""
def __init__(self, i, h, o):
"""
class constructor
"""
self.Wz = np.random.normal(size=(i + h, h))
... |
311e9d1640886325b2fbc488c3a397839d39de00 | anaruzz/holbertonschool-machine_learning | /supervised_learning/0x0D-RNNs/0-rnn_cell.py | 938 | 3.828125 | 4 | #!/usr/bin/env python3
"""
Script of class RNNCell that represents a cell of a
simple RNN
"""
import numpy as np
class RNNCell():
"""
Class methods
"""
def __init__(self, i, h, o):
"""
Class constructor
"""
self.Wh = np.random.normal(size=(i + h, h))
self.Wy = n... |
bc20069b1e5575cf58ed6f610912af0ed9cf10b7 | SakshiSingh737/HACKERRANK-SOLUTIONS | /Sherlock and GCD.py | 364 | 3.75 | 4 | #In this find the GCD of the given elements in list 'a' if its gcd is 1, it means there is no element which can divide all. Hence, it contains a subset
# import math
# Complete the solve function below.
def solve(a):
res = a[0]
for i in range(1,len(a)):
res = math.gcd(a[i],res)
if(res != 1):
... |
5ebd7f954d1ebf345d87d7cb8afa11bfbb9846a8 | whatarthurcodes/Swedish-Test | /swedishtest.py | 1,843 | 4.125 | 4 | import sys
import random
import csv
def swedishtest():
word_bank = select_module()
lang = choose_lang()
questions(word_bank, lang)
def select_module():
file_found = False
while file_found is False:
try:
module_choice = raw_input('Enter the file name. ex. module1.csv \n')
module = open(module_choi... |
a63975c4c143e0721abdbd8dd9a6ea69a3ed566b | melo0/Exercises-in-Python | /sqrt.py | 186 | 3.515625 | 4 | # sqrt of formula
import math
resault = []
h = [x for x in raw_input().split(',')]
c=50
d=30
for i in h:
resault.append(str(int(math.sqrt((2*c*(float(i)))/d))))
print ','.join(resault)
|
f9da7e0ea95a8b6acd1675612d1fc2592c2da0ef | metterian/programmers-dev-course | /week1/day1/code/linked-list-applied.py | 2,580 | 3.921875 | 4 | class Node:
def __init__(self, item):
self.data = item
self.next = None
class LinkedList:
def __init__(self):
self.nodeCount = 0
self.head = Node(None)
self.tail = None
self.head.next = self.tail
def __repr__(self):
if self.nodeCount == 0:
... |
a1634d16b58c73f4c064b0c786da3bf004d294d6 | metterian/programmers-dev-course | /week1/day2/code/환형큐.py | 1,224 | 4 | 4 | #%%
class CircularQueue:
def __init__(self, n) -> None:
self.maxCount = n
self.data = [None] * n
self.count = 0
self.front = -1
self.rear = -1
# 현재 큐 길이 반환
def size(self):
return self.count
# 큐가 꽉 차 있는가?
def isFull(self):
return self.count ==... |
04e2f58d814742b4645925440d2ae0b1ffa19686 | sbihel/project_IRESI | /distribution.py | 1,397 | 3.609375 | 4 | from numpy.random import *
def entry_uniform(size, u):
""" return a random entry with values in
{0..u} following distribution """
entries = []
for i in range(size):
x = int(uniform(0, u))
entries.append(x)
return entries
def entry_zipfian(size, u, alpha):
""" return a random ... |
cda6be636cb803ada61a164886ea00078e1a8f43 | denislobb/Python_apps | /Python-TEA-CXXTEA/app_cxxtea.py | 2,577 | 3.90625 | 4 | #!/usr/bin/python3.7
from CXXTEA_Cipher import *
# Main function to create an instance of the Blockcipher class and utilise provided functions.
def main():
# Create new Blockcipher object.
test = Blockcipher()
# Set the key to be used for the encryption and decryption operations.
key = [0x30cee881, ... |
9fef30ce589a4bac108dcc6c188512f766bc5290 | diksha-139/python-basics-study | /sample/pattern3.py | 240 | 3.78125 | 4 | # pattern of Alphabets
rows=int(input("enter no of rows"))
num = 97 # 65 for upper case and 97 for lower case
for i in range(0,rows):
for j in range(0,i+1):
a=chr(num)
print(a,end=' ')
num=num+1
print("\r")
|
a8b58552e4e196a5bc4f7a9dbe0c7cbf5d53a840 | diksha-139/python-basics-study | /sample/pattern2.py | 261 | 4.03125 | 4 | # triangle pattern
rows=int(input("enter no of rows"))
for i in range(0,rows):
for j in range(0,i+1):
print("*",end=' ')
print("\r")
for i in range( rows, -1, -1 ):
for j in range( 0, i + 1 ):
print( "*", end=' ' )
print( "\r" )
|
eafe141dac53c0d14d8e04108871fe3194f4eabe | diksha-139/python-basics-study | /PythonSQL/first.py | 717 | 3.5 | 4 | import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="PYTHON_sql1"
)
mycursor = mydb.cursor()
#mycursor.execute("CREATE DATABASE PYTHON_sql1")
#mycursor.execute("SHOW DATABASES")
#for x in mycursor:
# print(x)
#mycursor.execute("CREATE TABLE STUDENT... |
0209106b55769e0730814f1785e0c767dbc42ace | diksha-139/python-basics-study | /sample/count.py | 226 | 3.578125 | 4 | a="diksha,sruthi,anju,anita,anupma"
#a=input("enter names seperated by comma")
temp=a.split(",")
i=0
while i < a.count(",")+1:
res=0
res=temp[i]
if res[0]==res[-1] and len(res)>=2:
print( res )
i=i+1
|
c97da7c47cf3dad644a5f42a673e27e268ae0d3e | diksha-139/python-basics-study | /sample/unique.py | 150 | 4.125 | 4 |
num=list(input("enter list items"))
l1=[]
print("unique list of numbers is :")
for x in num:
if x not in l1:
l1.append(x)
print(l1) |
bbc16720848dc9834d8ca766ab78f39c07a32e30 | diksha-139/python-basics-study | /sample/function.py | 158 | 3.921875 | 4 | # functions
def addition(num1, num2):
print("sum is",num1 + num2)
addition(2, 3)
def multiply(x):
return 5 * x
print("multiply by 5 is",multiply(9)) |
07bf799bd2857e4b1bf1665da369065d918b6887 | diksha-139/python-basics-study | /sample/regular.py | 371 | 3.578125 | 4 | import re
txt="The rain in Spain"
x=re.search("^The .* Spain$", txt)
if x:
print("yes! we got a match")
else:
print("no match")
x2 = re.search( "\s", txt )
print( "the first white space is located at the position:", x2.start() )
#findall() function
x1=re.findall("ai",txt)
print(x1)
x3=re.split("\s"... |
cd2e4983b4d2e54e0208b690dcfcbc59d74fd2b9 | sanghvidhrumil/Python | /Python-Strings/Prime.py | 240 | 3.953125 | 4 | n = int(input('Enter the number:'))
n1 = 2
while n1 < n:
is_prime = True
for i in range(2, n1//2+1):
if n1 % i == 0:
is_prime = False
break
if is_prime == True:
print(n1)
n1 += 1 |
6804eaeece1feb6503dede8c0ba4c29e6772ff4a | rcchen/cs276-utils | /cs276.py | 1,546 | 3.578125 | 4 | import math
# Retrieves a list of all ngrams for a string
# Beginnings and ends of words are indicated with a $
# Strings are split into words with spaces as a delimiter
def ngrams(s, n):
grams = []
for word in s.split(" "):
for i, c in enumerate(word):
if i == 0:
grams.append("$" + word[:i+n-1])... |
37133b90b0bc173371e0874dee145c1b0cfc8c08 | yash42828/AI-for-Medicine-Coursera-Specialization | /AI for Medical Prognosis/Week 3/Programming Assignment Survival Estimates that Varies with Time.py | 14,195 | 3.984375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Survival Estimates that Vary with Time
#
# Welcome to the third assignment of Course 2. In this assignment, we'll use Python to build some of the statistical models we learned this past week to analyze surivival estimates for a dataset of lymphoma patients. We'll also evaluat... |
e0c8ea6a80836a339c55c702e6da8cde927de8c6 | Krupadave92/Data_Structures_and_Algorithm | /Project1/Find_longest_time.py | 1,245 | 4.03125 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files
"""
import csv
def finding_Duration(my_List):
Num_dict=dict()
Number = None
getDuration = 0
for calling, receiving, date_Time, Duration in my_List:
Num_dict[calling] = Num_dict.get(calling,0) + int(Duration)
... |
676adac1477cb20d8fc4a4d0a8cf739ba9e7bae2 | samyy321/python_crypto | /set1/break_rep_key_xor.py | 4,259 | 3.546875 | 4 | # Break repeating-key XOR
# It is officially on, now.
# This challenge isn't conceptually hard, but it involves actual error-prone coding.
# The other challenges in this set are there to bring you up to speed.
# This one is there to qualify you. If you can do this one, you're probably just fine up to Set 6.
# There's a... |
36907efc1bda82dd69f99a5abf2e459ca2111519 | Ruanzhenglin/alien_invasion | /settings.py | 1,728 | 3.625 | 4 | class Settings:
"""store the all settings of alien invasion"""
def __init__(self):
"""initialize the game's settings"""
# screen settings
self.screen_width = 1200
self.screen_height = 700
self.bg_color = (230, 230, 230)
# The settings of the ship
self.sh... |
4cc7c17d32330c63a87f02419dbed572956f9335 | Mr-Plume/Ban_System | /Linux.py | 3,692 | 3.59375 | 4 | def ban_system():
while True:
import time
import os
os.system("clear")
d = "type message"
for d in "type message":
import os
import time
import sys
print(d, end='')
sys.stdout.flush()
time.sleep(0.2)
input1 = input(":")
if "fuck" in input1.lower() or... |
f97065e8ac18d3875a7c68ac9e714763b1856f16 | ud-flori/RSA | /rsa.py | 6,669 | 3.921875 | 4 | import random
import sys
"""
RSA Object for implementing RSA algorithm object oriented.
Use only for educational purpose.
Project was made for a College project.
No warranty, may occur side effects.
Program is in test phase.
Algorithm worsk well, efficiently with 512 bi... |
157f0738477ed4d175ae58335c1147fcb7b8bc58 | alexheyuzhang/InteractionLogic | /week4 turtle.py | 952 | 3.640625 | 4 |
from turtle import *
import random
window = Screen()
window.bgcolor('#fcb1b1')
colors = ['#b22b2b', '#ef3f3f', '#dd9494', '#f7b5b5','#c11010','#ba1717','#7a2929','#fc1717','ff5050']
pensize(3)
speed(0)
pencolor('#6b0101')
def draw_shape():
fillcolor(colors[random.randint(0,len(colors)-1)])
begin_fill()
... |
f4faaa70016906f2fff96839859d08b918e05e16 | chris522229197/iTalk | /text_helpers.py | 986 | 3.53125 | 4 | import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
# Find the set of unique characters (vocabulary) for a particular column in a data frame
def find_vocab(df, col):
col_str = df[col].astype(str)
vocab = set()
for token in col_str:
vocab.update(list(token))
return voc... |
5f3ab29b4d3fd70ade3e1a9c061be33fff4bf370 | chunkman/lpthw | /ex13.py | 313 | 3.6875 | 4 | from sys import argv
script, first, second, third = argv
name = raw_input("What is your name? ")
age = raw_input("What is your age? ")
gender = raw_input("What is your gender? ")
print "Hello, my name is %s and I'm a %s year old %s who likes %s, %s and %s." % (
name, age, gender, first, second, third)
|
a9ebf6bc9cd550faf5a29ccddea47b67c2d441be | umknownone/IntroToProg-Python-Mod08 | /Assigment08-Starter.py | 8,471 | 3.5 | 4 | # ------------------------------------------------------------------------ #
# Title: Assignment 08
# Description: Working with classes
# ChangeLog (Who,When,What):
# RRoot,1.1.2030,Created started script
# RRoot,1.1.2030,Added pseudo-code to start assignment 8
# DAlexandrov,11.26.2019,Modified code to complete assign... |
c938c16840a748e6a7ab39dbffd3da2040b0a3c3 | chaoticmonky/Project_Euler | /p2_Fibbo.py | 240 | 3.671875 | 4 |
def fibbo(array):
array.append(array[-1] + array[-2])
fib = [1,1]
total = 0
while fib[-1] < 4000000:
fibbo(fib)
if fib[-1] % 2 == 0 and fib[-1] < 4000000:
total = total + fib[-1]
print("sum of even valued terms= {}".format(total))
|
b5341d6ce0593afda3e2675fd756c53e52a32fb8 | AlbertoEsc/marketing_results_prediction | /data_loading.py | 2,773 | 3.9375 | 4 | ########################################################################
# Routines to load the data from the csv files and to process it #
# #
# Author: Alberto N. Escalante B. #
# Date: 13.08.2018 ... |
088940c4dc9520e2ac38456b19065db4f523f55a | mfaria724/CI2691-lab-algoritmos-1 | /Laboratorio 01/Soluciones/Laboratorio/Lab1Ejercicio3.py | 487 | 3.859375 | 4 | #
# Lab1Ejercicio3.py
#
# DESCRIPCION: Programa que dado un entero b dice si b es par
#
# Autor:
# Prof. Rosseline Rodriguez
#
# Ultima modificacion: 13/01/2018
#
# VARIABLES:
# B: int // ENTRADA: valor entero
# esPar: bool // SALIDA: resultado
# Valores iniciales:
B = int(input("Introduzca e... |
decfb7ac854902e4d56966b01393383f42de59c7 | mfaria724/CI2691-lab-algoritmos-1 | /Laboratorio 03/PreLab3Ejercicio1.py | 1,716 | 3.921875 | 4 | #
# PreLab3Ejercicio1.py
#
# DESCRIPCION: Programa que dado un número N, calcula la sumatoria
# de los factoriales desde 0 hasta N. El resultado de la suma es
# almacenado en la variable suma
#
# Autor:
# Manuel Faria 15-10463
#
# Ultima modificacion: 26/01/2018
#
#
# VARIABLES:
# N: int // ENTRADA: Límite super... |
c059af3ececdcdbfbd8b99ff1aa192c644258d8a | mfaria724/CI2691-lab-algoritmos-1 | /Laboratorio 06/PreLaboratorio/Soluciones/Prelab6ejercicio1.py | 2,167 | 4 | 4 | #
# Prelab6ejercicio1.py
#
# Descripcion: Programa que dado un polinomio de grado 2 calcula sus raices
# Utilizando condicionales y funciones.
#
# Autores: Prof. Rosseline Rodriguez y Prof. Saul Hidalgo
#
# Ultima modificacion: 06/03/2018
from math import sqrt # Importamos sqrt para calcular raices cuadradas
import s... |
500fc15e2603153656642e44b4fe0026c9ece01e | mfaria724/CI2691-lab-algoritmos-1 | /Laboratorio 02/Soluciones/PreLaboratorio/Prelab2ejercicio1.py | 466 | 3.953125 | 4 | #
# Prelab2ejercicio1.py
#
# DESCRIPCION: Programa que calcula el valor absoluto de a
#
# AUTOR: Kevin Mena
# Variables:
# a: entero // ENTRADA: Valor a sacarle el absoluto
# b: entero // Salida: Valor absoluto
# Valores iniciales:
a = int(input("Ingrese un valor: "))
# Precondicion:
assert(Tru... |
b7b7a96cc77954df1e5c0965b6b2f0b5c0da24d2 | mfaria724/CI2691-lab-algoritmos-1 | /Taller/examenP2_1510463.py | 1,172 | 4 | 4 | #
# examenP2_1510463.py
#
# DESCRIPCION: Programa que calcula la cantidad de ascensos en una secuencia.
#
# Autor: Manuel Faria 15-10463
#
# Ultima modificacion: 27/02/2018
#
# VARIABLES:
# numasc: int // SALIDA: Valor que almacena el número de ascensos en la secuencia.
# continuar: bool // Valor para determinar... |
9028afe374d90a565b23cf9ff102d7dd70025ba1 | mfaria724/CI2691-lab-algoritmos-1 | /Laboratorio 05/Laboratorio/Lab05Ejercicio3r.py | 1,265 | 4.125 | 4 | #
# Lab05Ejercicio3r.py
#
# DESCRIPCIÓN: Programa que dada una secuencia de N números naturales
# pertenecientes al conjunto {1,2,3,4} devuelve el número de ocurrencias
# de cada elemento del conjunto en la secuencia dada.
#
# Autor:
# Manuel Faria 15-10463
#
# Ultima modificacion: 22/02/2018
#
import sys # Se imp... |
d42432513c5ddb508134478befd34d23594f97d0 | mfaria724/CI2691-lab-algoritmos-1 | /Laboratorio 02/Soluciones/Laboratorio/Lab02Ejercicio1.py | 758 | 3.90625 | 4 | #
# Lab02Ejercicio1.py
#
# DESCRIPCION: Programa para calcular si un año es bisiesto
#
# Autor:
# Kevin Mena
# Variables:
# anyo: entero // ENTRADA: año a ser verificado
# esBisiesto: booleano // SALIDA: saber si es bisiesto o no
# Valores iniciales:
anyo = int(input("Introduzca el año a verific... |
baa950af8b02b27963836a858ad0f2b35f9d3bd4 | osurett/comp110-21f-workspace | /exercises/ex01/relational_operators.py | 647 | 4.03125 | 4 | """Gaining a better understanding of relational operators through this straightforward program."""
__author__: str = str(730530127)
left: str = input("Left-hand side: ")
right: str = input("Right-hand side: ")
leftint: int = int(left)
rightint: int = int(right)
less: bool = bool(leftint < rightint)
greatorequal: bo... |
c45f6c817d7935c18669f3482ddeffdad83088f6 | osurett/comp110-21f-workspace | /projects/cyoa.py | 4,589 | 4.25 | 4 | """Interactive Program That Will Help the User Find The Right Place to Eat in Chapel Hill."""
from random import randint
__author__ = "730530127"
points: int = 0
player: str
burger_constant: str
def greet() -> None:
"""Function greet will greet the user upon starting the program."""
print("This program wi... |
257ecb3f0097ccf743b102462cb4f14c37b5cc2d | mlawan/lpthw | /ex39/ex39.py | 1,591 | 4.3125 | 4 | # creates a mapping to state to abbreviation
states ={
'Oregon': 'OR',
'Florida' : 'FL',
'CAlifornia' : 'CA',
'Konduga' : 'KDG',
'Maiduguri': 'Mag'
}
#creats a babsic set of states and some cities in them
cities = {
'CA': 'SanfranCisco',
'KDG': 'Sandiya',
'FL': 'Florida',
'Mag': 'MMC'
}
#ADD SOME MORE cities
cities['N... |
28a5ceae1d0b29e00c0a7e657c5ea9f3ce3ab08f | mlawan/lpthw | /ex30/ex30.py | 518 | 4.15625 | 4 | people = 30
cars = 40
trucks = 40
if cars > people or trucks < cars:
print("We should take the cars")
elif cars< people:
print("We should not take the cars")
else:
print(" We cant decide.")
if trucks > cars and cars == trucks:
print("Thats too much of trucks")
elif trucks <cars:
print("Maybe we c... |
48394e519b655d3796567c819cc7b363d67c04cc | mlawan/lpthw | /ex24/ex24.py | 864 | 3.9375 | 4 | print("Lets practice everything we have learn")
print('You\'d need to know \bout excapes with \\ that do:')
print('\n newlines and \t tabs.')
poem = """
\t The lovely wife and car
with good food and family
cannot escape the pleasure of Allah \n
nor compare to heaven
\n\t hwere he pray.
"""
print("---------------------... |
5750b1e2f315f33479f8de3d0d1bbf6ace5a6d94 | DataBiosphere/azul | /deployments/dev.gitlab/environment.py | 1,000 | 3.546875 | 4 | from collections.abc import (
Mapping,
)
from typing import (
Optional,
)
def env() -> Mapping[str, Optional[str]]:
"""
Returns a dictionary that maps environment variable names to values. The
values are either None or strings. String values can contain references to
other environment variable... |
e39df55a8b984f66d20025e81d7fb611d26d43a5 | hedamian/thq-analysis | /tesis-cern/time.py | 199 | 3.828125 | 4 | from math import *
print("Escribe tiempo la particula")
t1=float(input())
t=t1/sqrt(1-(0.99**2))
v=3.0e8
d=v*t
print("tiempo del segundo observador",t)
print("distancia recorrida ",d," metros")
|
7e0700b140fcd4e995866d5b1d2a0cb1e31d47b8 | mafm9/Problems | /Interpreter/sequence.py | 162 | 3.921875 | 4 | nums = input("Please enter a sequence of comma seperated numbers ")
nums_list = nums.split(',')
nums_tuple = tuple(nums_list)
print(nums_list)
print(nums_tuple)
|
c7c5ad2733968fe28f0d6b6b41094fffec387f36 | mafm9/Problems | /Basics/odd_or_even.py | 133 | 4.21875 | 4 | num = input("Input a number: ")
num = int(num)
if num%2 == 1:
print("The number is odd.")
else:
print("The number is even.")
|
9db862c853e39dac30ceb3e8775bb8f62c25ec0b | mafm9/Problems | /List_comprehension/list_of_even.py | 164 | 3.953125 | 4 | num_list = input("Enter list of numbers seperated by commas: ").split(",")
nums = list(map(int,num_list))
even_list = [x for x in nums if x%2 == 0]
print(even_list) |
a52f5ed21d3ebc95c8c1817a92f0e44b9ccaf775 | mafm9/Problems | /Interpreter/char_to_ascii.py | 83 | 3.84375 | 4 | character = input("Input a character to convert to ASCII: ")
print(ord(character))
|
663531b5ebaaad4323ed1d04dc906d3081184e8e | rastaehli/linuxConfig | /postgresDemo.py | 2,316 | 3.734375 | 4 | # demo accessing a row from postgres database from python script.
class Demo():
def __init__(self):
def connect(self):
"""Connect to the PostgreSQL database. Returns a database connection."""
try:
return psycopg2.connect("dbname=postgrestest")
except:
print "un... |
6cabeb498c3e5471c811e0b8b8397120889f061d | Index-Out-Of-Range/python_work | /dp1/1612841_丁鹏_1st.py | 3,833 | 3.828125 | 4 | import json
def MainList():
print("*" * 60, "\n")
print("南开大学软件学院通讯录管理系统V0.01a".center(55), "\n")
print("添加数据请按[a]".center(55, '-'))
print("删除数据请按[d]".center(55))
print("修改数据请按[m]".center(55))
print("查询数据请按[s]".center(55))
print("返回主菜单请按[q]".rjust(55))
print("退出程序请输入[quit]".rjust(55))
... |
edc742f35fd09ee65272111cc6bf4dd84d74b2fd | Index-Out-Of-Range/python_work | /dp7/test.py | 2,138 | 3.53125 | 4 | # from decimal import Decimal
#
# class Fees(object):
# def __init__(self):
# self._fee = None
#
# def get_fee(self):
# return self._fee
#
# def set_fee(self, value):
# if isinstance(value, str):
# self._fee = Decimal(value)
# elif isinstance(value, Decimal):
# ... |
258172d7b9d4e8216ee00153030156688632fe67 | samueladefiyiju/Software-Engineering-Assignments | /heapsort.py | 1,100 | 3.609375 | 4 | class heap:
pass
def siftdown(H, i):
siftkey = H.s[i]
parent = i
largerchild = 0
spotfound = False
while (2*parent+1 < H.heapsize and spotfound == False):
if (2 * parent < H.heapsize and H.s[2*parent] < H.s[2*parent +1 ] ):
largerchild = 2*parent + 1
else:
... |
b0c2802bc26971c19ef2567161082593b7c3d53a | saurabhkango/PythonTutorial | /Class/classes_property_decorator.py | 516 | 3.796875 | 4 | class person:
def __init__(self):
self.__name=''
@property
def name(self):
return self.__name
@name.setter
def name(self,name):
self.__name=name
@name.deleter
def name(self):
del self.__name
if __name__ == '__main__':
p1 =person()
p... |
ebbcbdc86cf43acdd4399e5595bf547f21c929bc | andrewn488/5061-entire-class | /Week 01/Week 1 Warmup.py | 713 | 3.984375 | 4 | """
Week 1 5-Minute Warmup
Write a program that gets a number from the user and prints out 3x that number
on the shell console
"""
#x = int(input('Is my number 3x the input? '))
#print(x * 3)
height = float(input('What is your height in inches? '))
if height < 60.0:
print('very short')
else:
... |
8950ac176813b900f3f4e7a4d3358e977987552e | andrewn488/5061-entire-class | /Week 05/pec1_decimal_to_binary.py | 741 | 4.21875 | 4 | """PEC1: Decimal to Binary
Author: Andrew Nalundasan
For: OMSBA 5061, Seattle University
"""
print('When you enter a non negative integer a string in binary representation will be shown')
n = int(input('Enter a non- negative integer: '))
if n < 0:
print('You must enter a non- negative integer: ')
p... |
a0e2b3c0f14e338909e5601998de8c02fd16c913 | andrewn488/5061-entire-class | /Week 05/p4_materials/p4_hints.py | 7,159 | 3.6875 | 4 | ### UP to the matching ### line, you might paste these lines near the top of each of your programs (after any imports)
# Which test case are we running?
# Change this line to switch to running a different test case
# (which is exactly what the grader will do and nothing more)
test_case = 1
# Following are instructor-p... |
5214cf548bb96cad7f604efd2b3e11e690250f4e | andrewn488/5061-entire-class | /Week 03/tw4_squares.py | 634 | 4.09375 | 4 | """
Week 3 Team Work Assignments
TW4_Odometer_Squares
9/30/2020
Chequala Fuller
Austin Bednar
Andrew Nalundasan
"""
# import math package
import math
# variables
lownumber = int(input('low: '))
squareroot = math.sqrt(lownumber)
highnumber = int(input("high: "))
#reverse integers if low > high
... |
fdf331bebea0223844ca64aa9bd222e0427fb6d8 | sophiawisdom/literscraping | /db_setup.py | 1,697 | 3.515625 | 4 | import sqlite3
file = open("liter.db",'w')
file.close()
conn = sqlite3.connect("liter.db")
c = conn.cursor()
c.execute("""CREATE TABLE members(
member_id INTEGER PRIMARY KEY,
gender TEXT,
age TEXT,
weight TEXT, -- 0 for no answer
height TEXT, -- 0
location TEXT,
orientation TEXT,
interested_in TEXT,
status TEXT,
smok... |
350c64019dd2b53aea3d37e0d80fc1bc4cd4f9a7 | chaetognatha/list-comprehension-aa-codons | /aa_codon_list.py | 1,102 | 4.03125 | 4 | """This was adapted from an incredibly elegant list comprehension found on
http://www.petercollingridge.co.uk/tutorials/bioinformatics/codon-table/ I wanted to see if I could adapt it to list
codons given the amino acid, and it worked. """
nts = "tcag" # nucleotides in genetic code
cods = [a + b + c for a in nts for b... |
b7e376fcfcda129568553425120fbfe57592d7d8 | adamjmohr/Python-FInal-Project | /Record.py | 1,635 | 4 | 4 | # Represents a generic record from a csv file. All the instance attributes are from the columns in csv file.
# Author: Adam Mohr
class Record:
"""A class used to represent one row of a generic data record in a csv file. Subclasses will inherit from this
parent class."""
"""Class attribute to specify type... |
7bc9ba62743b17a5031edbe60776d88e29fcdcda | martsallan/Desafio3_STI | /src/createDF.py | 567 | 3.671875 | 4 | ##Foi utilizado a biblioteca Pandas para a manipulação do arquivo CSV
##e após isso transformar em um DataFrame
import pandas as pd
# Feita a leitura do CSV a partir de uma função do pandas
doc = pd.read_csv('./dataset/notas.csv')
# Cálculo do tamanho total do documento
tamTotal = int(doc.size/doc.columns.size)
# Cr... |
0603b5ffa5753a8938df26dc3028bde962dd2650 | mdh266/Wikimedia_Challenge | /plotting_functions.py | 4,291 | 3.578125 | 4 | """
This contains some functions to make plots that were a little
move involved. They are in this file to save space in the
juptyer notebook.
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def plot_grouped_and_ungrouped(diff, rate, string):
"""
Function that plots the Pandas ... |
b85d6566cf702705783d267ef7f51d37d9433e46 | helenmfoster/IoTProject | /app/atRunTime.py | 3,446 | 3.609375 | 4 | """
This file contains the stuff we need to do at run time and some quick notes on how to use
"""
from routing import *
from trashBot import *
import csv
#each dumpster is 1.6 y^3, with compression ratio 2.5 => .52
#each truck is 30 cubic yards
#heights are given out of 5
#so, sum(height) * .52 / 5 = 30
#capacity... |
d185fd92cb1c50476a9585500b62093dff21589e | ibhargav7/amfoss-tasks | /task 12/reverse.py | 530 | 3.640625 | 4 | import string
import codecs
a='667b6c7d63677f3c733c7f323c3c7b333e7b3c3c7f3e7b333e3232393c3d3268'
b=codecs.decode(a,"hex")
c=[]
for i in b:
c.append(chr(ord(i)^10))
def shift(x):
upper = string.ascii_uppercase
lower = string.ascii_lowercase
digits = string.digits
n = []
for i in x:
if i.is... |
0a3c8d459722962a4cf49d524456b76d2069fc9a | python4kidsproblems/Operators | /comparison_operators.py | 1,266 | 4.28125 | 4 | # Comarison Operators Practice Problems
# How to use this file:
# Copy this to your python (.py) file, and write your code in the given space
################################### Q1 ###################################
# Write a program that asks the user, #
# "Are you older th... |
7c30b241f9e3360081ea01cac0cefc82b722a524 | rsurpur20/ComputerScienceHonors | /WinterTerm/randomwalks.py | 4,221 | 4.5 | 4 | # Roshni Surpur
# OMH
# January 10, 2019
# What is the longest walk you can take and still be close enough to walk back 50% of the time?
# 22 blocks.
# I found 20 to be the answer is a less effective way then in the video. I just changed the number in my randwalk variable when calling the walk function
# and increased/... |
fc09bc969303a4bddf367fc3748ffb53e20e7ba0 | rsurpur20/ComputerScienceHonors | /Classwork/convertor.py | 1,114 | 4.25 | 4 | # convert dollars to other currencies
import math
import random
#
# dollars=float(input("Dollars to convert: \n $")) #gets the input of how many dollars, the user wants to convert
#
# yen=dollars*111.47 #the conversion
# euro=dollars*.86
# peso=dollars*37.9
# yuan=dollars*6.87
#
# print("$"+str(dollars) + " in yen is"... |
111c5346ca6f32e8f25608a1d2cf2ea143056ed6 | rsurpur20/ComputerScienceHonors | /minesweeper/minesweepergame.py | 2,394 | 4.25 | 4 | # https://snakify.org/en/lessons/two_dimensional_lists_arrays/
#Daniel helped me,and I understand
import random
widthinput=int(input("width?\n"))+2 #number or colomns
heightinput=int(input("height ?\n"))+2 #number of rows
bombsinput=int(input("number of bombs?\n"))#number of bombs
width=[]
height=[]
# j=[]
# # for x in... |
1e60883c3a4f5f6562f494d76c5eb3f586172113 | rsurpur20/ComputerScienceHonors | /classes/demodeck.py | 6,706 | 4.03125 | 4 | # Roshni Surpur
# November 16,2018
# on my honor, I have neither given nor recieved unauthorized aid
# http://interactivepython.org/runestone/static/pythonds/SortSearch/TheSelectionSort.html Accessed November 16,2018
# I also used the code from the demo in class
# This code is for the card game rummy.
# import card cl... |
20d3ca33e7053f6bca9a03e369c5b1ecf33ce48f | rsurpur20/ComputerScienceHonors | /mandelbrot/mandelbrothw.py | 956 | 3.640625 | 4 | from PIL import Image
import math
imgx=3
imgy=3
num=2 #the number it should not exceed
iterations=3
pixels=[]
image=Image.new("RGB",(imgx,imgy)) #specifying color, width, height
for i in range(iterations):
for x in range(imgx):
for y in range(imgy):
z=(0,0)
c=(x,y)
znew=... |
4aa15e243b2122673e3a5029f78c8f344e5181a0 | rsurpur20/ComputerScienceHonors | /WinterTerm/calories.py | 1,845 | 3.53125 | 4 | # # stimulate 1 million holidays seasons
# import random
# from collections import Counter
# import matplotlib.pyplot as plt
# calorieslist=[]
#
# for i in range(1000): #how many holiday season
# parties=random.randint(1,13)
# totalcalories1=0
# for a in range(parties):
# servings=random.randint(1,8... |
f30d77e75e5632a8a31bde7b170f2c2ef47251df | yihanzhang9601/testZhang | /pythontest/wenjianchuli.py | 873 | 4.03125 | 4 | #!/usr/bin/env python37
# -*- coding : UTF-8 -*-
# 文件处理
# open() 打开文件 参数:读:r、写:w、追加:a、
# file object = open(file_name[,access_mode][,buffering])
file = open("test.txt","w" )
print("文件名:",file.name)
print("是否已经关闭:",file.closed)
print("访问模式:",file.mode)
file.close() # 关闭打开的文件
# write() \n:换行
fo = open('foo.txt','w'... |
d2d02e29ae487beb1c2c64e71c9a250d53907ef1 | yihanzhang9601/testZhang | /pythontest/students.py | 952 | 4 | 4 | #/usr/bin/env python37
# -*- coding : UTF-8 -*-
# 判断学生成绩是否达标的程序,要求输入学生数量,以及各个学生物理、数学、
# 历史三科的成绩,如果总成绩小于 180,程序打印 “failed”,否则打印 “passed”。
n = int(input("学生数量为:"))
date = {} #定义字典存储数据
date2 = {}
kemu = ['物理','数学','历史'] # 列表定义科目
for i in range(0,n):
name = input('学生姓名为:'.format(i)) # 学生名称
marks = [] # 定义列表存储学生... |
d3dc36670d91c66025bedbe7f1ac847eee23eba0 | alexmunoz502/Timing-Sorting-Algorithms | /insert_time.py | 1,124 | 3.921875 | 4 | import sys
import algo_timer
import algorithms
# CONSTANT - List sizes of N to test the sorting algorithm on
LIST_SIZES = [
5000,
7500,
10000,
12500,
15000,
17500,
20000,
22500,
25000
]
DEFAULT_SAMPLE_SIZE = 3
def calculate_insertion_sort_average_time(sample_size: int) -> None:
... |
9d572a5ab66b88d00a895864d416a10a6914eb7d | rahaf19-meet/yl1201718team6 | /personalproj.py | 4,040 | 3.71875 | 4 | from turtle import *
import turtle
import time
import random
from ball import Ball
import math
turtle.hideturtle()
hideturtle()
tracer(0)
colormode(255)
turtle.goto(-100,100)
turtle.write("START GAME", move=False, align="left", font=("Arial", 20, "normal"))
turtle.goto(-150,0)
turtle.write("Eat the other balls to ge... |
7f21b70de05987ea5571c35db353d0f3659d2560 | Zombrooc/URI-Online-Judge-Python | /1018.py | 202 | 3.671875 | 4 | num = int(input())
notas = [100, 50, 20, 10, 5, 2, 1]
print(num)
for nota in notas:
qtndNotas = num//nota
print("{} nota(s) de R$ {},00".format(qtndNotas, nota))
num = num - (qtndNotas*nota)
|
45b06f77f3387b59e475095a0fc78db729bc6835 | Zombrooc/URI-Online-Judge-Python | /1017.py | 127 | 3.578125 | 4 | firstValue = int(input())
secondValue = int(input())
answer = (firstValue * secondValue) / 12
print("{:.3f}".format(answer)) |
6209c787c5dedc58a0c7a0b03986ad4ab453bb73 | tantale/deprecated | /docs/source/sphinx/calc_mean.py | 343 | 3.875 | 4 | def mean(values):
"""
Compute the arithmetic mean (“average”) of values.
:type values: typing.List[float]
:param values: List of floats
:return: Mean of values.
.. deprecated:: 2.5.0
Since Python 3.4, you can use the standard function :func:`statistics.mean`.
"""
return sum(val... |
bac4234eb3635e084517cab020e5b8761e77967f | joelstanner/codeeval | /python_solutions/HAPPY_NUMBERS/happy_numbers.py | 1,485 | 4.3125 | 4 | """
A happy number is defined by the following process. Starting with any positive
integer, replace the number by the sum of the squares of its digits, and repeat
the process until the number equals 1 (where it will stay), or it loops
endlessly in a cycle which does not include 1. Those numbers for which this
process e... |
9668ba9aad876675efe26dc644d08c3f8cb049a1 | joelstanner/codeeval | /python_solutions/NUMBER_PAIRS/NUMBER_PAIRS.py | 2,563 | 4.3125 | 4 | """
You are given a sorted array of positive integers and a number 'X'. Print out
all pairs of numbers whose sum is equal to X. Print out only unique pairs and
the pairs should be in ascending order
INPUT SAMPLE:
Your program should accept as its first argument a filename. This file will
contain a comma separated lis... |
ccb519e563f642f2df8ce4ef071aa98cab8fd6fa | joelstanner/codeeval | /python_solutions/QUERY_BOARD/QUERY_BOARD.py | 2,358 | 4.03125 | 4 | """
There is a board (matrix). Every cell of the board contains one integer, which
is 0 initially.
The next operations can be applied to the Query Board:
SetRow i x: it means that all values in the cells on row "i" have been changed
to value "x" after this operation.
SetCol j x: it means that all values in the cel... |
a73717e0842d17d44f275aeafba71950e88e5b55 | joelstanner/codeeval | /python_solutions/PENULTIMATE_WORD/PENULTIMATE_WORD.py | 583 | 4.4375 | 4 | """
Write a program which finds the next-to-last word in a string.
INPUT SAMPLE:
Your program should accept as its first argument a path to a filename. Input
example is the following:
some line with text
another line
Each line has more than one word.
OUTPUT SAMPLE:
Print the next-to-last word in the following way... |
0dc79dcc5c3b026ad10e1328ed2ef84a12514fb1 | joelstanner/codeeval | /python_solutions/UNIQUE_ELEMENTS/unique_elements.py | 809 | 4.4375 | 4 | """
You are given a sorted list of numbers with duplicates. Print out the sorted
list with duplicates removed.
INPUT SAMPLE:
File containing a list of sorted integers, comma delimited, one per line. E.g.
1,1,1,2,2,3,3,4,4
2,3,4,5,5
OUTPUT SAMPLE:
Print out the sorted list with duplicates removed, one per line.
E.g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.