blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
02bb684370a2ee69f635f4108fb731a8338d081a | photonPrograms/TicTacToe | /play1p.py | 5,132 | 4.21875 | 4 | from random import choice as chrand
def disp_board(board, nrow = 3, ncol = 3):
"""display the current status of the board"""
print(" ", end = "")
for j in range(ncol):
print(f"{j + 1}", end = " ")
print()
for j in range(ncol + 1):
print("--", end = "")
print("-")
for i in r... |
7062768b022d7d32868aa727e824a369a2c5847a | thesourabh/python-practice | /ProjectEuler/145-unfinished.py | 316 | 3.671875 | 4 | def rev(n):
r = 0
if (n % 10 == 0):
return 2000000000
while(n > 0):
r = r * 10 + (n % 10)
n /= 10
return r
def reversible(n):
while (n > 0):
if (n % 10 % 2 == 0):
return False
n /= 10
return True
count = 0
for i in xrange(1, 500000):
n = i + rev(i)
if (reversible(n)):
count += 1
print count |
929b6dc095ea73c5111092c914de94c37573dec8 | soneo1127/pysc2-examples | /mineral/tsp2.py | 8,684 | 4.03125 | 4 | import math
import random
def distL2(x1,y1, x2,y2):
"""Compute the L2-norm (Euclidean) distance between two points.
The distance is rounded to the closest integer, for compatibility
with the TSPLIB convention.
The two points are located on coordinates (x1,y1) and (x2,y2),
sent as parameters"""
xdiff = x... |
a370331a756b5790e1dd67fba818520922da08b9 | niraj-r/RCXD | /rpLidar_python/Thread_Tests/threadtest2.py | 1,556 | 3.578125 | 4 | """
This comes from a tutorial found here:
https://www.youtube.com/watch?v=i1SW4q9yUEs
I want to create a queue so that LIDAR data can be captured
independently from any drawing. I'm worried the drawing
will slow down the reading and data points will be dropped
I initially thought to use RabbitMQ or ZeroMQ but this s... |
91ab6e03396f616b0bfd69b3e33f3ae99daf7c72 | wdampier2000/pyton-curso | /09-Listas/main.py | 1,291 | 4.0625 | 4 | """
Colecciones o conjuntos de datos/valores bajo un unico nombre
Para acceder a esos datos usamos indice numerico
"""
Lista1=["Victor", "Jose", "Raul"]
print (Lista1)
#otra forma
cantantes= list(("Luis Miguel", "Riqui Martin", "Julio Iglesias"))
print (cantantes)
#otra
year = list(range(2020,2025))
print (year)
... |
efe5f2e1cdd39d4bf49420e20b1b2f1822e8284c | szhao13/interview_prep | /girl_scouts.py | 763 | 3.890625 | 4 |
def merge_lists(array_0, array_1):
curr_id_0 = 0
curr_id_1 = 0
merged_array = []
len_0 = len(array_0)
len_1 = len(array_1)
total = len_0 + len_1
for index in range(total):
if curr_id_0 < len_0:
if curr_id_1 == len_1 or array_0[curr_id_0] <= array_1[curr_id_1]:
merged_array.append(array_0[curr_id_0])
... |
af9629037f201e6484c0825da4cc56c2d3fe5616 | Omkarj21/Data-Structures_Collections_Collectors | /number.py | 1,452 | 3.859375 | 4 | # Important Packages = math, binary, decimal, fraction
# -------------------------------------
# Numerical literals :
# integer, float, complex
# -------------------------------------
# Output: <class 'int'>
print(type(2))
# Output: <class 'float'>
print(type(2.0))
# Output: (15+2j)
a = 9 + 2j
print(a + 6)
# Output... |
6e84588e49e3cd9b087691296b572d11df4f3441 | NapsterInBlue/image_to_sprite | /spritify.py | 1,976 | 3.578125 | 4 | import cv2
import numpy as np
def mask_iterator(skip_n=20, take_n=10):
"""
Determines the filtering pattern of the image.
Infinately loops per skip_n, take_n, and generates
a 0/1 value, used to build a mask over an image
Parameters
----------
skip_n: int
How many sequential pixels are ski... |
9e358d7d1e2276e3ab12ab814aefb533d075c1ea | nucktwillieren/big_data_course | /20210303/ex5.py | 553 | 3.65625 | 4 |
def a_1():
n = int(input("Enter a integer number: "))
s = 0
for i in range(n):
three = i * 3
five = i * 5
if three > n: break
if i % 5 != 0: s += three
if five < n: s += five
print(s)
def a_2():
n = int(input("Enter a integer number: "))
... |
aee89a2e08d4d93ac06072f4af5488e7b4bbef0a | azrodriquez/MyPythonCourse | /CH04/num_list.py | 384 | 3.828125 | 4 | some_nums = [2,6,4,2,22,54,12,8,-1]
print(len(some_nums))
print("The sum of the list is: ", sum(some_nums))
print(some_nums[2])
hightest_num = some_nums[0]
for x in some_nums:
if x > hightest_num:
hightest_num = x
print("the highest number is: ", hightest_num)
for x in range(len(some_nums)-1):
prin... |
bb5d16d4fe0e84e70729519c94574a6984afc475 | tainenko/Leetcode2019 | /leetcode/editor/en/[489]Robot Room Cleaner.py | 4,218 | 3.578125 | 4 | # You are controlling a robot that is located somewhere in a room. The room is
# modeled as an m x n binary grid where 0 represents a wall and 1 represents an
# empty slot.
#
# The robot starts at an unknown location in the room that is guaranteed to be
# empty, and you do not have access to the grid, but you can... |
59000cac11b0c80dceb43e6b817270d491b53f4e | machillef/Mastermind-Clone | /modules.py | 6,130 | 3.796875 | 4 | # -*- coding: utf-8 -* -
import pygame, sys, textrect
import os
from os.path import dirname, realpath, abspath
from pygame.locals import *
from pygame.sprite import *
pygame.init()
#constants, like screen size, and some colors
#screen
WIDTH = 800
HEIGHT = 600
display = pygame.display.set_mode((WIDTH,HEIGHT))
#colors... |
9771797706bb2f19b0a4907c37bf94f312cb9ad9 | UWPCE-PythonCert-ClassRepos/220-Advanced-Summer-2019 | /students/AndrewMiotke/lesson02/assignment/src/charges_calc.py | 3,103 | 3.578125 | 4 | '''
Returns total price paid for individual rentals
'''
import argparse
import json
import datetime
import math
import logging
def parse_cmd_arguments():
""" Command line arguements to start the program """
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('-i', '--... |
e5af6c784289ec95cc90a298574e6871a7692402 | matheus-nbx52/Python | /matriz.py | 548 | 3.8125 | 4 | from random import randint
print(randint(1, 9))
coluna = []
matriz = []
linhas = int(input('Informe a quantidade de linhas: '))
colunas = int(input('Informe a quantidade de colunas: '))
i = 0
while i <= colunas:
numero = randint(1, 9)
coluna.append(numero)
i += 1
if i == colunas:
... |
db207090f5c4ab6d4de2a18fd9b31f8346b54537 | pluzun/supinfo_1ads_labs_2018 | /3.1.2.py | 246 | 3.75 | 4 | def syracuse(a, n):
if n == 0:
return a
print(int(a))
if a % 2 == 0:
return syracuse(a/2, n-1)
else:
return syracuse(a*3+1, n-1)
a = int(input("a : "))
n = int(input("n : "))
print(int(syracuse(a, n-1)))
|
6debe26429e591d54910e5126c590b02d07e9c9b | beloplv/practicasUnoDosTres | /p2e1.py | 366 | 3.515625 | 4 | tam = ['im1 4,14', 'im2 33,15', 'im3 6,34', 'im4 410,134']
lista1=[]
lista2=[]
num = int(input('ingrese un numero '))
for i in tam:
im,space,tupla = i.partition(' ')
aux = (int(tupla.split(',')[0]), int(tupla.split(',')[1]))
if num >= aux[0]:
lista1.extend([im,tupla])
else:
lista2.ext... |
1bcf87651c1eded053d78631a5a174d507839689 | elainekamlley/python_scripts | /while_loop/chips_eating.py | 612 | 4.1875 | 4 | #chips_eating.py
#Section 1: Set out current values
chips_in_bag = 30
print "There are "+ str(chips_in_bag)+ " chips in the bag."
#Section 2: Inside a while loop, ask the user how many chips they want to eat until the bag is gone.
#Ask the user how many chips they want to eat a time, until the bag is gone. When the... |
e098b4f8579fbf197ea0e04e37fc773f17247fb7 | garcheuy/python-challenge | /PyBank/main.py | 3,237 | 3.75 | 4 | import os
import csv
file_list = []
x = 0
for file in os.listdir("raw_data"):
if file.endswith(".csv"):
file_list.insert(x, os.path.join(file))
x += x
file_list.sort()
for file_name in file_list:
print("[" + str(file_list.index(file_name)) + "] " + file_name)
# ask user as to which of the t... |
0fdc8b41c64aa6773979362f6ba06ade122592b0 | aakash2602/InterviewBit | /xor_trie/xor_key_trie.py | 5,347 | 3.65625 | 4 | import collections
# import time
class Node:
def __init__(self):
self.left_child = None # corresponds to bit 0
self.right_child = None # corresponds to bit 1
self.terminus = False
self.bit_index = {}
self.word = ""
def add(self, child_node, bit, bit_index):
if... |
d66a3b94b3997bb33fec801ea1b0d88aa7fa6e8d | vondirath/functions | /quicksort.py | 584 | 4.125 | 4 | def quicksort(thisarray):
"""
A python Quicksort with recursion
"""
less = []
equal = []
greater = []
if len(thisarray) > 1:
pivot = thisarray[0]
for item in thisarray:
if item < pivot:
less.append(item)
if item == pivot:
... |
9e055c47be1762ca5fff0313b91996cd827dd5cd | Renmy/MyRepo | /fileSearcher/dbConnection.py | 828 | 4 | 4 | import sqlite3
class db_Connection:
def __init__(self, dbname):
"""Initialize db class variables"""
self.connection = sqlite3.connect(dbname)
self.cur = self.connection.cursor()
def close(self):
"""close sqlite3 connection"""
self.connection.close()
def ... |
c14e9d328f0ce405b0ad69fa35af5cd2f2fa7fa8 | apisqa/Group_2 | /Lessons/July_15/test.py | 316 | 4.03125 | 4 | """Word-revert the string"""
s = raw_input('\nEnter the string to revert:\n')
temp = ''
result = ''
for i in range(1, len(s) + 1):
temp2 = s[len(s) - i]
if temp2 != ' ':
temp = temp2 + temp
else:
result += temp + ' '
temp = ''
result += temp
print('Final string is:\n%s' % result) |
15c0a536f5bc62c937da2b8a94a28840c789edce | taisei-d/python-training | /break文.py | 254 | 3.921875 | 4 | kens = ["Tottori","Shimane","END","Hiroshima","Okayama","Yamaguchi"]
for ken in kens:
if ken == "END":
print("Break LOOP")
break
print(ken)
else:
print("End LOOP")
for ken in kens:
print(ken)
else:
print("End LOOP")
|
24c55abf940d267c3b93e82663a1165bf75e11ca | Ferveloper/python-exercises | /KC_EJ05.py | 187 | 3.875 | 4 | #-*- coding: utf-8 -*-
month1 = raw_input('Mes 1: ')
year1 = raw_input('Año 1: ')
month2 = raw_input('Mes 2: ')
year2 = raw_input('Año 2: ')
print(month1 == month2 and year1 == year2) |
06638c3a7b3ca9a4ba510bd9b4aba68144e830f9 | Spuntininki/Aulas-Python-Guanabara | /ex0062.py | 799 | 3.640625 | 4 | #Progressão aritimetica 2.0
n1 = int(input('Digite o primeiro termo da progressão: '))
raz = int(input('Digite a razão da PA: '))
soma = n1 + raz
print('{}'.format(n1), end=' ')
c = 1
d = 10
decision = ''
while c != d:
print('{}'.format(soma), end=' ')
soma = soma + raz
c += 1
if c == d:
print(... |
bb699b9c8bd49ad7d5eea9a78c2c3509e6c2c05a | SergeiEroshkin/python_basics | /functions/sort_list.py | 542 | 3.84375 | 4 | def find_smallest(lst):
# Store smallest value
smallest = lst[0]
# Store smallest index
smallest_idx = 0
for index in range(1, len(lst)):
if lst[index] < smallest:
smallest = lst[index]
smallest_idx = index
return smallest_idx
def get_sorted(lst):
sorted_lis... |
72109201a44c51b1ca168d5ea0da97fcf3143c06 | StellaNguyen68/Fundamental-in-Python | /Python basic.py | 1,258 | 3.71875 | 4 | a=29.11
print(a)
print(type(a))
#take decimal from libraby
from decimal import*
getcontext().prec=3 #take max 30 number behind ,
print(Decimal(10)/Decimal(3))
print(type(Decimal(10)/Decimal(3)))
#Fraction
from fractions import*
frac=Fraction(6,9)
print(frac)
print(type(frac))
print(frac+2/3)
#Complex
... |
52ec24bac243e57b2f24d55dac6d40e6f158c5e8 | Armando8766/Modified-8Puzzle-AI | /8Puzzle.py | 11,667 | 4.0625 | 4 | import time as t
print('Hey buddy! Hope you are having a great time! Are you in the mood to play some 8-Puzzle? :)\nYes??!\nWonderful!\nLets go then!\n')
print('Choose one of the following options for the difficulty level of the puzzle:')
print('1) EASY Mode\n2) MEDIUM Mode\n3) HARD Mode')
option = input()
if option ... |
0a737180df692377b18f863998d8e963841dc742 | innovatorved/python-recall | /py29 - decorators.py | 371 | 3.65625 | 4 | # Decorators
# """
def fun1(fun):
def fun2():
print("I am")
fun()
print("Ved Prakash Gupta")
def fun5():
fun()
return fun2
def fun3():
print("Good Boy")
# fun3()
fun3 = fun1(fun3)
fun3()
# """
# easiest way to do this @fun1 before fun3 functi... |
b61fafebdfb93c0bc605f42409b43a18263749a1 | flo62134/hyperskill_python_tic_tac_toe | /Problems/A list of words/task.py | 356 | 4 | 4 | # work with the preset variable `words`
def start_with_letter(word: str, letter: str):
first_letter = word[0]
starts_with_letter = first_letter.upper() == letter.upper()
if starts_with_letter:
return True
else:
return False
starting_with_a = [word for word in words if start_with_letter... |
414651c1f32098240ffe3a7fb5bee038b5b9ea38 | shcherbinaap/new_rep_for_hw | /Lesson_3/task 1.py | 826 | 4 | 4 | #1. Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление.
# Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль.
from sys import exit
def inp_num(a):
while True:
num = input(f"Введите число {a} или 'q' для выхода: ")
if num.lower(... |
ce027990e71a057b28a02f3dde1f0ddae260705c | mocmeo/algorithms | /Q2.py | 141 | 3.828125 | 4 | def sumOfThree(num):
if (num - 3) % 3 != 0:
return []
x = (num - 3) / 3
return [x, x+1,x+2]
print(sumOfThree(33))
print(sumOfThree(0)) |
9d30dada7480e710f0b76cfb69b438de55afb790 | LarisaOvchinnikova/Python | /Loops/loop.py | 1,829 | 3.734375 | 4 | # ----------------------------for ------------------------
colors = ["red", "green", "blue"]
for elem in colors:
print(elem)
elem = elem.capitalize()
print(f"I like {elem}")
for i in range(len(colors)):
print(i)
print(colors[i])
if i == 1:
colors[i] = "white"
# ----------------------
... |
8f3a90b39415f6288fc5c94a3a444690d8eefcb5 | ajaypraj/gittest | /operator_loading.py | 314 | 3.734375 | 4 | class Book:
def __init__(self,pages):
self.pages=pages
def __str__(self):
return str(self.pages)
def __add__(self,other):
total=self.pages+other.pages
b=Book(total)
return b
b1=Book(100)
b2=Book(200)
b3=Book(200)
print(b1+b2)
print(b2+b3)
print(b1+b2+b3) |
6260d81976829427907cce2c0f81f3ef5fb27dbe | gsudarshan1990/PythonSampleProjects | /Python/InputWithCommandLineArguments.py | 481 | 3.734375 | 4 | from sys import argv
script, user_name=argv
prompt='>'
print('The name of the this file is {} and your name is {}'.format(script,user_name))
print ('Answer the following question')
print('Do you like me {}'.format(user_name))
like=input(prompt)
print('where do you live {}'.format(user_name))
live=input(prompt)
print(... |
d42faed66c7045fdbb749092ebf3459b6bc21476 | lukeaparker/super-hero-team-dueler- | /superhero.py | 7,455 | 3.703125 | 4 | import random
import superhero
class Ability:
def __init__(self, name, attack_strength):
self.name = name
self.max_damage = attack_strength
def attack(self):
''' Return a value between 0 and the
value set by self.max_damage.'''
return random.randint(0, self.... |
7c4682edd9aebb582e2df1bfd9ab1ccaeedeff0d | Sivasankar-tech/Codewars-1 | /Solutions/6kyu/6kyu_transform_to_prime.py | 222 | 3.921875 | 4 | def minimum_number(numbers,add=0):
return add if isprime(sum(numbers)+add) else minimum_number(numbers,add+1)
def isprime(n):
return False if n<2 else True if n==2 else all(n%i!=0 for i in range(2,int(n**0.5)+1))
|
72ff1ad04f3106bd18598cd349085a884ed9beff | nathanstouffer/adv-alg | /project/implementation/code/vector2.py | 932 | 4.15625 | 4 | # a basic vector in \R^2
import math
class Vector2:
# CONSTRUCTOR ------------------------------------------------------------------
def __init__(self, x, y):
self.x = x
self.y = y
# PUBLIC METHODS ---------------------------------------------------------------
def normalize(self):
... |
f9e89fc5952c61e6ae2d3a9024d9956011f12fdb | Aasthaengg/IBMdataset | /Python_codes/p02899/s521305336.py | 267 | 3.5 | 4 | def main():
n = int(input())
a = [int(_) for _ in input().split()]
order = [0 for i in range(n)]
for i in range(n):
order[a[i] - 1] = i + 1
# order.append(a.index(i+1) + 1)
print(*order)
if __name__ == '__main__':
main()
|
f1c64982db09686238b4508bf903ea4fe3ce3efc | xiegd/sy | /zuoye/118010100411/4.2.py | 365 | 3.8125 | 4 | str = input('请输入一串字符:')
e = num = space = other = 0
for char in str:
if 'a' < char < 'z' or 'A' < char < 'Z':
e += 1
elif '0' < char < '9':
num += 1
elif char == ' ':
space += 1
else:
other += 1
print('英文字符数{},数字数{},空格数{},其他字符数{}'.format(e,num,space,other))
|
7eefacc4a87a608503971d30d8dd7d0ab96163c0 | tzablock/PythonLearn | /src/spark/python/collection/dictionary.py | 178 | 4.25 | 4 | dict = {"a":1,"b":2,"c":3}
# getting element by key
print(dict["a"])
# inserting element with key
dict["d"] = 4
print(dict)
# delete some element by key
del dict["b"]
print(dict) |
3d80e544c4855753da721a8c4522aa69371059d7 | AmitHasanShuvo/Programming | /kangaroo.py | 177 | 3.5625 | 4 | def kangaroo(x1, v1, x2, v2):
return 'YES' if (v1 > v2) and (x2 - x1) % (v2 - v1) == 0 else 'NO'
x1, v1, x2, v2 = map(int, input().split())
print(kangaroo(x1, v1, x2, v2)) |
4340221792b1a1fb1e6b6617089eed8ce4e58cb1 | philiphoang/Python-Machine-Learning | /Exercise2/main.py | 1,726 | 3.828125 | 4 | import numpy as np
#plot data
import matplotlib.pyplot as plt
from gradientrunner import gradient_descent_runner
from gradientearlystop import gradient_descent_runner_early_stop
from normaleq import normalEquation
from sklearn.linear_model import LinearRegression
#Exercise 1.1
np.random.seed(2)
#generate 100 x values... |
22db866fc5203585c92ef60c02cdcbf9421c923e | BenDataAnalyst/Practice-Coding-Questions | /leetcode/123-Hard-Best-Time-To-Buy-And-Sell-Stock-III/answer.py | 2,346 | 3.8125 | 4 | #!/usr/bin/env python3
#-------------------------------------------------------------------------------
# Brute Force O(n^2) Solution
#-------------------------------------------------------------------------------
class Solution:
def maxProfit(self, prices):
"""
:type prices: List[int]
:rt... |
fed10e92e2106b583fbd0b7d128d0c89fe90289d | kaisjessa/Project-Euler | /pe066.py | 980 | 3.53125 | 4 | from math import sqrt, ceil, floor
#x**2 - D * y**2 = 1
#x**2 = 1 + D * y**2
#for D <- 2 to 1000 (no perfect squares), find integer values for x,y s.t. x in minimized
#https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Algorithm
def determine_period(n):
period = 0
m = 0
d = 1
a_0 = int(sqrt(n))
a = ... |
e34c28723e2e6b989c558e467a890c1b7858dc15 | AyelaChughtai/CS88 | /Labs/lab03.py | 2,631 | 4.09375 | 4 | # Question 1-3
def second_max(lst):
"""
Return the second highest number in a list of positive integers.
>>> second_max([3, 2, 1, 0])
2
>>> second_max([2, 3, 3, 4, 5, 6, 7, 2, 3])
6
>>> second_max([1, 5, 5, 5, 1])
5
>>> second_max([5, 6, 6, 7, 1])
6
>>> second_max([5, ... |
d9027cec689a6f58fcaccba0a7006c47f2dd5ad8 | Shiv2195/Algorithm_Toolbox | /week2_algorithmic_warmup/1_fibonacci_number/fibonacci.py | 260 | 3.9375 | 4 | # Uses python3
def fibonacci_series(n):
fibo_list = []
fibo_list.append(0)
fibo_list.append(1)
for i in range(2,n+1):
fibo_list.append(fibo_list[i-1] + fibo_list[i-2])
return fibo_list[n]
n = int(input())
print(fibonacci_series(n))
|
7cc6851f07e89518d8f993a3efc8be7298e55e74 | bobbyhalljr/Hash-Tables | /src/hashes/hashes.py | 267 | 3.546875 | 4 | import hashlib
# bits string
key = b"str"
# another way for bit
my_string = 'This is a normal string'.encode()
# for i in range(10):
# hashed = hashlib.sha256(key).hexdigest()
# print(hashed)
for i in range(10):
hashed = hash(key)
print(hashed % 8) |
39d3ea9678ec2c96d61b441d959934f81f0819ef | zhaochuanshen/leetcode | /Search_for_a_Range.py | 1,658 | 3.9375 | 4 | '''
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found in the array, return [-1, -1].
For example,
Given [5, 7, 7, 8, 8, 10] and target value 8,
return [3, 4].
'''
class Sol... |
8044f340304f9c434c272e3823f5951f2b3a1dab | Joecth/leetcode_3rd_vscode | /49.group-anagrams.py | 4,631 | 3.6875 | 4 | #
# @lc app=leetcode id=49 lang=python3
#
# [49] Group Anagrams
#
# https://leetcode.com/problems/group-anagrams/description/
#
# algorithms
# Medium (53.31%)
# Likes: 2809
# Dislikes: 157
# Total Accepted: 537.4K
# Total Submissions: 997.8K
# Testcase Example: '["eat","tea","tan","ate","nat","bat"]'
#
# Given a... |
a44c34e52b52a2423dab7317cf1256d0835083d9 | himadrinayak/Color-Game | /scap.py | 1,612 | 3.671875 | 4 | import tkinter
import random
import tkinter.messagebox
colours = ['Red', 'Brown', 'Pink', 'Blue', 'Green', 'Purple', 'Violet', 'Yellow', 'Black', 'Orange']
score =0
timeleft = 30
def startGame(Event):
if timeleft== 30:
countdown()
elif timeleft ==0:
endgame()
nextcolor()
de... |
f82aa1fb7bec005ecc49715f38239aa050def162 | AChen24562/Python-QCC | /Exam2/Q9.py | 632 | 4.1875 | 4 | '''Given:
items = ['notebooks', 'pens', 'pencils', 'usb']
quantities = [10, 24, 16, 12]
1) Create a dictionary, supplies by using the two given lists above.
2) Use a loop to print all keys and values in the dictionary supplies.
3) Print the dictionary supplies.
Example Output
10 - NOTEBOOKS, 24 - PENS, 16 - PENCILS, 1... |
4d08331903105c326c53618de2d3871ff055fb4b | vi31/APS-2020 | /CodeLib/104-CountingSort.py | 461 | 3.625 | 4 | def CountingSort(lst):
left=min(lst)
right=max(lst)
Range=right-left+1
count=[0 for x in range(Range)]
sortedArray=lst[:]
for i in range(0,len(lst)):
count[lst[i]-left]+=1
for i in range(1,Range):
count[i]+=count[i-1]
for i in range(0,len(lst)):
count[lst[i]-left]-=1
sortedArray[count[lst[i]-left]]=lst[... |
15fd52b4a919488d2da49da080f18930524b96aa | danisbagus/data-visualization-python | /from_json.py | 388 | 3.515625 | 4 | import matplotlib.pylab as plt
import json
year = []
population = []
with open('population.json') as json_file:
data = json.load(json_file)
for value in data:
year.append(value['year'])
population.append(value['population'])
plt.plot(year,population)
plt.title('data population')
plt.xlabel('ye... |
79bcfa61cf6bc85ebe2a1f717e638f37a5b8f791 | MustafaMuhammad2000/Neural_Net | /Test.py | 839 | 3.6875 | 4 | import NeuralNet as MN
import numpy as np
# Using the neural network!
test_neural_network = MN.neural_network([2, 3, 3, 1], 0.2)
# Testing a simple XOR bitwise function
input_arr = [[0, 0], [0, 1], [1, 0], [1, 1]]
target_arr = [[0], [1], [1], [0]]
print("Pre-training results")
print(test_neural_network.test(input_... |
da9bbb610f3966c5f3fa2d63f5b583ceb1a67015 | srinidhi136/python-app | /Volume of cone.py | 261 | 4.5 | 4 | ##this program is to calculate the Volume of the cone
Radius_of_the_cone = 7.5
height_of_the_cone = 21.5
pi = 3.14
volume_of_the_cone =(pi*Radius_of_the_cone*Radius_of_the_cone*height_of_the_cone)/(1/3)
print("The volume of the cone", volume_of_the_cone)
|
700dd85b92006177b860cda5d027e4a19c08ded5 | shachafk/FeedbackVertexSet | /graphs/multi_graph.py | 515 | 3.890625 | 4 | import networkx as nx
from utils.functions import show_graph
from utils.reductions import run_reductions
mg = nx.MultiGraph()
mg.add_node(1)
mg.add_node(2)
mg.add_node(3)
mg.add_edge(1, 2)
mg.add_edge(1, 3)
mg.add_edge(2, 3)
mg.add_edge(1, 2)
# mg.add_edge(1, 1)
k = 3
# show_graph(mg, "before")
print("number of nodes... |
f573fde72ed101360a2a41cf648cedcd8f2268c3 | floo1/Richtungshoeren_mit_Python | /combinig_arrays.py | 850 | 3.890625 | 4 | # Arrays zusammenführen
# hier mal ein Beispiel wie man Arrays zu einem Array zusammenfassen kann:
import numpy as np
# erzeuge zwei zeilenvektoren mit jew. 2 spalten
a = np.zeros([2,2])
b = np.array([[5,6],[7,8]])
# ranheangen der zwei vektoren als zeilenvektor in einem array
p=np.vstack([a,b])
# weiter Array erz... |
47d932de814350ae2947cde5d0aff6e5299a5470 | riturajsingh2015/Algorithms-and-Datastructures-with-Python | /matrix_ele_sum.py | 352 | 3.640625 | 4 | def matrixElementsSum(matrix):
total=sum(matrix[0])
for i in range(1,len(matrix)): # row index
for j in range(len(matrix[i])): # col index
if matrix[i-1][j] !=0:
total+=matrix[i][j]
return total
matrix=[[0,1,1,2],
[0,5,0,0],
[2,0,3,3]]
pr... |
5861087fd3a093f080c343137f300c2975a407f6 | fnpy/fn.py | /fn/immutable/finger.py | 7,130 | 4.125 | 4 | """Finger tree implementation and application examples.
A finger tree is a purely functional data structure used in
efficiently implementing other functional data structures. A
finger tree gives amortized constant time access to the "fingers"
(leaves) of the tree, where data is stored, and the internal
nodes are label... |
24b81468ea0defee70e319dab673cc74369dfa0c | brentoncollins/wateringsys | /livelevel.py | 631 | 3.6875 | 4 | #!/usr/bin/python3
#!/
# This is a python script reading the live level in the water tank.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.OUT) # set pin 22 gpio to an output
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # P... |
c272b6a2f57292851b097536be1810e3515ba77b | Sanjay-2001/Assignment | /Day1_assignment.py | 315 | 4 | 4 | #Question no. 1
a="hello"
b="hello"
print(a is b)
c=89.3
d=78.4
print(c is d)
#Question no. 2
print(1>3>4)
#Question no. 3
str='100'
print("int('100') with base 2 = ", int(str,2))
s=str
print("value of str function = ",s)
float_string=float("-12")
print("value of float function = ",float_string) |
dc66a0705b1585b986dbd5a984b818efec84effc | rahilanjum/PIAIC | /Assignment 2.py | 2,560 | 4.46875 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Step 1. Import the necessary libraries
# In[1]:
import pandas as pd
# In[ ]:
# # Step 2. Import the dataset Euro_2012_stats_TEAM
# # Step 3. Assign it to a variable called euro12.
# In[140]:
euro12 = pd.read_csv("Euro_2012_stats_TEAM.csv", skipfooter=4, engine='py... |
3b809a638726ffec612b160b6fa8087d18bc8608 | Tom-van-Grinsven/Sudoku-Solver | /src/solver.py | 2,768 | 3.65625 | 4 | import urllib.request, json
def get_board():
with urllib.request.urlopen("https://sugoku.herokuapp.com/board?difficulty=easy") as url:
data = json.loads(url.read().decode())
return data["board"]
board = get_board()
# board = [
# [0,0,3,7,0,0,0,6,0],
# [0,0,0,5,6,0,0,4,0],
# [0,6,2,0,0... |
756c79ed1fc6fa02c4383a2656cae004827a20da | fanwangwang/fww_study | /doc/_book/py_example/femknowledge/usefor.py | 201 | 4 | 4 | # 使用`for`循环
# 给定一个函数 $f(x) = x*x + x + 1$ ,求从0到n的值以及他们的和
def f(x):
f = x*x + x + 1
return f
s = 0
for i in range(5):
s += f(i)
print(f(i),s)
|
c7e3a6d361c1bb5453f60f37b47dda1d772be648 | Rebecca-Simms/10-Days-of-Statistics | /2-Quartiles_Interquartile_Range_SD.py | 2,450 | 4.5625 | 5 | """ The quartiles of an ordered data set are the three points that split the data set into four equal groups. The three quartiles are defined as follows:
- Q1: The first quartile is the middle number between the smallest number in a data set and its median.
- Q2: The second quartile is the median (50% percentile) of th... |
9628be44e10ce921120a17a6ad3f2053eba649a3 | vizeit/Leetcode | /MergeKSortedLists.py | 1,269 | 3.8125 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def mergeKLists(lists) -> ListNode:
if not len(lists): return None
elif len(lists) == 1: return lists[0]
d = {}
front = None
while len(lists):
i = 0... |
c2c9342fc0c49f979b2ef3ce910a6cabaed1af80 | neerajp99/intro_to_cs_CS-101 | /cs1101/Neeraj_Pandey_cs1101_practice4/q11.py | 836 | 4.125 | 4 | """
Concatenate two different lists in the following way:
List1 = ["bingo ", "bango"]
List2 = ["bongo ", "dry”]
[“bingle bongo”, “bingo dry”, “bango bongo”, “bango dry”]
Solution: Using list comprehensions, makes work simpler
"""
if __name__ == "__main__":
list1 = list()
list2 = list()
... |
19449a8c3d7391986351f441cf5c2b743a3dbcb2 | tx991020/MyLeetcode | /腾讯/回溯算法/022括号生成.py | 2,960 | 3.78125 | 4 | '''
给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。
例如,给出 n = 3,生成结果为:
[
"((()))",
"(()())",
"(())()",
"()(())",
"()()()"
]
'''
'''
class Solution:
def generateParenthesis(self, n):
"""
:type n: int
:rtype: List[str]
"""
self.res = []
self.singleStr('', 0,... |
caacbe649b7d147338a246d9276480152c704980 | danielcanuto/python_revisao | /fucoes/unpacking.py | 543 | 3.71875 | 4 | #!/usr/bin/python3
def soma_2(a, b):
return a + b
def soma_3(a, b, c):
return a + b + c
def soma_n(*args):
soma = 0
for n in args:
soma += n
return soma
if __name__ == "__main__":
print(soma_2( 20, 30))
print(soma_3(10, 20, 30))
# packing
print(soma_n(10, 20, 30, 22))
... |
f54278a00f8a7ede8600c1e14fbcacc8dd8499ad | CarolineSantosAlves/Exercicios-Python | /Exercícios/ex105AnilisandoGerandoDicionarios.py | 1,075 | 3.703125 | 4 | def notas(* nota, sit=False):
"""
->Função para analisar notas e situções de vários alunos.
:param nota: uma ou mais notas dos alunos (aceita várias)
:param sit: valor opcional, indicando se deve ou não adicionar a situação
:return: dicionário com várias informações sobre a situação da turma
"""... |
0bea1f33b56ed7cdcfb4daf08848043b362c439c | dbwilson35/TicTacToe | /TicTacToe.py | 4,599 | 3.515625 | 4 | class ttc_board:
def __init__(self):
self.board = {1: '_',2: '_',3: '_',
4: '_',5: '_',6: '_',
7: '_',8: '_',9: '_'}
def display(self):
print(self.board[1] + '|' + self.board[2] + '|' + self.board[3])
print(self.board[4] + '|' +... |
1b9f3d7efbce8a408868f4b3e0f1915321815e9b | kk31398/guvi-project | /Given a string S-check if it is a palindrome.Print yes or no.py | 68 | 3.828125 | 4 | value=str(input())
a=value[::-1]
print("yes" if a==value else "no")
|
4e21a9e050ed9f8ab9372970a2c7fd6df271e556 | FerdinandAlick/Python-Assignment | /Python Assignmet1/Question4.py | 282 | 4.53125 | 5 | #Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit, and print out the converted temperature.
celsius=float(input("Enter the temperature in degree celsius:"))
fahrenheit = (celsius * 1.8) + 32
print("Fahrenheit=",fahrenheit) |
52ea80abad4906c7c587989e62d50e28415c768d | czs108/LeetCode-Solutions | /Medium/371. Sum of Two Integers/solution (1).py | 510 | 3.578125 | 4 | # 371. Sum of Two Integers
class Solution:
def getSum(self, a: int, b: int) -> int:
x, y = abs(a), abs(b)
if x < y:
return self.getSum(b, a)
sign = 1 if a > 0 else -1
if a * b >= 0:
# Sum of two positive integers x + y.
while y:
... |
c274ee8fefa3f228aaf3fd4a070b463776e82fb8 | MatheusFilipe21/exercicios-python-3 | /exercicio24.py | 104 | 3.765625 | 4 | cidade = str(input('Em que cidade que você nasceu: ')).strip()
print(cidade[0:5].upper() == 'SANTO')
|
9b7ca16e1d86edccd175ca2b0ea93bf94d3be9d2 | ankitaroyyy/JISAssasins | /Tenth.py | 279 | 3.890625 | 4 | X = input("Enter your string")
l=len(X)
print("The length is", l)
Y = "Ankita"
Z= X+Y
print("After concatenation", Z)
print(''.join(reversed(X)))
old="I like Python"
new=old.replace("like","love")
print(new)
if X == Y:
print("Equal")
else:
print("Not Equal") |
891bd5a620a45683f40ab4b8428e6fb0b119eca6 | Uma98/Python | /Day3/namesList.py | 128 | 3.609375 | 4 | list = ["john", "jake", "jack", "george", "jenny", "jason"]
for i in list:
if len(i) < 5 and "e" in i:
print(i) |
1754a73482f44b96680cc7a81660fb4add73ac53 | bogeoung/AIffel-X-SSAC | /Leetcode/week 03/344. Reverse String.py | 1,073 | 3.609375 | 4 | class Solution:
def reverseString(self, s) -> None:
# 반복할 횟수를 정하기 위해 전체길이의 2를 나눈 몫을 구함
time = len(s)/2
# 바꿀 문자열의 위치를 지정할 변수 count 선언
count = 0
while time >= 1 :
time -= 1 # 무한루프를 막기 위해 time 감소
temp = s[count] # temp라는 임시 변수에 s[count]값을 저장 후, 값을 교환함
... |
1235ad04057f91b827c57836083a2c87c5797a28 | rodrigojgrande/python-mundo | /desafios/desafio-097.py | 468 | 4 | 4 | #Exercício Python 097: Faça um programa que tenha uma função chamada escreva(), que receba um texto qualquer como parâmetro e mostre uma mensagem com tamanho adaptável.
# Ex: escreva(‘Olá, Mundo!’) Saída:
#~~~~~~~~~
#Olá, Mundo!
#~~~~~~~~~
def escreve(frase):
tamanho = (len(frase) + 4)
print('~'... |
75ab92954f109e3e28ea7d05970859a3811ddde2 | gene63/BaekJoonStep | /step1/9.py | 121 | 3.6875 | 4 | a, b = input().split()
a = int(a)
b = int(b)
print(str(a+b)+'\n'+str(a-b)+'\n'+str(a*b)+'\n'+str(int(a/b))+'\n'+str(a%b)) |
e5dffe9f0e4e37ba2bcf0fe78987183ecf1f2905 | lizwikhanyile/challenge2 | /dna_complementary.py | 862 | 4 | 4 |
### START FUNCTION
def dna_complementary(dna):
# define how key and values will be maped
maping = {'ins':'0'}
# A dictinary of links
dict_links = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
#We assume other letters or characters may exist
# other than 'ATGC' and we map them to single letters... |
bd2f459186e85151205aece274f97169b5ce3615 | AndrejLiptak/schoolwork | /Python/class5.py | 1,822 | 3.671875 | 4 | def find_max(lst):
maximum = lst[0]
for value in lst:
if maximum < value:
maximum = value
print(maximum)
def find_min(lst):
minimum = lst[0]
for value in lst:
if minimum > value:
minimum = value
print(minimum)
def list_sum(lst):
to... |
1e1208a3ce1c967cc98c9f3485242cf798c1cdca | techkids-c4e/c4e5 | /Vũ Đình Hưng/Lesson 4/Bài 1 phần 5.py | 294 | 4.1875 | 4 | from turtle import *
speed(0)
def draw_square(x, y):
color(y)
for a in range (4):
forward(x)
left(90)
square_length = float(input('What is the length of the square?: '))
square_color = input('What is the color of the square?: ')
draw_square(square_length, square_color)
|
42b5a11339851544418f71b3cd7e1ceb8ab46966 | dlcios/coding-py | /basic/def.py | 594 | 3.65625 | 4 | #coding: utf-8
# to16mod = hex
# n1 = to16mod(25)
# print(n1)
# #定义函数
# def mabs(num):
# if num > 0:
# return num
# else:
# return -num
# a = -15
# b = 15
# print(mabs(a), mabs(b))
# def power(x):
# return x * x
# print(power(a))
# def powern(x,y = 2):
# s = 1
# while y > 0:
... |
ab457e196aca3eae49300e84606518350dea7120 | adailsom/arquiv | /loop.py | 119 | 3.96875 | 4 | a = 2
while a > 0:
print(a)
a -= 1
print('fim do while')
for x in range(-10):
if x % 2 == 0:
print(x) |
da3cde5fe0ebccf7df02602392fd1d0a5c17d6b8 | damoyaweb/Python | /CursoInical/tablasMultiplicarConFor.py | 161 | 3.734375 | 4 | table = int(input('Que tabla quieres ver: '))
mumeros = range(0,112)
for num in mumeros:
result = table * num
print(f'{table} X {num} = {result}')
|
3cf05f83acb236b10a0666298d39b1a940f139f6 | GauravRoy48/XGBoost | /xgboost_GR.py | 1,981 | 3.515625 | 4 | #####################################################################################
# Creator : Gaurav Roy
# Date : 22 May 2019
# Description : The code applies XGBoost on the Artificial Neural Network algorithm
# for the given dataset Churn_Modelling.csv.
##############################... |
4a4f79db929eb24d9a211fca329a9f6ce2478678 | VassarIgniteCS/intro_to_python | /lecture_3/activities/solutions/list_shuffle.py | 1,555 | 4.34375 | 4 | '''
==========================================================
LIST SHUFFLE
----------------------------------------------------------
Say we have two lists:
[1, 2, 3, 4, 5] and
['a', 'b', 'c', 'd', 'e']
If we interleaved them together they would look like:
[1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e']
Let's write a func... |
700772fc7146da538c39c6db77a6b028967e6ea2 | lleonie/hackinscience | /exercises/025/solution.py | 193 | 3.78125 | 4 | import datetime
from datetime import time
date = datetime.date.today()
now = datetime.datetime.now().time()
heure = now.replace(microsecond=0)
print("Today is %s and it is %s" % (date, heure))
|
b596b0843e57375625daeacd6c857013644c75a9 | hariss0411/Python-Codes | /linked_list.py | 2,147 | 4.125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class Linked_list:
def __init__(self):
self.start=None
def insert_start(self,new_node):
if self.start==None:
self.start=new_node
else:
(new_node.next,self... |
6b3a525a2356e997a8bdffbd4f52b89ce8804e28 | virakobrynchuk/Olimpiada | /6.2015.py | 138 | 3.609375 | 4 | from fractions import gcd
a, b = [int(i) for i in input().split()]
def lcm(a, b):
return abs(a*b) // gcd(a, b)
print(lcm(a, b))
|
02175cdb6fd8f861b2f8ff7561977c9f862244d0 | mwnickerson/python-crash-course | /chapter_9/dice.py | 895 | 4.3125 | 4 | # Dice
# Chapter 9 exercise 13
# Create a die with imported random module
from random import randint as r
class Die:
def __init__(self, sides=6):
"""initialize default dice side value"""
self.sides = sides
def roll_dice(self):
"""generate a number between 1 and number of sides"""
... |
65a7a896c236f76859beccb888b869d2b100510e | SubuNayak/Python-Basic-Programs | /maxlist.py | 240 | 4.3125 | 4 | #Python program to find largest number in a list
def maxlist(arr):
return max(arr)
n = int(input("Enter the size of the array: "))
arr = []
arr = list(map(int,input('Enter the elements: ').strip().split()))[:n]
print(maxlist(arr)) |
dea1a298c4470fafb9ea4548bc432c24a3cdf522 | slawektestowy/bootcamping | /struktury_danych/petla_for.py | 638 | 3.703125 | 4 |
# ZADANIE: WYPISZ ILE JEST DANYCH ELEMNTOW (UJEMNYCH I DODATNICH0
# lista = [1,2,-3,4,5,6,-7,8,9]
#
# ile_d=0
# ile_u=0
#
# for i in lista:
# if i >0: # widze liczbe dodatnia
# ile_d +=1 # zwiekszam licznik dodatnich ile jest elementów
#
# for i in lista:
# if i <0: # widze liczbe ujemnych... |
9d7b1c79a99c650cad7e2a7a727ea1dcbf119c0c | jishnujagadeeshpi/OS-Lab | /First Come First Serve Scheduling.py | 6,758 | 3.640625 | 4 |
'''
Write a program to implement FCFS scheduling with arrival time.
'''
from prettytable import PrettyTable
time = 0
processes = []
ID = 0
table = PrettyTable()
table.field_names = ["Process" , "Arrival Time" , "Burst Time" , "Completion Time" , "Turn-around Time" , "Waiting Time" ]
class Pro... |
f959daa8292a10e590a46e4bec3eaed205d7cb98 | Usefulmaths/Linear-Regression | /ridge_regression.py | 1,633 | 3.53125 | 4 | import numpy as np
from linear_regression import LinearRegression
class RidgeRegression(LinearRegression):
def __init__(self, lambd):
super().__init__()
self.lambd = lambd
def fit(self, X, y, bias=True):
'''
Finds the parameters that minimises the
MSE + L2 norm of the... |
37cc436e5a879d95ed038b63471fdb1600cfccee | ericohenrique/Udacity-DataScienceI | /Semana2/Semana2-Lesson2-25.py | 540 | 3.859375 | 4 | # Define a procedure, measure_udacity,
# that takes as its input a list of strings,
# and returns a number that is a count
# of the number of elements in the input
# list that start with the uppercase
# letter 'U'.
def measure_udacity(list):
count = 0
i=0
while i < len(list):
if list[i].find('U') =... |
4d1c34ae5819b78b1115dd9ab988d72ba6c94c0f | sakshi303/CS50_web_programming | /lecture_python/functions.py | 93 | 3.8125 | 4 | def cube(n):
return n*n*n
for n in range(6):
print(f"the cube of {n} is {cube(n)}")
|
e1cd49e61627c3e3e73ff6d8a4b50dac2b2f625a | suryaraj93/LuminarPython | /FlowControls/Decisionmaking/Modulus.py | 117 | 4.0625 | 4 | num1=int(input("Enter number 1: "))
num2=int(input("Enter number 2: "))
modulus=(num1%num2)
print("result: ",modulus) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.