blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
682efdd4127fb5e71f52d6c25498f5ef9a18bb4b | TweedyKim/Python_Study | /dictionary.py | 227 | 3.796875 | 4 | #Dictionary (Hash Map, key: value, JSON)
fruits = {'orange':400, 'apple':200, 'banna':100}
print(fruits.keys())
print(fruits.values())
print(int(500) in fruits.values())
for key, val in fruits.items():
print(key,' ', val) |
813741a73ae14d2b1093b6dee7bd3db126b6b372 | ethanp55/repeated_games | /agents/fictitious_agent.py | 1,827 | 3.671875 | 4 | import numpy as np
history = [1,1] #Stores action count history of opponent
game = None #Store the game being played
name = "FictitiousPlayer" #The name of this agents
def startGame(g):
"""
Called when a new game begins.
Agent should reset any information
Parameters:
... |
d576baf9b294661a764be7b0f942fe78b9fb55c1 | abhisaxena5694/nlp-autonomous-systems | /door/opendoor.py | 1,372 | 3.78125 | 4 | from changeDoorState import change_state
door_state = False #door is closed
# True => door is opened
# False => door is closed
while True:
if door_state == True:
print("Door state: Opened")
else:
print("Door state: Closed")
command = input().split()
print(command)
#if len(command) == 0:
#break
#door_s... |
9ec4ced61b809ddfcc7c4044aa0f36138250804c | julinvictus/python-noobs | /bonus3_2.py | 719 | 3.640625 | 4 | from sys import argv
# python bonus3_2.py input.txt cat dog
script, filename, findword, replaceword = argv
# open input filename
readfile = open(filename)
# print "This is your file %r:\n" % filename
# print readfile.read()
# It got too complicated, skipped print for now
# read the contents
contents = readfile.read... |
9cbd0151cc376174d81c5dae90fee40da40c09d7 | Sridhar-R/Python-basic-programs | /python practice L2/binarsearch.py | 358 | 3.515625 | 4 | import math
def bin_search(li,element):
bottom=0
top=len(li)-1
index=-1
while top>=bottom and index==-1:
mid=int(math.floor(top+bottom)/2.0)
if li[mid]==element:
index=mid
elif li[mid]>element:
top=mid-1
else:
bottom=mid+1
return index
li=[8,9,3,5,4,12,6,19,23,15]
print(bin_search... |
f9780f5a8e9e2a47c4973a4d29a321008f011ef1 | YesselmanLab/python_tutorials | /lesson06.py | 7,332 | 4.625 | 5 | # Welcome to the sixth lesson in the Yesselman Group's Python series
# Topics covered: sets, review of strings
########################################################################################################################
# Part I: sets
# In programming, a container object is something that holds other types ... |
b441d0fb482129d89dfd1a0bda1811b94c095eca | borjamoll/programacion | /Python/Act_07/12.py | 728 | 3.890625 | 4 | #Escribir un programa que lea una frase, y pase ésta como parámetro a una función que debe contar el número de palabras
# que contiene. Debe imprimir el programa principal el resultado.
# Asumir que cada palabra está separada por un solo blanco:
#Asumir que cada palabra está separada por un solo blanco.
#No se sabe c... |
fd3408b24190f1cb633c296329d97de8c8c4225c | Iven022/TD3_Iven_Henna | /mulTwolnt.py | 394 | 3.71875 | 4 | import sys
def mul(a,b):
return int(a)*int(b)
if __name__ == "__main__":
try:
if (len(sys.argv)>3):
print("Inserez que deux valeur")
else:
print(mul(sys.argv[1],sys.argv[2]))
except Exception as e:
print("Inserez 2 valeur")
i=len(sys.argv)
CopyArg=sys.argv
while(i<3):
CopyArg.append(int(input("... |
6d1d47de8aa53cda34238f980577f41af3c6c76c | Riley24e/289.114-Python- | /conditional_statements/conditional_statements.pyde | 205 | 3.859375 | 4 |
mark = 105
if mark < 0 or mark > 100:
print('INVALID MARK')
elif mark >= 80:
print ('A')
elif mark >= 65:
print('B')
elif mark >=50:
print('C')
else:
print('Get Fucked')
|
ae3619971fc16b4f5b0ee6ef3ae71bd481c9bbd8 | KitsuneNoctus/makeschool | /site/public/courses/SPD-2.31/archive/lab/refactoring-pep8/whitespace_naming_convention2.py | 1,309 | 3.875 | 4 | # By Kami Bigdely
# PEP8 - whitespaces and variable names.
class pizza:
def __init__ (obj, mybread_type,CHEESE_TYPE,meatType,pizza_toppings,size):
obj.bread_type= mybread_type
obj.cheese_type = CHEESE_TYPE
obj.meatType= meatType
obj.toppings = pizza_toppings
obj.size ... |
dac11319c6b4f34907b91ea768048405cbcab32f | nikita1610/100PythonProblems | /Problem26/Day26.py | 299 | 3.5 | 4 | def leaders(x,n):
*l,last= x
l1=[]
l1.append(last)
for j in reversed(l):
if j>=last:
l1.append(j)
last=j
l1.reverse()
return l1
x=[16 ,17, 4, 3 ,5, 2]
n=len(x)
l=leaders(x,n)
print(*l)
|
d3fe929aa7c726539e568cd66294492de1863af6 | dahyeeeon/Python | /Hello/test/Step11_if.py | 614 | 3.671875 | 4 | #-*-coding:utf-8 -*-
'''
제어문 if
'''
#숫자를 입력 받아서
inputNum=input('정수 입력:')
#홀수인지 짝수인지 판별
if inputNum%2==0:
print u'입력한 수는 짝수디'.format(inputNum)
else:
print u'입력한 수는 홀수다'.format(inputNum)
'''
문자열 format
'''
result1=u'이름:{} 주소:{}'.format(u'김구라', u'노량진')
print result1
result2=u'이름:{1} 주소:{0}'... |
b343744940a8bc2151f7e3a5c2fb694155f1c57b | Rrochasantos/PPZ | /Lista de exercicios II.py | 6,058 | 4.3125 | 4 | #1. Faça um Programa que peça os três lados de um triângulo.
#O programa deverá informar se os valores podem ser um triângulo.
#Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno.
3
'''lado1 = int(input("Digite o primeiro lado do triângulo: "))
lado2 = int(input("Digite o... |
5ab5c833b61bb995706612bfa646b93b84f89bea | meghshah136/PDS-practicals | /prac6.py | 537 | 4.21875 | 4 | num1 = float(input("Enter first number : "))
num2 = float(input("Enter Second number : "))
addition = num1 + num2
subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2
div = num1 // num2
remainder = num1 % num2
print(f"Addition of two numbers : {addition}")
print(f"Subtraction of two nu... |
04dbd008a750399080dd82cad42c8ae0c4ce7a19 | mvrramos/python | /curso-em-video/radar.py | 192 | 3.765625 | 4 | vel = int(input('Qual a velocidade do carro?\n'))
if vel > 80:
multa = (vel-80) * 7
print(f'Você irá pagar {multa} reais de multa')
else:
print('Muito bom, dirija com cuidado!') |
70a99ba2f5b44db25e292dcdbe855cb1ed4fb2d3 | JeanCremonezzi/phrases_similarity | /main.py | 1,848 | 3.71875 | 4 | from math import sqrt
from nltk.corpus import stopwords
from nltk.stem.snowball import SnowballStemmer
def removeStopwords (phrase):
noStopwords = []
for word in phrase:
if word not in stopwords:
noStopwords.append(word)
return noStopwords
def stemmingPhrase (phrase):
stemmed = []... |
07e7e64e896fc16e6421a34d3b6d4d4a6da545af | mlaizure/holbertonschool-higher_level_programming | /0x0A-python-inheritance/7-base_geometry.py | 1,194 | 3.65625 | 4 | #!/usr/bin/python3
"""Module with a class BaseGeometry with public methods area and int
validator"""
class BaseGeometry:
"""public methods area and int validator"""
def area(self):
"""area() is not implemented"""
raise Exception("area() is not implemented")
def integer_validator(self, nam... |
0dc58b0083d6da4618878b6259cc854f27e36097 | treble-clef/london_schools_aq | /london_schools_aq.py | 4,566 | 3.78125 | 4 | ###############################
## Interactive Data Analysis ##
###############################
## The london_schools_aq module allows for the user to interactively select a specific city or school type to get the average NO2 level.
## User please remember to change the file location in line 11 to your own.
def ... |
84e5cc03636db1603168f388658bbba9d2f7db3d | H6yV7Um/testcode | /myprojects/python/svc_load/tests/fib.py | 1,243 | 3.875 | 4 | #这个数列从第3项开始,每一项都等于前两项之和。
def fib1(n, f=1, s=1, cache={}):
'''递归版'''
import sys
sys.setrecursionlimit(9999)
result = cache.get(n)
if result is None:
if n == 1:
result = f
if n == 2:
result = s
elif n > 2:
result = fib1(n-2) + fib1(n-1)
... |
cbc59459ba2e91e471cd8ec5502960163fafdbcb | kimha1030/holbertonschool-higher_level_programming | /0x04-python-more_data_structures/0-square_matrix_simple.py | 272 | 3.609375 | 4 | #!/usr/bin/python3
def square_matrix_simple(matrix=[]):
new = []
for r in range(len(matrix)):
sub = []
for c in range(len(matrix[0])):
x = (matrix[r][c]) * (matrix[r][c])
sub.append(x)
new.append(sub)
return new
|
b7a3f1ac87e4167ea8cc05a15196873d63373b77 | mpayalal/Talleres | /TalleresDatos/Taller1/punto8Taller.py | 431 | 3.90625 | 4 | def triangulo(a, fila = [], cero = [], b = 1):
for n in range(b):
fila = [1]
cero = [0]
if (a == 0):
fila = [i + d for i, d in zip(fila + cero, cero + fila)]
else:
for n in range(b):
print(fila)
fila = [d + i for d, i in zip(fila + cero, cero + fila)]
print... |
c4874e30b3315d1bb5450836fab872ca1663f584 | mossk92/SC_Python | /project_parity/katie.py | 279 | 4.03125 | 4 | grid = [
["x","b","c"],
["x","x","o"],
["o","o","x"],
["x","o","x"],
]
choose_column = input(f"Please select a number from 1 to {len(grid[0])}? ")
choose_row = input(f"Please select a number from 1 to {len(grid)}? ")
print(choose_column)
print(choose_row)
|
ff2ae3bdd02e583cb6af5e183b27611c97bc9332 | bhushanmahangare/Python-Demo-Application | /Assignment2/Assignment2_1.py | 1,352 | 4.03125 | 4 | """=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1. Create on module named as Arithmetic which contains 4 functions as Add() for addition, Sub()
for subtraction, Mult() for multiplication and Div() for division. All functions accepts two
p... |
2e240f12af13b6ed35390c1409823b6a9e6da56e | albertopha/ds-algo | /LC/980/980.py | 2,633 | 3.8125 | 4 | """
WATCH OUT FOR THE COMPLEXITY CALCULATION!
[[1,0,0,0],
[0,0,0,0],
[0,0,2,-1]]
Brute force:
1. Iterate through the grid:
a. find the start point.
b. find the end point and change end point to 0.
c. count the number of obstacles
2. Using the dfs backtracking to find the end point.
a. Each recu... |
065d18619939466e5b475c18c81525216b374fa3 | quarkgluant/boot-camp-python | /day01/ex01/game.py | 1,116 | 4 | 4 | #!/usr/bin/env python3
# -*-coding:utf-8 -*
class GotCharacter:
"""class for characters of Games Of Throne
attributes: first_name, is_alive=True
"""
def __init__(self, first_name, is_alive=True):
self.first_name = first_name
self.is_alive = is_alive
class Stark(GotCharacter):
""... |
4bce95c782eaa2c59021c9c85aae96df1a3afd65 | JonnyGreat456/IntroToAI | /Assignment2/tf_train_model_ASSIGNMENT_FILE.py | 7,668 | 3.640625 | 4 | import tensorflow as tf
import numpy as np
import os
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
class build_train:
def __init__(self):
self.rootPath = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) # DO NOT EDIT
self.save_dir = self.... |
bb5993abb3c8f6757f7d40fa24964561c8182c76 | Sheep-coder/practice2 | /Python00/chap03list0308.py | 218 | 3.8125 | 4 | # 読み込んだ整数値の符号を表示(ゼロはパス)
n=int(input('整数値:'))
if n>0:
print('その値は正です。')
elif n==0:
pass
else:
print('その値は負です。')
|
196a74129458a2ad7058c63a5374a90273891b77 | EvaSedlarova/pyladies | /06/mountains.py | 1,104 | 4.15625 | 4 | mountains = {
'Mount Everest' : 8848,
'K2' : 8611,
'Kangchenjunga' : 8586,
'Lhotse' : 8516,
'Makalu' : 8485,
}
def print_dict (slovnik):
print()
print('Keys:')
for mountain in mountains:
print(mountain)
print('\nHeights:')
for mountain in mountains.values():
print(mountain)
print... |
230ba2b8c2220470b30c3c41fe22b6fb3a8a2b06 | first0506/Algorithm-Problem-Solving | /2020카카오인턴십1_김현준.py | 1,271 | 3.828125 | 4 | def solution(numbers, hand):
answer = ''
curleft = [3, 0]
curright = [3, 2]
for num in numbers:
if not num:
num = 11
num -= 1
if not num%3:
answer += 'L'
curleft = [num//3, num%3]
elif num%3==2:
answer += 'R'
cur... |
ebd9c2d61231b434f87d237ac8a1e1db0bb0a03e | gloxiinia/Programming_ForumXercise | /sentence_splitter.py | 2,742 | 4.1875 | 4 | '''
Your task here is to write a program that given the name of a text file can write its content with each sentence on a
separate line. Test your program with the following short text:
Mr. Miyagi bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot for it. Did he mind? Adam Jones Jr. thinks he
didn't. I... |
6405e38b25ce7eadf57ae688f314d582e3cdffa9 | trsong/LanguageDocument | /Python Documents.py | 76,673 | 4 | 4 | Python2.0 Documents
By T.R.Song 4/25/2013 Version 1.0
You should open it with notepad++
________________________________________________
Chapter 1: Values,Expressions,Statements
Chapter 2: Functions
Chapter 3: Conditionnals and recursions
Chapter 4: Loops
Chapter 5: Strings
Chapter 6: Lists
Chapter 7: Diction... |
b8a406cdf4ca49c367257a9e8d3256d3529d7a38 | ankushbosi13/workfromhome | /DAY_8 DT-07-04-2020-TUESDAY/listcompre.py | 718 | 3.75 | 4 | mylist=[num for num in range(0,100)]
print(mylist)
mylist_1=[num*3 for num in range(0,50)]
print(mylist_1)
mylist_2 = [char for char in 'ALPHANUMERO']
print(mylist_2)
mylist_3 = [num%2 !=0 for num in range(0,100)]
#print(range)
print(mylist_3)
mylist_4 = [num *2 for num in range(0,100) if num %2 == 0]
... |
346616db94cff25f16ee05ffd974b5924403425e | Dituohgasirre/python | /python-1025/python/1_base_syntax/homework.py | 3,271 | 3.59375 | 4 | #!/usr/bin/env python3
import kyo
import menu
def ball(index, args):
"""
一个袋子里有3个红球, 3个绿球,6个黄球, 一次从袋子里取6个球
列出所有可能的颜色组合
"""
r = 0
y = 0
while r < 4:
g = 0
while g < 4:
y = 6 - r - g
print("红球: %d, 绿球: %d, 黄球: %d" % (r, g, y))
g += 1
... |
45e21f2698e6aaa324d2316680e333c47c7ebe08 | giovannamascarenhas/Projeto-simples-de-Caixa-Eletr-nico-com-Python | /caixa_eletronico.py | 753 | 3.8125 | 4 | def caixa_eletronico():
print('===== Bem Vindo ao Caixa Eltrônico =====')
valor = int(input('Valor a ser sacado: R$'))
total = valor
cédulas = 50
total_de_cédulas = 0
while True:
if total >= cédulas:
total -= cédulas
total_de_cédulas += 1
else:
... |
86c439fd0e284862ec4c92bc61e505dfc518ea01 | GitAbdelali/Python | /Homework/HW1/Average&Maximum.py | 755 | 4.5625 | 5 | # Write a Python program that reads in 3 numbers and displays the following:
# a) the average of the three numbers
# b) the maximum fo the three numbers
print("Please enter three numbers of your choosing.")
num1 = float(input("Enter your first number: "))
num2 = float(input("Enter your second number: "))
num3 = float... |
d54d5018cdb4a65713e546c8a687df927ef9d500 | anhmvc/CS30 | /hw2_turtle.py | 1,756 | 4.1875 | 4 | '''
Description: A program that implements recursive functions to draw shapes using the Python turtle library.
(I discussed the last problem with Sally Seok and Miles Kang and got help from the other classmates' questions on Piazza.)
Written By: Anh Mac
Date: 10/23/2018
'''
from turtle import *
def regularNGon(n, sid... |
2af3d781de561ba03575c81b764a62abab97f68a | pmeystre/caesarCipher | /caesar.py | 3,887 | 3.59375 | 4 | import string
import time
from operator import itemgetter
import nltk
from nltk.corpus import words
from rich.console import Console
from rich.table import Table
def main():
start_time = time.time()
ciphered_text = input(str('Enter text to decipher: '))
try_iterations(message=ciphered_text)
end_time =... |
195ac14fc55363461817048ed38f22ad803103df | rvmodesto/ORGANIZAR | /Exercicios ILM/Aula_2/exercicios_lista/Exercicio_10.py | 475 | 3.765625 | 4 | # 10 - Calcule a nota final de um aluno sabendo que ela é composta da seguinte forma: Prova 1 (40%) +
#Prova 2 (40%) + Trabalhos (20%). Os três valores que compõem a nota final serão informados pelo
#usuário, exiba-a com duas casas decimais.
p1 = float (input ('Insira a nota da P1: '))
p2 = float (input ('Insira a not... |
96722d15c647be3a8135c2db0424ae738737a19c | tknieza/advent-of-code-2019 | /day3/day3.py | 960 | 3.5625 | 4 | import math
def get_wires():
f = open("input.txt", "r")
wires = []
line = f.readline()
while line:
wires.append(line.strip().split(","))
line = f.readline()
return wires
def possible_coords(wire):
x = 0
y = 0
steps = 0
coords = {}
for i in range(len(wire)):
for j in range(int(wire[i][... |
3fb76681095bed9d2cdf95942b0740b5e6c01e57 | CoderSahara/Python_Study | /第2天/04-字典函数举例.py | 483 | 3.90625 | 4 | # -*- coding:utf-8
stu={"name":"sahara",
"age":"33"}
for key in stu.keys():
print(key)
for value in stu.values():
print(value)
print("#"*30)
#迭代字典常用方式
for item in stu.items():
print("key为:%s,value为:%s"%item)
#print("%s----%s"%(a,b))
print("="*30)
#判断某个key是否在字典中
key="name"
if key in stu:
... |
ef842474de3f9b59fdb1516ee00b7a1603110500 | YashaModievsky/QA-targilim | /תרגילים/L+W/Wj1.py | 244 | 3.890625 | 4 | num = int(input("enter number: "))
list = []
while 0<=num<=100:
list.append(num)
num = int(input("enter number: "))
if 0>num or 100<num:
print(max (list), '\n', sum(list)/len(list), '\n', (max (list))-(sum(list)/len(list)))
|
23fb49e73b64493f4bc8633126d1108b88c0602a | todaatsushi/python-data-structures-and-algorithms | /structures/stack.py | 400 | 4.0625 | 4 | """
Python implementation of a stack.
"""
class Stack:
def __init__(self):
self.vals = []
def put(self, new):
return self.vals.append(new)
def get(self):
return self.vals.pop()
def __str__(self):
return str(self.vals)
stack = Stack()
print(stack) # []
stack.put(1)
... |
8b1a7fe796253407369426497d169726cea830b0 | chanhosuh/algorithms | /graphs/depth_first_search/depth_first_search.py | 462 | 3.625 | 4 | class DepthFirstSearch(object):
def __init__(self, graph):
self.visited = [False] * graph.num_vertices
for v in graph.vertices:
if not self.visited[v]:
continue
self.search(v)
def search(self, vertex):
self.visited[vertex] = True
... |
2dfdcd2fc91bf9ef02a20119d44768a1a60f3a04 | hellion86/pythontutor-lessons | /5. Строки/Замена внутри фрагмента.py | 405 | 3.734375 | 4 | '''
Условие
Дана строка. Замените в этой строке все появления буквы h на букву H, кроме первого и последнего вхождения.
'''
s = input()
s1 = list(s[s.find('h')+1:s.rfind('h')])
for i in range(len(s1)):
if s1[i] == 'h':
s1[i] = s1[i].upper()
print(s[:s.find('h')+1]+''.join(s1)+s[s.rfind('h'):])
|
7cfc9f6bc8a6ecdb7e4ace5dc2461dba233cefaa | PacktPublishing/Python-Data-Science-with-AI-for-Beginners | /Chapter16/Exercise 23 Activation Functions/A1.py | 850 | 3.859375 | 4 | def get_y( f, x3 ):
return f(2*1+0.5*2+1.5*x3)
import numpy as np
def sigmoid(x):
return 1 / (1 + np.e ** (-x))
def tanh(x):
return 2 / (1 + np.e ** (-2*x)) - 1
def relu(x):
return 0 if x < 0 else x
get_y( sigmoid, -2 )
#The output is 0.5
get_y(sigmoid, -1)
#The output is 0.8175744761936437
get_y(sigmoid, 0)
#The out... |
98190a37da1521105729d8d53e2dcd71f113a1f2 | talavis/rosalind | /bioinformatics-stronghold/dna.py | 994 | 4.3125 | 4 | #!/usr/bin/env python3
'''
Problem
A string is simply an ordered collection of symbols selected from some alphabet and formed into a word; the length of a string is the number of symbols that it contains.
An example of a length 21 DNA string (whose alphabet contains the symbols 'A', 'C', 'G', and 'T') is "ATGCTTCAGAA... |
4288ca231e797a3d8f5fef141a486869e8eddf73 | zippyjake/python-1 | /review/dice | 657 | 3.734375 | 4 | #!/usr/bin/env python3
import random
import colors as c
dice=[]
dice.append(''' -------
| |
| o |
| |
-------''')
dice.append(''' -------
| o |
| |
| o |
-------''')
dice.append(''' -------
| o |
| o |
| o |
-------''')
dice.append(''' -------
| o o |
| |
| o ... |
dcbc7296618751c1b07c0e99f635dfed8f073dac | ibuscio/Python | /Temperaturas.py | 343 | 3.578125 | 4 |
def run(temps):
sum_of_temps = 0
for temp in temps:
sum_of_temps = sum_of_temps + temp
aux_average = float(sum_of_temps / len(temps))
return aux_average
if __name__=='__main__':
temps = [30, 31, 22, 20, 25]
average = run(temps)
print('La temperatura promedio ... |
79e18e7240473987d234f7856f9dff0de1aa926a | unikith/pythontest | /pigLatin.py | 547 | 3.90625 | 4 | #!/usr/bin/python
print "Input a word or name to translate to pig latin (or 0 to exit)"
initialWord = raw_input()
while (initialWord != '0') :
if(initialWord.isalpha()):
count = 0
while (count < len(initialWord) and initialWord[count] not in 'aeiou'):
count += 1
if (count == len(initialWord)):
print init... |
78f867c34ee8615244728b6d9ac9ef2df11a43b2 | sharyudongre/game | /main.py | 2,839 | 4.21875 | 4 |
#this is the link to the code on repl.it
https://repl.it/@sharyuDongre/game#main.py
# written code:
print("Welcome to the game!")
name=input("ENTER YOUR NAME : ")
print ("Hello ",name,"!")
age=int(input("ENTER YOUR AGE : "))
print("You are ", age,"years old.")
bonus=0
if age>18:
print("Congratulations!,you are eli... |
79c12e05e8b96d03011a8dc4b9bb62ad29230411 | mit308/Python | /number_guess/Number_guess.py | 1,112 | 4.3125 | 4 | # creating a random number generator
import random
def guess(x):
random_number = random.randint(1, x)
# print(random_number)
guess_1 = 0
while guess_1 != random_number:
guess_1 = int(input(f"Enter the guessing number between 1 to {x} "))
if guess_1 > random_number:
... |
d0eb3d8917f7f951ae92213cdf1edd7d960f77da | kushalppp/Python-Ass2 | /Q9.py | 367 | 3.921875 | 4 | #!/usr/bin/python3
print("Check if two No. sum between 15 to 20 return 20")
x=int(input("enter 1st No:-"))
y=int(input("enter 2nd No:-"))
c = x + y
if c>=15:
if c<=20:
c=20;
print(c)
Output:-
Check if two No. sum between 15 to 20 return 20
enter 1st No:-15
enter 2nd No:-4
20
Check if two No. sum between 15 to 20... |
111a4bde1d439c4a7517827bc53269aec894fd06 | pythongitproject/python-project | /basics/filter.py | 715 | 3.71875 | 4 | #coding=utf-8
#过滤序列/筛选
def is_odd(x):
return x % 2 ==1
#删掉偶数,只保留奇数
print(list(filter(is_odd,[1,5,69,7,8])))
#去掉序列中
def not_empty(s):
return s and s.strip()
print(list(filter(not_empty,['a','','b',None])))
def old_iters():
n = 1
while True:
n = n + 1
yield n
def fil... |
23aacf27a87f8c2406c26ed808bd6c20f9fd1154 | HJ1nitj/Practice-datasets | /predicting 1996 american election/predicting 1996 american election.py | 4,159 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 05 12:01:02 2018
@author: DELL
"""
#***************Importing the packages**********************
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import Logistic... |
d006519b08c46679770a5c0df5ea73a3bdb029be | Renato9889/Multithreaded | /robin.py | 1,071 | 3.765625 | 4 | #Renato Luiz de Almeida - Trabalho Pratico 2 de Sistemas Operacionais
processos = [5,2,4,6,7,8]
num1 = 5
quantum = 2
def filaround_robin_com_prioridade():
contadorfila = num1
frentefila = 1
while (contadorfila != 0):
while (processos[frentefila]<=0):
frentefila = frentefila + 1
... |
6c78af7d53bbb996f178da608408ff153441de59 | bennwei/Bioinformatic-algorithm | /peptide_encoding_2.py | 1,655 | 3.84375 | 4 |
def DNA_to_RNA(DNA_file):
"""Return dna string as rna string.
>>>DNA_to_RNA('CCGGAAGAGCTTACTTAG')
'CCGGAAGAGCUUACUUAG'
"""
DNA_seq = open(DNA_file)
DNA = DNA_seq.readline().strip()
RNA = DNA.replace('T', 'U')
return RNA
def make_codon_dictionary(filename):
codon_table = {}
w... |
fadfd4f1ee7ec136405ef8aa2237a166feefa68d | ida-code88/House-Price-Prediction-Kaggle-Competition | /house-price-prediction.py | 12,004 | 3.625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Exploratory Data Analysis (EDA)
# In[54]:
# Import libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
get_ipython().run_line_magic('matplotlib', 'inline')
import warnings
warnings.filterwarnings('ignore')
import math
f... |
53e01936e54cc4677daf221f02fb54f5d88e2b6a | oanapanduru/python-exercises | /transfer.py | 1,078 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 14 22:25:13 2020
@author: oanap
"""
#question =input('do you want to add money batches or you want to transfer money batches?')
#account = 0
#money = 0
question =input('do you want to add money batches or you want to transfer money batches?')
def transfer():
number ... |
8cfbb2e7a69f976e2c6e1f9bb4f14b7273d47994 | xXG4briel/CursoPythonGuanabara | /19 - Dicionários/Desafio 093.py | 698 | 3.5 | 4 | dicio = {}
soma = 0
dicio['nome'] = str(input('Nome do Jogador: '))
dicio['jogos'] = int(input('Quantos partidas jogou? '))
for x in range(dicio['jogos']):
if x == 0:
lista_gols = list(range(0,dicio['jogos']))
dicio['gols'] = lista_gols.copy()
dicio['gols'][x] = int(input(f'\tQuantos gols no jo... |
3b93e53aedca064fb6a71db829e3633543e71af5 | maryella/python_exercises | /while_loops/n_to_m.py | 139 | 3.625 | 4 |
# 2. n to m
# start = input("Start from: ")
# end = input("End on: ")
# i = int(start)
# while i <= int(end):
# print(i)
# i += 1
|
dfcf5b8a78c2a94dec13e1225cb788529a6032f6 | mstoiovici/module3 | /extra_work/unit_testing/functionalities.py | 286 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Jan 29 11:58:53 2019
@author: maria
"""
def add(x,y):
return x+y
def subtract(x,y):
return x-y
def multiply(x,y):
return x*y
def divide(x,y):
if y == 0:
raise ValueError("can not divide by zero!")
return x/y
|
63c699548cf0299b61212d9140f7680694c3e104 | theakers/Class5-Python-Module-Week5 | /society.py | 1,352 | 4.3125 | 4 | class Society:# I created the class Society
def __init__(self,society_name,house_no,no_of_members,income):#An __init__ method to assign initial values
self.society_name=society_name
self.house_no=house_no
self.no_of_members=no_of_members
self.income=income
def allocate_flat(... |
73b7af4319e2d1da9aaa06aff59ce2101ed8e1bf | Vagacoder/Codesignal | /python/Arcade/Core/C122BishopAndPawn.py | 1,561 | 3.984375 | 4 | #
# * Core 122. Bishop and Pawn
# * Given the positions of a white bishop and a black pawn on the standard chess
# * board, determine whether the bishop can capture the pawn in one move.
# The bishop has no restrictions in distance for each move, but is limited to
# diagonal movement. Check out the example below to ... |
c84db1c30eb1e92e463cef51e2e10ac2e129edda | sagarvns/pythonProject | /the day in the month.py | 335 | 4.25 | 4 | day = int(input("Enter the day"))
if day == 1:
print("Monday")
elif day == 2:
print("Tuesday")
elif day ==3:
print("wednesday")
elif day ==4:
print("Thrusday")
elif day ==5:
print("friday")
elif day == 6:
print("Saturday")
elif day ==7:
print("sunday")
else:
print("Please Enter the day b... |
486f69aa58d921642731bbae76500ce2f3391258 | fritogotlayed/Extended-UVA-Judge | /extended_uva_judge/languages.py | 1,671 | 3.671875 | 4 | """Module to assist with language standardization.
This module is to assist with mapping the problems submission language to a
language we can standardize against for the Judge code. For example: a user
could make a submission with "python", "py2" or "python2" as the language and
the judge will use "python2" as the su... |
e1a006024d1f419bf0f7b8a531ed8ca03ad9450f | techresidents/trsvcscore | /trsvcscore/service/handler/base.py | 1,078 | 3.5 | 4 | import abc
class Handler(object):
"""Handler abstract base class.
Services consist of one or more servers, which expose portions of the
service interface through one or more endpoints. Each server fulfills
the service interface through delegation to its Handler's.
"""
__metaclass__ = abc.ABCMe... |
1241f511e282f91c48f674ab6ded8a3f977232a9 | walkman097/python | /three.py | 539 | 3.6875 | 4 | #!/usr/bin/python3
age = 18
if age > 20:
print("age more than 18");
else:
print("age less than 18");
# 请打印出以下变量的值:
# n = 123
# f = 456.789
# s1 = 'Hello, world'
# s2 = 'Hello, \'Adam\''
# s3 = r'Hello, "Bart"'
# s4 = r'''Hello, Lisa!'''
n = 123
print(n);
f = 456.789
print(f)
s1 = 'Hello, world'
print(s1);
s2 = ... |
720f81c9dba4a84201b901fa6f4f1c2ee4655346 | kgy-idea-study/study | /python/python_base/python_base/DataType/String.py | 1,502 | 4.25 | 4 | #!/usr/bin/python3
# -*- coding: UTF-8 -
"""
String(字符串)
Python中的字符串用单引号(')或双引号(")括起来,同时使用反斜杠(\)转义特殊字符。
字符串的截取的语法格式如下:
变量[头下标:尾下标]
索引值以 0 为开始值,-1 为从末尾的开始位置。
加号 (+) 是字符串的连接符, 星号 (*) 表示复制当前字符串,紧跟的数字为复制的次数
"""
str = 'Runoob'
print(str) # 输出字符串
print(str[0:-1]) # 输出第一个到倒数第二个的所有字符
print(str[0]) # 输出字符串第一个字符
print(str[... |
d8b03a739c6992a4021df3bbe143c899f88ce9db | pimbi98/Python | /Udemy/AprendeAProgramarPythonConProyectos/7Bucles/71While.py | 1,203 | 4.125 | 4 | #Bucle while. Mientras se cumple condicion.
Cuenta = 5
while Cuenta > 0:
print(Cuenta) #Iteración.
Cuenta = Cuenta - 1
print("Despegue!!") #Fin.
#Bucle while. Mientras se cumple condicion. Pero aplicamos un break.
Cuenta = 5
while Cuenta > 0:
print(Cuenta) #Iteración.
if Cuenta == ... |
31a36ef0e3b8dfd7b6c2c9402b26731973c67f6d | lindabelle/textforgit | /leapyear.py | 263 | 3.671875 | 4 | a=int(input("Введите число дней в году: "))
if a%4!=0:
print("Обычный год")
elif a%100==0:
if a%400==0
print("Високосный")
else:
print("Обычный")
else:
print("Високосный")
|
541d39fe2f6ef9cc7f86284554fc10a7fe0d7678 | JamesMcPeek/Python-100-Days | /Day 2.py | 342 | 4.125 | 4 | print("Welcome to the tip calculator!")
billTotal = float(input("What is the total bill? "))
percTip = int(input("What percentage tip would you like to give? "))
people = int(input("How many people will split the bill? "))
results = round((billTotal * (1 + (percTip / 100))) / people,2)
print("Each person should pay: " ... |
92582e199045c37d0bf11ffc564deb37ca2f4c3e | GunjanPande/tutions-python3 | /14. String Methods/StringFunctions-2.py | 882 | 4.28125 | 4 | def main():
name = input("enter a string: ")
print(name) # harshit jaiswal
# always remember, in coding, couting starts from 0 and it is called
# variable_name[start_index: end_index + 1] will give a part of the complete string stored in the variable_name
first_name = name[0: 7]
print(fi... |
2238414b91d1c5b041ab627e1d611e3318ab5bee | HeepIO/HeepDev | /Device Creator/DeviceInfo.py | 975 | 3.5625 | 4 | from ControlInfo import ControlInfo
class DeviceInfo:
# Basic Info
deviceName = "Default"
numControls = 0
deviceSystem = "PC"
controlArr = []
def __init__(self):
return
def GetDeviceName(self) :
return raw_input('Enter device name: ')
def GetNumControls(self) :
numControlStr = raw_input('Enter numbe... |
a72543ec9034a7cf8f9d78fbd5e2ac583b8bfb02 | sedge0183/prideWeek | /changing_words.py | 1,711 | 3.734375 | 4 | import os
import time
# Global variable to hold all the colorus for the rainbow
# Red Orange? Yellow Green Blue Violet
colours = ["\033[91m", "\033[33m", "\033[93m", "\033[32m", "\033[34m", "\033[35m"]
def flag():
global colours # Use the global variable colours
line... |
2633d743d90e9e062acf5f177b8e59e4b059650e | Ron530/Projects | /Programming_scientific_applications/Monte-Carlo/lab3 python.py | 694 | 3.640625 | 4 | def throw_die():
import random
return random.randint(1,6)
money = 100
startMoney = money
n = 4
win = 0.0
j = 0.0
while money > 0:
j += 1
money -= 1
total = 0
for i in range(n):
total += throw_die()
if total < 9:
win += 1
money += 10
if j == 1000:
bre... |
16128c24100d03ed3779b3287bb2310a22a4fc9c | chaossky/python_ex | /for_statement.py | 138 | 3.578125 | 4 | words=['cat','dog','bird','zebra','fox','wolf','rat','sparrow','solar','lunar','tiger','lion','shark']
for w in words:
print(w,len(w)) |
af9392ccecf4699dea51a92c29cdc785381a1360 | swapnilnandedkar/Python-Assignment | /Assignment3/Assignment3_2.py | 659 | 4.25 | 4 | # 2.Write a program which accept N numbers from user and store it into List. Return Maximum
# number from that List.
# Input : Number of elements : 7
# Input Elements : 13 5 45 7 4 56 34
# Output : 56
import functools
def main():
List = []
print("Enter total number you want to insert in List... |
c2e1958b51be44fa9134753cf19fef8eca256fd1 | DuttaSejuti/HackerRank-Python | /runup.py | 181 | 3.65625 | 4 | f_name=str(input())
l_name=str(input())
f_len=length(f_name)
l_len=length(l_name)
if(f_len+l_len<=10):
print("Hello ",f_name," ",l_name,"!","You just delved into python")
|
2407841abb87e4e3f438c9ca3553528b8845a81a | imaana/PRAK-ASD | /Modul-6/Soal-8.py | 1,668 | 3.546875 | 4 | class Node():
def __init__(self, data, nextNode=None):
self.data = data
self.nextNode = nextNode
def cetak(head):
curr = head
while curr is not None:
try:
print (curr.data)
curr = curr.nextNode
except:
pass
a = Node(1)
b ... |
e0f4ce686e595354b343f4fc081941110fddbb0c | claudiomarpda/numerical_methods | /1.Introduction/lista01.py | 2,752 | 4 | 4 | '''
1. Introducao aos metodos numericos
Representacao de numeros em maquinas
Truncamento, arredondamento e erros
Propagacao de erros
'''
import math
def questao_15():
i = 1
soma = 0
for i in range(1, 1001):
soma = soma + (i * (i + 1))/2
print 'A soma da serie eh ' + str(soma)
# subprograma da questao 16
... |
bc0cda65acf5698d1dbf476796f3361b66178cff | halobrain/knode | /python/python/1-setup/5-Multi-Line-Statements.py | 547 | 3.8125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 13 19:56:38 2018
@author: star
"""
Statements in Python typically end with a new line. Python does, however, allow
the use of the line continuation character (\) to denote that the line should
continue. For example:
total = first_one + \
second_tw... |
31bab82a058e22009cafb1eb43fc421bba5eb801 | vpc20/leetcode-may-2020 | /FindAllNumbersDisappearedInArray.py | 1,185 | 3.84375 | 4 | # Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
#
# Find all the elements of [1, n] inclusive that do not appear in this array.
#
# Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra
# ... |
537224a250e118effc2b8d5250f4014f7fb61705 | 1oscar/dive-into-python-code | /plural.py | 528 | 3.734375 | 4 | # __author__ = 'dkf'
#-*- coding:utf-8 -*-
#IDE:Pycharm3.4.1
import re
def rules(language):
for line in file('D:\Project\python\dive into python\\rules.%s' % language):
pattern, search, replace = line.split()
yield lambda word: re.search(pattern, word) and re.sub(search, replace, word)
def plura... |
5284d588c8301810cf21ff69416d07090b61e99f | D4TI3C/iqbal-fitra-ramadhan-1144023 | /TUGAS/tugas1.py | 1,752 | 3.65625 | 4 | import time
print("Hitunglah ( a * b ) + ( c / d )")
print("=====================")
a = raw_input("Masukkan nilai a : ")
b = raw_input("Masukkan nilai b : ")
c = raw_input("Masukkan nilai c : ")
d = raw_input("Masukkan nilai d : ")
print("=====================")
t1 = time.time()
if a == 'satu':
... |
7b2fc9439f152e8f4a61b8bfc76fcd85fbc9d114 | e1810/kyopro | /ac/abc049/arc065_a/9339286.py | 173 | 3.5625 | 4 |
s = list(input());tmp = ""
t = ["maerd", "remaerd", "esare", "resare"]
while s:
tmp += s.pop()
if tmp in t: tmp = ""
if len(tmp)>=7: print("NO")
else: print("YES")
|
ac85eef97ca3fe668814e18e8e5ee60a1f13ba85 | vit-001/fget | /history.py | 1,184 | 3.609375 | 4 | __author__ = 'Nikitin'
class HistoryRecord():
def __init__(self, data=None, context=None):
self.data = data
self.context = context
def __repr__(self, *args, **kwargs):
return self.data.__repr__()
def __eq__(self, hr2):
return hr2.data == self.data
class HistoryException... |
7a177cd55724ecfa0272cfd5e2a9e4c45e376c6d | wagnersistemalima/Exercicios-Python-URI-Online-Judge-Problems---Contests | /Pacote Dawload/Projeto progamas Python/ex1079 Médias Ponderadas For.py | 308 | 3.59375 | 4 | casos = int(input())
peso1 = 2
peso2 = 3
peso3 = 5
soma_pesos = peso1 + peso2 + peso3
for c in range(1, casos + 1):
valor1, valor2, valor3 = map(float, input().split())
media_ponderada = ((valor1 * peso1) + (valor2 * peso2) + (valor3 * peso3)) / soma_pesos
print('{:.1f}'.format(media_ponderada)) |
e40ddd6f1858dfb0855ec455b4b72155e3f38a68 | tcw321/scifair_program_creator | /projects.py | 10,562 | 3.734375 | 4 | import unittest
# handle first and last names
# find teachers in second teacher list that does not equal primary teacher
# make that teacher's student first student and return with teacher, students and title
# Same with third student, fourth student
#
class Entries(object):
values = ""
results = []
de... |
6b38ea0fc2e35c43ba876a45da552b2fa005898c | keetsky/tensorflow_learn | /按功能分/tf_contrib_learn/Basic_usage_custom_model.py~ | 6,193 | 4.25 | 4 |
#%%Basic usage 采用自带模式
import tensorflow as tf
# NumPy is often used to load, manipulate and preprocess data.
import numpy as np
# Declare list of features. We only have one real-valued feature. There are many
# other types of columns that are more complicated and useful.
features = [tf.contrib.layers.real_valued_col... |
05cb5e04643efc8032360afc20216606b61734b8 | daniel-reich/ubiquitous-fiesta | /GP6cjzQ3xs9gJ8Q2b_15.py | 187 | 4.03125 | 4 |
def is_polydivisible(n):
num, d = n, 0
while num: #find number of digits
num //= 10
d += 1
while n:
if n % d:
return False
n //= 10
d -= 1
return True
|
373b4c016d98a096444949715ce696c516c46891 | Anirban2404/LeetCodePractice | /199_rightSideView.py | 2,803 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 4 15:32:11 2019
@author: anirban-mac
"""
"""
199. Binary Tree Right Side View
Given a binary tree, imagine yourself standing on the right side of it, return
the values of the nodes you can see ordered from top to bottom.
Example:
Input: [1,2,3... |
783a18bc687b0fbb8db8a95f5d18595e9d9cc660 | jayhebe/w3resource_exercises | /Basic - Part2/ex11.py | 205 | 3.515625 | 4 | x = [10, 20, 20, 20, 20]
y = [10, 20, 30, 40, 30]
z = [10, 30, 40, 20, 20]
target = 70
result = []
for a, b, c in zip(x, y, z):
if a + b + c == target:
result.append((a, b, c))
print(result)
|
7da8588e5cd609a14958a71ebdf0ecea6a70e18e | jercamadalina/python-codewars-exercises | /8kyu/to-square-root-or-not-to-square-root.py | 1,306 | 4.25 | 4 | from math import sqrt
def square_or_square_root(arr):
return list(map(lambda num: sqrt(num)
if has_integer_sqrt(num) else num**2, arr))
def has_integer_sqrt(num):
return int(sqrt(num)) == sqrt(num)
tests = [
[[4, 3, 9, 7, 2, 1], [2, 9, 3, 49, 4, 1]],
[[100, 101, 5, 5, 1, 1], [1... |
9b8249bacadb7953dd148b28091089b235f0d78d | mrinxx/Pycharm | /PDF 02-10/7.py | 631 | 3.953125 | 4 | #Usando un bucle while, mostrar en pantalla la serie: 1, 50, 3, 48, 5, 46, 7, 44...................., 0.
listapar=list(range(0,51,2)) #cojo una lista con los valores pares
listaimpar=list(range(1,50,2)) #cojo una lista con el rango de valores impares
listapar.reverse() #doy la vuelta a la lista
i=0 #inicializo una va... |
b3c97d0b6021489fc8bb93b1523df1f1c2c96741 | LuisAugusto0205/C-digos-python | /Python/Aulas/unb/aula15/B.py | 426 | 3.609375 | 4 | def main():
#leitura
n = int(input())
word = input()
print(solve(n, word))
def solve(n, word):
divs = divisores(n)
for d in divs:
word = word[0:d][::-1] + word[d:]
return word
def divisores(n):
lista_div = [1]
temp_div = 2
while lista_div[-1] < n:
if not... |
e7f0dce7f0d4324909f42b4fb8899de6f83763b8 | optionalg/programming-introduction | /Aula 11/ex_5.py | 2,632 | 3.90625 | 4 | """
Exercício 5
Autor: Lucien Constantino
"""
class City():
def __int__(self, code, passenger_cars, traffic_accidents_with_victim):
self.code = code
self.passenger_cars = passenger_cars
self.traffic_accidents_with_victim = traffic_accidents_with_victim
def __eq__(self, other):
... |
36528d66a14824279ae32e817206a64a8fd11426 | darklatiz/python-near-earth-prj | /cli/arg.py | 525 | 3.65625 | 4 | import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Say a simple greeting")
# required arguments
parser.add_argument("nombre", type=str)
parser.add_argument("edad", type=int)
# optional arguments
parser.add_argument("--pais", type=str, default="San Panchis... |
52ac9bdc1ad6ee1c6c5f0e242ce9ad3bb230dac8 | arturbs/Programacao_1 | /uni4/ljtg/desvio_padrao.py | 1,465 | 3.8125 | 4 | # coding: utf-8
# aluno: Artur Brito Souza
# matricula: 118210056
# UFCG - Programação 1 2018.2
# Programa : Desvio Padrão
import math
sequencia1 = raw_input()
sequencia2 = raw_input()
numero1 = ""
numero2 = ""
soma1 = 0
soma2 = 0
elevado1 = 0
elevado2 = 0
contador1 = 0
contador2 = 0
diferenca1 = 0
diferenca2 = ... |
5b92b64a0777365b196a35771091fc8218a6b3e9 | zubie7a/Algorithms | /HackerRank/Algorithms/02_Implementation/15_Find_Digits.py | 327 | 3.78125 | 4 | # https://www.hackerrank.com/challenges/find-digits
t = int(raw_input())
# Check by how many of its digits (sans 0) can a number
# be divided evenly.
for _ in xrange(t):
number, count = raw_input(), 0
for digit in number:
if int(digit) != 0:
count += (int(number) % int(digit) == 0)
print... |
97bb6fde818b39ebf8121e45da1ba562ab736fde | trohit/interviewkickstart | /trees/basic_tree_ops.py | 5,850 | 3.765625 | 4 | from collections import deque
# For debugging
import time
#-----
# Define Node class
#-----
class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
def __repr__(self):
return str(self.val)
#-----
# DFT - recursive
#-----
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.