blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
8b48481854b9fa62cd360e305b3c835d7b08dc46 | ReethP/Kattis-Solutions | /filip.py | 120 | 3.5 | 4 | x,y= input().split()
a = x[::-1]
b = y[::-1]
c = int(a)
d = int(b)
if c>d:
print(c)
elif d>c:
print(d)
|
ee576b9d1b58d77a9ca86e590a87a1673778ccff | ReethP/Kattis-Solutions | /quickestimate.py | 77 | 3.703125 | 4 | itera = int(input())
for i in range(0,itera):
num = input()
print(len(num)) |
306cf192fedb5623fd35ed3082b1bd3fd0bc079c | ReethP/Kattis-Solutions | /quickbrownfox.py | 651 | 3.5625 | 4 | fulllist = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
spechars = ['?','.',"'",'"',',','!']
numberlist = ['0','9','8','7','6','5','4','3','2','1']
iterations = int(input())
for i in range(0,iterations):
letterlist = []
uint = input()
uint = uint.lower()
... |
542b6ff77c1f7dccce56b28a8f37f2a4a568181e | ReethP/Kattis-Solutions | /reversebinary.py | 209 | 3.5 | 4 | def reversi(bina):
newnum = ['0','b']
bina = bina[::-1]
for j in bina:
newnum.append(j)
finalnum = ''.join(newnum)
print(int(finalnum,2))
inputs = int(input())
userint = bin(inputs)
reversi(userint[2:]) |
350299d792e9cd280a0ae65729128d43b5cb9b85 | ReethP/Kattis-Solutions | /modulo.py | 149 | 3.875 | 4 | numbers = []
for i in range(0,10):
number = int(input())
number = number%42
if number not in numbers:
numbers.append(number)
print(len(numbers)) |
014b47f115ac7c2f68ceefbe04e5ff1772a8d188 | ReethP/Kattis-Solutions | /licensetolaunch.py | 154 | 3.6875 | 4 | input()
mainlist = list(map(int,input().split()))
smallest = mainlist[0]
for k in mainlist:
if k<smallest:
smallest = k
print(mainlist.index(smallest)) |
68b7b78a40d87058ee5251fe5a1585697b7416d7 | ReethP/Kattis-Solutions | /different.py | 178 | 3.53125 | 4 | try:
userinput = 0
while(userinput != ''):
userinput = input()
a,b = userinput.split()
a = int(a)
b = int(b)
c = a-b
if(c<0):
c = c*(-1)
print(c)
except:
pass |
a8adefe823ab12a2848a7f40799c03221e7e5b5c | ReethP/Kattis-Solutions | /backspace.py | 170 | 3.609375 | 4 | stack = []
userint = input()
for i in userint:
if i == "<":
stack.pop()
else:
stack.append(i)
if(len(stack) != 0):
for j in stack:
print(j, end = "")
print() |
f51395054c5afd75b45a41f82a908bd1f4604ee8 | Habibu-R-ahman/My_Python_Learning | /Basic/String.py | 720 | 4.21875 | 4 | """Declared a string in a variable"""
name = "habibur rahman"
"""Changing Case in a String without change value"""
print(name.title())
print(name + "\n")
"""Convert Upper and Lower Case"""
print(name.upper())
print(name.lower() + "\n")
"""Concat string"""
first_name = "habibur"
last_name = "rahman"
age = 32
print(fi... |
78e57441bd7b80bb97b477afa34f3ce40c1d91de | VladGaliulin/Repository1 | /for1.py | 96 | 3.53125 | 4 | n = int(input('Введите значение: '))
for i in range (1,n):
print (i)
print(n) |
d52a0bba4ec4ec1220c58a179fdbae340ff43c81 | MLAB-project/utils | /pst | 320 | 3.53125 | 4 | #!/usr/bin/python3
from sys import argv
if ("-h" in argv) or (len(argv) < 2):
print("Usge: pst [-h] [SINCE] [TO]")
exit()
while True:
if argv[1] in input():
while True:
line = input()
if argv[2] in line:
exit()
else:
print(line)
|
a96521bb62f07231af87a55a6dd977d7d64214b6 | Hiten-98/Snake-Game-using-Python | /design.py | 545 | 3.828125 | 4 | from turtle import Turtle
class Design(Turtle):
def __init__(self):
super().__init__()
self.color("white")
self.penup()
self.hideturtle()
self.boundary()
self.author()
def boundary(self):
self.goto(0,230)
self.write("______________... |
8872cd0c7bcd0e8eb2dea55e810fe5c04511adf4 | Evan1987/RL | /Morvan/04_Sarsa_lambda_maze/RL_brain.py | 3,926 | 3.640625 | 4 | """
This part of code is the Q learning brain, which is a brain of the agent.
All decisions are made in here.
"""
import numpy as np
import pandas as pd
class RL:
def __init__(self, actions, learning_rate=0.01, reward_decay=0.9, e_greedy=0.9):
self.actions = actions
self.alpha = learning_rate
... |
ae7a4c5d20fd1b52ddd2401575f9195071d71921 | Raafi101/CSCI133 | /UnitTests/test10Stuffs/test10.py | 6,052 | 3.5 | 4 | #CS133 Test 10
#Raafi Rahman
# A-1K: Mean or NastyMirror
# A-8K: Mean
# A-32K: NiceMirror
#
# B-1K: NastyMirror
# B-8K: Random or NiceMirror or NastyMirror (NastyMirror sometimes wins, but rarely)
# B-32K: Random or NiceMirror
#
# C-1K: NastyMirror
# C-8K: NiceMirror or Counting (Although ver... |
899af773eb21352f38339cd4b95fccba9a2241c3 | kadertarlan/python | /bazi_donguler.py | 265 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
a=0;
while a<3:
a=a+1
print a
print "\n"
for i in range(1,10):
print i
for i in "kelime":
print i
print "\n"
for i in range(0,11,2):
print i
print "\n"
print range(10,15)
print range(0,20,3)
|
8b6acb281a83585f85887422f9c7c0b4e191755c | kadertarlan/python | /sayi2.py | 276 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
sayi=100
if sayi==100:
print (" sayi 100 dür.")
elif sayi <= 150:
print (" sayi 150 den küçüktür.")
elif sayi > 50:
print ("sayi 50 den büyüktür.")
elif sayi <=100:
print("sayi 100 den küçüeşiitir.")
|
84c16042450e826872a48f101c0a3900bedd8902 | tulare/misc-python-scripts | /scripts/sqldump.py | 680 | 3.703125 | 4 | # -*- encoding: utf8 -*-
import sys
import os
import argparse
import sqlite3
def parse_args() :
""" Parse command line arguments
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'dbname',
#nargs='?',
help='sqlite database filename'
)
args = parser.parse_arg... |
528eb1a67e8cfdccf02267e65fbc099f452865f2 | itqop/labs_4sem_py | /lab4/task 3.py | 1,515 | 3.890625 | 4 | class Stack:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items) - 1]
def size(self):
... |
8ad8205e738ee9970a7025b67b3db53265bc6f26 | yukiskate/AtCoder_Python | /abc131/A.py | 109 | 3.671875 | 4 | S = str(input())
tmp = ''
s = 'Good'
for v in S:
if tmp == v:
s = 'Bad'
tmp = v
print(s)
|
7320f1de5f6a04875d056e65cb499248b357f84b | sgiann/sleeplight | /flash_led_blink_thread_class.py | 884 | 3.84375 | 4 | import threading
import time
#param list
#name : Give as name the colour of the LED to be handled.
#pin_number - The pin number that the LED is hooked at.
#dtime_mins - Give the desired time in minutes that you want the led to blink for.
class LEDThreadStill(threading.Thread):
def __init__(self, name, pin_number,... |
60055ed616960cd8314ad01bf5e82940b6f11a53 | thejackxu/BK | /Database.py | 4,072 | 3.515625 | 4 | import sqlite3
from sqlite3 import *
class DBManager:
def __init__(self):
self.conn = None
def createTable(self):
try:
#primary property id & address
pidTable = '''
CREATE TABLE IF NOT EXISTS pidTable(
primary_id TEXT PRIM... |
11cc67cbd5ad81aacf017371a8047547c2a104a7 | SarahMLawrence/IsomorphicStrings | /main.py | 240 | 3.515625 | 4 | def csIsomorphicStrings(a, b):
# first find the length of each string
s1 = len(a)
s2 = len(b)
# length of both strings needs to be the same in order to be True
if s1 != s2:
return False
return True |
f8e8a2e0d5996116a26461c1fb09bf7ee204a965 | aggo/jku-ul | /ul_a2_e3/ex3.py | 1,410 | 4.09375 | 4 | #!/usr/bin/python
# Author: Amalia Ioana Goia
# Matr. Nr.: k1557854
# Exercise 3
import math
def read_data(filename):
import csv, numpy as np
instances = []
with open(filename, 'r') as csvfile:
dataset = csv.reader(csvfile, delimiter=',')
for row in dataset:
instances.append(fl... |
69d1c616e6a53b72198bb599d7c79bff1cc0f4f2 | gaelroue/Cyphware | /function/beaufort.py | 465 | 3.59375 | 4 | from itertools import izip, cycle
def encrypt(text, key):
text = text.lower()
key = key.lower()
alphabet = "abcdefghijklmnopqrstuvwxyz"
vigenered = ''.join(alphabet[(ord(j)-ord(i)-2*97)%26] for (i,j) in izip(text, cycle(key)))
return vigenered
def decrypt(text, key):
text = text.lower()
key = key.lower()
al... |
5b545729265031d652844c3093370fd672ce69a6 | sireeshadaruvuri/Python-Programs | /Lists.py | 573 | 4.40625 | 4 | # List can contain mixed datatypes
# idex start from 0 in lists
mylist = [10, 2, 4, 5]
print(mylist)
myfirstlist = ["siri", 2.5, True, mylist]
print(myfirstlist)
# range
print(range(15))
print(list(range(15)))
print(list(range(2, 15)))
a = list(range(300, 320))
print(a)
print(list(range(100, 150, 2)))
b = ... |
7337174dc0d5b575c2b3bc22d2383ca8f5a85b7c | sireeshadaruvuri/Python-Programs | /slicing arrays.py | 482 | 4.125 | 4 | import numpy as np
a = np.array([12, 34, 56, 78])
print(a)
print(a[:2])
#while working on arrays we r not making the copy of an array
#in lists it creates the copy of a list
print(a[2:4])
b = a[2:4]
print(b)
print(b[0])
#change values of b
b[:]=211
print(b)
print(a)
#b doesn't copy array a, it just crea... |
ce42a1a448c66f6c4e4899d080a3ad2ca997d673 | sanviChottera/Correlation-project | /code.py | 788 | 3.5 | 4 | import csv
import numpy as np
def getDataSource(data_path):
marks_in_percentage = []
days_present = []
with open(data_path) as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
marks_in_percentage.append(float(row["Marks In Percentage"]))
... |
f4be101efb434330f1e3dfe6b88a43c12edfce2a | OrianaArevalos/facultad | /python/Practica4/ejercicio6.py | 1,239 | 3.609375 | 4 | import math
class Punto():
def __init__(self,un_punto_x,un_punto_y):
self.__x = un_punto_x
self.__y = un_punto_y
def getX (self):
return self.__x
def getY (self):
return self.__y
def setX (self,un_punto_x):
self.__x = un_punto_x
def setY (self... |
47554b963071b50dc8fe586b684aafe639f84caf | kedarnath6970/algorithm | /python/convert.py | 1,620 | 4 | 4 | # Problem: Given a list of "name elements", e.g. "alex thirty" or "dong forty-nine"
# return the list, sorted first by name, then by the numerical value of the number
# alex two
# bob five
# one
# one-hundred-million
# alex two
# alex ten
# bob twenty-one
# bob twenty
from functools import cmp_to_key
lookup = {... |
651be1e67a2359bafc2157a3417c0953e570106c | ikosenn/tensor_flow | /tensorflow_simple.py | 496 | 3.546875 | 4 | """
Minimize the cost function (w-5)^2
"""
import numpy as np
import tensorflow as tf
w = tf.Variable(0, dtype=tf.float32)
cost = tf.add(tf.add(w**2, tf.multiply(-10.0, w)), 25)
train = tf.train.GradientDescentOptimizer(0.01).minimize(cost)
init = tf.global_variables_initializer()
with tf.Session() as session:
... |
75ad7de24a8f0b8b766c0eeaa3df113909a5b7f7 | Darsana33/programming-lab-darsana | /co1.pg8.py | 215 | 3.671875 | 4 | d=str(input("Enter data:"))
for i in range(0,len(d)):
if i==0:
print(d[i],end="")
else:
if d[i] == d[0]:
print("$",end="")
else:
print(d[i],end="")
|
d7c1e70120bb13abfa8fb6f1afa62e381e076967 | Darsana33/programming-lab-darsana | /co1.pg19.py | 196 | 3.890625 | 4 | n1 = int(input("Enter 1st number: "))
n2 = int(input("Enter 2nd number: "))
i = 1
while(i <= n1 and i <= n2):
if(n1 % i == 0 and n2 % i == 0):
gcd = i
i = i + 1
print("GCD is", gcd) |
7aa0c38dda09901322a50cb4873b6d575bc4b2f8 | kammunfoo/Weather_Station_Raspberry_Pi_BCM2837_written_in_Python | /improvement_db_select_last_row.py | 954 | 3.515625 | 4 | list1 = ['a', 'b', 'c', 'd', 'e',]
for index, item in enumerate(list1):
print(index, item)
print()
length = len(list1)
print(length - 1, list1[length - 1])
print()
print(list1[-1])
print()
list2 = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi',]
length = len(list2[-1]) - 1
record = 'eeee ' + list2[-1][length - len... |
574ca579706a3459c2c2dc2813a219c5108ef47b | veedaaw/Guess-The-Word-Game | /game.py | 3,428 | 4.0625 | 4 | """
A class used to represent a Game
...
Attributes
----------
number : int
a Static variable to store number of object of this class
letter_freq : dict
this dictionary contains frequency of each letters, used for score calculation
word_to_guess : str
this the word that pl... |
e0cb9419c175d98ed742341569baba395b75f32f | mkioga/43_python_Comprehensions | /timeit3.py | 17,744 | 4.03125 | 4 |
# ==========
# timeit3
# ==========
# ======================================
# Passing code to timeit as a function
# ======================================
# It is important to pay attention to what you are timing and under what conditions under which the code is running.
# in our earlier examples, printing the ou... |
0cb8274d00c2d1f6501d492f687f2c9373722210 | yuanshuo98/Leetcode_python | /Leetcode_python/009palindromeNum.py | 893 | 3.75 | 4 | #######solution1#######
# def isPalindrome(x):
# if x<0:
# return False
# else:
# l=str(x)
# #newl=reversed(l)
# newl=l[::-1]
# i=0
# while l[i] is newl[i]:
# if i<len(l)-1:
# i=i+1
# else:
# return True
# ... |
b67afa4bd6c8a0eb77cf34b320d6757aa58d49e4 | yuanshuo98/Leetcode_python | /Leetcode_python/007reverseInt.py | 925 | 3.625 | 4 | ###solution1####small data
# def reverse(x):
# res=[]
# t=0
# p=1 #记录位数
# y=x
# if x<0:
# x=-x
# while x//10!=0:
# p=p+1
# res.append(x%10)
# x=x//10
# res.append(x)
# l=p
# p=p-1
# for i in range(l):
# t=t+res[i]*(10**p)
# p=p-1
# ... |
c90515782935842e472cb245e04b1824415776ca | davidburdelak/exercises-studies | /python/task_1_1.py | 846 | 4.15625 | 4 | """
Task: Please write a script that displays the menu of the following form:
*******************CALCULATOR******************
1 - Addition
2 - Subtraction
3 - Multiplication
4 - Division
0 - End
It will then prompt you which option to choose, print the selected option number, and exit.
"""
#DEVELOPED BY D... |
85510a48f936dbea1be05923f072dd2e295505d6 | davidburdelak/exercises-studies | /python/task_3_1.py | 768 | 3.859375 | 4 | """
Task: Replace the data.txt file with the following values:
Isabella
Roberts
24
Taylor
Brown
22
James
Smith
23
to the CSV file in this form:
Isabella;Roberts;24
Taylor;Brown;22
James;Smith;23
"""
file_write = open('data.csv','w')
file_read = open('data.txt','r')
i=1
all_lines = file_read... |
3fba18d1d3596d92f1fd41e593b914679cd43043 | bbbarron/POC | /week1/week 1 merge function mini-project.py | 1,230 | 4.09375 | 4 | """
Barry Barron
Principles of Computing 7/2016 Week 1, Mini-project 1
Merge function for 2048 game
CodeSkulpter link http://www.codeskulptor.org/#user41_J1T44jaXXX_2.py
"""
def merge(line):
"""
Function that merges a single row or column in 2048
"""
original_length = len(line)
empty... |
4c8b4c7db3ac6b33cabef4cd606e4ebbd89a17ae | EmanueleLM/__gcp | /experiments/MNIST/models/mnist.py | 10,545 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Oct 5 18:21:07 2019
@author: Emanuele
Simple neural network to classify images in MNIST dataset.
"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def _normalize(x, std):
import tensorflow as tf
def py_func_init(out):
... |
76e54a5d6b0a0cd685830c4a4e67c2794d72008c | arthurcorreiasantos/pi-web-full-stack | /01 - Coding Tank/01 - Exercícios/15 - Aula/4 - Fixação.py | 445 | 3.75 | 4 | '''Enunciado
Faça um programa que leia 10 números do usuário e os coloque corretamente no dicionário D abaixo.
D = {'pares': [], 'impares':[]}'''
D = {'pares':[], 'impares':[]}
pares = []
impares = []
for i in range(10):
num = int(input('Digite um número inteiro: '))
if num%2 == 0:
pares.append(num)
... |
073029160c263f305c9937c03843c56591ac3de4 | arthurcorreiasantos/pi-web-full-stack | /01 - Coding Tank/01 - Exercícios/5 - Aula/8 - dia da semana.py | 248 | 4.09375 | 4 | num = int(input('Digite um número inteiro de 1 à 7: '))
if num > 1 and num < 7:
dias = ['domingo','segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado']
print('O dia da semana é: ', dias[num-1])
else:
print('Número inválido') |
c2e953bf0d3f4f649833a600525fd494c8394e3d | arthurcorreiasantos/pi-web-full-stack | /01 - Coding Tank/01 - Exercícios/5 - Aula/3 - flux.py | 330 | 3.859375 | 4 | opcao = int(input('escolha uma bebida: 1 - Coca, 2 - Pepsi, 3 - Guaraná, 4 - Chá'))
if opcao == 1:
print('Você escolheu Coca-Cola')
elif opcao == 2:
print('Você escolheu Pepsi')
elif opcao == 3:
print('Você escolheu Guaraná')
elif opcao == 4:
print('Você escolheu Chá')
else:
print('Opção inválida') |
d062c241c531e7cabe0f03b6517895a4ebf13af1 | arthurcorreiasantos/pi-web-full-stack | /01 - Coding Tank/01 - Exercícios/11 - Aula/3 - digitar.py | 84 | 3.9375 | 4 | num = int(input("Digite um número inteiro: "))
for i in range(0,num):
print(i) |
4a645104a504496d6044512ef776ce6dc9e03763 | arthurcorreiasantos/pi-web-full-stack | /01 - Coding Tank/01 - Exercícios/5 - Aula/5 - identify de novo.py | 313 | 3.921875 | 4 | x = int(input())
if x % 2 == 0:
print('Par')
if 0 <= x <= 10:
print('Par entre 0 e 10')
else:
print('Impar')
if 0 <= x <= 10:
print('Impar menor entre 0 e 10')
'''#O código identifica se o número é par e se é impar.
Depois o código informa se o número está entre 0 e 10.''' |
1b0aaa042540613f3419d0c9326c4d93ad896e7d | arthurcorreiasantos/pi-web-full-stack | /01 - Coding Tank/03 - Desafios/3 - Desafio.py | 1,639 | 3.78125 | 4 | cpfs = []
nomes = []
emails= []
base = {}
lista = ()
num = str(input('Digite o número referente a opção: 1 - Cadastrar, 2 - Visualizar os cadastrados e 3 - Buscar um cadastro específico. Digite 4 se quiser sair do programa: '))
while num != '4':
#menu principal. adicionando nomes a lista e dicionário
if num =... |
ae8a76c36288ca8840abe058dab4c81cc54f17dd | TakeshiJay/Apartement-Rental-System | /Term_Project/ARS_Multiuser/Tenant.py | 1,974 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
########## Term Project ############
# #
# owner: @author Sterling Engle #
# #
# Due Jun 24, 2021 at 11:59 PM PDT #
# Finished: Jun 19, 2021 #
#----------------------------------#
# CSULB CECS 343 Intro to S/W Eng... |
3818f0d4b3589ba64c29981db64995e81cae7ac3 | 633-1-ALGO/introduction-python-MichaelGomesHeg | /9.2 Exercice - Traitement de string/string2.py | 646 | 3.5 | 4 | # Consigne : Rechercher le nombre d'occurences du mot "exemple" et l'afficher. Remplacer le mot "est" par "représente".
# Bonus : Inverser le sens de lecture.
texte = "Ceci est un exemple exemplaire d'exemple exempté d'exemple."
nbMot = texte.count("exemple");
print(nbMot);
print(texte[::-1])
#fonction bonus : 1) ... |
0a7f48df392c098601418adc7208b8db6aec425f | vithuyan/python_fundamentals1 | /excise5.py | 249 | 4 | 4 | print ("Would you like to walk or run?")
user_name = input ()
walk = 1
run = 5
if user_name == input(walk):
print("walk {}km.".format(walk))
walk += 1
if user_name == input(run):
print("run {}km.".format(run))
while run < 5:
run += 5
|
4a7ee72029e64d17babee40e6ac4726d557f327e | stefanobozicek/python | /HW_8.3.py | 466 | 4.28125 | 4 | first_num = int(input("Enter the first number: "))
operation = input("Enter which operation parameter to use (+ - / *)")
second_num = int(input("Enter the second number: "))
if operation == "+":
print(first_num + second_num)
elif operation == "-":
print(first_num - second_num)
elif operation ==... |
8b067973068a5aa54eb5e8b14375c6b4731cf349 | chenjuncau/theproj | /calc.py | 130 | 3.5 | 4 | import sys
x = []
for line in open(sys.argv[1]):
num = int(line)
x.append(num)
print 'average is', sum(x) / float(len(x))
|
82e3ae0e6febe231342da6881b182295409adc4b | sfali16/udacity-python | /hellopythonworld/test/PointTest.py | 673 | 3.53125 | 4 | '''
Created on Jul 30, 2017
@author: Faraz
'''
import unittest
from PointFile import Point
class PointTest(unittest.TestCase):
def testEquals(self):
p1 = Point(1,3)
p2 = Point(1,3)
print( p1 )
print( "p2={0}".format(p2))
self.assertFalse( p1 is p2, "p1 is not p2, so this ... |
49a3cbf435728812412ff6ca86b17f451474c15a | Moriango/Shopping-List | /shopping.py | 2,307 | 3.984375 | 4 | import os
import time
shopping_list = []
def clear_screen():
os.system("cls" if os.name == "nt" else "clear")
def addList(item):
if(shopping_list):
position = input("Where should I add {}?\n"
"Press Enter to add to the end of the list\n"
"> ".format(ite... |
d4759cca0ad2868f100a85d3915afebd110ad370 | dragoste17/course-projects | /Comparing Sorting Techniques/shell_sort.py~ | 743 | 3.875 | 4 | #2013CSB1032
#Shinde Lav Chandrakant
import math
def gapGen(array):
'''This function will create the gaps to be used while shell sorting'''
gap=[]
N=len(array)
k=1
while math.floor(N/(2**k)) != math.floor(N/(2**(k+1))) and N/(2**k) != 1:
gap.append(N/(2**k))
k=k+1
gap.append(1)
return gap
def... |
3216abbf35090b626bb9a7ced9c8a7cc46c89555 | dragoste17/course-projects | /Pocket Cube Solver/a.py | 3,498 | 3.875 | 4 | import time
import rubik
import random
class queue:
''' This will create a queue and while removing maintain track of seen elements'''
def __init__(self,val):
'''Creates an empty queue'''
self.item = [val]
def push(self,a):
'''Adds a list to the queue'''
for i in a:
self.item.append(i)
def pop(sel... |
339546d95ebd6878bd88742f5444ff759421e4a4 | SunatP/ITCS425_Algorithm | /BFS/BFS.py | 578 | 3.671875 | 4 | def BFS(graph,start):
visited,queue = set(), [start]
while queue :
vertex = queue.pop(0)
if vertex not in visited:
visited.add(vertex)
queue.extend(graph[vertex]- visited)
return visited
def BFS_Paths(graph,start,goal):
queue = [(start,[start])]
while queue:
... |
b83a719dd5cf6a9b52ec55deb32f73ebf40605ec | SunatP/ITCS425_Algorithm | /binary_search/binary.py | 542 | 3.890625 | 4 | def Binary_Search(A: list,low:int,hi:int, x: int):
if hi >= low :
mid = (hi + low) // 2
if A[mid] == x:
return mid
elif A[mid] > x:
return Binary_Search(A,low,mid -1 ,x)
else:
return Binary_Search(A,mid+1,hi,x)
else:
return -1
arr = [... |
cddbc1c489cd1d9f1bb9398e8719d44c933c8545 | hhp123/pyt1 | /pyt1.py | 922 | 3.921875 | 4 | print("h")
# 注释
a = 100
print(a)
a = 'asd'
print(a)
print("---------------------------------------")
# 格式化输出
print("my name is %s" %a)
age = 21
name = 'hhp'
print("my age is %d" %age)
print("my name is %s, my age is %d" %(name,age))
print("---------------------------------------")
print("===================")
name ... |
24fb1612301e8938f761405149e2e8a91300fb39 | sampsonliao/cst311.TCP.CliServ | /PA2Client_Liao_Ochoa.py | 1,050 | 3.640625 | 4 | # client.py
#to run this program use python3 client.py X
# or python3 client.py Y
import threading
from socket import *
import sys
# In your command prompt, type in hostname and press enter.
# What comes up is your computer's hostname
#we are using system variables to determine what client is runni... |
734c0c61d53baaeca44c5d60cc139d64d44fe7cd | niveenhaddad/pdsnd_github | /bikeshare_2.py | 9,203 | 4.4375 | 4 | import time
import pandas as pd
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) - name of the city to analyze
... |
a91018e1cbc18241150abe6332818fffb91d32bf | NikolayVaklinov10/Python_Challenges | /Introduction/loops.py | 354 | 4.3125 | 4 | n = 5
# my solution
for i in range(n):
print(i**2)
# solution 2
n = 5
# * is an arbitrary list. It works by expanding a list into a sequence of positional parameters
# by using the * operator.
print(*[num**2 for num in range(n)], sep='\n')
# solution 3
[print(i**2) for i in range(n)]
# solution 4
i=0
for i in ... |
a772a7feba67e276bf24156a83e3b8bd9bc4211f | NikolayVaklinov10/Python_Challenges | /Strings/Text_Wrap.py | 1,133 | 4.125 | 4 | """
You are given a string S and width w.
Your task is to wrap the string into a paragraph of width w.
Input Format
The first line contains a string, S.
The second line contains the width, w.
Constraints
* 0 < len(S) < 1,000
* 0 < w < len(S)
Output Format
Print the text wrapped paragraph.
Sample Input 0
ABCDEF... |
f278efb57542dc7d51afbb197548f84061998530 | NikolayVaklinov10/Python_Challenges | /Regex_and_Parsing/Validating_postal_Codes.py | 2,040 | 4.4375 | 4 | """
A valid postal code
have to fullfil both below requirements:
must be a number in the range from to
inclusive.
must not contain more than one alternating repetitive digit pair.
Alternating repetitive digits are digits which repeat immediately after the next digit. In other words, an alternating repetitive di... |
37161ad7bf0563065977e8c54d2d20f5f9a80048 | NikolayVaklinov10/Python_Challenges | /Python_Functionals/Validating_Email_Addresses_with_a_Filter.py | 2,005 | 4.4375 | 4 | """
You are given an integer followed by
email addresses. Your task is to print a list containing only valid email addresses in lexicographical order.
Valid email addresses must follow these rules:
It must have the username@websitename.extension format type.
The username can only contain letters, digits, das... |
65a06725cac33a2347c1fae8a0b61ef406717f0b | NikolayVaklinov10/Python_Challenges | /Numpy/Mean,_Var,_and_Std.py | 2,162 | 4.03125 | 4 | """
mean
The mean tool computes the arithmetic mean along the specified axis.
import numpy
my_array = numpy.array([ [1, 2], [3, 4] ])
print numpy.mean(my_array, axis = 0) #Output : [ 2. 3.]
print numpy.mean(my_array, axis = 1) #Output : [ 1.5 3.5]
print numpy.mean(my_array, axis = None) #Output ... |
082b48e5ffc61bbca885f4aab573c7e6b5634ce6 | NikolayVaklinov10/Python_Challenges | /Built-ins/Zipped!.py | 1,972 | 4.53125 | 5 | """
zip([iterable, ...])
This function returns a list of tuples. The
th tuple contains the
th element from each of the argument sequences or iterables.
If the argument sequences are of unequal lengths, then the returned list is truncated to the length of the shortest argument sequence.
Sample Code
>>> print zip([1... |
3706ab56e8c90fce8e3420527995e00ced5cfca3 | NikolayVaklinov10/Python_Challenges | /Errors_and_Exceptions/Incorrect_Regex.py | 605 | 4.09375 | 4 | """
You are given a string .
Your task is to find out whether
is a valid regex or not.
Input Format
The first line contains integer
, the number of test cases.
The next lines contains the string
.
Constraints
Output Format
Print "True" or "False" for each test case without quotes.
Sample Input
2
.*\+
.*+
Samp... |
bcdc6d272f1c202b65faeb62879f918e8445a6ae | NikolayVaklinov10/Python_Challenges | /Math/Find_Angle_MBC.py | 758 | 4.3125 | 4 | """
is a right triangle, at .
Therefore,
.
Point
is the midpoint of hypotenuse
.
You are given the lengths
and .
Your task is to find (angle
, as shown in the figure) in degrees.
Input Format
The first line contains the length of side
.
The second line contains the length of side
.
Constraints
Lengths and
... |
7167a51fbfbeb7338cf4dbd088a9f93f800bbfb4 | NikolayVaklinov10/Python_Challenges | /Strings/What's_Your_Name?.py | 1,374 | 4.1875 | 4 | """
You are given the firstname and lastname of a person on two different
lines. Your task is to read them and print the following:
Hello firstname lastname! You just delved into python.
Input Format
The first line contains the first name, and the second line contains
the last name.
Constraints
The length of th... |
8e88e76f53224a6b175d5b0afa57210ae132f06b | NikolayVaklinov10/Python_Challenges | /Regex_and_Parsing/Validating_UID.py | 1,302 | 3.90625 | 4 | """
ABCXYZ company has up to
employees.
The company decides to create a unique identification number (UID) for each of its employees.
The company has assigned you the task of validating all the randomly generated UIDs.
A valid UID must follow the rules below:
It must contain at least
uppercase English alphabet ... |
ab685276ec90e815204f6b8930ae499aabdfa3bf | NikolayVaklinov10/Python_Challenges | /Strings/String_Formatting.py | 1,687 | 3.9375 | 4 | """
Given an integer, n , print the following values for each integer i from 1 to n:
Decimal
Octal
Hexadecimal (capitalized)
Binary
The four values must be printed on a single line in the order specified above for each i
from 1 to n. Each value should be space-padded to match the width of the binary v... |
1ac0b7b4bbd94be96dbc3ddc6b1a27f3ab01725c | Liuhao-bupt/Learn-Python-The-Hard-Way | /Exercise 15.py | 841 | 4.1875 | 4 | from sys import argv
script, filename = argv
txt = open(filename)
print "Here's your file %r:" % filename
print txt.read()
print "Type the filename again:"
file_again = raw_input(">")
txt_again = open(file_again)
print txt_again.read()
#
1.用python open函数打开文件
x = open(r"D:/pycharm/PyCharm 2016.1.4/build.txt")
2.open(... |
fe6fe68888938bda9dfa6ec75e8a48f6140b222f | Liuhao-bupt/Learn-Python-The-Hard-Way | /Exercise 41.py | 4,538 | 3.578125 | 4 | import random
from urllib import urlopen
import sys
WORD_URL = "http://learncodethehardway.org/words.txt"
WORDS = []
PHRASES = {
"class %%%(%%%):":
"Make a class named %%% that is-a %%%.",
"class %%%(object):\n\tdef __init__(self, ***)":
"class %%% has-a __init__ that takes self and *** paramet... |
e5593fd0444323d7bb48dc5d8de7dd9e3dbbc239 | LucasChanChan/internship_2017 | /src/classify/train.py | 8,594 | 4.09375 | 4 | """Routines used to train a classifier
The file contains two classes `TrainClassify` and `TrainClassifyCNN`.
`TrainClassify` can be used for any network architecture as long as
we always use cross entropy loss. Prediction accuracy is evaluated
through the whole training process.
To inherit from this class one should... |
13a0d9cae11b36d02535346ce42e2b44d7d6cea8 | philipdongfei/LeftEarListenWind | /pipeline_demo.py | 387 | 3.96875 | 4 | def even_filter(nums):
for num in nums:
if num % 2 == 0:
yield num
def multiply_by_three(nums):
for num in nums:
yield num * 3
def convert_to_string(nums):
for num in nums:
yield 'The Number: %s' % num
nums = [1,2,3,4,5,6,7,8,9,10]
pipeline = convert_to_string(multiply... |
73bd55d35337d8cdc62dae15758f1e3c6e37ebb4 | lefturner/python-lists | /wishlist.py | 1,212 | 4.1875 | 4 | books = [
"Automate the Boring Stuff with Python: Practical Programming for Total Beginners - Al Sweigart",
"Python for Data Analysis",
"Fluent Python: Clear, Concise, and Effective Programming - Luciano Ramalho",
"Python for Kids: A Playful Introduction To Programming - Jason R. Briggs",
"Hello Web... |
50e1dd47c55da983a5c1138ecee31620da34f49b | Mobius5150/C115_Logic_Analyzer | /solve.py | 4,810 | 3.796875 | 4 |
from solver import *
def solve_system(m, input_i, output_i, state_i, nstate_i, input_n, output_n, state_n):
"""
Solve a system with data gathered in the matrix m, and the input / output
/ state names / indicies in that matrix specified.
The _n name arrays are contain the names of the given col indicies into
t... |
82d39610ad5adce324f1df443a6cef827561bb89 | juliacoelho/ProjectEuler | /PE1.py | 291 | 4.15625 | 4 | def isMultiple3(n):
return ((n%3 == 0) and (n > 0))
def isMultiple5(n):
return ((n%5 == 0) and (n > 0))
total = 0
for number in range(1,1000):
if (isMultiple3(number) or isMultiple5(number)):
print (number)
total += number
print ("total : ", total)
|
1f21c0e0e797685b244c4e4bafe843c22c175340 | juliacoelho/ProjectEuler | /PE14.py | 629 | 3.5625 | 4 | dict_nb = {nb:0 for nb in range(1, 1000001)}
biggestNb = 1
biggestChain = 1
#print(dict_nb)
def collatz(nb):
nb_ = nb
global dict_nb
count = 1
while nb != 1:
if nb < 1000001 and dict_nb[nb] != 0:
count += dict_nb[nb] - 1
nb = 1
else:
c... |
0926178233c9c3a4455906530c2ad1f0041625d5 | zilulu/Test | /HelloWorld.py | 1,353 | 4.09375 | 4 | __author__ = 'Administrator'
print("Hello World!")
string = "python"
print(string)
print(100 + 200)
print("""line1
line2
line3""")
print(True)
print(3 > 2)
print(True and False)
print(True or False)
v = 123
print(v)
v = "abc"
print(v)
print("Hi,%s,you have $%d" % ("yy", 1000))
classmates = ["yy", "cy", "ly"]
print(clas... |
1b4481089b542f5c226d003b86c6e7a533e258c3 | pholton/PyTraining | /named_tuples.py | 1,259 | 4.75 | 5 | # Pros of named tuples
# Looks and acts like an immutable object.
# It is more space- and time-efficient than objects.
# You can access attributes with dot notation instead of dictionary style
# square brackets
# You can use it as a dictionary key
from collections import namedtuple
# Creates a named tup... |
522bc5cdcd24a0210f4d7fffae934554b3a1dcda | davidlkt/python_lab | /crash_course/_08_Functions/message.py | 4,585 | 4.78125 | 5 | print("\n-----------")
print("8-1. Message:") #Write a function called display_message() that prints one sen- tence telling everyone what
#you are learning about in this chapter . Call the function, and make sure the message displays correctly .
print("-----------\n")
def display_message():
print("Helo World!\n")... |
bb50387f8cd8d04e5a86bd7ee3ee44f9ff692864 | davidlkt/python_lab | /crash_course/_09_Classes/inherit.py | 559 | 3.59375 | 4 | class Parent():
def __init__(self, param1, param2):
self.p1 = param1
self.p2 = param2
def parent_print(self):
print('%s %s' % (self.p1,self.p2))
my_obj01 = Parent('argument1', 'argument2')
my_obj01.parent_print()
class Child(Parent):
def __init__(self, param1, param2, para... |
d2c10c2ff5f9d637fc278b545803a3a47f2c69b9 | davidlkt/python_lab | /crash_course/_06_Dictionaries/cities.py | 1,264 | 4.53125 | 5 | print("\n-----------")
print("6-11. Cities:") #Make a dictionary called cities . Use the names of three cities as keys in your dictionary .
# Create a dictionary of information about each city and include the country that the city is in, its approximate
# population, and one fact about that city . The keys for each c... |
fa23e483e72ad93bac597f14c20f2d087255400c | Rohansr2727/Book-My-Show-project | /Booktickit.py | 1,581 | 4.0625 | 4 | import mycinema as mc
welcome = '''Welcome to bookmyticket.com'''
Tagline = 'Wear mask and use hand sanatizer'
print(welcome.center(90))
print(Tagline.center(90))
row = int(input('Enter no of row for making auditorium\n'))
col = int(input('Enter no of column for making auditorium\n'))
theater = mc.Theater(row,co... |
6d52f64d71b151ea0fb8287313467cbcf6e82678 | yiqin/HH-Coding-Interview-Prep | /Use Python/BinaryTreePaths.py | 940 | 3.71875 | 4 | class TreeNode(object):
"""docstring for TreeNode"""
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
"""docstring for Solution"""
def binaryTreePaths(self, root):
if root == None:
return []
results = []
self.dfs(root, "", results)
return results
... |
fb5768ac7fb5e011547d86876368ed14d14a04cd | yiqin/HH-Coding-Interview-Prep | /Use Python/MIssingNumber.py | 407 | 3.828125 | 4 | def missingNumber(nums):
hasN = False
hasZero = False
for idx, val in enumerate(nums):
if val == len(nums):
hasN = True
elif val == 0:
hasZero = True
else:
nums[idx] = -val
if hasN and hasZero:
for idx, val in enumerate(nums):
if val > 0:
return idx
elif hasZero is False:
return 0
else:... |
466d4fadc30745c2a0358b96644d89bd2f950a03 | yiqin/HH-Coding-Interview-Prep | /Use Python/(New)IsomorphicStrings.py | 656 | 3.546875 | 4 | class Solution(object):
"""docstring for Solution"""
def isIsomorphic(self, s, t):
dictS = dict()
dictT = dict()
for i in range(len(s)):
if s[i] in dictS:
tmp = dictS[s[i]]
tmp.append(i)
else:
tmp = [i]
dictS[s[i]] = tmp
print(dictS)
for i in range(len(t)):
if t[i] in dictT:
... |
a0f9b31036c730c951a7470f6978208f529569f7 | yiqin/HH-Coding-Interview-Prep | /Use Python/AddTwoNumber.py | 972 | 3.6875 | 4 | class ListNode(object):
"""docstring for ListNode"""
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
# print(l1.val)
i = 0
firstRound = True
head = ListNode(0)
currentNode = head
while l1 != None or l2 != None:
sum = i
if l1 !=... |
70be97a849da3f88fbd1548f0cdc6487b8aa5592 | yiqin/HH-Coding-Interview-Prep | /Use Python/ReverseLinkedListII.py | 479 | 3.625 | 4 | class ListNode(object):
"""docstring for ListNode"""
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def reverseBetween(self, head, m, n):
print(head.val)
def revsereTwoNodes(self, node1, node2):
node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(... |
516b41fb72bd7005a19e3249e71feb53920a9d26 | yiqin/HH-Coding-Interview-Prep | /Use Python/RemoveDuplicatesFromSortedListII.py | 599 | 3.578125 | 4 | class ListNode(object):
"""docstring for ListNode"""
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
"""docstring for Solution"""
def deleteDuplicates(self, head):
if head == None:
return None
newHead = None
previous = head.val
if head.next != None:
else:
return ... |
a9948f5964a792dd176a3f3a73ec313cecb96407 | yiqin/HH-Coding-Interview-Prep | /Use Python/WordBreak.py | 539 | 3.640625 | 4 | class Solution(object):
"""docstring for Solution"""
def wordBreak(self, s, wordDict):
n = len(s)
matrix = [False for i in range(len(s))]
for i in range(n):
# print(s[i:i+1])
for j in range(i+1):
subString = s[j:i+1]
if subString in wordDict:
if j == 0:
matrix[i] = True
break
... |
c1498e2a6b8761fafe093457ea4a862cff2a7f8d | moonspb75/Lessons2 | /task3.py | 300 | 4.15625 | 4 | seasons = ["Весна", "Лето", "Осень", "Зима"]
monthnumb = int(input("введите номер месяца: "))
if 3 <= monthnumb <= 5:
print(seasons[0])
elif 6 <= monthnumb <= 8:
print(seasons[1])
elif 9 <= monthnumb <= 11:
print(seasons[2])
else:
print(seasons[3]) |
7b4b9fad544fdad01d09c254d63b9b8ad1ddac02 | joysn/general_algo | /interview.io.6_delete_nodes_tree.py | 3,206 | 3.875 | 4 | # https://www.youtube.com/watch?v=2KuGYl76Ul4&list=PL7_9joZ9PjilgeB6wk9ECEIvLAq6c_bBB&index=4&t=0s
# Coding interview with a Google engineer: Delete nodes from tree
# We want to delete certain nodes from a binary tree. We have a function shouldDelete(Node) that returns True
# if we should delete the node. we can as... |
9441314760d6a7b62dad63b0b08df3b1e8b31cdb | joysn/general_algo | /interview.io.balanceParenthesisRemovingParen.py | 1,505 | 3.65625 | 4 |
def balanceParethesis(string):
if len(string) == 0:
return
count = 0
partialResult = ""
for ch in string:
if ch == "(":
count += 1
partialResult += ch
elif ch == ")":
if count <= 0:
continue
cou... |
04df5f4b2aabdcf63bf90605a9a0f0c5f651ad13 | ccbility/pythonStack | /qpython/3div2.py | 268 | 3.59375 | 4 | import tools
while True:
num1 = tools.getBitNum(3)
num2 = tools.getBitNum(2)
print(str(num1) + " / " + str(num2))
ans = str(num1 / num2 * 100)[0:1]
userAns = input("答案:")
if(ans == userAns):
print('right')
else:
print('wrong,答案是:' + ans) |
c9a887101037a08b8bfb08cec7ac9c1d9244af94 | lvyunze/sort | /pysort/shell_sort.py | 783 | 3.796875 | 4 | """
希尔排序
"""
import inspect
def sort(_list):
"""
:param _list: list of integers to sort
:return: sorted list
"""
gap = len(_list) // 2
while gap > 0:
for i in range(gap, len(_list)):
current_item = _list[i]
j = i
while j >= gap and _list[j - gap] > c... |
87f693d88bb81cb37e1d2384aa06315e8ae432fc | thedeepakchaturvedi/PythonCodes | /manipulating_strings.py | 767 | 3.921875 | 4 | name = "DeePak"
lower_name = name.lower()
print(lower_name)
print("Hello".lower() + " " + lower_name)
print(lower_name.upper())
# find method in string
x = lower_name.find("pa")
print(x)
y = lower_name.find('z')
print(y)
# replace method in strings
z=lower_name.replace('ee','aa')
print(z)
# to re... |
087b0acae8629ad7afd387caf8b0e12864666fdc | thedeepakchaturvedi/PythonCodes | /conditionalProgramming.py | 361 | 4.1875 | 4 | print('conditional statement')
#always use try and except so that you
#can avoid tracebacks
istr=input('Enter anything :')
try:
astr=int(istr)
print("You entered number")
if astr<100:
print('Number is less than 100')
else:
print('Number is greater or equal to 100')
excep... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.