blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
799c1906da15ac1d452f3795901ac8c494769920 | shlee16/cit_shl | /20200722/variable.py | 363 | 3.65625 | 4 | santa = 80
rudolph = "giuliani"
print(santa +100)
print("rudolph" * 5)
santa = 800
print(santa)
name = "ryan"
print("Today's Diary by " + name )
print(name + " ate pancakes for morning")
print(name + " was not hungry")
print("Martha said Hi to " + name)
print(name + " got A+ on his exam.")
santa = santa + 300
santa... |
0497750dca9db0e6bb2f55a9790aee5f1b571a6f | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4144/codes/1800_2567.py | 151 | 3.75 | 4 | from numpy import *
a = int(input("digite o nro.: "))
for i in range(a):
print((a-i)*"*")
i = i - 1
for i in range(a+1):
print(i*"*")
i = i +1
|
8d3a345bbec06324517deb4c46e6c397c66af302 | FreeFlyXiaoMa/personal_project | /re_/test1.py | 1,006 | 3.734375 | 4 | #!/usr/bin/env python # -*- coding: utf-8 -*-
# @Author : Ma
# @Time : 2021/1/2 17:45
# @File : test1.py
# Input='aabcdbefgde'
#
# child_list=[]
# for i in range(len(Input)-1):
# for j in range(i+1,len(Input)):
# child_list.append(Input[i:j+1])
#
# list1=[]
# for k in child_list:
# if len(k) ==... |
9040f5ce7cd2c5061bd64eda2f1382957698c4f7 | vanch1n1/SoftUni-programming-projects-and-exercises | /Python-programming-fundamentals/functions_lecture/calcualte_reactangle_area.py | 186 | 3.890625 | 4 | def calculate_rectangle_area(width, height):
area = int(width * height)
return area
width = int(input())
height = int(input())
print(calculate_rectangle_area(width, height)) |
fdfb999efb42ecd020cb699359e30e7632a2de0e | Gijsbertk/afvinkblok1 | /5.21.py | 672 | 3.84375 | 4 | import random #importeert library
print('Je doet steen papier schaar, voor steen kies je 1 voor papier 2 en schaar 3') #print wat je moet doen
def main():
game() #roept functie aan
def game(): #functie
speler = int(input('Kies een nummer voor steen papier schaar: ')) #vraagt om functie
comp = random.ra... |
4de920758b2a75cf658d4e298a6fa07cfa9527d8 | Buorn/FDC | /Lista 2/L2_EX_5.py | 477 | 3.859375 | 4 | # -*- coding: cp1252 -*-
#UNIVERSIDADE DO ESTADO DO RIO DE JANEIRO - UERJ
#BRUNO BANDEIRA BRANDO
#LISTA 2: FUNDAMENTOS DA COMPURAO 2018/2
#EXERCCIO 5
a = float (input ('Digite a primeira nota:'))
b = float (input ('Digite a segunda nota:'))
c = float (input ('Digite a terceira nota:'))
m = (a + b + c)/3
dif = ... |
8cf589d07f34ad6667e76428b5810550128d6e55 | GitXuY/data_analysis | /DataAnalysis/generate_dict.py | 221 | 3.578125 | 4 | # from itertools import zip
column = 1
column_name = []
while column !=199:
column_name.append(column)
column += 1
column_name2 = column_name
# print column2
zipped = zip(column_name, column_name2)
print(dict(zipped)) |
9e481265d0b9f5e87b861038752627063830dc83 | rolisz/examenfp | /213/UI/console.py | 371 | 3.734375 | 4 | __author__ = 'Roland'
def getNr(text="Dati un numar",max = 0):
while True:
try:
nr = int(input())
if nr not in range(1,max) and max != 0 :
print("Trebuie sa alegeti una din optiunile date")
else:
return nr
except TypeError:
... |
098ab54c7fb1fca74d2135a2b547c8cf7ced8c60 | SneakBug8/Python-tasks | /nod.py | 291 | 3.734375 | 4 | # Наименьшее общее кратное WIP
n1 = int(input())
n2 = int(input())
n = 0
while n==0:
t1=n1%n2
if t1==0:
if n1>n2:
print(n1)
elif n2>n1:
print(n2)
break
elif n1>n2:
n1=t1
elif n2>n1:
n2=t1
|
d6ac8a418ed26be6ca5bc4b57a6936457a8e6feb | Samie-mirghani/Python-Graphics | /Project 4.pyw | 4,978 | 4.3125 | 4 | #Project 4.pyw
#Shamsadean Mirghani
#This program will ask the user two draw two triangles and colors the
#the larger one red and will display the area under the triangles
#Where ever they are plotted
from graphics import *
import math
# Function to find the distance between two points
def distance(p1,p2):
x1= p1.... |
22a57dfde9ead8c1a8d60a3b54f134e245e95870 | pavelneda/Lab2 | /task2_6.py | 1,642 | 3.703125 | 4 | class Node:
price=[]
def __init__(self, data,quantity):
self.left = None
self.right = None
self.data = data
self.quantity=quantity
def set_price(self,*prices):
Node.price.append(None)
for price in prices:
if not(isinstance(price,(int,float)) and pr... |
fcd9c69701372c6b66e0588e41ab6f9f7259d567 | mixterjim/Learn | /Python/Basics/16 Subclass.py | 424 | 3.609375 | 4 | class Animal(object):
def run(self):
print('Animal is runing...')
Animal().run()
class Dog(Animal): # Inherit form Animal
def run(self):
print('Dog is running...')
Dog().run()
class Cat(Animal):
def run(self):
print('Cat is running...')
def sleep(self):
print('Ca... |
ed2cf23aa4585706fd4176bc51ba1851d0d37a1f | swang2000/BinaryTree | /reverselevelordertraversal.py | 1,060 | 4.09375 | 4 | '''
Reverse Level Order Traversal
2.4
We have discussed level order traversal of a post in previous post. The idea is to print last level first, then second
last level, and so on. Like Level order traversal, every level is printed from left to right.
Example Tree
Example Tree
Reverse Level order traversal of the abov... |
146ccd212b13b9061cf16303166f0b55f8f21908 | LXYykdf/ichw | /pyassign2/currency.py | 4,555 | 4.09375 | 4 | '''
currency.py:
Module for currency exchange
This module provides several string parsing functions to implement a
simple currency exchange routine using an online currency service.
The primary function in this module is exchange.
Returns: amount of currency received in the given exchange.
__author__=... |
c3228b54787ee6ba20de92d89ad475123bec3fa2 | rmopia/tokenize-parse-stackmachine | /stack_machine.py | 2,822 | 3.6875 | 4 | class StackMachine:
def __init__(self):
self.stack = []
self.currentLine = 0 # numerical iterator used during driver program
self.lst = [None] * 15 # empty list that will be used during the save and get functions
def push(self, value):
self.stack.append(int(value)) # string 'val... |
cc759059428814b9ebedefe4a2fdc45446b81fea | PedroPaAl/EjerciciosPyPedro | /5.Ejercicios Ficheros/Ficheros 2.py | 242 | 3.71875 | 4 | prompt = '> '
print("Introduzca un numero")
numero = int(input(prompt))
try:
f = open("tabla-%d.txt"%numero, "r")
for i in range(11):
print(f.readline())
f.close()
except IOError:
print("El archivo no existe") |
cd3566af2cdde0776ba9709754d9252d3c6b7ac3 | Akshat111999/Python | /GUI/labels.py | 256 | 4.09375 | 4 | from tkinter import *
root = Tk() #creates a root window
Label(root, text="First Label").pack() #.pack() method is used to organise the blocks in rows and columns
root.mainloop() # it is an infinite loop and this method is used to run the application
|
ed39c3cba97c3652f9e94383135ef590bca343e5 | robertoweller/GUI-Chess-Implementation-in-Python | /Data_Conversion/difference_for_letter.py | 326 | 3.828125 | 4 | '''
This is to convert letters to numbers when calculations occur
'''
dictionar_of_letters_to_numbers = {
'a': 1, 'b': 2, 'c': 3, 'd':4, 'e': 5, 'f': 6, 'g':7, 'h': 8
}
'''
This is to save the corrdinates of where the user pressed, in order
to promote the pawn to the correct piece
'''
promotion_piece ... |
30a2a5110947d77e08fe7f2aef644af5b887a72d | liangqiding/python-milestone | /04高级特性/2迭代.py | 324 | 3.9375 | 4 | # 迭代
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
print(key)
# 判断是否可迭代
from collections.abc import Iterable
print('判断是否可迭代:',isinstance(d, Iterable) )
# Python内置的enumerate函数可以把一个list变成索引-元素对
for i, value in enumerate(['A', 'B', 'C']):
print(i, value)
|
14a355ed3fc9f249ad2668e12d4ad3278fafaa92 | karma-19/Algorithm-Visulizers | /bubblesort_visualizer.py | 1,872 | 4 | 4 | import pygame, sys, random
""" PYGAME PRACTICE
PROJECT NAME : BUBBLE SORT VISUALIZER
CREATED ON 08/21/2020 """
pygame.init()
#screen window
WIDTH = 800
HEIGHT = 600
screen = pygame.display.set_mode((WIDTH , HEIGHT))
#caption
pygame.display.set_caption('BUBBLE SORT - PRAVEEN VISHWAKARMA ')
#icon
#... |
e33dda0d91628fcb0a7b5202695ce52ac02cfff1 | vovo1234/pepelats | /games/tiltedtowers/town.py | 3,355 | 3.859375 | 4 |
import turtle
def draw_house_anya( x, y, size, house_color, roof_color, door_color ):
# Move turtle to where we want to draw
turtle.up( )
turtle.setpos( x - size / 2.0, y )
turtle.setheading( 0 )
turtle.down( )
# draw box
turtle.color( house_color )
turtle.begin_fill()
for x in ra... |
2057806d53f725f04a31d73929804535e97e2d26 | cunyu1943/python-programming-instance | /src/4.py | 890 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @version : 1.0
# @Time : 2021/3/31 19:30
# @Author : cunyu
# @Email : 747731461@qq.com
# @Site : https://cunyu1943.site
# 公众号 : 村雨遥
# @File : 4.py
# @Software: PyCharm
# @Desc : 练习实例4
if __name__ == '__main__':
list1 = [31, 28, 31, 30, 31, 30, 31, 3... |
e5a5ce550e9273ecde8f143880cfad55f1461aa9 | HuebnerC/DSIassignments | /DSI/OOP_pair_assigment.py | 4,177 | 3.796875 | 4 | from fractions import Fraction
class Polynomial():
# from fractions import Fraction
def __init__(self, lst):
self.lst = lst
self.degree = len(lst) - 1
def __repr__(self):
return f'Polynomial({self.lst})'
def __str__(self):
poly_lst = []
pol_st... |
3c7c38312ec37f7308c092b5f5291ca842598ed9 | nishantchaudhary12/Leet_Code | /Python/437_pathSumIII.py | 1,227 | 3.78125 | 4 | '''You are given a binary tree in which each node contains an integer value.
Find the number of paths that sum to a given value.
The path does not need to start or end at the root or a leaf, but it must go downwards (traveling only from parent nodes to child nodes).
The tree has no more than 1,000 nodes and the valu... |
07c203e961cfad85d42fb87433c20cb7ff10ff40 | rexshang/hackerrank | /apple_and_orange.py | 644 | 3.53125 | 4 | '''
Created on Nov 8, 2016
@author: erexsha
'''
#!/bin/python
import sys
def count_fruit(s, t, tree, fruit):
count = 0
for i in fruit:
dist = i + tree
if dist >= s and dist <= t:
count = count + 1
return count
s,t = raw_input().strip().split(' ')
s,t = [... |
4800e5d119ca9e1dfbf52b248f867939d0abd7e6 | camalot2011/data-science | /Python/py4e/Assignment3_3.py | 330 | 4.0625 | 4 | # Printing scores
score = input("Enter Score:")
try:
sc = float(score)
if sc>=0.9:
grade = "A"
elif sc>=0.8:
grade = "B"
elif sc>=0.7:
grade = "C"
elif sc>=0.6:
grade = "D"
elif sc<0.6:
grade = "F"
print(grade)
except:
print("Score is out of... |
ca4779d7a2281d1c6ab3a85f33817a77ac35fbff | vuminhdiep/c4t--20 | /session1/session2/session7/capitalize_print.py | 113 | 3.828125 | 4 | items = ["Sport", "LOL", "BTS", "Death Note", "Netflix"]
for i in range(len(items)):
print(items[i].upper())
|
1d874547a537f0f13457b71182d7a6224bccd42d | harshi93/jupyterNotebooks | /Python-Practice/30-days-of-code/bubble-sort.py | 543 | 4.28125 | 4 | array = [8,5,2,9,5,6,3]
def bubbleSort(array):
# Write your code here.
array_length = len(array) - 1
for i in range(0, array_length):
j = i + 1
item1 = array[i]
item2 = array[j]
swapped = False
if (item1 > item2):
array[i] = item2
array[j... |
22c4f6423784c80714d0910323a02831ba379782 | RyanHiatt/Becca_HW | /HW4/HW4b-stem.py | 4,038 | 4.125 | 4 | import numpy as np
import matplotlib.pyplot as pyplot
from scipy import linalg
from math import *
def RSquared(x, y, a):
'''
To calculate the R**2 value for a set of x,y data and a LeastSquares fit with polynomial having coefficients a
:param x:
:param y:
:param a:
:return:
'''
AvgY = ... |
6bfd62a136462c01f5f28fa402b4abec0f42e7c6 | germandouce/AyP-1 | /Parciales/2021-C1-P1/ejercicio3 hecho en clase por franco.py | 4,981 | 4.125 | 4 |
MENU = {
"Baguette Clásica": 250,
"Baguette Rellena": 350,
"Baguette Vegana": 250,
"Baguette con Muzzarella (a la pizza)": 500,
"Merlot": 300,
"Vin rosé": 300,
"Borgoña blanc": 550
}
def altaCliente(clientes, dni_cliente):
nombre = input("Ingrese su nombre: ")
apellido = input("In... |
fa78f4896abe6dbf6999d1cb51ce47f4b6020c6e | Francisco-Galeano/Programming | /FG-09-03/exc3.py | 706 | 3.734375 | 4 | def devolver_mayor(numero_1, numero_2):
if numero_1 > numero_2:
return numero_1
else:
return numero_2
numero_1 = int(input("Ingrese el 1er numero: "))
numero_2 = int(input("Ingrese el 2do numero: "))
print(devolver_mayor(numero_1, numero_2))
def pueder_votar(edad):
if edad >= 16:
return True
... |
f6ba15e82314dae05524291cea4e42a9e57825bc | eeeeegor/Personal-expense-manager | /interface.py | 2,304 | 4.0625 | 4 | import banking
def get_month(month_number):
months = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
return months[month_number - 1]
def check_month_year_validness(date):
year = int(date[:4])
month = int(date[5... |
095591dfb167bb0ea8371d07b5bf3798e54bfcc9 | hugechuanqi/Algorithms-and-Data-Structures | /other_code_programe/04.python实现一个二叉树类.py | 771 | 3.625 | 4 | class Tree:
def __init__(self, val = '#', left = None, right = None):
self.val = val
self.left = left
self.right = right
#前序构建二叉树
def FrontBuildTree(self):
temp = input('Please Input: ')
node = Tree(temp)
if(temp != '#'):
node.left = self.FrontBu... |
2e442e3dd9e9ef80c18517946c4d6ac82db7c795 | ave2407/CourseraPythonProjects | /week2/while/artist_splitter.py | 817 | 4.34375 | 4 | """Исполнитель “Раздвоитель” преобразует натуральные числа.
У него есть две команды:
“Вычесть 1” и “Разделить на 2”, первая команда уменьшает число на 1
, вторая команда уменьшает число в два раза, если оно чётное
Напишите алгоритм для Раздвоителя, который преобразует число A в число B
и при этом содержит минимальн... |
4ae13f978c1df2460f345d947dc43e3b80200235 | mikuna-xe/AoC_2019 | /Day3.py | 3,640 | 3.5625 | 4 | #!/usr/bin/env python3
def main():
# Day 3
with open('AoC_input.txt', 'r') as f:
input_str = f.readlines()
wire0 = input_str[0].strip().split(',')
wire1 = input_str[1].strip().split(',')
dir0 = []
dir1 = []
dist0 = []
dist1 = []
for cmd in wire0:
dir0.append(cmd[0]... |
1ad2a8231048522495c0bcbf23b9d310013d8c93 | osspuddles/py_course | /listsRangesTuples/listsRangesTuples2.py | 362 | 4.21875 | 4 | # #!/usr/bin/python3
#
# list_1 = []
# list_2 = list()
#
# print("List 1: {}".format(list_1))
# print("List 2: {}".format(list_2))
#
# if list_1 == list_2:
# print("The lists are equal.")
# else:
# print("The lists are not equal")
#
# print(list("The lists are equal"))
even = [2, 4, 6, 8]
another_even = even
a... |
4fd5b0dbf682654f4b35ca56e3cbfda3588b99e0 | AngryGrizzlyBear/PythonCrashCourseRedux | /Part 1/Ch.11 Testing Your Code/Testing A Class/Try_it_yourself_2.py | 575 | 4.0625 | 4 | # 11-3. Employee: Write a class called Employee. The __init__() method should
# take in a first name, a last name, and an annual salary, and store each of these
# as attributes. Write a method called give_raise() that adds $5000 to the
# annual salary by default but also accepts a different raise amount.
# Write a test... |
b63c786a919f9c4e3ef480328078a30b3f613880 | VictorSega/toxic-substances-ship | /Domain/User.py | 834 | 3.53125 | 4 | import sqlite3
import hashlib
conn = sqlite3.connect('Navio.db')
def InsertUser(username, password):
encodedPassword = hashlib.sha1(password.encode()).hexdigest()
cursor = conn.cursor()
cursor.execute(f"INSERT INTO User (Username, Password) VALUES ('{username}', '{encodedPassword}');")
conn.comm... |
9d04bf5d26eb6be518f268ed0ace39cc0117cbd3 | DonatasNoreika/7paskaita | /main.py | 531 | 3.75 | 4 | class Irasas:
def __init__(self, suma):
self.suma = suma
class PajamuIrasas(Irasas):
pass
class IslaiduIrasas(Irasas):
pass
biudzetas = []
irasas1 = PajamuIrasas(2000)
irasas2 = IslaiduIrasas(20)
irasas3 = IslaiduIrasas(10)
biudzetas.append(irasas1)
biudzetas.append(irasas2)
biudzetas.append(iras... |
59507422158111de630884c9f7d0819f7f397cf1 | micahwar/Project-Euler | /37.py | 944 | 3.828125 | 4 | import math
#Truncatable Primes
def isPrime(n):
if n == 2: return True
if (n % 2) == 0 or n == 1:
return False
y = 3
while y*y <= n:
if (n % y) == 0:
return False
y = y + 2
return True
def isTruncatable(n):
n = str(n)
return isTruncat... |
0e3bcfd8097f9ca228b7b98a2c62cd80512bcd57 | manoznp/LearnPython-Challenge | /DAY4/homework1.py | 1,314 | 3.78125 | 4 | # Write the function that calculate the discount amount and discount %, and profit of an item.
def DiscountAmount():
return MP - SP
def DiscountPercentage():
return (DiscountAmount() / MP) * 100
def ProfitAmount():
return SP - AP
def ProfitPercentage():
return (ProfitAmount() / AP) * 100
def switch(... |
d0fc3cf5aea42fcfa34fae1d382a6c002b07c1cc | shiraz19-meet/yl1201718 | /lab 4/lab4.py | 861 | 3.890625 | 4 | #class Animal(object):
# def __init__(self,sound,name,age,favorite_color):
# self.sound = sound
# self.name = name
# self.age = age
# self.favorite_color = favorite_color
# def eat(self,food):
# print("yummy!!"+ self.name + "is eating" +food)
# def description(self):
# print(self.name + "is " + self.age +" years ... |
4d1fa3c2aacd6f114ef411b9f9ca7abf1768d7a1 | mrdc1790/python-_-recap-_beginner-concepts | /tutorials/recaps/newModules -easy02/08-regularExpressions-additionalSyntax-02.py | 1,311 | 4.34375 | 4 | import re
catOr = re.search(r'cat|dog', 'The cat is here') ## '|' stands for OR. very versatile
periodWild = re.findall(r'..at', 'The cat in the hat went splat.') ## '.' stands for an arbitrary value/wildcard, spaces mess it up
print(catOr)
print(periodWild)
beginsWith = re.findall(r'^\d', '1 is a number') ##the carr... |
c1a7efd88b1c449916f7db70c49bcaad553f7fb1 | hebe3456/algorithm010 | /Week02/144.二叉树的前序遍历.py | 1,100 | 3.609375 | 4 | #
# @lc app=leetcode.cn id=144 lang=python3
#
# [144] 二叉树的前序遍历
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def preorderTraversal(self, root: TreeNode) -> List[i... |
a204cb2e8c4e6d2204740ccbc33cbcb06faa527b | thankew/BTVN_Python | /pythonProject2/BTVN_Buoi17/hh.py | 1,901 | 3.90625 | 4 | class people:
full_name = ""
phone = []
email = []
address = ""
note = ""
tags = []
def __init__(self, full_name, phone, email, address, note, tags):
self.full_name = full_name
self.phone = phone
self.email = email
self.address = address
self.note = n... |
07c9cbadb58598318b5bcade2640fc851fddb20a | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4011/codes/1635_2445.py | 199 | 3.703125 | 4 | e = input("Qual e a escala esta representada(C/F)? ")
t = int(input("Qual e a temperatura? "))
if (e == "C"):
F = (1.8 * t) + 32
print(round(F, 2))
else:
C = (5 / 9) * (t- 32)
print(round(C, 2)) |
1f4b5751a4761cf366f680dd430012c488ddb0d6 | InnocentSuta/python_bootcamp | /week_4_List & Loops/while_loops.py | 422 | 4.28125 | 4 |
health = 5
while health > 0:
print(health)
health -= 1 # forgetting this line will result in infinite loop
# using two or more loops together is called a nested loop
for i in range(2): # outside loop
for j in range(3): # inside loop
print( i, j )
sentinel = input("Enter quit to exit: ")... |
7cca5cbc6d4594267807d5123bcd3730c4fc64d9 | christianesl/python-workspace | /Advanced Funtions/LongestCharSequence.py | 450 | 3.65625 | 4 | def method(input):
charS = ''
previous = ''
maxS = 0
dict1 = {}
for itr in input:
if(previous == itr):
dict1[itr] = dict1[itr] + 1
if(dict1[char] > maxS):
maxS = dict1[char]
charS = char
else:
dict1.clear()
... |
1793f50d87eb2d80f998a0103d2e8ad77dfb06d5 | CoderKn1ght/Algorithm-Implementations | /CH5_Bit_Manipulation/q3_longest_sequence_of_ones.py | 755 | 3.71875 | 4 | from CH5_Bit_Manipulation.basic_bit_functions import get_nth_bit
number = 0b11110111011001000000
# not solved
print(bin(number))
start_index = 0
current_index = 0
zero_index = 0
longest = 0
flag = False
while number != 0:
nth_bit = get_nth_bit(number,0)
if nth_bit == 0:
if flag == False:
... |
fc15631fb41b441e7089c12c7a8877ee38fc68c1 | MihailTr/learningPythonSD | /m2l43.py | 234 | 3.671875 | 4 | a = []
nun = int(input("Введите число:"))
coun = 0
for i in range(nun):
if i == 0:
i += 3
if i % 2 == 0 and i % 3 == 0:
a.append(i)
elif i % 2 == 1 and i % 7 == 0:
a.append(i)
print(a)
|
b09d083bd2449e156a1736a89b0b2d3107694fd0 | computerMoMo/ForMyOffer | /pythonCode/robotMovingCount.py | 1,571 | 3.625 | 4 | # -*- coding:utf-8 -*-
class Solution:
def getDigitSum(self, number):
total_sum = 0
while number//10 > 0:
total_sum += number % 10
number = number//10
total_sum += number
return total_sum
def movingCount(self, threshold, rows, cols):
# write code ... |
a71fec95e07d36b7ebfa6ea556a3c974dc6c32b0 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/3135/codes/1646_87.py | 143 | 3.90625 | 4 | p=int(input("Insira o primeiro numero:"))
s=int(input("Insira o segundo numero:"))
t=int(input("Insira o terceiro numero:"))
print(min(p,s,t)) |
5f6259212fcad9087d0886239e25c4ef2a339c07 | gshruti015/pyLab | /lab3/Gupta_Shruti_3.1.py | 2,958 | 4.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# Exercise 1.
# ```
# A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT, and RIGHT with a given steps. The trace of robot movement is shown as the following:
# UP 7
# DOWN 5 LEFT 2 RIGHT 9 X
# The numbers after the direction ... |
512f98e1fe76066662c7c0ff9962a2c8fd470806 | garyholiday-umich/Connect-Four-Python-Coding-Challenge | /connect_four.py | 42,539 | 4.0625 | 4 | import random
class player:
def __init__(self, playername, playernum):
self.playername = playername
self.playernum = playernum
def getname(self):
"""This returns my username"""
return self.playername
def getnum(self):
"""This returns the number I am that game - 1 o... |
b8999109342be0f5aa9c8ddb8d582ba8f070707e | NH1922/Arithematic-Game | /main.py | 2,525 | 4.125 | 4 | # simple maths game
import random
import time
# Function to generate expressions
def generate_expression(no_of_operators):
operations = ['+', '-', '*', '/']
expression = []
expression.append(random.randint(0, 20))
for _ in range(no_of_operators):
expression.append(random.choice(operations))
... |
0b8333949d8b4a32573cd24b8c83cedd9585e25e | pancham2016/ScubaAdventure | /bubble.py | 1,042 | 3.921875 | 4 | import pygame
from pygame.sprite import Sprite
class Bubble(Sprite):
"""A class that manages bubbles released from the diver."""
def __init__(self, sa_game):
"""create a bubble object at the diver's current position."""
super().__init__()
self.screen = sa_game.screen
self.setti... |
7209d2d72d91bf7ed11ca0731d36409d3e65cc73 | xCraudin/ORUS-RPG | /ORUS_RPG.py | 69,994 | 4 | 4 | import random
import time
print("╔══════════════════════════════════════════════════════════════════╗")
print("║ SEJA BEM-VINDO AO MUNDO DE ORUS! ║")
print("║ Aqui você encontrará uma aventura muito imersante e desafiadora! ║")
print("╚═════════════════════════════════════════════... |
9ef756df9f9b18607b42121f9500007f9bcbaf64 | johngarrett/hackCOVID | /src/Grid.py | 3,283 | 4 | 4 | import math
import random
from Desk import Desk
"""
Grids are laid out so that the origin is the top left corner of the office/map/etc.
"""
class Grid:
def __init__(self,
height: int,
length: int,
desk_x: float = 1.0,
desk_y: float = 1.0,
... |
670a2f69fb144ba21c9cdb6fd5ac94a93127a1ea | jbial/daily-coding | /dailycoding053.py | 1,431 | 4.125 | 4 | """
This problem was asked by Apple.
Implement a queue using two stacks. Recall that a queue is a FIFO
(first-in, first-out) data structure with the following methods:
enqueue, which inserts an element into the queue, and dequeue, which removes it.
Solution:
Continually push elements to the first stack for the enqueu... |
0751a3a070add3c4cc6b95de450567cfbc4af975 | patcoet/Advent-of-Code | /2017/03/1.py | 1,342 | 3.828125 | 4 | # Given a number, returns the layer it's on (starting at 0)
def layer(x):
for i in range(x):
# Layer i contains numbers ((2*(i-1) + 1)^2 + 1) to ((2*i + 1)^2)
if (i*2 + 1)**2 >= x:
return i
# Given a layer, returns the smallest number in it
def smallest(layer):
if layer == 0:
return 1
else:
... |
8be6d9e8ecc8f2570e34e638a35e901fdb1fec99 | li-mo-feng/Python | /PythonProjects/面试宝典/字符串操作.py | 302 | 3.984375 | 4 | i='name'
print(i.startswith('m'))
# 判断是否以XX开头并返回结果
print(i.endswith('e'))
# 判断是否以XX结尾并返回结果
print(i.replace('a','f'))
# 字符串内容替换
print(i.split('a'))
# 以a字符进行分割
print(i[2])
# 输出字符串的第三个字符
print(i.index('m'))
|
2bdbdbf76f7b0f99c4cc3dee93958406b168002e | mjjin1214/algorithm | /190218_binary_search.py | 424 | 3.625 | 4 | import sys
sys.stdin = open('input.txt', 'r')
data = list(map(int, input().split()))
def binary(list_x, x):
start, end = 0, len(list_x)-1
while end < start:
mid = (start + end) // 2
if list_x[mid] == x:
return mid
else:
if list_x[mid] > x:
end ... |
62631c6595a2731b08bf5852876d8b0da628bdf2 | AgenttiX/random | /gmail_filter.py | 2,369 | 3.578125 | 4 | """
This is a simple program to create Gmail compatible domain filters (for spam etc.)
Created by Mika "AgenttiX" Mäki, 2016
"""
filename = "domains.txt"
class Spam:
def __init__(self):
self.__domainlist = []
def readfile(self):
""" Reads the domains from a predetermined file """
try... |
62de955cf09f62705fa81b2156f9f2c296d52f6d | ReethP/Kattis-Solutions | /heliocentric.py | 370 | 3.5 | 4 | while True:
try:
for i in range(0,10):
earth, mars = input().split()
earth = int(earth)
mars = int(mars)
totaldays = 0
while(earth != mars):
earth = earth+1
mars = mars+1
totaldays = totaldays+1
if(earth == 365):
earth = 0
if(mars == 687):
mars = 0
print("Case",i+1,... |
121d2e8a922eb9c5cb66a4bbbd39f835440d7b40 | childe/leetcode | /diagonal-traverse/solution.py | 1,741 | 4.25 | 4 | # -*- coding: utf-8 -*-
'''
https://leetcode-cn.com/problems/diagonal-traverse/
Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.
Example:
Input:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
Output: [1,2,4,7,5,3,6,8,9]
Explan... |
5d315cee74ec974ca84729e60201f206a868a056 | huangyuzhen/let | /94/walk.py | 3,006 | 3.953125 | 4 | # Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def walk(self, root, result):
if root:
self.walk(root.left, result)
result.append(root.val)
... |
b203919789491ec16d9d3030ef29ebab9333dbb5 | RSnoad/Python-Problems | /Problem 15.py | 556 | 4 | 4 | # Find the number of possible routes from top left to bottom right for an n x n grid, only by moving right or down.
from math import factorial
# Use Binomial coefficient formula for n choose r = n! / (r! = (n-r)!)
# Our n = 2 * size of grid as this is the total number of choices we need to make to reach the end.
# Our... |
930a4506ff79a4ffd61cf60de746a85552bd9678 | igorprati/python_modulo | /codelabs02/desafio01.py | 1,158 | 3.828125 | 4 | # Declaração de variável
listaCand = ['José', 'Inácio', 'Tião', 'Severino', 'Branco', 'Nulo'] # lista dos possíveis votos
contador = 0
jose = inacio = tiao = severino = branco = nulo = 0 # contador de votos para cada canditato
continuarVoto = 'S' # laço while
print('Essa é a lista dos candidatos: \n') # mostra a list... |
2d5baf701e4e6d2ee01a8afbc0834312bde25321 | kumarshyam7777/CorePythonPrograms | /dictionary_methods.py | 1,573 | 4.25 | 4 | dict = {
1: 2,
'name': 'shyam',
'profession': 'Python Programmer',
list: [20, 40, 60, 80]
}
print(type(dict))
print(dict.keys()) # Prints the key of the Dictionary
print(type(dict.keys()))
print(list(dict.keys())) # Covertys the dict_keys to list
print(tuple(dict.keys())) # Converts the dict_keys to... |
6e4ce4f5050d85e7187432c737fe91489f0466d5 | Roshanbagla/Leetcode | /palindrome.py | 249 | 4.3125 | 4 | """An Integer is a palindrome."""
def isPalindrome(number):
"""To check if an integer is a palindrome."""
reverse = number[::-1]
if number == reverse:
return True
return False
number = input()
print(isPalindrome(number))
|
94e333af34ce9e5ee1356b690f4330ae251d4882 | krzaladin/FlappyBirdWorkShop | /FlappyBird4.py | 3,100 | 4 | 4 | #we first import pygame library
import pygame
#to use the random feature
import random
#initialize pygame
pygame.init()
#define colors
black = (0, 0, 0)
white = (255, 255, 255)
blue = (135, 206, 250)
purple = (186, 85, 211)
#define new color 'green'
green = (0, 255, 0)
#define new color 'red'
red = ... |
181a504290fcc2ea5284c97c4c2f24364c8bb6a1 | andresouzaesilva/Python | /calculadora.py | 1,625 | 3.984375 | 4 | from tkinter import *
from tkinter import ttk
janela=Tk()
# função soma
def soma():
num1=float(num1Entry.get())
num2=float(num2Entry.get())
lb["text"] = num1 + num2
#função subtração
def sub():
num1=float(num1Entry.get())
num2=float(num2Entry.get())
lb["text"] = num1 - num2
... |
dbd17fd9e651995bbd3944b54b5d52e171edf6d3 | nordap/BOJ | /1157_1.py | 573 | 3.5 | 4 | if __name__ == "__main__":
s = input()
s = s.upper()
d = dict()
#for i in upper_s:
# if i in d.keys():
# d[i] += 1
# else:
# d[i] = 1
for i in range(ord('A'),ord('Z')+1):
d[chr(i)] = s.count(chr(i))
chk = 0
max_key = '0'
max_... |
2b56fbf7bab995396f0b4a41c46ccdd42b65b436 | chrishuan9/codecademy | /python/16Stats-4.py | 324 | 3.734375 | 4 | def main():
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
print_grades(grades)
print grades_sum(grades)
def print_grades(grades):
for grade in grades:
print grade
def grades_sum(scores):
total = 0
for grade in scores:
total+=grade
return total
if __name__ == "__main__":
mai... |
b051ab283c5361e92127b17d2b691c1b9d97ec57 | mgorgei/codeeval | /Hard/c113 Multiply Lists.py | 892 | 4.1875 | 4 | '''MULTIPLY LISTS
You have 2 lists of positive integers. Write a program which multiplies
corresponding elements in these lists.
INPUT SAMPLE:
Your program should accept as its first argument a path to a filename. Input
example is the following
9 0 6 | 15 14 9
5 | 8
13 4 15 1 15 5 | 1 4 15 14 8 2
The lists are sepa... |
de06f091462df5462f6ddc73acd3f5bf9ed8e112 | AlexisDongMariano/leetcode | /1021 - Remove Outermost Parenthesis.py | 2,114 | 3.875 | 4 | # ==============================
# Information
# ==============================
# Title: 1021 - Remove Outermost Parenthesis
# Link: https://leetcode.com/problems/remove-outermost-parentheses/
# Difficulty: Easy
# Language: Python
# Problem:
# A valid parentheses string is either empty (""), "(" + A + ")", or... |
65f655c56882674f489b3e5259821e287be94725 | AtulSinghBankoti/DataStructure-And-Algorithms | /Problems/src/hackerRank/mars-exploration.py | 492 | 3.5625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the marsExploration function below.
def marsExploration(s):
c = 'SOS'
p = 0
res = 0
for i in s:
if i != c[p]:
print(f'c: {c}')
print(f'i: {i}')
res += 1
if p == len(c... |
bc65632ca68071fa04950834c2fea02ecb287b18 | djmar33/python_work | /ex/ex10/10.1.6.py | 589 | 4 | 4 | #10.1.6包含一百万位大型的文件
#文件赋值给变量filename;
filename = 'pi_million_digits.txt'
#使用open打开文件,并且将内容对象存储到变量file_object中;
with open(filename) as file_object:
#readlines()从文件中读取每一行,并存储在一个列表中;
lines = file_object.readlines()
pi_string = ''
#for循环导出每一行数字;
for line in lines:
pi_string += line.strip()
... |
0786bc92e2e1941132043d73953093e8c4ac486f | xxwqlee/pylearn | /hdd/day2.py | 2,273 | 4.375 | 4 | """
控制结构练习:
1.选择结构:三角形面积周长
2.循环结构:判断素数、最大公约数和最小公倍数
"""
import math
class Triangle:
def __init__(self, a, b, c):
if a + b > c and a + c > b and b + c > a:
self.a = a
self.b = b
self.c = c
else:
print('不能构成三角形')
def perimeter(self):
... |
3e616cd04c6971dace16788680d08dc03a981674 | felpssc/Python-Desafios | /Lista 4/ex006.py | 222 | 4.03125 | 4 | n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro número: '))
if n1 == n2:
print('Números iguais!')
elif n1 > n2:
print('Primeiro número é maior!')
else:
print('Segundo número é maior!') |
5e3f39aaa2141faf231879bee37657bdaa3d40bb | alexsomai/tensorflow-getting-started | /basic-classification.py | 2,581 | 3.546875 | 4 | # Fashion MNIST basic classification https://www.tensorflow.org/tutorials/keras/basic_classification
# TensorFlow and tf.keras
import tensorflow as tf
from tensorflow import keras
# Helper libraries
import numpy as np
import matplotlib.pyplot as plt
# Could use either fashion_mnist or mnist dataset
fashion_mnist = k... |
861e7b840110ce7a458eb360b7232f19591a20cc | smwelisson/Exercicio_CeV | /18 - Listas 2 - 84 a 89/86.py | 672 | 3.875 | 4 | matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for l in range(3):
for c in range(3):
matriz[l][c] = int(input(f"Digite um numero para [{l}, {c}]: "))
for l in range(3):
for c in range(3):
print(f"[ {matriz[l][c]:^5} ]", end="")
print()
# n1 = 0
# for x1 in range(3):
# n2 = 0
# for x2... |
77e927126fd90e2e8deb4b2d57fc45134562e69b | zachard/python-parent | /hello_python/chapter05/if_condition_test.py | 3,160 | 4.5 | 4 |
# 每条if语句的核心都是一个值为True或False的表达式, 这种表达式被称为条件测试.
# 如果条件测试的值为True, Python就执行紧跟在if语句后面的代码;
# 如果为False, Python就忽略这些代码.
# 条件测试-检查是否相等
car = 'bmw'
print(car == 'bmw')
car = 'audi'
print(car == 'bmw')
# 条件测试-检查是否相等时区分大小写
# 两个大小写不同的值会被视为不相等
print('\n')
car = 'audi'
print('当前车品牌是否为audi: ')
print(car == 'audi')
print('当前车品牌是否... |
72a2ba7e035e1a572e405db9f65f5f0c500f9c4f | maggishaggy/SequenceClusterScripts | /SummarizeOrthoMCLResults.py | 17,681 | 3.765625 | 4 | #!/usr/local/bin/python
#Created on 2/12/13
__author__ = 'Juan Ugalde'
import sys
from collections import defaultdict
#This are functions involved in reading files
def read_genome_list(input_file):
"""
Function used to read the genome list. The output is a dictionary with the genome list (fasta_prefix -> n... |
2f93ad5428bc39fad30c3f2aa451e8096a8bb802 | NikitaInozemtsev/python-practice | /Additional tasks/practice_1/naive_mul/naive_mul.py | 161 | 3.796875 | 4 |
def naive_mul(x, y):
if x == 0 or y == 0:
return 0
r = x
for i in range(0, y - 1):
x = x + r
return x
print(naive_mul(10, 15)) |
49bf980ed31d590ee0c7a9e3fc3c7e6c0b65579d | sincerehwh/Python | /Grammer/3.Container/set.py | 919 | 4.09375 | 4 | '''
- 无序
- 不重复
'''
# 自动去重:C++内是有序的,python中是无序的
new_set = set([1,2,3,4,4,1111,4,4,5,5,6])
new_set2 = set([11,22,33,44,45,1111,45,45,55,56,66])
print(type(new_set))
print(new_set)
print(type(new_set2))
print(new_set2)
# 判断元素是否存在
print(1 in new_set)
print("" in new_set2)
# 并集
print(new_set | new_set2)
print(new... |
0159ac54bb7e62ac300655de8402ad94320fd302 | Sai-Ram-Adidela/hackerrank | /challenges/itertools/iterables_and_iterators.py | 568 | 3.6875 | 4 | """
Title : Iterables and Iterators
Subdomain : HackerRank/Python/Challenges/itertools
Domain : Python
Author : Sai Ram Adidela
Created : 09 May 2018
"""
from itertools import combinations
if __name__ == '__main__':
N = int(input())
s = input().split()
k = int(input())
count, tot... |
21e2b1ebae411b274be607a5e726ec84198c9303 | brandoni27/PythonClassScripts | /P38_FindTheLongestWord.py | 612 | 4.34375 | 4 | # FindTheLongestWord.py
# Brandon Washington
# 5/22/2019
# Python 3.6
# Description: Finds the longest word in a list and counts the number of characters.
words = ['one','two','three','four','five']
longest = words[0]
for i in range(1,len(words),1):
if len(words[i]) > len(longest):
longest = words[i]
print... |
41e246acfc95073ea71c4fcd3cdb71f26a8c85f3 | ody1205/Daily-Coding | /Leetcode/top_100_liked_problems/7.py | 960 | 4.03125 | 4 | '''
7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, ... |
0d7968c72617cb23a589bf2a16caad4ea9e8fa42 | sharda2001/Function | /STRONG_NO_.py | 306 | 3.953125 | 4 | def Strongnum(n):
a=n
sum=0
while n>0:
i=1
f=1
b=n%10
while i<=b:
f=f*i
i=i+1
sum=sum+f
n=n//10
if a==sum:
print("strong num")
else:
print("not strong num")
n=int(input("enter number"))
Strongnum(n) |
1a059e4f8bfa13728c1889fbbca927b5abd9a9e0 | Ggayane/adventofcode-answers | /python/day-1.py | 353 | 3.546875 | 4 | inputFile = __file__.replace('py', 'txt')
def getInput(fileName):
with open(fileName) as f:
return f.readline()
def captchaCalc():
sum = 0
input = getInput(inputFile)
input += input[0]
for i in range(len(input) - 1):
if input[i] == input[i+1]:
sum += int(input[i])
r... |
d52a63426988b85fb6d01d5a6e4a864f366c23e2 | 77rui77/lianxipython | /多分支结构.py | 230 | 3.671875 | 4 | s=int(input('请输入成绩:'))
if 90<=s<=100:
print('A')
elif 80<=s<90:
print('B')
elif 70<=s<80:
print('C')
elif 60<=s<70:
print('D')
elif 0<=s<60:
print('不及格')
else:
print('请输入有效成绩') |
024c86353f8d912b140be4f070f8450baae98330 | ryansocha03/Pathfinder | /node.py | 3,128 | 3.84375 | 4 | '''Class file for the graph nodes'''
import sys
import pygame
pygame.init()
class node(object):
def __init__(self, row, col):
self.row = row #Contains the row of the node in the grid
self.col = col #Contains the column of the row in the grid
self.isWall = F... |
8e66b85de76179e4c3330c8a7cc46d62fe036da4 | da-ferreira/uri-online-judge | /uri/1357.py | 1,336 | 3.578125 | 4 |
number_to_braille = {
1: '*.....',
2: '*.*...',
3: '**....',
4: '**.*..',
5: '*..*..',
6: '***...',
7: '****..',
8: '*.**..',
9: '.**...',
0: '.***..'
}
braille_to_number = {
'*.....': '1',
'*.*...': '2',
'**....': '3',
'**.*..': '4',
'*..... |
7f07e6cc592a3ddbc4d22fd6decfb8ef32d5b19c | IvayloValkov/Python-the-beginning | /Simple_Solutions/07_house_painting.py | 381 | 3.65625 | 4 | x = float(input())
y = float(input())
h = float(input())
front_back_walls = (x * x) * 2
door = 1.2 * 2
side_walls = (x * y) * 2
windows = (1.5 * 1.5) * 2
roof = ((x * h) / 2) * 2 + side_walls
total_house = (front_back_walls - door) + (side_walls - windows)
green_paint = total_house / 3.4
red_paint = roof / ... |
0ab1b2fb67f4f2ca98a95fc410ffccd44c513ebc | ngocminhdao88/tdms2uff | /treeitem.py | 5,110 | 4.0625 | 4 | # Ngoc Minh Dao
# minhdao.ngoc@linamar
class TreeItem(object):
def __init__(self, data, parent=None):
"""
Each TreeItem is constructed with a list of data and an optional parent
"""
self._childItems = []
self._itemData = data #list
self._parentItem = parent
... |
719688f57a7fe9c0e0b56e0a379d21f44281699a | StHagel/CSE415_Assignments | /Assignment_5/sthagel_VI.py | 4,363 | 3.625 | 4 | """sthagel_VI.py
Value Iteration for Markov Decision Processes.
"""
from math import fabs
# Edit the returned name to ensure you get credit for the assignment.
def student_name():
return "Hagel, Stephan" # For an autograder.
Vkplus1 = {}
Q_Values_Dict = {}
Policy = {}
def one_step_of_VI(S... |
d3eb414f1519abc12b857e001bd20c3753971edd | pombredanne/poodle-lex | /Generator/Common.py | 562 | 3.875 | 4 | def lower_nullable(text):
"""
None-safe version of 'str.lower'
@param text: the text to convert to lower-case
"""
if text is None:
return None
return text.lower()
def compare_nullable_icase(lhs, rhs):
"""
None-safe case-insensitive comparison
@param lhs: an... |
fea32404df791ba919992ae2d53dca705870dcc5 | phani653/fresh-water | /clg_programs/python/linkedList.py | 1,126 | 3.78125 | 4 | '''
https://jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/
'''
class Node:
def __init__(self,data):
self.data= data;
self.next= None;
class LinkedList:
def __init__(self):
self.head= None;
def insertAtbe... |
57d97523f4a9ec1a9ae003ca4703aa038e1044c2 | rianayar/Python-Projects | /Girls Code Inc./Complimenter.py | 320 | 3.890625 | 4 | import random
compliments = ["You're Awesome!", "I think you are great!", "Keep being you!"]
wantsCompliment = input("Would you like to be complimented? Please type 'T' or 'F' \n")
if wantsCompliment == 'T':
print(compliments[random.randint(0,len(compliments)-1)])
else:
print('You chose not to be complimented.') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.