blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
9f41f1caca9d3393efade64830af320ec93d192d | eclipse-ib/Software-University-Entry-Module | /Programing_Basics_with_Python/6 While Loop/Lab/7-Най-малко_число.py | 205 | 3.578125 | 4 | min_num = 9223372036854775808
while True:
number = input()
if number == "Stop":
break
if int(number) < min_num:
min_num = int(number)
else:
continue
print(min_num)
|
9333029314fd52436b31d9d84258a36c3769d19a | eclipse-ib/Software-University-Entry-Module | /Programing_Basics_with_Python/2 Conditional Statements/More/2D_rectangle_area.py | 222 | 3.78125 | 4 | import math
x1 = float(input())
y1 = float(input())
x2 = float(input())
y2 = float(input())
a = abs(x1-x2)
b = abs(y1-y2)
area = math.floor(a*b)
to_int = int(area)
perimeter = math.floor(2*a + 2*b)
print(area, perimeter) |
1587d794f50377d300312b7c145eff07d89592aa | eclipse-ib/Software-University-Entry-Module | /Programing_Basics_with_Python/1 - First Steps in Coding/7-Пазар_за_плодове.py | 685 | 3.921875 | 4 | strawberries_price = float(input())
bananas_quantity = float(input())
oranges_quantity = float(input())
raspberries_quantity = float(input())
strawberries_quantity = float(input())
price_raspberries = strawberries_price * 0.5
price_oranges = price_raspberries * 0.6
price_bananas = price_raspberries * 0.2
final_price_... |
6766e61024ca6c4d9bd17d4422ef11897a120f57 | arrenfaroreuchiha/ciclos | /ciclo6.py | 592 | 3.859375 | 4 | # -*- coding: utf-8 -*-
print "numeros impares y el promedio"
i = 1
impar = 0
numero = int(raw_input("cantidad de numeros: "))
impar2 = 0
vector = []
for i in range (numero):
numero2 = int(raw_input("numero: "))
contador = numero2
contador = numero2 % 2
if contador > 0:
impar = impar + numero2
else:
vector.a... |
4c49a4d7d43ddd0ab4fc0dfe63744c3cf165dcab | arrenfaroreuchiha/ciclos | /vector.py | 736 | 4.03125 | 4 | # -*- coding: utf-8 -*-
print "un vector"
lista = []
matriz = []
def entra():
cantidad = int(raw_input("cantida de numeros:"))
return procesa(cantidad)
def procesa(cantidad):
for i in range(cantidad):
numero = int(raw_input("cual es el numero:"))
lista.insert(i, numero)
for i in range(2):
matriz.append... |
cc553025ba9f436a605d598d4c74127a4bac4356 | simmsb/rewriting-aqa-spec-code | /original.py | 15,834 | 4 | 4 | # Skeleton Program code for the AQA COMP1 Summer 2015 examination
# this code should be used in conjunction with the Preliminary Material
# written by the AQA COMP1 Programmer Team
# developed in the Python 3.4 programming environment
import sys
import re
from itertools import groupby
BOARDDIMENSION = 8
DEBUG = Fals... |
de45f8fbccd4d188e79561497ffa32665795fb88 | SSJ1Joey/PDXCGLabs | /atm.py | 1,674 | 3.859375 | 4 |
class atm:
def __init__(self, balance = 0, history = []):
self.balance = balance
self.history = history
def check_balance(self):
return self.balance
def deposit(self, amount):
self.balance += amount
self.history.append(f'You deposited ${amoun... |
7280aae58a96bc8afe9b0bb60455d37c3d0569e7 | SSJ1Joey/PDXCGLabs | /number_phrase.py | 1,580 | 3.96875 | 4 | low_nums = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
teens = ['elevin', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
tens = ['twenty-', 'thirty-', 'forty-', 'fifty-', 'sixty-', 'seventy-', 'eighty-', 'ninety-']
def spell():
... |
076cd61d60e8d2ecb3e4d5a0b2a18048fe5c800a | UWSEDS/homework-2-python-functions-and-modules-agesak | /pronto_checks.py | 696 | 3.6875 | 4 | import pandas as pd
def read_in_data(url):
df = pd.read_csv(url)
return df
def test_create_dataframe(df, cols):
conditions = []
# Does the dataframe contain only cols?
conditions.append(list(df) == cols)
# Do the values in each column have the same python type?
col_typ... |
63a70635dbfdc0bb79ca8eb8c115381028532f97 | SMathewsMMC/myProject | /Slow_Sort_Random_Ints.py | 1,523 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
Program Name: Slow_Sort_Random_Int.py
Writen by: Sean Mathews
Date: 18 October 2020
Synopsis: This will make a list of random ints and then sort them by comparing the next value in teh index and then move it to the order that it should be in. It repeats thi... |
f50bb5b09447b63a54a644c36570e12e0b3c9b43 | Jason30102212/python_basics_refresher | /5.WorkingWithNumbers.py | 737 | 4.25 | 4 | # 5.WorkingWithNumbers
number = 5.234
print(number)
number = number + 10
print(number)
#
print(3 * 4 + 5) # Multiplication then addition
print(3 * (4 + 5)) # Addition then multiplication
# Modular
print(10 % 3) # Remainder of division
# Convert to string
print(str(number))
# print(number + " and String"). # Erro... |
8ca8f8e1f00ab13925bd6e33d72126c4f53d4eea | JaiKumar7/Lab4 | /task2.py | 1,099 | 3.875 | 4 | import string
def clean_book(fileName):
''' opens book and return list of cleaned words '''
f1 = open(fileName)
book = f1.read()
tempBook = book.lower()
cleanBook = ''
for letter in tempBook:
if letter not in string.punctuation:
cleanBook += letter
words = cleanBook.split()
return words
def... |
0b1b8dc72204b8d32db868d159d908ad74fada5c | louis0121/consensus | /test.py | 128 | 3.71875 | 4 | #!/usr/bin/env python3
import time, os
for i in range(5, 25, 1):
print('i:', i)
while True:
time.sleep(3)
pass
|
a5b68ffeacc0f619578fe0583ff6b76eafe26ffe | frozenjava/infested | /Game/src/Infested.py | 2,281 | 3.75 | 4 | #
# Infested.py
# Josh Artuso
# 06/02/2015
#
# This is my first attempt at creating a game with PyGame
#
import pygame
import Player
# VARIABLES
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
def main():
"""
The Main function
:return:
"""
# Initialize pygame
pygame.init()
... |
c62b357770f3b94288b5e1a0fc5620d6c0788867 | ByronJayJee/katas | /pascals_triangle/pascal_triangle.py | 406 | 3.5 | 4 | def triangle(n):
if(n<1):
return []
p_arr=[]
p_arrl=0
for x in range(1,n+1):
p_arrl += x
for y in range(0,x):
out=0
if(y==0 or y==(x-1)):
out=1
else:
coor=p_arrl - (2*x) + y + 1
out = p_arr[coor-... |
a8927b4114c509defdc098d40bcdc29d2b9c30d7 | JaredMoca/EjerciciosPython3_JaredMontes | /Tarea_2/Tarea_2_Jared_Montes.py | 1,201 | 3.5625 | 4 | import re
regex = r"(^[a-zA-Z_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
def check(email):
if (re.search(regex, email)):
print("valido Email")
else:
print("incalido email")
regex1 = '^\d{10}|\(\d{2,3}\)\d{7,8}|\(\d{2,3}\)[-\s]??\d{3,4}[-\s]??\d{4}$'
def telephone(phone):
if (re.match(reg... |
d6b3c3a8759a162418c7b98c6d11060a23f2ddaa | anitanavgurukul/ifelsepython | /perfect no.py | 156 | 3.859375 | 4 | a=int(input("enter the number"))
b=int(input("sum of proper divisor"))
if a%b==0:
print("perfect number")
else:
print("not perfect number")
|
c50d12db2c9af07019f8f77fe449a8d1e6a16984 | anitanavgurukul/ifelsepython | /que10.py | 177 | 3.75 | 4 | # varx=int(input("enter the number"))
# vary=int(input("enter the number"))
# if varx%vary==0:
# print("divisible hai")
# else:
# print("divisible nahi hai")
|
cede83f2701f68ce6f68d0f24126bfccc24c46fc | anitanavgurukul/ifelsepython | /que2.py | 119 | 3.734375 | 4 | num_1=100
num_2=33
num_3=55
if num_1-num_2==num_3:
print("barabar hai")
else:
print("barabar nahi hai") |
5298fbfde39a0c7ed73b42e264a1ade528017442 | anitanavgurukul/ifelsepython | /que11.py | 141 | 4.03125 | 4 | a=int(input(" enter the number"))
b=int(input(" enter the number"))
if a>b:
print("greatest is",'a')
else:
print("greatest is",'b') |
9430d0cb4d9a287d1af23a9266a2e4adea358c81 | Raghavkhandelwal7/atm-thing-made-better-with-improvements- | /atm.py | 1,785 | 4 | 4 | class Atm():
def __init__(self,atmCardNum,pinNum):
self.atmCardNum=atmCardNum
self.pinNum=pinNum
def BankAtmCardNum(self):
return self.atmCardNum
def BankPinNum(self):
return self.pinNum
balance=1000000
#All the empty print's are for leaving a line of space so that... |
b108ebb9d70a7fb74ded43116ae07b52caa03f09 | nesarasr/Optimisation-And-Heuristic-Methods--IM31012-IM39003 | /TermProject/SA_Class.py | 4,203 | 3.71875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 6 11:32:19 2021
@author: nesarasr
"""
"""
SIMULATED ANNEALING CLASS
"""
import numpy as np
class SA:
# initializes the required paramers
def __init__(self,df,D,K,N,PIC,rT,rD):
self.df = df
self.D = D
se... |
f27e98d2cd04796eb9c9a0859dfc6b0581e0ff30 | janavarro95/Python-iDTech-Cryptography | /FakeVirusProgram/Viruses/VirusProgram.py | 5,290 | 3.734375 | 4 | import random;
import path; #User defined library to assist in doing C# Path functionality.
"""YOU: Are not allowed to edit/modify/hack/cheat your way around this file whatsoever.
You may look at it for reference as an idea for what is happening but you can't change anything here.
"""
class Virus(object):
... |
28b1130646f9ae240bfbeff70659e6b57e186145 | janavarro95/Python-iDTech-Cryptography | /ImageProgram/ImageUtilities.py | 6,437 | 4.09375 | 4 | #Image Utilities
from PIL import Image;
from Color import Color;
import random;
#Notes, the (0,0) position of an image is the upper left hand corner.
def createPNGImage(mode,width,height,Color):
"""
Create a new png image with the given width, height and color for the whole image.
"""
ret... |
badd696a38aafe5ef12ea4c937102cc177c52759 | janavarro95/Python-iDTech-Cryptography | /FakeVirusProgram/Viruses/path.py | 1,990 | 3.859375 | 4 | import os;
from os import listdir
from os.path import isfile, join
def combine(path, value):
"""
Combine the path, C# style
Params:
path<string>: The base path to append to.
value<string>: The path to append to the base path.
"""
return path+"/"+value;
def createDirect... |
718fd30bdf19b0ca75bd76af423aa0746c390b12 | ZayX0/training-at-its-finest | /ex_04_06.py | 363 | 3.9375 | 4 | hrs = input("How many hours did you work: ")
h = float(hrs)
pay = input("What is your payrate: ")
p = float(pay)
def computepay(payamount, hours):
OThours = hours - 40
OTpay = payamount * 1.5
OTamount = OTpay * OThours
TotalOTWage = (40 * payamount) + OTamount
return TotalOTWage
if h > 40:
pri... |
53136710fcf980ef9c16c934ac12e8688e6228c3 | Shamsher-Desai/Data_Log | /File-Handling.py | 716 | 4.0625 | 4 | # Data_Log
Python Program for File-Handling: Data Logging is Used to add an information of Visitors visited in hospital or Reception
Name = input("Enter a name of visitor: \n")
Phone_Number = int(input("Enter a Contact Number of Visitor: \n"))
Place_From = input("Visitor Address: \n")
Body_Temp = int(input("Enter Bo... |
2ed13aa72d42ccc421577ae254c6d87349f6eb55 | travistang/AI-playground | /snake.py | 1,878 | 3.5 | 4 | from random import sample,choice
from collections import deque
from enum import Enum
class GridType(Enum):
SPACE = 0
FOOD = 1
SNAKE = 2
HEAD = 3
class Direction(Enum):
UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3
class Snake(object):
def __init__(self,size,max_food,min_food):
self.h... |
397ce79ad11842c46751a0e18ce0def946f3381e | krimsz/python-workshop-features | /_3_iterables/packing_unpacking.py | 1,208 | 4.09375 | 4 | import itertools
a_list = list(range(5))
print("------------Zipping------------")
another_list = [str(element) for element in reversed(a_list)]
zip_list = list(zip(a_list, another_list))
print("Zipped list with another list {0}".format(zip_list))
print("------------Cartesian Product------------")
vals = ['2', '3', '... |
78d1aaa609a6ef3686ab180e21ff342f1ec9746d | krimsz/python-workshop-features | /_3_iterables/accesing_iterables.py | 514 | 3.8125 | 4 | a_list = list(range(23))
print("The list: {0}".format(a_list))
# By index
print("Index: {0}".format(a_list[4]))
# By negative index
print("Negative index: {0}".format(a_list[-1]))
# Slicing
print("By slice [1:5]: {0}".format(a_list[1:5]))
print("By slice [:5]: {0}".format(a_list[:5]))
print("By slice [5:]: {0}".for... |
629bf7fa7e085fa3cb503871e741a5939ff61630 | RellRex/Sword-for-offer-with-python-2.7 | /test14_反转链表.py | 782 | 4.125 | 4 | # -*- coding: utf-8 -*-
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# 返回ListNode
def ReverseList(self, pHead):
# write code here
if pHead is None:
return None
elif pHead.next is None:
... |
e1397ef592ea5294f0572e99f31a21c9ba6b4bbc | RellRex/Sword-for-offer-with-python-2.7 | /test57_二叉树的下一个结点.py | 997 | 3.75 | 4 | # -*- coding: utf-8 -*-
# 我的方法是首先去寻找了树的根结点
# 进行中序遍历,然后输出结果
# class TreeLinkNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# self.next = None
class Solution:
def __init__(self):
self.lst=[]
def GetNext(s... |
c620861159a7619ea8e57074897c475f77c2da24 | RellRex/Sword-for-offer-with-python-2.7 | /test50_重复数组中的数字.py | 516 | 3.65625 | 4 | # -*- coding: utf-8 -*-
class Solution:
# 这里要特别注意~找到任意重复的一个值并赋值到duplication[0]
# 函数返回True/False
def duplicate(self, numbers, duplication):
# write code here
lst=[]
for i in numbers:
if i in lst:
duplication[0]=i
return True
... |
a11386a4876ad16e9260b72e14282d6a961df8a3 | RellRex/Sword-for-offer-with-python-2.7 | /test25_复杂链表复制.py | 1,368 | 3.828125 | 4 | # -*- coding: utf-8 -*-
# 思路:
# 1.在旧的链表中创建新的链表
# 2.根据旧的链表,初始化新的链表
# 3.拆分新的链表
class RandomListNode:
def __init__(self, x):
self.label = x
self.next = None
self.random = None
class Solution:
# 返回 RandomListNode
def Clone(self, pHead):
# write code here
... |
628e298f16c6e96ef227fd5955513ba673af9b14 | RellRex/Sword-for-offer-with-python-2.7 | /test19_顺时针打印矩阵.py | 1,089 | 3.9375 | 4 | # -*- coding: utf-8 -*-
class Solution:
def __init__(self):
self.lst=[]
# matrix类型为二维列表,需要返回列表
def printMatrix(self, matrix):
# write code here
n,m=len(matrix)-1,len(matrix[0])-1
if n==1:
self.lst.extend(matrix[0])
self.lst.extend... |
54ed2d27b017bd1f5c44dfb1d5fddf63bac25f9a | RellRex/Sword-for-offer-with-python-2.7 | /test39_平衡二叉树.py | 1,572 | 3.5625 | 4 | # -*- coding: utf-8 -*-
# 平衡二叉树:一棵空树或者左右两个子树的高度差的绝对值不超过1
# 统计左右两棵子树的深度,进行比较
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def IsBalanced_Solution(self, pRoot):
# write code here
if pRoot is ... |
9885b2a816a25453c21ff9749d66cd72f730cd36 | RellRex/Sword-for-offer-with-python-2.7 | /test31_整数中1出现的次数.py | 775 | 3.640625 | 4 | # -*- coding: utf-8 -*-
# python默认的最大递归深度为998
# 这里我们可以自定义最大递归深度
import sys
sys.setrecursionlimit(30000)
class Solution:
def NumberOf1Between1AndN_Solution(self, n):
# write code here
def sub_count(f,i):
if i>n:
return f
count=self.count_1(i)
... |
6cc8b07138b418809e923d0820f98111ed3ea1f2 | rAndrewNichol/oldrepo | /Python/monty_hall/monty_hall.py | 619 | 3.640625 | 4 | #monty_hall.py
import random
def gen_doors():
doors = [0,1,2]
car = random.randrange(3)
doors[car] = "Car"
goats = list(range(3))
del goats[car]
for i in goats:
doors[i] = "Goat"
return doors
def random_play(doors = ["Goat","Car","Goat"], switch = True):
goats = [... |
b29bbe69edede0d750f127c62698da9ea693465a | jaehunro/boardgame-rl | /rl/agent.py | 7,880 | 3.78125 | 4 | """Reinforcement learning agent."""
import numpy as np
import json
import sys
class Agent(object):
"""Agent is the reinforcement learning agent that learns optimal state action pairs."""
def __init__(self, game, qtable=dict(), player='X', learning_rate=5e-1, discount=9e-1, epsilon=5e-1):
"""Initiali... |
9b7e3bfdace551c2f6866c83aa350053049f0b29 | ghostinlinux/Inventory-Management-System | /AddingProduct.py | 884 | 3.6875 | 4 | import json
read_data= open("Project/record.json",'r')
final_data = read_data.read()
read_data.close
final_rec = json.loads(final_data)
print(f"Your current Product >>>> \n\n {final_rec}")
print("\n")
print("\n")
# Adding Product
item_count = int(input("How many item you want to add >> "))
for i in range(item_count)... |
509f47ab4ef4cb3fdd8a02e4bea84d8f4c52ccba | weiziyoung/RSA_CLIENT | /client.py | 3,531 | 3.546875 | 4 | # -*- coding: utf-8 -*-
# @Time : 07/01/2019 23:38
# @Author : weiziyang
# @FileName: client.py
# @Software: PyCharm
from tkinter import *
from socket import *
def encode(string, e, n):
ciphertext = ''
for each in string:
num = ord(each)
temp = num ** e % n
code = str(temp).zfill(... |
fd7d70d94e112bb157b80391e0d93740864ebc24 | irBiss/PrometheusPython | /Python/31.py | 1,294 | 3.984375 | 4 | import sys
def find_most_frequent(text):
text = text.lower()
res=[]
numbers = ',.:;!?-...'
new=text
for char in numbers:
new = new.replace(char, ' ')
new=new.strip()
count = {}.fromkeys(new.split(" "))
new=new.split(" ")
for item in count:
count[item]=0
... |
fa25eb6704b752f1f5769598da25d63c17ee6809 | irBiss/PrometheusPython | /Python/40.py | 609 | 3.578125 | 4 | import sys
def convert_n_to_m(x, n, m):
if type(x)!=int and type(x)!=long and type(x)!=str:
return False
numbers="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
num=str(x).upper()
decimal=0
k=0
for letter in num[::-1]:
if letter not in numbers[:n]:
return False
decimal=numbers.find(letter)*... |
e6058547a5cdc86e292c20132612a49d9e003ca4 | tobias-fyi/vela | /cs/python/python_general/misc_functions/dates.py | 3,892 | 4.21875 | 4 | """Fun(c) with dates"""
# %% Imports
from datetime import datetime, timedelta
from typing import List
# %% Mondays
def mondays_between_two_dates(start: datetime, end: datetime) -> List[str]:
"""Returns the dates of each Monday between two dates, inclusive.
:param start (str) : ISO-formatted start date.
:... |
73ee6afe567bde8f4db1d5dfc8fb39d3386490ee | tobias-fyi/vela | /cs/lambda_cs/06_graphs/projects/social/social.py | 6,060 | 3.78125 | 4 | """
Graphs :: Day 3 - Social network graph
"""
import os
import random
import sys
sys.path.append(os.path.abspath("../graph"))
from util import Stack, Queue
class User:
def __init__(self, name):
self.name = name
class SocialGraph:
def __init__(self):
self.last_id = 0
self.users = {... |
e1edfc74e7463503a5153aa7591996511e77241e | tobias-fyi/vela | /cs/lambda_cs/06_graphs/notes/islands/island_generator.py | 382 | 3.703125 | 4 |
import random
def generate_island_matrix(width, height, density):
matrix = []
for h in range(height):
matrix.append([0] * width)
for x in range(width):
for y in range(height):
print(random.random() < density)
if random.random() < density:
matrix[y]... |
67ed210063ba649f0b2bea7ae21404212a11ed38 | tobias-fyi/vela | /cs/lambda_cs/02_algorithms/Sorting/src/recursive_sorting/notes/recursion_brian.py | 1,720 | 3.828125 | 4 | # def my_recursion(n):
# print(n)
# if n == 100:
# return
# my_recursion(n+1)
# my_recursion(n+1)
# my_recursion(1)
# Fibonacci
# 0, 1 - Base - if we solve recursively move towards it
# 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
# 10th fib number?
# 9th fib + 8th fib
# 9th fib is?
# 8th plus... |
d31fb84a7081f1ba0920d907810848c2d71cee01 | tobias-fyi/vela | /cs/lambda_cs/07_computer_architecture/notes/674/lesson.py | 1,096 | 4 | 4 | """
Computer Architecture - Day 4
"""
# === Stack frames === #
# Stack grows downward
# 701:
#
# 700: # return point 1 |
# 699: a = 2 | main()'s stack frame
# 698: b = ?? |
#
# 697: # return point 2 |
# 696: x = 2 |
# 695: y = 7 | mult2()'s stack ... |
1f78efab9616a60701a2dcf4d7f7a26ace06a810 | tobias-fyi/vela | /cs/lambda_cs/06_graphs/notes/662_islands.py | 1,494 | 4.15625 | 4 | """
Takes a 2D binary array and returns the number of 1 islands.
An island consists of 1s that are connected to the north, south, east or west.
For example:
```py
islands = [[0, 1, 0, 1, 0],
[1, 1, 0, 1, 1],
[0, 0, 1, 0, 0],
[1, 0, 1, 0, 0],
[1, 1, 0, 0, 0]]
island_counter... |
8d7f134695f7f067a0474f71bf206bceae596dca | tobias-fyi/vela | /cs/lambda_cs/01_intro_python/Intro-Python-I/src/13_file_io.py | 1,226 | 4.34375 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# Open up the "foo.txt" file (which already exists) for reading
# Print all the contents of the file, then close the file
# Note: pay close... |
8ba8907bae0d698b5bdb5cb8ef46f1ae13d6816f | tobias-fyi/vela | /cs/lambda_cs/07_computer_architecture/ls8/cpu.py | 9,220 | 3.671875 | 4 | """Computer Architecture :: CPU emulator class"""
import os
import sys
class CPU:
"""Main CPU class."""
def __init__(self):
"""Construct a new CPU."""
# 256 bytes (8 bits = 1 byte) of RAM
self.ram = [0b00000000] * 256
# === Internal registers === #
self.reg = [0b0000... |
bfab19f9e3338666dc7eeea34061147600785c3a | tobias-fyi/vela | /cs/lambda_cs/02_algorithms/Algorithms/making_change/making_change.py | 2,753 | 4.125 | 4 | """
Algorithms :: Practice - making change
"""
import sys
def making_change(amt: int, coins: list) -> int:
"""Iterative implementation of the making change algorithm.
:param amt (int) : Amount, in cents, to be made into change.
:param coins (list) : List of coin denominations
:return (int) : Num... |
e1ad73776b2bf1d194e7083b8a58db26277cfd35 | tobias-fyi/vela | /cs/lambda_cs/06_graphs/notes/graphs_vera.py | 943 | 3.625 | 4 | # edges
edges = self.get_neighbors(starting_vertex)
if visited is None:
# instantiate empty set for visited
visited = set()
if path is None:
# instantiate empty list for path
path = []
# mark current vertex as visited
... |
f57f6a20b2923b5b45666c2cb5cbe34d8f25901d | tobias-fyi/vela | /ds/practice/daily_practice/20-08/assets/code/warehouse_robot.py | 3,665 | 4.0625 | 4 | # You're part of a warehousing team running simulations on
# robots performing the pick-and-pack task. Another team has
# completed the simulations and provided a log of the robot routes.
# Your task is to validate if the routes are valid.
# Heres' how a route looks like:
# [
# [1, 0, 0, 0, 0],
# [1, 0, 0, 0, 0],... |
509650fe50562333518992f6269f0c5d50715e36 | scene25/python | /4.multiplication_table.py | 168 | 3.671875 | 4 | for i in range(2, 10, 1):
print("* %d ********" % i)
for j in range(1, 10, 1):
print("%d x %d = %d" % (i, j, i * j))
print("")
|
f7130e4b1e6914b82670ce01465d30545547a965 | scene25/python | /1.multiple.py | 186 | 3.84375 | 4 | data = (2, 45, 55, 200, -100, 99, 37, 10284)
listResult = []
for i in data:
if(i % 3 == 0):
listResult.append(i)
for nValue in listResult:
print(nValue) |
eb44513b838854c6b86bb1393b4db847fc0fc610 | LeguizamonLuciano/DataAnalysisHelsinkiUni | /WEEK 1/part01-e14_find_matching/src/find_matching.py | 307 | 3.6875 | 4 | #!/usr/bin/env python3
def find_matching(L, pattern):
enumeratedL = list(enumerate(L))
matched=[]
for i in range(len(enumeratedL)):
if pattern in enumeratedL[i][1]:
matched.append(i)
return matched
def main():
pass
if __name__ == "__main__":
main()
|
7f87d66efbba70d594356ccee498fabb23b239e1 | LeguizamonLuciano/DataAnalysisHelsinkiUni | /WEEK 1/part01-e09_merge/src/merge.py | 320 | 3.953125 | 4 | #!/usr/bin/env python3
def merge(L1, L2):
L3 = L1+L2
L4 = []
while len(L3) > 0:
mi = L3[0]
for i in L3:
if i < mi:
mi = i
L3.remove(min(L3))
L4.append(mi)
return L4
def main():
merge(L1,L2)
pass
if __name__ == "__main__":
main()
|
0d1041739f3179cc812ccd9b1b513c73af905fc6 | Callmekrishna/Board-Practicals | /solutions/1.py | 1,495 | 3.8125 | 4 | import pickle
def initial():
try:
f = open('STUDENT.dat','ab+')
except:
return
r = int(input('Enter the total number of children\nEnter 0 if you dont want to enter any : '))
for I in range(r):
roll_no = int(input('enter roll no : '))
name = input('enter name : ... |
69657de5d06f9354c58d5040bda4b03fa6b5c1d1 | dichen001/CSC522-Spark | /helpers.py | 1,413 | 3.765625 | 4 | import math
def dotprod(a, b):
""" Compute dot product
Args:
a (dictionary): first dictionary of record to value
b (dictionary): second dictionary of record to value
Returns:
dotProd: result of the dot product with the two input dictionaries
"""
return sum(a[k]*b[k] for k in... |
d0d26c994c179f2487fbca4fe970e720b2480c83 | OwenBang/codeup | /1901.py | 162 | 3.609375 | 4 | n = 1
def test(num):
global n
if n == num:
print(n)
else:
print(n)
n += 1
test(num)
num = int(input())
test(num)
|
815bc1c67bb5421bb736ba4b3c744f1851f57db1 | OwenBang/codeup | /1912.py | 176 | 3.640625 | 4 | result = 1
def test(num):
global result
result = result * num
num -= 1
if num > 0:
test(num)
return result
num = int(input())
print(test(num))
|
6592e548167b47f2bf976fdf571d1e89aa115186 | hazel-nut-old/euler-python | /helper.py | 2,076 | 3.59375 | 4 | from math import sqrt
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
def lcm(a, b):
return (a * b) / gcd(a, b)
def is_palindrome(num):
digits = str(num)
for i in range(len(digits) / 2):
if digits[i] != digits[len(digits) - 1 - i]:
return False
return True
def get_factor... |
07cba54b1b6b4fa7075784efdf4fb6599207654f | davidgillard/formation | /notebook/chapitre3/05-suite_fibonacci.py | 803 | 3.6875 | 4 | # -*- coding: UTF-8 -*-
# fichier : 05-suite_fibonacci.py
# auteur : David GILLARD
""" Le programme suivant affiche les 8 premiers termes de la suite de Fibonacci, dont chaque terme est égal à la somme des deux précédents :
a, b, c = 1, 1, 1
while c < 9:
print b,
a, b, c = b, a+b, c+1
Pour bien comprendre le... |
9498c20021802b84ba0b4ea2ccf09d8d8c7e53c9 | davidgillard/formation | /notebook/chapitre3/02-inserer_caractere.py | 414 | 3.59375 | 4 | # -*- coding: UTF-8 -*-
# fichier : 02-inserer_caractere.py
# auteur : David GILLARD
""" Écrire un script qui recopie une chaîne en insérant un astérisque entre ses caractères.
Utilisez une boucle while.
Par exemple "Gaston" deviendra "G*a*s*t*o*n" """
chaine = input("Veuillez saisir une chaine de caractére : ")... |
b147a3e0ff509b89cd4afe2756d800188fb31347 | bhawana01/Python-Basic-Practices | /fibonacci_no.py | 422 | 4.125 | 4 | def fibonacci(n):
a = 0
b = 1
if n < 0:
print("Incorrect Input")
elif n == 0:
return a
elif n == 1:
return b
else:
# return fibonacci(n-1)+fibonacci(n-2)
for i in range(2, n):
c = a+b
print("value of c:", c)
... |
5e58ab5e53bba23cfd2a7f5d7ce851dac42968ba | xchmel33/Calculator-TeamProject | /src/stddev.py | 1,236 | 3.578125 | 4 | ######################
# IVS - team project #
# Calculator #
######################
import fileinput
import calc
#get all items from stdin
def getAllItems():
allItems = []
for item in fileinput.input():
allItems.append(float(item))
return allItems
#calculating arithmetic mean from input d... |
ea41a0da65926986715efc3ddc92b2a31e73f982 | khueluu/SE | /CW1/IOutputStream.py | 455 | 3.515625 | 4 | import abc
class IOutputStream(abc.ABC):
@abc.abstractmethod
def write(self, text: str):
pass
class ConsoleStream(IOutputStream):
def write(self, text: str):
print(text)
class FileStream(IOutputStream):
def __init__(self, file_path):
self.file_path = file_path
def write(s... |
025c173585d6912c448b36aea7d9c25eac03f0fb | ProjectsUCSC/ProgrammingLanguages | /interactive_parser.py | 339 | 4.03125 | 4 | from parser_python import *
def main():
answer = 'y'
while(answer == 'y'):
regex = str(input("Enter the regex to be evaluated "))
#print(type(regex))
string = str(input("Enter the input string "))
print(parser(regex, string))
answer = str(input("Do you want to continue... |
356bce1a3d4ee21227e18f9f32aade7111658686 | Jokeren/Tutorial | /Python/basic/number.py | 543 | 3.796875 | 4 | def is_even(x):
if x % 2:
return False
else:
return True
def is_int(x):
if x - int(x) == 0:
return True
else:
return False
def digit_sum(n):
s = str(n)
total = 0
for c in s:
total += int(c)
return total
def factorial(x):
if x == 0:
r... |
efdbeda13a9eeae8819e9c19b8aee4530291b3a3 | jpbulman/Project-Euler | /src/PY/34.py | 437 | 3.59375 | 4 | facts = [1]*99999
def factorial(n):
if(n is 0):
return 1
elif(facts[n]!=1):
return facts[n]
else:
num = n*factorial(n-1)
facts[n]=num
return num
def digFact(n):
sum = 0
numStr = str(n)
for a in range(len(numStr)):
sum+=factorial(int(numStr[a]))
... |
208c9ec60373b51995fc398d897f78f1f3a21b58 | jpbulman/Project-Euler | /src/PY/Problem56.py | 368 | 3.921875 | 4 | import math
#Gets the sum of all the digits in a number
def digSum(num):
count = 0
while num>0:
count+=num%10
num=math.floor(num//10)
return count
sum = 0
#Finds the biggest digital sum in 0 <= a,b, < 100 in a^b
for a in range(100):
for b in range(100):
big = digSum(a**b)
... |
371d8626fbe3c1180991730158298994d16d5349 | guilhermemaas/python-use-a-cabeca | /python_files/for.py | 472 | 3.859375 | 4 | >>> for i in [1, 2, 3]:
print(i)
1
2
3
>>> for i in range(0, 10):
print(i)
0
1
2
3
4
5
6
7
8
9
>>> for i in 'Palavra':
print(i)
P
a
l
a
v
r
a
>>>
>>> for i in range(0, 10):
print('Head First Rocks!')
Head First Rocks!
Head First Rocks!
Head First Rocks!
Head First Rocks!
Head First Rocks!
Head First Ro... |
f042c1523b8095488fdea60f4aac278e2d257c2e | guilhermemaas/python-use-a-cabeca | /vowels.py | 2,251 | 4.03125 | 4 | prices = []
temps = [32.0, 212.0, 0.0, 81.6, 100.0, 45.3]
words = ['hello', 'world']
car_detail = ['Toyota', 'RAV4', 2.2, 60807]
everything = [prices, temps, words, car_detail]
odds_and_ends = [[1, 2, 3], ['a', 'b', 'c'],
['One', 'Two', 'Three']]
vowels = ['a', 'e', 'i', 'o', 'u']
#word = "Mil... |
c8bec554f51b34299b633a6367bc6b3db8bec042 | rrahul4/Python | /Assign_10_Decorator.py | 464 | 3.59375 | 4 | #!/usr/bin/python
import time
def my_decorator(func):
def wrapper():
print "Time Start "
start = time.time()
func()
end = time.time()
print "Time End"
print "Elapsed time: ", str(end - start), "Start : ", start, "End : ", end
return wrapper
def my_method():
... |
20ddaa6041456a8643b0e5fec99250863a9f2be2 | rrahul4/Python | /Assign_4_Regular_Expression.py | 958 | 4.375 | 4 | #!/usr/bin/python
import re
print "Python Scripting L2 Hands-on_Assignment:04"
print " "
print(" This is Filter Digit at beginning and at ending of String")
StringList1= ['1 Cooking is great hooby 9', '2 India is great country 8','3 Reading a Book is great 7']
for SampleString1 in StringList1:
print(re.findall(r'^[1... |
e37120a3f926c7d52b8676f2cbc530a3f05b00d4 | Bit64L/LeetCode-Python- | /PowerofTwo231.py | 514 | 3.859375 | 4 | class Solution:
def isPowerOfTwo(self, n):
"""
:type n: int
:rtype: bool
"""
lo = 0
high = (int(len(str(n)) / 3) + 1) * 10
while lo <= high:
mid = int((lo + high) / 2)
print(mid)
if 2 ** mid == n:
return True
elif ... |
b9d8cd0c793cfec5b3ef5bb825e49555de77e331 | Bit64L/LeetCode-Python- | /Lowest_Common_Ancestor_of_a_Binary_Tree_236. .py | 1,925 | 3.546875 | 4 |
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
"""
:type root: TreeNode
:type p: TreeNode
:type q: TreeNode
:rtype: TreeNode
... |
652068af8631ded1ee22020ea9b6804af3e2ad0d | Bit64L/LeetCode-Python- | /N-aryTreeLevelOrderTraversal429.py | 933 | 3.71875 | 4 | """
# Definition for a Node.
"""
class TreeNode(object):
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def levelOrder(self, root):
"""
:type root: Node
:rtype: List[List[int]]
"""
if root is None:
... |
10cc2ea4226f6c9c102a169fbfce7250e3819095 | Bit64L/LeetCode-Python- | /MergeSortedArray88.py | 458 | 3.8125 | 4 | class Solution:
def merge(self, nums1, m, nums2, n):
"""
:type nums1: List[int]
:type m: int
:type nums2: List[int]
:type n: int
:rtype: void Do not return anything, modify nums1 in-place instead.
"""
for i in range(0, n):
j = m - 1
... |
2de5904306243b2700492b6d3220cbffe4e94d07 | Bit64L/LeetCode-Python- | /SumofTwoIntegers371.py | 902 | 3.5 | 4 | # encoding=utf8
class Solution(object):
def getSum(self, a, b):
if b == 0:
return a
s = a ^ b
offset = (a & b) << 1
s += offset # use +=
return s
def getSum1(self, a, b):
"""
:type a: int
:type b: int
:rtype: int
"""
... |
8a4017363e521fa60617f70860ecced0a69864e0 | Bit64L/LeetCode-Python- | /TwoSumIVInputisaBST653.py | 1,561 | 3.875 | 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 __init__(self):
self.mark = False
self.pocket = []
def findTarget(self, root, k):
if not root or... |
2c80602781d4a577e121f46c9bb455be7b8427ba | Bit64L/LeetCode-Python- | /# Definition for singly-linked list.py | 723 | 3.859375 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None:
return head
work = ... |
14e8f39d176577ad04150b734708d3cc6a1843ff | vurokrazia/Curse-Python-101 | /Strings/reverse.py | 568 | 3.859375 | 4 | def tipo (adn):
if type(adn) is str:
print ('\n' + adn + ' is a string\n')
def sus (w):
if w == "G":
return "C"
elif w == "A":
return "T"
elif w == "T":
return "A"
elif w == "C":
return "G"
return ""
def palabra(siz,b):
new_word = []
for a in range(b):
new_word.append(sus(siz[a]))
return new_word... |
a84f0bd275586fcfd62170d2a6217d5de0eb0112 | matheusnno/PythonVivoMaua | /Exercicios extra/ex4_triang.py | 463 | 3.890625 | 4 |
a = int(input("Digite o valor de A: "))
b = int(input("Digite o valor de B: "))
c = int(input("Digite o valor de C: "))
vet = []
vet.append(a)
vet.append(b)
vet.append(c)
vet.sort()
if ((vet[2] ** 2) == vet[1] ** 2 + vet[0] ** 2):
print("E um triangulo retangulo !!")
area = (vet[1] * vet[0] / 2)
print("A... |
a41c7250bd11dbf710195599a527f929ce1a2e82 | Ashna-Nawar-Ahmed/4th-year-1st-semester | /Artificial Intelligence Lab/Term Assignments/CSE4108_TermAssignment 1/monster_hunting_propositional logic.py | 2,923 | 3.734375 | 4 |
import random
#KNOWLEDGE BASE
grid={
#cell number: [monster, gold, smell]
11:[False,False,False],
12:[False,False,True],
13:[False,False,True],
14:[True,True,True],
21:[False,False,True],
22:[False,True,True],
23:[True,False,True],
24:[False,False,T... |
2701ec00557ee908b2651b9ed3f6bf89a1123743 | nishant-giri/450-DSA-Questions | /python/Array/1_array_reverse.py | 338 | 3.796875 | 4 | class Solution:
def reverseWord(s):
# for reversing the array we will traverse it from 0th index to the mid index
# and keep swapping the ith index value with (len(s)-i)th index value
l=len(s)
for i in range(len(s)//2):
s[i],s[l-i-1] = s[l-i-1],s[i]
... |
903d971762f6a1e2c0f5256703cf6d40a201d4ab | wagnerfilho1995/Metro-de-Paris | /estrela.py | 5,903 | 3.984375 | 4 | #-*- coding: utf-8 -*-
# INFORMAÇÕES DO PROBLEMA
# VELOCIDADE MEDIA DE UM TREM = 30km/h
# TEMPO MÉDIO PARA TROCAR DE ESTAÇÃO = 4 mins
# ARRAY COM NOME DAS ESTAÇÕES DO MAPA
E = ["La Défense", "Charles de Gaulle Étoile", "Concorde", "Palais Royal Musée du Louvre", "Reuilly-Diderot",
"Daumesnil", "Gare de Lyon",... |
e2fda7f3a2c15dea6add729e060f367098e105dc | RunicSage/GenericAdventureGame | /Introduction.py | 1,332 | 3.5625 | 4 | print("Welcome to another...")
slp(2)
print("""
_____ _
/ ____| (_)
| | __ ___ _ __ ___ _ __ _ ___
| | |_ |/ _ \ '_ \ / _ \ '__| |/ __|
| |__| | __/ | | | __/ | | | (__
\_____|\__... |
42612047d1dfd7c58319c557c9a929b02c07d419 | sunghyungi/git_python_study | /chapter05/comprehension_study.py | 226 | 3.953125 | 4 | # 리스트 컴프리헨션, if 추가
numbers = [1, 2, 3, 4, 5]
square = [i ** 2 for i in numbers]
print(square)
square2 = [i ** 2 for i in numbers if i >= 3]
print(square2)
print([i ** 2 for i in range(1, 6) if i >= 3])
|
db3fe2322f0778e4606447a7ba0ec77cc7664831 | sunghyungi/git_python_study | /chapter04/exam02.py | 706 | 4.03125 | 4 | import random as rnd
def bubble_sort(random_list):
for i in range(0, len(random_list)-1):
for t in range(0, len(random_list)-1-i):
if random_list[t]> random_list[t+1]:
random_list[t], random_list[t+1] = random_list[t+1], random_list[t]
# swap = random_list[t]
... |
7b59e0e56c0ce128d65450e23892711153830e44 | sunghyungi/git_python_study | /chapter04/set_study.py | 455 | 4.0625 | 4 | # 로또번호생성기를 작성하고 당첨번호에 따라 순위를 구하는 프로그램 작성
import random as rnd
from chapter04.exam02 import bubble_sort
def lotto_generator():
rnd.seed(1)
lotto_num = set()
while len(lotto_num) < 6:
lotto_num.add(rnd.randint(1, 46))
return lotto_num
if __name__ == "__main__":
set_lotto = bubble_sort(l... |
abe37c014429c1389f645a1da8b2430ee9ccaade | abkfenris/permit_finder | /permit_finder/time_helpers.py | 460 | 3.625 | 4 | from datetime import datetime
def date_string_to_dt(date):
"""Expects a date in m/d/yyyy form"""
month, day, year = date.split('/')
return datetime(year=int(year), month=int(month), day=int(day))
def dt_to_date_string(dt):
"""Returns a formated date string in m/d/yyy form"""
return dt.strftime('... |
45d7714ef3edcd579e9badb7b50a86ad1346e8a4 | Yucheng7713/CodingPracticeByYuch | /Medium/863_allNodesDistanceKInBinaryTree.py | 2,445 | 3.703125 | 4 | import collections
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
# BFS - Convert the tree into graph then perform BFS
# Low performance
def distanceK(self, root, target, K):
"... |
aafe4ae505bd2b93db24f02da8222e4eda635651 | Yucheng7713/CodingPracticeByYuch | /Easy/746_minCostClimbingStairs.py | 480 | 3.5625 | 4 | class Solution:
def minCostClimbingStairs(self, cost):
"""
:type cost: List[int]
:rtype: int
"""
cost += [0]
dp = [0] * len(cost)
dp[0], dp[1] = cost[0], cost[1]
for i in range(2, len(cost)):
dp[i] = cost[i] + min(dp[i - 1], dp[i - 2])
... |
3af8bbf1d46333ca0aabcf68c8346eb9cd09c312 | Yucheng7713/CodingPracticeByYuch | /Medium/418_sentenceScreenFitting.py | 1,439 | 4.0625 | 4 | class Solution:
# Time complexity : O ( # of row * max_word_length )
# Space complexity : O ( # of words * max_word_length )
def wordsTyping(self, sentence, rows: int, cols: int) -> int:
sentence_str = " ".join(sentence) + " "
start, n = 0, len(sentence_str)
for i in range(rows):
... |
b7dc2361c8fc77c2194dc5515d712ea05462ec86 | Yucheng7713/CodingPracticeByYuch | /Easy/534_diameterOfBinaryTree.py | 569 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def diameterOfBinaryTree(self, root):
self.max_Diameter = 0
def maxDepth(node):
if not node: return 0
... |
659f926cfd11c9a13cffafff1a5e4990e53aaf4d | Yucheng7713/CodingPracticeByYuch | /Easy/217_containsDuplicate.py | 278 | 3.53125 | 4 | class Solution:
def containsDuplicate(self, nums):
return len(nums) != len(set(nums))
def containsDuplicate_2(self, nums):
n = 1
for num in nums:
if num in nums[n:]:
return False
n += 1
return True |
9d25166c352195c5090a9a0a6b92db3708da1dc2 | Yucheng7713/CodingPracticeByYuch | /Medium/333_largestBSTSubtree.py | 1,835 | 3.78125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def largestBSTSubtree(self, root: TreeNode) -> int:
if not root:
return 0
self.max_BST = 1
def dfs(n... |
15fe05ac778fd0ce0addc47c5f68039fb637b9c3 | Yucheng7713/CodingPracticeByYuch | /Medium/285_inorderSuccessorInBST.py | 660 | 3.859375 | 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 inorderTree(self, node):
if not node: return []
return self.inorderTree(node.left) + [node.val] + sel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.