blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
e0e2b442c15380e609c20d5728c3e1d81c6abddd | DanielMarquesz/AD2---FP | /estruturadedados.py | 507 | 3.78125 | 4 |
M = [1,5,6,2,3,0,4]
menores = []
div = len(M)// 2 # Elemento V[i]
for i in range(7): # tamanho da lista
if M[i] < 3:
menores.append(M[i])
M = [1,5,6,2,3,0,4]
menores := [] # Novo vetor com os elementos menores que [n/2]
comprimentodaLista := tamanho(M) # Atribui a variável o tamanho da lista
elementoMe... |
0b500e1556d05cb59e87b985b634d9c8e70f9771 | Werewolfgenesis/Python-Free-Time | /passGenerate.py | 653 | 3.578125 | 4 | import random
import string
letters = string.ascii_letters
numbers = string.digits
punctuation = string.punctuation
def get_pass_lenght():
length = input("Choose pass length: ")
return int(length)
def generate_pass(length = 6):
to_print = f'{letters}{numbers}{punctuation}'
to_print = lis... |
bb6ed17657344c15b8adaec256664e40e0a73fa2 | RubinaBegum/DSA | /Algo/sorting/quicksort.py | 582 | 4.15625 | 4 | def partition(List1, low, high):
pivot = List1[high]
i = low - 1
for j in range(low, high):
if List1[j] <= pivot:
i = i + 1
(List1[i], List1[j]) = (List1[j], List1[i])
(List1[i + 1], List1[high]) = (List1[high], List1[i + 1])
return i + 1
def quickSort(List1, low, high):
if low < high:
p... |
9088dd26b3c61664dd2be6e4402d6c8912ef18b2 | kurosawa4434/checkio-mission-evenly-spaced-trees | /verification/tests.py | 1,762 | 3.796875 | 4 | """
TESTS is a dict with all you tests.
Keys for this will be categories' names.
Each test is dict with
"input" -- input data for user function
"answer" -- your right answer
"explanation" -- not necessary key, it's using for additional info in animation.
"""
from random import randint, sample
from collectio... |
f96c221c7f21b6d5ed25fd8bd180e20d99e2d9d8 | GoreRichard/birthday-assignment-1 | /Birth day assignment.py | 832 | 4 | 4 | Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import calendar
>>> age = int (input ("Enter Your age:"))
Enter Your age: 20
>>> date = int (input ("Enter your date of birth:"))
Enter your date of b... |
fc289e838dcd9007e46d04dd3a3406555775ca33 | patdriscoll61/Practicals | /Practical01/Practical02/saveName.py | 114 | 3.75 | 4 | name = input("What is your name? ")
file_name = open("name.txt","w")
print(name,file=file_name)
file_name.close()
|
f5d847d8c03067e848836263ac81e7923b8bc10b | STAT545-UBC-hw-2018-19/hw09-figalit | /make-hw/KeepGreaterThanK.py | 793 | 3.515625 | 4 | # Use python to do remove all words of length smaller than k
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-p','--filePath', required=True)
parser.add_argument('-o','--outputFilePath', required=True)
parser.add_argument('-k','--kThreshold', required=... |
804c63785595f17c7eefc534af0a11667856ef11 | cruzvarona/Python | /a01_hamming_distance.py | 1,236 | 4.28125 | 4 | #The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
#
#Given two integers x and y, calculate the Hamming distance.
#
#Note:
#0 ≤ x, y < 231.
#
#Example:
#
#Input: x = 1, y = 4
#
#Output: 2
#
#Explanation:
#1 (0 0 0 1)
#4 (0 1 0 0)
# ↑ ↑
#
#... |
d24cedbf0e994c8019c40561f64eb1a1b6b99897 | akhileshyadav12/pythonproject | /human.py | 608 | 3.53125 | 4 | from database import *
class Human:
__name=""
__age=0
def __init__(self,name,age,school,roll_no):
create_table()
insert_data(name,age,school,roll_no)
self.__name=name
self.__age=age
@property
def __repr__(self):
return "Hello I am {name} and my age is {age}".... |
d74678e96d91310e315a28bb7b4a3eaace52101b | lordjuacs/ICC-Mentoring | /2020-2/4th/test10.py | 278 | 3.90625 | 4 | n = int(input())
tramposo = False
if n < 0:
tramposo = True
else:
if n < 100 and n%3 == 0 and n%2 != 0:
tramposo = True
elif n >= 100 and n%10 == 1:
tramposo = True
if tramposo:
print("Es tramposo")
else:
print("No es tramposo")
|
70937b19cc0660f54882995b33592d8d22402a68 | rduvalwa5/OReillyPy | /PythonHomeWork/Py3/Py3_Lesson13/src/count_thirtyone_days.py | 484 | 3.65625 | 4 | '''
Created on Nov 25, 2013
@author: rduvalwa2
'''
# import datetime
from datetime import datetime, timedelta # more attractive import
# now = datetime.datetime.now()
now = datetime.now()
delta = timedelta(31) # create a timedelata of 31 days
# date = now.strftime("%d")
# delivery = now + int(date) + 31
delivery = n... |
05223dd31776e9607ea1b5ec72cf9010b5ee4ff2 | AdrianoCavalcante/exercicios-python | /Lista_exercicios/ex023-separando_digitos.py | 763 | 3.6875 | 4 | """num = input('digite um número de 0 até 9999: ')
print(num)
num1 = str(num)
print('milhar: ' + num1[0])
print('centena: ' + num1[1])
print('dezena: ' + num1[2])
print('unidade: ' + num1[3])
print(num1.split())"""
#from random import randint
#n = randint(0000, 9999)
n = int(input('Digite um numero de 0... |
787e0c15f34bc6dc5a30fc97e4f90b267a6505cf | rpf1980/PYTHON_lnv | /Relacion01Ejercicios/Ejercicio05.py | 472 | 3.78125 | 4 | #Disea un programa que lea la edad de dos personas y diga quin es ms joven, la
#primera o la segunda. Ten en cuenta que ambas pueden tener la misma edad. En
#tal caso, hazlo saber con un mensaje adecuado.
persona1 = int(input("Edad persona 1:"))
persona2 = int(input("Edad persona 2:"))
if(persona1 > persona2):
print... |
53f89dc9b6fa279bfa722f69d7d03bb0da79cca9 | vedantvajre/Day8-and-Day9-Homework | /8.9.py | 215 | 3.6875 | 4 | magicians_list = ['Derren Brown', 'Michael Carbonaro', 'David Blaine', 'David Copperfield']
def show_magicians(magician_name):
for magician_name in magicians_list:
print(magician_name.title())
show_magicians(magicians_list)
|
5d4f37e0a25e6be1ac02e171eb160e3145bda1d0 | LizMichez/Python_Practice_Highschool | /CompSci Club/Area of Triangle.py | 274 | 4.21875 | 4 | # This program calculates the area of a triangle
base = int(input("Length of base:")) # Declares the variable base
height = int(input("Height of triangle:")) # Declares the variable height
area = (base * height) / 2
print("The area of the triangle is", area, "cm^2.")
|
83e79fc5f15cfbea63e7b77d780e3287fe7931ca | amitvalluri/MyPython | /ifconditon.py | 45 | 3.671875 | 4 | a=5
b=50
if a<b:
print("a is less than b")
|
e5b7e59d39b1a7f850dc1aa1eab2369efe5e5511 | user-is-absinthe/numerical_methods | /tests/test_for_p.py | 392 | 3.796875 | 4 | def main():
number = input('Введите число:\n')
print('Сейчас мы будем Ваше число вращать!')
number = list(number)
exit_number = ''
for i in range(len(number)):
exit_number += str(number[len(number) - i - 1])
print('Перевернутое число: {0}!'.format(exit_number))
if __name__ == '__main__... |
281f02eefb4225ebb5110e4d6f5d5f56976aaa05 | SAROJ7/python_tutorial | /dictionary.py | 193 | 3.703125 | 4 |
student = {'name': 'John', 'age': 25, 'courses': ['Math', 'Science']}
student['phone'] = 9843322391
print(student['name'])
print(student['courses'])
print(student.get('phone', 'Not Found'))
|
16ded36989a97deda45c9c501fe9068a6afb8181 | francisvanoliveira/Python-curso-em-video | /Exercícios/ex026.py | 478 | 4.03125 | 4 | #Faça um programa que leia uma frase pelo teclado e mostre quantas vezes aparece a letra “A”, em que posição ela aparece a primeira vez e em que posição ela aparece a última vez.
frase = str(input('Digite uma fase: ')).upper().strip()
print('A letra "A" aparece {} vezes na frase'.format(frase.count('A')))
print('A pri... |
243655454f77ebe008ff32437536e1dd622bb31b | Chase-42/cs-module-project-hash-tables | /applications/histo/histo.py | 1,128 | 3.703125 | 4 | text = open("/Users/chasecollins/Documents/git/cs-module-project-hash-tables/applications/histo/robin.txt")
remove_characters = ["\"", ":", ";", ",", ".", "-", "+", "=", "/", "\\",
"|", "[", "]", "{", "}", "(", ")", "*", "^", "&", '', "!", "?"]
space = " "
word_tally = {}
word = ""
for character in tex... |
2cb22b46e823bc9f045fa6c3d57ecad8f49d778c | n3n/CP2014 | /CodePython/CountChar.py | 162 | 3.8125 | 4 | def count(message, char):
count = 0
for letter in message:
if letter == char:
count += 1
return count
print count('banana','n')
|
7c770f7b5b424d3c0f63ae51b5770236cc32f532 | MagnusPoppe/NAS | /src/learning_rate.py | 1,122 | 3.671875 | 4 | def adjust_learning_rate(data: [(float, float)]):
"""
Adjusts learning rate according to the weighted average
slope found towards the best scored learning rate.
:param data: List of tuples containing (accuracy, learning_rate)
:return: Adjusted learning rate
"""
def slope(x1, y1, x2, y2) -> ... |
293e4b3d73a2b7eebdd6dea72538847f7a111c55 | savadev/python3-admin | /exercises/ex7_print_line_from_file | 843 | 4.03125 | 4 | #!/usr/bin/env python3.8
import argparse
import sys
def positive(string):
value = int(string)
if value <= 0:
msg = f"{value} is not a positive number"
raise argparse.ArgumentTypeError(msg)
return value
parser = argparse.ArgumentParser(description='Print specified line number from given fil... |
894eb0ea9b8678c4f7a8a7e106758ea3310e61a7 | SatyamAnand98/mini_projects | /tic.py | 3,342 | 3.71875 | 4 | # works only in Jupyter notebook
'''
from IPython.display import clear_output
clear_output()
'''
# in other IDE's we can use "print('\n'*100)"
board_position = ['1','2','3','4','5','6','7','8','9']
player2 = player1 = ''
flag = c = 0
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
... |
2c092824cfbcada79160f9007e71cccaff680a50 | jonathanjaimes/python | /4.4_Armstrong2.py | 481 | 3.84375 | 4 | numero = int(input("Ingrese un número positivo: "))
copiaNumero = numero
i = 0
#suma = 0
suma = 0
j = 0
while copiaNumero != 0:
ultimaCifra = copiaNumero % 10
copiaNumero = copiaNumero // 10
i = i + 1
while j < i:
numero = str(numero)
suma = suma + (int(numero[j])**i)
j = j + 1
#print(s... |
b5f8be458c16357651f601d362c63e17eb63438c | robintux/python_intro | /docs/src/chapter8/polynomial_class.py | 2,281 | 4.0625 | 4 | class Polynomial:
"""
class implementation of a polynomial, using a list to
represent the polynomial coefficients.
"""
def __init__(self, coefficients):
self.coeff = coefficients
def __call__(self, x):
s = 0
for i in range(len(self.coeff)):
s += self.coeff[i... |
0dc2f5cb833996f1c7618c187d7384f991001f9c | luryus/adventofcode-python | /2016/12/day12-1-2.py | 1,486 | 3.640625 | 4 | #!/usr/bin/env python3
def cpy(ip, regs, x, y):
if x in 'abcd':
x = regs[x]
else:
x = int(x)
regs[y] = x
return ip + 1
def inc(ip, regs, a):
regs[a] += 1
return ip + 1
def dec(ip, regs, a):
regs[a] -= 1
return ip + 1
def jnz(ip, regs, x, y) -> int:
if x in 'a... |
29764690b161bb89bcd634b6e8db4793c0198a9c | sanjay-3129/Python-Tutorial | /24.Assertions.py | 1,097 | 4.34375 | 4 | #check the 3 sections one by one using the comments. we cant compile the 3 types at a time bcs after giving an exception the program exits.
"""
An assertion is a sanity-check that you can turn on or turn off when you have finished testing the program.
An expression is tested, and if the result comes up false, an e... |
5b7ad9bbd58b59d7e7319bad5d970b5dbba1a529 | moha0825/Personal-Projects | /Resistance.py | 1,018 | 4.375 | 4 | # This code is designed to have multiple items inputted, such as the length, radius, and
# viscosity, and then while using an equation, returns the resistance.
import math
def poiseuille(length, radius, viscosity):
Resistance = (int(8)*viscosity*length)/(math.pi*radius**(4))
return Resistance
def main():
... |
77fc6e040cdbdc0f0fd59353a00b25e993a581bb | katelynrm/algorithms | /coding_problems/rps_refactor.py | 3,380 | 3.78125 | 4 | import random
BEATS = [('R', 'S'), ('S', 'P'), ('P', 'R')]
class RPSgame:
def start_game(self, level):
if level == 'random_chance':
RPSRandom().play_a_game()
elif level == 'hard':
RPSHard().play_a_game()
else:
raise ValueError('Must select from easy or ... |
b19e42deb83b5463e2190946d15521e068c5f71c | julenka/euler | /066.py | 1,768 | 3.796875 | 4 | #!/usr/bin/env python
# coding=utf-8
""" Diophantine equation
Consider quadratic Diophantine equations of the form:
x**2 – Dy**2 = 1
For example, when D=13, the minimal solution in x is 6492 – 13×180**2 = 1.
It can be assumed that there are no solutions in positive integers when D is square.
By finding minimal sol... |
3a7881106a7677265d80de8231545660157c582f | heroblood/pythonStudy | /exercise1.py | 574 | 3.78125 | 4 | '''
http://wenku.baidu.com/link?url=mxcmfQxbV2I1_XX0oZBtzetQAb6FxyFr2WkMvI6fpw2rmVf754xeSVuDxLfIGFv8R-LwVheT8wnEA05Hq9rJ7w5WP4X47-ZwcHwYPN2r6Bm
【程序1】
题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
'''
import copy
a=['1','2','3','4']
set3=[]
for i in range(len(a)):
b=copy.deepcopy(a)
b.pop(i)
for j in range(len(b... |
b2c1415ee8c3462eeb7e63fad2cedb24609fd86d | rciorba/jam | /3pgfun_1.py | 739 | 3.65625 | 4 | from collections import defaultdict
import sys
from blist import sortedlist
def not_really_anagrams(lines):
data = defaultdict(sortedlist)
for line in lines:
word = line.strip()
anagram = word[::-1]
if anagram in data[len(word)]:
print anagram, word
else:
... |
beede7359d1776a03f2735f669e205d000ff06b5 | jasminekalra18/python_programss | /forsk.py | 1,482 | 3.9375 | 4 | list1=[1,2,3,4,5]
#tuple
t=(1,2,3,4,5)
print(type(t))
"""t[0]=10""" #immutable and read only
print(t)
print(len(t))
tt=(10,20,13)
print(tt.index(20))
ttt = (1,20,3,20,20)
print(ttt.count(20))
print(ttt.count(1))
tttt = (2)
tttt1=(2,)
print(type(tttt))
print(type(tttt1))
t=(20.4,40, True)
prin... |
ec83081f18d475fdbb71571616e4cdb0e8c696e7 | andradejunior/cracking-the-code | /Python/I. Data Structures/Chapter 1 | Arrays and Strings/1.4 Palindrome Permutation.py | 1,219 | 4.34375 | 4 | """
1.4 Palindrome Permutation.
Given a string, write a function to check if it is a permutation of a
palindrome. A palindrome is a word or phrase that is the same forwards and
backwards. A permutation is a rearrangement of letters. The palindrome does not
need to be limited to just dictionary words.
EXAMPLE
Input: T... |
63da21ab91148d656049b9d611f86b3c0005903d | Rinki8890/PythonTrial | /DynamicProgramming/StairCaseFibonacci.py | 1,160 | 3.90625 | 4 | def fib(n):
if n <=1:
return n
else:
return fib(n-1)+fib(n-2)
def ways(n):
return fib(n+1)
print(ways(4))
#Fibonacci without recursion
def fibonacci(n):
a = 0
b = 1
if n < 0:
print("Incorrect input")
elif n == 0:
return a
elif n == 1:
... |
cfa74ef8f368aabe32dcd63973cdc1073d7fccef | vasanthsteve23/ADF_Vasanth | /ADF_DAY5/main.py | 627 | 3.578125 | 4 | import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",password="mettur@123",database="sample")
mycursor=mydb.cursor()
mycursor.execute("select * from employee")
myresult=mycursor.fetchall()
for db in myresult:
print(db)
fname=input("Enter First name ")
mname=input("Enter middle name... |
e5b066a86a9cc2b551901a2940a7300aa0ecfd31 | coder-me1/Degenerate-Triangle-Checker | /SumOfTwoEqualSides.py | 1,671 | 4.3125 | 4 | ## Author: Feras
## Problem: If you are given three sticks, you may or may not be able to
## arrange them in a triangle. For example, if one of the sticks is 12
## inches long and the other two are one inch long, you will not
## be able to get the short sticks to meet in the middle. For any three... |
b9cb88e1527c063938d608f38af9105a83346628 | SegFault2017/Leetcode2020 | /20.valid-parentheses.py | 690 | 3.53125 | 4 | #
# @lc app=leetcode id=20 lang=python3
#
# [20] Valid Parentheses
#
# @lc code=start
class Solution:
def isValid(self, s: str) -> bool:
""" Strategy 1: Stack
Runtime: O(n)
Sapce:O(n)
Args:
s (str): the parentheses string
Returns:
bool: determine wh... |
0edf83512beed6eee8d41f0af0c3c36660c9385c | lslshu/lslmybook | /python/Day1-15/Day7/list1.py | 478 | 4.1875 | 4 | """
定义和使用列表
- 用下标访问元素
- 添加元素
- 删除元素
Date: 2019-10-17
"""
def main():
fruits = ['grape','@pple','strawberry','waxberry']
print(fruits)
print(fruits[0])
print(fruits[1])
print(fruits[-1])
print(fruits[-2])
fruits[1] = 'apple'
print(fruits)
fruits.append('pitaya')
fruits.insert(0,'banana')
print(fruits)
del ... |
b0ef379b3262df168611863988b0fee9d2d8775e | rafaelperazzo/programacao-web | /moodledata/vpl_data/155/usersdata/271/65670/submittedfiles/investimento.py | 280 | 3.890625 | 4 | # -*- coding: utf-8 -*-
from __future__ import division
#COMECE SEU CODIGO AQUI
#ENTRADA
x = float(input('Digite o valor inicial de investimento: '))
y = float(input('Digite o valor da taxa anual: '))
#PROCESSAMENTO
a = x+(x*y)
b = a+(a*y)
c = b+(b*y)
print(a)
print(b)
print(c)
|
b639e51602299cdcf6727fe36bf6f90e0dc5fa03 | Rinkikumari19/codechef_questions | /recursion/factors.py | 115 | 3.75 | 4 | # a = 0
# b = 1
# c=1
# while c<6:
# print(a,b)
# a=a+b
# b=b+a
# c=c+1
def pali(word):
|
b7fed6fab626fa4d7e88ad9d854bddb94349bcfe | sntwr/UVa-Solved-Problems | /solved/UVa11498/11498.py | 543 | 3.671875 | 4 | #!/usr/bin/env python3
K = int (input ())
while K > 0:
(X, Y) = [ int (i) for i in input ().split () ]
for i in range (K):
(x, y) = [ int (i) for i in input ().split () ]
if x == X or y == Y:
print ("divisa")
else:
res = ""
if y > Y:
... |
c5f0d0d444978e8583a7d072ad064fc3d1001992 | livefun/pyston | /test/tests/closure_test.py | 840 | 4.25 | 4 | # closure tests
# simple closure:
def make_adder(x):
def g(y):
return x + y
return g
a = make_adder(1)
print a(5)
print map(a, range(5))
def make_adder2(x2):
# f takes a closure since it needs to get a reference to x2 to pass to g
def f():
def g(y2):
return x2 + y2
... |
1fdb06f5ac0fd3475e3f78a0a62668b4dd9acabb | gionanide/Euler_Project | /problem6.py | 168 | 3.625 | 4 | #!usr/bin/python
sum=0
sumSquare=0
for number in range(1,101):
sum+=number*number
sumSquare+=number
sumSquare = sumSquare*sumSquare
hence=sumSquare-sum
print hence
|
9a8e25f43b810f8954fd6fed935c8c189eb10acd | Rajeev70133/PyPractice | /UniqNonUnq.py | 3,330 | 4.125 | 4 | # You are given a non-empty list of integers (X). For this task, you should return a list consisting of only the non-unique elements in this list. To do so you will need to remove all unique elements (elements which are contained in a given list only once). When solving this task, do not change the order of the list. E... |
e344565a2ae09d6c99d27c11abadcee9c1ffdc47 | mikkelam/project-euler | /problem 12/problem4.py | 463 | 3.5625 | 4 | import math
def Tri(num):
tries = []
val=0
for x in xrange(1,num):
val = val + x
tries.append(val)
return tries
def Divisors(num):
divisors = 0
i = 1
end = int(num**0.5)
while i<end:
if num%i==0:
divisors+=1
i+=1
divisors *= 2
return divisors
interval=100000
tries =[]
tries = Tri(interval)... |
bee3d9fd6760b856b13b128af85ebfaea5e98d2d | robbyrenz/python-jumpstart-course-demos | /apps/04_journal/you_try/program.py | 2,094 | 3.984375 | 4 | def main(): # defining a main method; high level code up here
print_header()
run_event_loop()
# main() can't be defined here as Python would not know the definition of the functions in the main method
def print_header():
print('-------------------------------')
print(' JOURNAL APP')
prin... |
77d5bd00550a9c9190686e0cd667e34c949a161f | KrehlK/INST326-Final-Project-Financial-Advisor | /project_file.py | 9,038 | 3.953125 | 4 | import pandas as pd
import csv
from argparse import ArgumentParser
# ignore pandas chained assignment warning
pd.options.mode.chained_assignment = None
# constants for user input
MENU_CHOICES = {"display_all" : 1, "display_one" : 2, "deposit" : 3, "withdraw" : 4, "saving" :5, "receipt": 6, "exit" : 7}
class Bank:
... |
80efa07d5b7c4803b9b0053053b09285c26380eb | mx419/assignment7 | /mx419/divide_array.py | 748 | 3.921875 | 4 | """This module contain a class to solve Question 2. The class contain the 5*5 2-Darray and a method to generate the divided result"""
import numpy as np
#author: Muhe Xie
#netID: mx419
#date: 11/01/2015
class Divide_Array:
"""The class contain the 5*5 2-Darray in Question2 and a method to generate the divided r... |
72ab3a7104e69a4b733b136b87b78c44fef9407c | JodanGalas/Python_para_zumbis | /Lista 04/Lista 04 Python Para Zumbis.py | 2,275 | 3.828125 | 4 | #01 -
from random import randint
lista = []
for x in range(10):
n = randint(1, 100)
lista.append(n)
maior = lista[0]
menor = lista[0]
for x in range(0, 10):
if maior < lista[x]:
maior = lista[0]
for x in range(0, 10):
if menor > lista[x]:
menor = lista[x]
print(f'''Lista: {lista}... |
03d8db0d6af5847f949d0d84731e79cc074956d9 | LYNN-CHEN/Snake | /snake.py | 8,463 | 4.03125 | 4 | import turtle
import random
from time import time
screen = None
pen = None
monster = None
snake = None
isMoving = False
pauseGame = False
stampID = []
stampPosition = []
foodList = []
isEaten = [False]*9
bodyLength = 5
contact = 0
#details part (including intialize and upadte the screen, check ... |
14fe6615ec3d1a5897cf03b666ba8c6163a91178 | DIGITALFRANK/dsc-object-oriented-shopping-cart-lab-nyc-ds-career-042219 | /shopping_cart.py | 1,413 | 3.71875 | 4 | class ShoppingCart:
# write your code here
def __init__(self, total=0, employee_discount=None, items=[]):
self.total = total
self.employee_discount = employee_discount
self.items = items
def add_item(self, name, price, quantity=1):
self.items.append({'item': name, 'price': p... |
200d944b5c92b11780bd61513ad61ee585e0a848 | ravitejag8698/guvi | /palindrome_sumofanum.py | 276 | 3.609375 | 4 | n = int(input())
sum_n = 0
while n>0:
r = n%10
sum_n += r
n //=10
def rev(sum_n):
reverse = 0
while sum_n > 0:
rem = sum_n%10
reverse = reverse*10 + rem
sum_n //= 10
return reverse
if(sum_n == rev(sum_n)):
print('YES')
else:
print('NO')
|
2564e7f5582c02a717d4efab47caf8f98af6c769 | oliviachang29/python-elementary-school | /Guess My Number.py | 1,094 | 4.1875 | 4 | # Guess My Number
#
# The computer picks a random number between 1 and 100
# The player tries to guess it and the computer lets
# the player know if the guess is too high, too low
# or right on the money
#There is a limted number of guesses: 10 per game
import random
print("Welcome to Guess My Number!")
... |
38d6efe36a4c8c1d14367fa61fab39f48d0adb07 | Chockchockhancookie/Algorithm | /dp/1793.py | 265 | 3.65625 | 4 | def tile(n):
if n == 0 or n == 1:
return 1
dp = [0] * (n+1)
dp[0], dp[1] = 1, 1
for i in range(2, n+1):
dp[i] = 2 * dp[i-2] + dp[i-1]
return dp[n]
while True:
try:
print(tile(int(input())))
except:
break |
727a516ece49e1e1b87848fc929c3af8281c4550 | moh-sagor/web-development-html-css-bootstrap-javascript-python-django | /Python/files handle in py.py | 398 | 3.734375 | 4 | # open a file
# f = open("Test_file.txt","w")
# getting some info from file
# print('name = ',f.name)
# print('name = ',f.mode)
# f.write("My name is Sagor.")
# f.close()
# f = open("Test_file.txt","a")
# f.write(" My age is 22.")
# f = open("Test_file.txt","r+")
# info = f.read()
# print(info)
# # f.write(" My age ... |
5bb53ed37f5b76c4ecd29dfd9fa398c31d81c252 | MichalBrzozowski91/algorithms | /leetcode/medium/0229_Majority_Element_II.py | 1,126 | 3.8125 | 4 | # Boyer-Moore Voting Algorithm
class Solution:
def majorityElement(self, nums):
res = []
state1 = None
state2 = None
counter1 = 0
counter2 = 0
for num in nums:
if num == state1:
counter1 += 1
elif num == state2:
... |
4a188142cc014626d628470c05d3ebf52891814a | NicholasStone/Homeworks | /Compilers/RPN.py | 3,789 | 3.671875 | 4 |
def main():
with open("expression.txt", "r") as f:
expression = f.readline()
try:
notation = reverse_polish_notation(expression)
except Exception as e:
print(e)
else:
print(" ".join(notation))
def reverse_polish_notation(expression: str) -> list:
output_queue = []... |
e6b5d4f9d0bbe602ed7a63bbacddfa0f565854ac | nalle631/Algoooo | /lab1matrix.py | 1,271 | 3.796875 | 4 | class Graph:
def __init__(self, n):
self.matrix = []
i = 0
while (i < n):
j = 0
tempMatrix = []
while(j < n):
tempMatrix.append(0)
j = j + 1
self.matrix.append(tempMatrix)
i = i +... |
7f07a529dfcfa6183d6b52bf038150d1ebb88562 | Anirudh-Munnangi/Flying_Etiquette_Survey_Analysis | /data_quality_analysis.py | 4,449 | 3.53125 | 4 | """ This script accepts the dataset and acts like a tool to analyze the data quality.
It is well documented with comments and readable/user friendly as takes a functional approach.
It contains auxillary functions to generate some important charts and visuals which shall be required for analysis.
1) analyze_basic_quali... |
3455be22cd97e3ae7ec6eece63742c4ea7319915 | weflossdaily/Project-Euler | /019.py | 829 | 3.75 | 4 | years = []
for year in range(1901,2000+1):
years.append(year)
months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
daysInMonth = {
'Sep' : 30,
'Apr' : 30,
'Jun' : 30,
'Nov' : 30,
'Jan' : 31,
'Mar' : 31,
'May' : 31,
'Jul' : 31,
'Aug' : 31,
'Oct' : 31,
'Dec' : 31,
'Feb' : 28
}
d... |
d2f788ffb907d7be18dea138449a4567f46976bf | Amiaya/Data_Structures | /stacks.py | 545 | 4.03125 | 4 | class Stack:
def __init__(self):
self.stack = []
#add a value to the stack
def push(self, item):
return self.stack.append(item)
#deletes a value from the top of the stack
def pop(self):
if len(self.stack) < 1:
return None
else:
return sel... |
a2dc1bee4499e4593b6be6b9982d46c3593c7876 | varunchandan2/python | /boxVolume.py | 530 | 4.5 | 4 |
#Accept length from the user and store as a integer
length = input("Enter length of the box: ")
length = int(length)
#Accept width from the user and store as a integer
width = input("Enter width of the box: ")
width = int(width)
#Accept height from the user and store as a integer
height = input("Enter height of the bo... |
c324193d8dafc16b5384578a800163ae4674e810 | mixeract/my_scripts | /python/class1_testing.py | 683 | 4.125 | 4 | class Car(object):
first = 'Mazda'
second = 'BMW'
def __init__(self,name):
self.name = name
self.second = 'BMW Indeed'
# Create an instance of Car class
mycar = Car('I love it')
# Change the class variables (global variable)
Car.first = "Nothing"
print (Car.first)
# Test the instance variable value, it did c... |
7d4b49b0ef53ed0a3e07e41ffc165a83a46b9807 | jdsareault/Intro-to-Machine-Learning | /Projects Local/svm/svm_author_id.py | 1,460 | 3.546875 | 4 | #!/usr/bin/python
"""
This is the code to accompany the Lesson 2 (SVM) mini-project.
Use a SVM to identify emails from the Enron corpus by their authors:
Sara has label 0
Chris has label 1
"""
import sys
from time import time
sys.path.append("../tools/")
from email_preprocess import preprocess
### ... |
87e18dc0b309a4dd8c6d38774717f00024d393d1 | BattuPrakash/python- | /simple interest1.py | 145 | 3.671875 | 4 |
p=int(input("principal is"))
t=int(input("time is"))
r=int(input("rate of interest"))
s=p*t*r/100
print("simple interest iS",p,t,r)
|
c36afbaf58801a74f1713eeb7ef4380b76c5ff8a | Ryushi-tech/card3 | /ABC/ABC_105C_nBase.py | 146 | 3.5 | 4 | n = int(input())
s = ""
while n != 0:
a = n % -2
s += str(-a)
n = -(n//2)
if s == "":
print(0)
else:
print("".join(s[::-1]))
|
498e8c6b7669ed2bb7b3b659294321bb8e31fbee | wooseokoh/python | /python04/printList/listTest6.py | 267 | 3.734375 | 4 | # a 선언
a = [8,3,1,7,5,4,2,6,9]
print(a)
# a 정렬
a.sort()
print(a)
# 최솟값
for i in range(0, len(a)):
min = a[0]
if min > a[i]:
min = a[i]
print(min)
# 최솟값 위치
print(a[0])
# 찾고 싶은 위치
print(a[5]) |
671ae613e2ac06dd2fca14845732694e1be7764c | jeremy812/distrogenerator | /discretedistrogenerator.py | 3,177 | 3.515625 | 4 | #from mythos.domain.generators.generator import Generator
import random
'''
An implementation of the alias method using Vose's algorithm. The alias method samples random values from a discrete
probability distribution in O(1) time after O(n) preprocessing time.
'''
class DiscreteDistributionGenerator:
# preproc... |
81314c4b2edf6ba33b69584fbeb37bf201b4b1a5 | Pulkit12dhingra/Python_and_the_Web | /Scripts/Web_Scrappers/Google Search Using Python/code.py | 377 | 3.734375 | 4 | # We will be using the search() function from the googlesearch module.
from googlesearch import search
def query_finder(query):
for item in search(query, tld="co.in", num=10, stop=10, pause=2):
print(item)
if __name__ == "__main__":
query = input(
"Enter your query : "
) # This is the t... |
7b355e288cf1ca5f91c1eda199992fad41834ee6 | bravinjuan/Complejidad | /Ej3/tateti2.py | 4,405 | 3.765625 | 4 | from os import system, name
tablero = [2, 2, 2, 2, 2, 2, 2, 2, 2] # 2-->Vacio
valores = [8, 3, 4, 1, 5, 9, 6, 7, 2]
tableroprin = ['_', '_', '_', '_', '_', '_', '_', '_', '_']
def limpia():
if name == 'nt':
_=system('cls')
else:
_=system('clear')
def tablerof():
print(str(tableroprin[0])+" "+str(tableropri... |
4338f54628e6a75e510ed86f4a5f3362c2c84c3c | Made-of-Dark-Matter/DSA-Algorithms_on_Graphs | /1-2-my_connected_components.py | 1,313 | 3.96875 | 4 | #python3
#Reachability of graphs
#implementing a graph vertex using adjacency List
import sys
class Vertex():
def __init__(self, value, visited = False):
self.value = value
self.visited = False
self.CCnum = None
self.N = [] #Neighbours
def Explo... |
944e71e2bdba919ab2a51cc9696b5cc983d62f6f | Bernardo-MR/Mision_02 | /VelocidadBernardo.py | 400 | 3.796875 | 4 | # Autor: Bernardo Mondragon Ramirez, A01022325
# Descripcion: distancia en 6,3.5 horas y tiempo en 485 km.
# Escribe tu programa después de esta línea.
v= int(input("Ingresa la velocidad en Km/h : "))
d1= 6*v
d2 = 3.5*v
t= (485)/v
print("Distancia recorrerá en 6 horas = %.1f"% (d1), "km")
print("Distancia recorrer... |
2c3de2fbad8aa6b50173f844d7a49150f16c548f | diegotbl/Exercicios-How-to-Think-Like-a-Computer-Scientist | /Aula 2/Exercicio7.26.13.py | 763 | 4.4375 | 4 | # It's possible to draw the graph when there is 0 or 2 vertices with odd degree
print("In the first shape there are 2 vertices with odd degree, so IT IS"
" possible to draw this image")
print("In the second shape there are 2 vertices with odd degree, so IT IS"
" possible to draw this image")
print("In the ... |
04269240a5ca9de2153503b49eccc7c4e47af35c | iverny11/basketball-quiz | /user_details/user_details v2.py | 304 | 3.9375 | 4 | #this is version 2
def user_details(name,age):
print("Hello", name, "and your age is", age)
while True:
name=input("What is your name? : ")
if name.isalpha():
break
print("Please enter characters A-Z only")
age = input("What is your age? : ")
user_details(name,age)
|
52126794baac781a8658bbf6efc89a90cde870a9 | jjspetz/digitalcrafts | /fileIO-exe/ex3.py | 696 | 3.5625 | 4 | #!/usr/bin/env python3
'''
Opens a user specified file and prints the letter and word histogram of it
Current;y won't work without putting letterSummary and wordSummary into the
same folder
'''
import letterSummary as ls
import wordSummary as ws
PUNCTUATION = ".!,?;:''\"\"/\\"
def dual_histogram():
file_name = ... |
d774bcff306856867829767146eac16dd7d4dc66 | Tanmay53/cohort_3 | /submissions/sm_001_aalind/week_13/day_4/session_1/count_vowels.py | 274 | 4.1875 | 4 | def is_vowel(char):
if char == "a" or char == "e" or char == 'i' or char == 'o' or char == 'u':
return True
else:
return False
string = input("Enter a string: ")
count = 0
for char in string:
if is_vowel(char):
count += 1
print(count) |
45c019948ed9b2c864aa28b4acaf6203f1d077fa | salikansari6/Data-Structures-Algorithms-and-Coding-Problems | /DoublyLinkedList.py | 4,100 | 3.875 | 4 | class Node:
def __init__(self, value):
self.value = value
self.next = None
self.prev = Node
class DoublyLinkedList:
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def shift(self):
if self.head is None:
print("List ... |
49e1ec7ce592d6bccc73cec40c56217dde8dc124 | isakss/Forritun1_Python | /sequence_analysis.py | 3,731 | 3.96875 | 4 | """
This program reads values from files, inserts them into a list and then prints that list unsorted, sorted, cumulative sum and median value from that particular list.
Wrong values are handled, as are invalid file reads.
"""
#File handling functions: The functions below are meant to take in strings that represent the... |
bd431632bfd7ae423792bf5caf2d40a3256bf929 | loukasstamos/christmastree | /loukas.py | 399 | 3.96875 | 4 | height = int(raw_input("Please give the height of the Tree: "))
Trunkh = int(raw_input("Please give the height of the trunk: "))
Trunkw = int(raw_input("Please give the width of the trunk: "))
p=0
while p < height:
print((' '*(height-p))+('*'*(p*2+1))+(' '*(height-p)))
p=p+1
if(p == height):
j=0
while... |
921a97dbc79ceed78540e4ae8c75827e019487c3 | silenttemplar/tensorflow_example_project | /example/tensorflow2/conv_and_pooling_layer.py | 683 | 3.515625 | 4 | import tensorflow as tf
from tensorflow.keras.layers import Conv2D, MaxPooling2D
'''
[Tensorflow2 강의] 21강 Conv and Pooling Layer 강의 예제샘플
'''
conv = Conv2D(filters=8, kernel_size=3, padding='valid', activation='relu')
pool = MaxPooling2D(pool_size=2, strides=2)
#image = tf.random.normal(mean=0, stddev=1, shape=(1, 2... |
d4d06d88f3e1e7c2648c1fb96c59bdba765e92ac | ItsLogical/LetsLearnIP-ProgrammingForEconomists | /solutions/electronics.py | 475 | 4.15625 | 4 | DISCOUNT_MULTIPLIER = 0.15
price1 = float(raw_input("Enter the price of the first article: "))
price2 = float(raw_input("Enter the price of the second article: "))
price3 = float(raw_input("Enter the price of the third article: "))
highest = price1
if price2 > highest :
highest = price2
if price3 > highest :
... |
96cfbac939fdec930db9aa38a9b8daf352f6feaa | leiger/socket-programming | /UDP/UDPPingerServer.py | 1,293 | 3.578125 | 4 | # UDPPingerServer.py
# We will need the following module to generate randomized lost packets
import random
from socket import *
import time
# Create a UDP socket
# Notice the use of SOCK_DGRAM for UDP packets
serverSocket = socket(AF_INET, SOCK_DGRAM)
# Assign IP address and port number to socket
serverSocket.bind(('',... |
b6c555759043c93efb14f903a0fb22b8232a9a36 | ndf14685/pythonBasic | /clase6/scriptTkinter.py | 589 | 3.84375 | 4 | from tkinter import *
from tkinter import scrolledtext
from tkinter import messagebox
ventana = Tk()
ventana.title("Hola Buen Mundo ")
ventana.geometry("600x400")
titulo = Label(ventana, text="GUI 1.0", font=("Arial Bold",24))
titulo.grid(row=0, column=0)
def clicked():
messagebox.showinfo('Message Tittle', 'M... |
859d16876a42f28ef7ff3f49b7b25ad585afa8bd | 6bstkc1/PythonForAbsoluteBeginners | /guessing_game_ask_number.py | 941 | 3.84375 | 4 | import random
def ask_number(question,low,high,step=1):
response = None
while response not in range(low,high,step):
response = int(input(question))
return response
def main():
print("\tWelcome to 'Guess My Number'!\n")
print("\tI'm thinking of a number between 1-100.\n")
pri... |
15ab3984bd52176144fc6690d4a87f6a5d4349be | mykaeull/Curso-Python | /biblioteca_math.py | 88 | 3.765625 | 4 | import math
num = float(input("Número:"))
raiz = math.sqrt(num)
print("raiz:", raiz) |
aada20e90316ba8ef62725c1082a1db7eafcb64b | innovatorved/BasicPython | /Python Programs/20.tuples.py | 331 | 4.0625 | 4 | #tuples :
#1. sequence of python objects like list
#2. we use parenthesis() instead of squire brackets[]
#3. unlike list tuples are immutable meaning thier value can't be changed
x=(1,2,3,'abhi',[2,3,'nidhi'])
print(x)
#4. we can change value of list stored in tuple
x[4].append('divya')
print(x)
x[4].insert(0,'ram'... |
fb5400608745e4bd4917a849f4fef9bb8243ec29 | Parya1112009/mytest | /nestedlist.py | 183 | 3.734375 | 4 | list = [[1,2,3],[3,4,5],[6,7,8]]
list1 = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(0,len(list)):
for j in range(len(list[i])):
list1[i][j]=list[j][i]
for r in list1:
print r
|
067b512d5bbb9c93f3f4e7b4781f49a20bb1b766 | demo112/1807 | /自用文件/自建函数/猴子打字.py | 1,281 | 3.890625 | 4 | import re
def count_words(text: str, words: set) -> int:
a = 0
for i in words:
pattern = r"%s" % i
regex = re.compile(pattern, re.I)
n = regex.findall(text)
if n:
a += 1
print(a)
return a
if __name__ == '__main__':
# These "asserts" using only for self-c... |
8337ea05d101b716c51ce591809309c20f225f0d | jianwei20/Big-Data-Project | /superset.py | 1,767 | 3.546875 | 4 | #!/usr/bin/python
import sys
import csv
import re
import os
import itertools
def FindSubsets(S,m):
#return set(itertools.combinations(S,m))
return list(itertools.combinations(S,m))
# def ComposeFeature(Feature_supersets): #( ) or input resulf
f = open('train10.csv', 'r')
rows = csv.reader(f)
Feature_super... |
c946153ba1aabd3525fe1506b1326f6f69d87896 | AndreeaCimpean/Uni | /Sem1/FP/L1/FirstSet2.py | 593 | 3.953125 | 4 | def isPrime(x):
if x <= 1:
return False
else:
for d in range(2,x//2+1):
if int(x)%d == 0:
return False
return True
def goldbach(x):
i = 2
j = x-2
l=[]
while len(l) == 0:
if isPrime(i) and isPrime(j):
l+=[i,j]
i+=1
... |
5e81874dd4b6ba4f7d497389e3aa985a06591234 | MioPoortvliet/COP-Ising-Model | /src/physics.py | 7,054 | 3.546875 | 4 | """
Contains all physics of the Ising model system.
Authors: Mio Poortvliet, Jonah Post
"""
import numpy as np
from numba import njit
from itertools import product
from typing import Callable
# True is down
# False is up!!!!!
class IsingModel:
def __init__(self, dimensionless_temperature=1., dims=2) -> None:
... |
0c9bcdf7d5ed4fc421eab70657fa0383d55d1d33 | ashishraste/leetcode | /hackerrank/tree/check_binary_search_tree.py | 550 | 3.671875 | 4 | from tree import Node
def check_binary_search_tree_(root):
def check_binary_search_tree(root, min_val=-1, max_val=10**4 + 1):
if not root: return True
val = root.data
if val <= min_val or val >= max_val:
return False
if not check_binary_search_tree(r... |
6df1dbba392f6967104f8a960c4d149ecfde5790 | Iqrar99/Project-Euler | /problem45.py | 716 | 4.0625 | 4 | """
Iterate the triangle, pentagonal, and hexagonal numbers
and save them in different sets. Then, union all of them.
"""
def main():
triangle_numbers = set()
for n in range(1, 10**5):
x = (n * (n + 1)) // 2
triangle_numbers.add(x)
pentagonal_numbers = set()
for n in range(1, 10**5):
... |
f3a4455e20d424109a11681c225d6cb7a5c1d12a | dudulacerdadl/Curso-Python | /testes/Teste01.py | 187 | 3.703125 | 4 | name = input('Digite seu nome: ')
years = input('Digite sua idade: ')
weigth = input('Digite seu peso: ')
print('Meu nome é', name, 'e tenho', years, 'anos, e peso', weigth, 'Kg')
|
4605a1621f1ddd354d611f008608008efd521e51 | 2571792460/testing | /practicefinal/grocery_list4.py | 1,274 | 3.953125 | 4 | import csv
def main():
user_input = user_input = str(input('Enter food item (or "x" to exit): '))
num_input = 0
grocery_list = []
while user_input != 'x':
while type(num_input) != str:
try:
num_input = int(input(f'How many {user_input}? '))
ex... |
7d30ef9868dd497b8c3f5d41decd3b4709b1f70d | MacStan/tsp-elastic-net | /vec.py | 1,086 | 3.875 | 4 | import math
class Vec:
def enforcevec(self, vec):
if not isinstance(vec, Vec):
raise TypeError( "passed wrong type to Vec" )
def __init__(self, a, b):
self.x = a
self.y = b
def __add__(self, other : "Vec"):
self.enforcevec(other)
return Vec( self.x + other.x, self.y + other.y)
def __sub__(self... |
e03969f55ba923a66fbaca21193ebd7db2292240 | LuannALONE/hello-python | /python-integer.py | 200 | 3.671875 | 4 | age = 17
weight = 49.75
data = {"name": "Luann",
"age": 17,
"weight": 49.75}
#print(data)
printdata(data["name"])
print ("My first FIL grade is {}"
.format(data["grades"][0])
|
12c5fc2305cb8f5ff321e6147eceaf4d613294f9 | AleksandarShishkov/_my.Py-projects | /Python_Profile_class/options.py | 911 | 3.9375 | 4 |
def options(): # options() method
print('\n\tSelect between the following:\n') # printing the options
print('\t1 - look up an profile')
print('\t2 - add new profile')
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.