blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
5df44fab429d251f964eb561f8a06f9a71a94a4a
pedrosimoes-programmer/exercicios-python
/exercicios-Python/ex020.py
1,191
3.875
4
#forma 1 #from random import shuffle #a1 = input('Primeiro aluno: ') #a2 = input('Segundo aluno: ') #a3 = input('Terceiro aluno: ') #a4 = input('Quarto aluno: ') #lista = [a1, a2, a3, a4] #random.shuffle(lista) #print('A ordem de apresentação será: {}'.format(lista)) #forma 2 (A melhor forma) from random import sample...
bb4a8f606ab02c1c198c339fadc59a2992c23da8
sumanth82/py-practice
/python-workbook-practice/76-100/84-piglet.py
554
3.71875
4
# Use pyglet library to create a hello world application # It should pop open a window which displays - Hello World; # pyglet library is used for gaming apps/softwares import pyglet window = pyglet.window.Window() label=pyglet.text.Label('Hello, World', font_name='Times New Roman', ...
6f064f3fe9a22ff6e5a0193f4ed4a6f280537b25
AbhayKumarJain/Hackerrank-Codes
/30 Days of Code/D1-Data-Types.py
2,530
4.0625
4
''' Objective Today, we're discussing data types. Check out the Tutorial tab for learning materials and an instructional video! Task Complete the code in the editor below. The variables , , and are already declared and initialized for you. You must: Declare variables: one of type int, one of type double, and o...
3b260701f7b0f17fac57e74ebfdd1bf113f147ab
badbayesian/game_theory
/game_theory/model.py
10,402
3.78125
4
import copy import itertools import numpy as np import pandas as pd from game_theory.minimax import LinProg class game(): """Collection of methods to solve games in game theory. Currently able to solve and find nash equilibriums for any two player game with finite choices and deterministic strategies giv...
968a885f41619acdb74cc8bb08f89a3e70d88f4f
bharat0071/Python_Assignments
/triangle_area.py
270
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sat May 16 20:21:08 2020 @author: MOHANA D """ #write a program to enter base and height of atraingle and find its area h=float(input("enter height value:")) b=float(input("enter base value:")) a=(b*h)/2 print("area:",a)
41f266997998141d1331f64b05a696b51138d366
VinayakSingoriya/Data-Structures-Python
/Binary_Tree/14_Iterative Search In BST.py
1,060
4.25
4
# Implementation of Searching Operation in a BST in a Iterative Way. class Node: def __init__(self, data): self.data = data self.left = None self.right = None def printInorder(root): if root is not None: printInorder(root.left) print(root.data, end=" ") printIno...
e48cdd23e1c1ea5668e8fdb2fbd5415c5ed9f892
mrgiser/helloworld-python
/oop/multipleInheritance.py
686
4.09375
4
class A: def __init__(self,name): self.name = name print("class A init") def hello(self, word): print("class A helloA " + word) class B: def __init__(self,name2): self.name2 = name2 print("class B init") def hello2(self,word): print("class B helloB " + ...
94c6de2b3be968e517c4baf85f937880fc28003b
snehamathur01/coding
/catc.py
708
4.21875
4
#!/usr/bin/python3 option=''' Press 1 to view file contents : Press 2 to view multiple files contents : Press 3 to show content preceding with line number : Press 4 to create a file : ''' print(option) choice=int(input()) if choice == 1 : print("enter file name") f=input() fi=open(f) ...
82cb46ddc3d1b1c3d94007134b7d2ae9e9153dca
artbohr/codewars-algorithms-in-python
/7-kyu/monty-hall-problem.py
1,035
4.09375
4
def monty_hall(c_door, p_guesses): return int(round(sum([x/x for x in p_guesses if c_door!=x])/len(p_guesses)*100)) ''' The Monty Hall problem is a probability puzzle base on the American TV show "Let's Make A Deal". In this show, you would be presented with 3 doors: One with a prize behind it, and two without (r...
10a21c3b749e81497e9e6ea94546ca56e7e46126
MichaelCurrin/machine-learning-server
/mlserver/lib/imageTransformer.py
11,185
3.578125
4
# -*- coding: utf-8 -*- """Image Transformer application file. The purpose of the ImageTransformer is to transform (resize, crop, etc) images so that images meet the requirements so that the images can be sent to plugins, or returned. We use float division from Python 3.x instead of floor division, so scaling factor ...
13064e0569f38840ac4c4f5b468619795104d71a
cs-richardson/fahrenheit-jelchakieh21
/fahrenheit.py
278
3.921875
4
while True: try: celsiusInput = float(input ("Input Celsius: ")) fahrenheitOutput = 1.8*celsiusInput+32 print("Fahrenheit:" , fahrenheitOutput) import sys sys.exit() except ValueError: print("Fooey! That's not a number!")
c3c31e0d2abf127c8a47903fcdaba587db206680
ag-python/pyzzle
/pyzzle/datafile.py
3,762
4.125
4
import sqlite3 import os class Table(type): """A metaclass used to represent the tables of a database. Intstances of a table class are stored in the rows attribute, indexed by their primary key. For instance, Slide.rows['foobar'] accesses the instance 'foobar' from the Slide class, ...
e6b478b0b54658996c0284ff8f9c289289239536
adamandrz/Python-basics
/practice-python/eve-odd.py
554
3.59375
4
number = int( input("Podaj liczbe (dzielna) :" ) ) check = int( input ("Podaj dzielną :")) if number % 2 == 0: if number == 4: print ( "To jest liczba cztery, która jest liczbą parzystą! ") else: print ( str(number) + " jest liczba parzystą! ") else: print ( str(number) + " jest liczba nie...
c523ab39acdb669a694049e67a8d54c2c628c994
haivt28/advent-of-code
/2020/day10.py
1,895
3.5625
4
input = open('input/day10.txt').read() # PART 1 adapters = list(map(int, input.split('\n'))) adapters = sorted(adapters) init = 0 count1 = 0 count3 = 0 for adapt in adapters: if adapt - init == 1: count1 += 1 if adapt - init == 3: count3 += 1 init = adapt print(count1*(count3+1)) # PAR...
816f6572afa4cba53d4845153653e21574443061
sangeethanandha/SANGEETHA
/b85.py
153
3.953125
4
str=input("enter the string") lst=list(str) even="" odd="" i=1 for j in lst: if i%2==0: even=even+j else: odd=odd+j i=i+1 print(odd, even)
d80062915ffe2fe07946c031a6492506e053e86a
DenisIvanovo/test-task
/#1.py
1,198
4.34375
4
""" Дан массив чисел, состоящий из некоторого количества подряд идущих единиц, за которыми следует какое-то количество подряд идущих нулей: 111111111111111111111111100000000. Найти индекс первого нуля (то есть найти такое место, где заканчиваются единицы, и начинаются нули) """ array = [1, 1, 1, 1, 1, 1, 1, ...
a1739de74fcf824ff8eea95a38b21e0cae8c76fb
E2057SalihPoyraz/Python-Daily_Challenges
/majority-element.py
879
3.90625
4
# QUESTION: Level of Interview Question = Easy # Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. # You may assume that the array is non-empty and the majority element always exist in the array. # Example 1: # Input: [3,2,3] # Output: 3 ...
c5d160fa90534b6b83e6f4649417122dce98fa1d
Goku-kun/1000-ways-to-print-hello-world-in-python
/using-for.py
96
4.15625
4
#print "Hello, World!" using for loop for letter in "Hello, World!": print(letter, end="")
cb2b22ff3ef934654983f20a2f789861fd69fdb6
wslxko/LeetCode
/tencentSelect/number14.py
839
4.125
4
''' 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素。 示例 1: 输入: [3,2,3] 输出: 3 示例 2: 输入: [2,2,1,1,1,2,2] 输出: 2 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/majority-element 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 ''' class Solution: def majorityElement(self, nums): n...
6e9d02087889e7fdc6413d4a9091d8a7e4dcdee9
zaleskasylwia/Resident
/community.py
2,357
3.546875
4
import csv class Community: def __init__(self, community_name, year_of_fundation, address): if type(community_name) is str and type(year_of_fundation) is int and type(address) is str: self.community_name=community_name self.year_of_fundation=year_of_fundation self.addr...
d337e135daac60dbe0a182e168faeb53c93fa6e9
Garvit-32/DL-from-scratch
/math.py
4,712
3.640625
4
import matplotlib.pyplot as plt import matplotlib import numpy as np from numpy import ndarray from typing import List, Callable, Dict def square(x): return np.power(x, 2) def relu(x): return np.maximum(0, x) def sigmoid(x): return 1 / (1+np.exp(-x)) # 'A function to calculate deriv' def deriv(fun...
9b75139623ef1c7edf76b90f02c5d79f3bd40a32
sumrdev/Code-Portfolio
/OBJECTORIENTED/Geometry2D/Circle.py
220
3.921875
4
class Circle: def __init__(self, x, y ,r): self.x = x self.y = y self.r = r def printCircle(self): print((self.x, self.y), "Radius: ", self.r) c = Circle(20,10,3) c.printCircle()
0c7ebc72746934b5e74bbb42f4b11b049a4a806e
niurerav/Batch_rename
/batch_rename.py
638
3.625
4
""" This script removes a substring from a filename. BackStory: I downloaded bunch of mp3 files from webmusic.in and as expected all of them had "_(webmusic.in)" sub string attached to them. And as such I put on my geeky hat and wrote this simple script to remove the substring in the file. """ import os for filename ...
c6cf7198030e9c7e9f0e348000f5f88280996a4f
lamatehu/study-c-python
/python/chapter 5/exams/2.py
481
3.546875
4
import turtle def koch(size, n): if n == 0: turtle.fd(size) else: for anger in [0, 60, -120, 60]: turtle.right(anger) koch(size/3, n-1) def main(level): a= level turtle.setup(600, 600) turtle.penup() turtle.goto(-200, 100) turtle.pendown() turtl...
361f1a500b6738377eb779f0a9775127b5a334ec
saminathansami/alphabet
/leapyear.py
184
3.578125
4
ly=int(input(" ")) if ly%100==0: if ly%400==0: print ('yes') else: print ('no') elif (ly%4==0): print ('yes') else: print ('no')
73cedcd757c5f6d2bd710bd1d78a840d1734f3c5
alexs95/ARC
/src/manual_solve.py
25,154
3.5
4
#!/usr/bin/python """NUI Galway CT5148 Programming and Tools for AI (James McDermott) CT5148 Assignment 3: ARC Student name(s): Alexey Shapovalov Student ID(s): XXXXXXXX GitHub: https://github.com/alexs95/ARC Choice of Task --------------------------------------------------------------- I looked through about 50 - 75...
204d89e2cd7f6f6d8dd0dcf5fdd12e2e4bf52d06
Ved005/project-euler-solutions
/code/the_incenter_of_a_triangle/sol_482.py
638
3.5625
4
# -*- coding: utf-8 -*- ''' File name: code\the_incenter_of_a_triangle\sol_482.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #482 :: The incenter of a triangle # # For more information see: # https://projecteuler.net/problem=482 # Prob...
c03077f528f01261c65eb40ecf1a3b4553438b27
Rachelspdo/Anagram-and-Substring
/solutions.py
1,531
4.125
4
###### Question: Given two strings s and t, determine whether some anagram of t is a substring of s. For example: if s = "udacity" and t = "ad", then the function returns True. Your function definition should look like: question1(s, t) and return a boolean True or False. ###### import collections def check_anag...
fcd2dc90a9f3c2a60dbcc99437e4ce66976a3611
msamassa/git_lesson
/src/my_square.py
236
3.984375
4
def m_square(x): """ take a value and returns the square value. use operator ***** """ return(x ** 2) def my_square2(x): """ uses the operator to calculate square """ return(x * x) print(m_square(4)) print(my_square2(9))
9ebe6de372d7d35e0c9ea0adbae988c96e09a3e9
csu100/LeetCode
/python/leetcoding/LeetCode_04.py
884
3.75
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/1/12 21:32 # @Author : Zheng guoliang # @Site : # @File : LeetCode_04.py # @Software: PyCharm """ 1.需求功能: https://leetcode-cn.com/problems/median-of-two-sorted-arrays/ 2.实现过程: """ class Solution: def findMedianSortedArrays(self,nums1,nums2):...
a7bf957786d694360c04f2fbb0736f10820677ef
gwolf/sistop-2017-2
/practicas/5/HernandezIvan/camino.py
784
3.6875
4
from os import walk from colorama import init, Fore, Back, Style init() for (path, directorio, archivos) in walk("."): #Lo primero es leer el path, ver donde se esta""" print(Fore.RED + Style.BRIGHT + "PATH") print(Style.RESET_ALL) print (Fore.RED) print path print(Style.RESET_ALL) """Leer l...
7b287e4588aa01ea40a2303adda6ff2160ed1cc8
hanrick2000/LeetcodePy
/leetcode/dp/two_keys_board_solution1.py
1,303
3.984375
4
from collections import deque import random class Solution(object): def minSteps(self, n): """ :type n: int :rtype: int """ if n == 1: return 0 # org_n = n prime_list = deque() # iteratively divide by 2 while n % 2 == 0: ...
dfc00f375172a34fa4bb5f22078e0cf696bdca3d
WAMaker/leetcode
/Algorithms/48-Rotate-Image.py
595
3.546875
4
class Solution: def rotate(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ n = len(matrix) if n < 2: return lb, rb, tb, bb = 0, n - 1, 0, n - 1 while lb < rb: for i in range(0, rb ...
f5d0499bf33d2aaa93fd537ddd7c1deb232849fc
Heckfy85/learnpython8
/test_func.py
252
3.765625
4
def get_vat(price, vat_rate): if price==int and vat_rate==int: vat = price / 100 * vat_rate price_no_vat = price - vat print(price_no_vat) else : print('введите число') price1 = 100 vat_rate1='5' get_vat(price1,vat_rate1)
1462fdf5d6082945a8b4d3518bcc1eaa7a5cb179
alvyxc/dailycode
/10_14_2019_MinNum.py
930
3.65625
4
#Given an array of integers, find the first missing positive integer in linear time and constant space. #In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and #negative numbers as well. #For example, the input [3, 4, -1, 1] should give 2. The input [1, ...
4f8f0f7cf9f526d500f4d238dde254b662e243e1
jhandrad/agenda-tefonica
/classes.py
4,749
3.5625
4
# imports da lib padrão from typing import Type from functools import total_ordering import os # imports de terceiros # imports de módulos próprios import funcoes_bd ''' Arquivo que contem as classes responsáveis pelo funcionamento da agenda. Poderiamos dizer que é o back-end. ''' class ListaUnica(): # classe legad...
bcbe8170a2a831e9c9d7da1b5a82fe36473bb543
euzin4/gex003_algprog
/material/respostas_exercicios/lista4/exe3.py
148
3.953125
4
N = int(input("Informe um número: ")) if N <= 10: print("F1") elif N > 10 and N <= 100: print("F2") else: #caso seja maior que 100 print("F3")
4279b85f04ee9dcd7916bab733d800297096b452
escm1990/PhythonProjects
/Otros/POO/Ejercicios POO/03_Ejercicio.py
847
3.96875
4
# Crear una clase Fabrica que tenga los atributos de Llantas, Color y Precio; # luego crear dos clases mas que hereden de Fabrica, las cuales son Moto y Carro. # Crear metodos que muestren la cantidad de llantas, color y precio de ambos transportes. # Por ultimo, crear objetos para cada clase y mostrar por pantalla l...
4a4c68ae28971ac23e94b948356ee611f42159a2
aveetron/Algooo
/Sort/selection-sort.py
772
3.875
4
class SelectionSort(object): def __init__(self,number_list): self.number_list = number_list def sort_list(self): for i in range(len(self.number_list)): min_index = i for j in range(i, len(self.number_list)): if self.number_list[j] < self.number_list[min_...
dea1489c3567ec2bc982143ac1cc57361274917f
vaibz96/Special-Topics-in-Software-Engineering-Course-work
/Homework 5/Homework05-Vaibhav.py
3,318
4.1875
4
""" @author: Vaibhav Vishnu Shanbhag @homework: HW 05 @date: 02/24/2019 @time: 05:08:11 PM This code Implements a class for string methods and the automated testing """ import unittest """Part 1""" def reverse(str): string = '' index_val = len(str) """ While loop will start with the length of the strin...
7c412dcfce2d1237887521546c43e32078cabe8d
Pavche/python_scripts
/remove_duplicates.py
305
4.03125
4
def remove_duplicates(list_of_items): new_list = [] for item in list_of_items: for elem in new_list: # is this item present in new_list if elem == item: break else: new_list.append(item) result = new_list return result print remove_duplicates(['a','b','c','a','b','c'])
9db8a4fcf1ab8b9a74a692c295c3398e23bd8d4f
BarnetteME1/textminer
/textminer/validator.py
1,918
3.71875
4
def binary_numbers(string): if re.search(r"[2-9]", string): return False return True def binary_even(string): if re.search(r"0$", string): return True return False def hexadecimal(string): if re.search(r"[A-F]\d", string): return True return False def word(string): ...
a1854e8a9459161e890498275ea9a964db1f8d40
LukazDane/CS-2-Tweet-Generator
/sample.py
1,345
4
4
import random import sys # words = sys.argv[1:] words = ["one", "fish", "two", "fish", "red", "fish", "blue", "fish"] histogram = {'cats': 3, 'dogs': 4, 'rabbits': 2, 'turtles': 1} hg = {'cats': 3, 'dogs': 4, 'rabbits': 2, 'turtles': 1} def sample(histogram): tokens = sum([count for word, count in histogram.ite...
feababa0ba2e52b185b9f252d57b9a2eff73f147
IgorJordany/Compiladores-1-20172
/Implementações/AnalisadorLexico_v2.py
1,808
3.84375
4
def pReservada (token): reservadas = ['var', 'integer', 'real', 'if', 'then'] if token in reservadas: return True return False def operador (token): operadores = [':=','+'] if token in operadores: return True return False def delimitador (token): delimitadores = [':',',',';'] if token in delimitadores: ...
1d36a0cec63d0a13f7db4f4d58c5f561160611cc
mrozsypal81/323-Compilers-Assignment-3
/compiler/syntax_analyzer/syntax_analyzer.py
2,676
3.515625
4
class Syntax_analyzer (object): def __init__(self, *arg): self.lexemes = arg # print('arg = ', arg) # statemenize method - create statement list from lexemes def syntaxA(self): lexemes = list(self.lexemes[0]) begin = 0 tablestart = 5000 resultlist = [] ...
0d8fe7b7aba67a18a81993c8ca3b67dde007d636
AMALj248/sentdex_cnn
/sentdex_pt_3.py
740
3.59375
4
import numpy as np import pandas as pd import cv2 img = cv2.imread('images/omega.jpg' , cv2.IMREAD_COLOR) #Drawing a black line cv2.line(img , (0 ,0 ) , (150 , 150) , (0,0,0)) #Drawing a Rectangle cv2.rectangle(img , (15,15) , (200 , 150) ,(0,255,0) , 5) #Drawing a Circle , -1 fills the circle with color c...
256b6631e6b2e8fc72e3874dd67774bc3db796dc
Schimith98/Exercicios_em_Python
/ex043.py
763
4.0625
4
#Exercício Python 043: Desenvolva uma lógica que leia o peso e a altura de uma pessoa, calcule seu Índice de Massa Corporal (IMC) e mostre seu status, de acordo com a tabela abaixo: #- IMC abaixo de 18,5: Abaixo do Peso #- Entre 18,5 e 25: Peso Ideal #- 25 até 30: Sobrepeso #- 30 até 40: Obesidade #- Acima de 40: ...
bb2dc40fe7545feedda25114e32e118b623debcf
naturalis/biovel-nbc
/script/ParseTsvFile.py
2,111
3.546875
4
import sys,os sys.stdout.write('Insert the input file location\n') # Metadata TSV file location. the first column is often TaxonID Input=raw_input() sys.stdout.write('Insert a list of column names seperated by semicolon\n') # list of headers names that you wish to extract and put them in csv file (e.g. 'GeographicalO...
be187ae27095d30747e723bf48400c71ef54d3a6
robojukie/coursera_p4e
/ds9_4.py
1,041
3.78125
4
# 9.4 Write a program to read through the mbox-short.txt and figure out who has # the sent the greatest number of mail messages. The program looks for 'From ' # lines and takes the second word of those lines as the person who sent the # mail. The program creates a Python dictionary that maps the sender's mail # address...
bbc00934e9b5900886f979c0a40ee1c21d1243f4
samkitsheth95/InterviewPrep
/com/Leetcode/824.GoatLatin.py
729
3.609375
4
class Solution: def toGoatLatin(self, S: str) -> str: vowel = set('aeiouAEIOU') def latin(w, i): if w[0] not in vowel: w = w[1:] + w[0] return w + 'ma' + 'a' * (i + 1) return ' '.join(latin(w, i) for i, w in enumerate(S.split())) def toGoatLati...
1a126e881c5a7c359d68fcac83058d6c02abfa11
csills/DIGITAL-CRAFTS
/week1/day3/loops/triangleII.py
125
3.828125
4
rows = int(raw_input("What is the height of the triangle? ")) for i in range(rows): print ' '*(rows-i-1) + '*'*(2*i+1)
cb61e42e0a5f549f0019a43538f55ea30c6168a9
CirXe0N/AdventOfCode
/2019/03/puzzle_01.py
1,115
3.71875
4
def load_input() -> list: wire_paths = [] with open('input.txt') as f: for line in f.readlines(): wire_path = [] for wire in line.split(','): wire_path.append({ 'direction': wire[0], 'steps': int(wire[1:]) }...
3b662ae9a6ed17f4cf659c32f855282fd9c34f74
Blackshirt99/1902
/1902/_python_/base/for.py
173
3.578125
4
li = list() li.append(200) li.append(100) li.append(300) print(li) print('*'*50) s = {400, 500, 600, 200} for i in li: print(i) print('*'*50) for i in s: print(i)
82d9e57233b9cce0c833b42274c321a55e4fe7af
ydj515/record-study
/Web_Crawling_Python3/BeautifulSoup4/13_naver_menu.py
894
3.578125
4
import urllib.request import bs4 def main(): url = "https://www.naver.com" html = urllib.request.urlopen(url) # url에 해당하는 html이 bsObj에 들어감 bsObj = bs4.BeautifulSoup(html, "html.parser") # <ul class="an_l">의 ul 태그만 뽑는다 ul = bsObj.find("ul",{"class":"an_l"}) # 위의 찾은 ul 태그에서 li태그를 다 찾아 list...
b2ddbbefe481b383cea0c37a1b7db9115d55aedd
KiranSpace/pythonScriptsTutorial
/Naveen/for.py
578
3.6875
4
#! /usr/bin/python lst=[0,'one',2,"three"] lst1=lst print(id(lst1)) lst1=list(lst) print(id(lst1)) scores={"kohli":100,"Shewag":55,"Ghambir":85} newScores=scores newScores['dravid']=200 print (id(scores)) print (id(newScores)) x=10 y=x print (id(x)) print (id(y)) x=100 print("y :",y) pr...
30a37bc812e420d55d9530bfd4b2c4b3fa2fdff5
Vinez1/TugasUas
/input-nilai.py
1,160
3.75
4
data = [] data = {} print("PROGRAM MENAMPILKAN DAFTAR NILAI MAHASISWA") while True: print("") c =input("(L)lihat, (T)ambah, (U)bah, (H)apus, (K)eluar : ") if c.lower() == 't': print("=======Tambah Data=======") nama = input("Nama : ") nim = input("Nim ...
01681d3cab571283947064c7c6b2d8675db86338
Artimbocca/python
/demos/08-exceptions/06_tryfinally.py
484
3.546875
4
import traceback def ExceptionDoNotCatch(): try: print ("In ExceptionDoNotCatch") i = 10 j = 0 z = i/j print (z) finally: print ("Finally executed in ExceptionDoNotCatch") print ("Will never reach this point") print ("\nCalling ExceptionDoNotCatch") try: ...
39bf54d87234eb3e93c57f5a7d1ec6c0421c1eb8
jrotithor/summer-projects
/matrix_multiplier.py
1,266
4
4
import sys def matrix_multiplier(list_1, list_2,cols,rows,cols2,rows2): sum = 0; final_list = [[0 for i in range(rows)]for j in range(cols2)]; for i in range(rows): for j in range(cols2): for k in range(cols): sum += list_1[i][k] * list_2[k][j]; #sum += 5; print(sum); k = 0; final...
8dfeacef6b844931cfbb3a4a2eebacf891856dbf
peltierchip/the_python_workbook_exercises
/chapter_3/exercise_71.py
349
3.984375
4
#Display 15 approximations of pi greek #Store the number of approximations as a constant LIMIT=15 app=3.0 #Display the approximations of pi greek up to the limit for i in range(LIMIT): #Compute the approximations app=app+4*((-1)**i/((2*i+2)*(2*i+3)*(2*i+4))) #Display the result print("Approximation %2d...
ed3390a3240ace528d23cd5fe3c6d03ad102c044
guozhaoxin/leetcode
/num001_100/num091_100/num096.py
1,060
4.09375
4
#encoding:utf8 __author__ = 'gold' ''' Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5 unique BST's: 1 3 3 2 1 \ / / / \ ...
5024a61791bcb8cddcafbfa5416f7668921cc553
Psylekin/Advent_of_code
/advent_of_code/2/project/calc.py
1,137
3.828125
4
def find_unique_characters(word): return list(set(word)) inputList = [line.rstrip('\n') for line in open('input.txt')] endresult = 0 def find_double_and_tribble_chars(inputList): counter2 = 0 counter3 = 0 # Iteriere durch die Liste for entrie in inputList: # Finde einzigarti...
70f759af5dae88243501465b95af9ce92500f8fe
Lucas0liveira/Aulas-Inteligencia-Artificial
/Trabalho I - Algoritmos de Busca/MissionariosLargura.py
3,079
3.71875
4
def filhosToString(s): return ' '.join([str(v) for v in s]) def objetivo(s): goal = False if (s[0] == 0) and (s[1] == 0) and (s[2] == 0): goal = True return goal def validar(s): # mais canibais que missionarios em qualquer lado do rio if(s[0] > 0 and s[0] < s[1]) or (s[0] < 3 and s[0...
5126bebb8e60744a49ea5c3e1586101594a85b88
sf-yaya/testPro
/task_two/game_g/game.py
1,067
4.21875
4
""" 一个回合制游戏,每个角色都有hp 和power,hp代表血量,power代表攻击力,hp的初始值为1000,power的初始值为200。 定义一个fight方法: final_hp = hp-enemy_power enemy_final_hp = enemy_hp - power 两个hp进行对比,血量剩余多的人获胜 """ # 定义一个游戏类 class Game: # 初始化变量 def __init__(self, hp, power): self.hp = hp self.power = power # 定义一个fight方法,传入对手的攻击力enemy_...
1729fff9f46556b1efd2fb430bb4de34708f9bb0
Ahmed--Mohsen/leetcode
/house_robber 2.py
1,683
3.640625
4
""" Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Mean...
667e0adb73594c4cbb3056e27bfd16fcd198daac
huwenbo920529/otherLibraryStudy
/pandasStudy/test3.py
1,838
3.6875
4
# -*- coding:utf-8 -*- # Pandas面板(Panel) # 面板(Panel)是3D容器的数据。面板数据一词来源于计量经济学,部分源于名称:Pandas - pan(el)-da(ta)-s。 # 3轴(axis)这个名称旨在给出描述涉及面板数据的操作的一些语义。它们是 - # items - axis 0,每个项目对应于内部包含的数据帧(DataFrame)。 # major_axis - axis 1,它是每个数据帧(DataFrame)的索引(行)。 # minor_axis - axis 2,它是每个数据帧(DataFrame)的列。 # pandas.Panel() # 可以使用以下构造函数创建面...
57c109f9b68c71f6fcaab1f52bafe7c48f828cec
mmenghnani/CS_learn
/Pattern Searching/anagram_substring_search.py
846
3.640625
4
def compare(count_pat, count_txt): for i in range(256): if count_pat[i] != count_txt[i]: return False return True def search(pat, txt): m = len(pat) n = len(txt) count_pat = [0]*256 count_txt = [0]*256 for i in range(m): count_pat[ord(pat[i])] += 1 c...
e648a29b5bff7a52d18bb4e1c90d8f9490d4c5b1
ErinSmith17/100-days-of-code
/Days 67-69.py
949
4.0625
4
#Copy and Paste with Pyperclip import pyperclip AFFILIATE_CODE = '&tag=pyb0f-20' url = pyperclip.paste() if 'amazon' not in url: print('Sorry, invalid link.') else: new_link = url + AFFILIATE_CODE pyperclip.copy(new_link) print('Affiliate Link generated and copied to clipboard') #tex...
703d3c255ce43567959c142c55a05ac4da359187
jachang820/r-vs-python
/python/scatterplot.py
838
3.75
4
import matplotlib.pyplot as plt # Interpolate more points to make it easier to visualize # model prediction. This is especially necessary for CART # algorithms to properly show the nodes. def smooth_regression_line(X_test, model): X_grid = np.arange(min(X_test), max(X_test), 0.1) X_grid = X_grid.reshape((len(X_grid)...
ddbfef958a943647f7ae3c0b90f4a41ab2ced36c
gavrie/pycourse
/examples/memoize1.py
511
3.515625
4
########## def make_cached(func): cache = {} def cached_func(*args): key = args if key not in cache: cache[key] = func(*args) return cache[key] return cached_func ########## @make_cached def calc(a, b): # .... result = 42 + a + b print "calc({}, {}) => ...
211ccad6ad35466e6200649295cc8147c31be34c
deblina23/CodeChef
/Beginner/enormousInputTest.py
618
3.8125
4
#!/usr/bin/env python3 def readInput(): n,k = map(int,(input().split())) listData = [] for number in range(0,n): listData.append(int(input())) return(k,listData) def resultCalculation(data): result = 0 k,listData = tuple(value for value in data) if(k<=pow(10,7)): for number i...
05443f3fb5b14fe9d97ef81eed5fdf934e4603c9
DKCisco/Starting_Out_W_Python
/4_8.py
169
4.03125
4
# Rewrite the code so it calls the range function instead # of using the list. # Print a message five times for x in range(1,5, +1): print('I love to program')
be5bfd864077b303279777f1cba595cebe5809f1
blackozone/pynet-ons-feb19
/day1/lists_ex1lee.py
218
3.859375
4
my_list = ["non", "naan", "nyan", "nine", "nein"] print(my_list) my_list.append("gucci") my_list.append("prada") print(my_list.pop(0)) print("Length of list: {}".format(len(my_list))) my_list.sort() print(my_list)
331f599b854d006ece817977c34b029a27087850
pilgeun/Python2-Day-5-HW-Exercise-Song
/test_cities.py
743
3.578125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: import unittest from city_functions import city_info class CityTestCase(unittest.TestCase) : """Test for 'city_functions.py'""" def test_city_country(self) : """Testing city = 'Anchorage', country = 'United States'""" result = city_inf...
941c04b580379d99c81ffff80762a4bb95d522a7
DontTouchMyMind/education
/MFTU/lesson 3/practice/task_I.py
835
4.125
4
# Последовательность состоит из натуральных чисел и завершается числом 0. # Определите значение наибольшего элемента последовательности. # # Числа, следующие за нулем, считывать не нужно. # # Формат входных данных # Вводится последовательность целых чисел, # оканчивающаяся числом 0 (само число 0 в последовательност...
0d65a4819226e7cd6491872a34d26323b20d9df8
SRK-wakasugi/Dx-
/Python課題1/Q4.py
314
3.96875
4
import math #ユーザー入力用 print("任意の自然数を入力してください") num_a = float(input("a= ")) num_b = float(input("b= ")) #割り算(小数点以下切り捨て) print(math.floor(num_a / num_b)) #割り算(小数点込み) print(num_a / num_b) input("処理終了")
c76d134c63ccd54934f8ca54422b5ff52b49aae6
praveenv253/idsa
/endsem/find-the-count.py
803
3.859375
4
#!/usr/bin/env python def main(): import sys from bisect import bisect_left # http://docs.python.org/2/library/bisect.html#searching-sorted-lists def contains(a, x): """Locate the leftmost value exactly equal to x""" i = bisect_left(a, x) if i != len(a) and a[i] == x: ...
6d6dda6f91c46252b85a653d55e3859aebef082b
TJJTJJTJJ/leetcode
/31.next-permutation.py
1,466
3.8125
4
# # @lc app=leetcode id=31 lang=python3 # # [31] Next Permutation # # https://leetcode.com/problems/next-permutation/description/ # # algorithms # Medium (30.07%) # Total Accepted: 217.9K # Total Submissions: 724.3K # Testcase Example: '[1,2,3]' # # Implement next permutation, which rearranges numbers into the # le...
c5909f23f28f343ae0f4f4c51e856ff2bf7b0325
sberk11/Python-Projects
/Python_Gui_Programming.py
5,324
3.5
4
from tkinter import * from tkinter import messagebox #PENCERE OLUŞTURMA pencere = Tk() # Pencere Objesi pencere.title("Program") pencere.geometry("650x650") #KULLANMAK İSTEDİĞİNİZ KISIMLARIN TIRNAKLARINI KALDIRIN. """ # alt ve üst frameler oluşturup ilerde bu bölgelere bi şeyler koyacağız. #"INVISIBLE CONTAINERS" den...
e6f52e70fd77e5a176aef7d4781f28109eab4d28
AlexanderBrandborg/DesignPatterns4Python
/Construction/singleton.py
917
4
4
# The classic singleton pattern. Now in Python! # It's a bit wacky since we cannot protect the constructor # Instead of accessing the singleton through a static method, # we access it through dummy instances that are wrapped around it. # (Usually I'd just implement singletonish behavior through a cached module, # but ...
a37715580315d38ce33bcd9182c9525daa8e5200
wibowodiditri/Tugas-1
/Soal - [3].py
412
3.734375
4
Teori = 70 Praktek = 70 nilai1 = int (input ("Masukkan Nilai Teori : ")) nilai2 = int (input("Masukkan Nilai Praktek : ")) if nilai1 & nilai2 >= 70: print ("Selamat anda lulus!") elif nilai2 < 70 & nilai1 >= 70: print ("Anda harus mengulang ujian praktek") elif nilai1 < 70 & nilai2 >= 70: print ("Anda har...
ffb775b61d8e6268d65137edf12950d26b360431
LigianeBasques/aluraparte1
/advinhacao.py
601
3.953125
4
print("*************************************") print("Bem vindo ao jogo de advinhação!") print("**************************************") numero_secreto = 42 chute_str = input("Digite seu número: ") print("Você", "digitou", chute_str) chute = int(chute_str) acertou = chute == numero_secreto maior = chute>numero_secreto...
ed21bced915dc8378907e5031fd5df8f845bb833
Jashwanth-k/Data-Structures-and-Algorithms
/4.Linked Lists/MergeSort in Linked Lists .py
2,071
3.859375
4
class Node: def __init__(self,data): self.data = data self.next = None def printLL(head): while head is not None: print(str(head.data)+'->',end='') head = head.next print('None') return def takeInput(): inputList = [int(ele) for ele in input().split()] ...
b6035c5d8ea752af0333cf02867065f630ffd397
DasHache/Learnbybook
/bamboo/bamboo.py
2,977
3.9375
4
# To run this file # python3 ./bamboo.py "1 2 10 3" # ... # Answer = 4 def splitter(a, m): ''' Input: a = list of integers, example: [1, 2, 3, 4] m = element to split the list, example: 3 Output: list of lists of integers, example: [ [1, 2], [4] ] ''' # make list of strings ...
41a15c892132b5d558a3ed2430bb7b38d15d9acd
Zadrayca/Kourse
/lect10.1.py
499
3.671875
4
# Декораторы # # def decorator(funk): # # преобразуем функцию в новую # # return new_funk def decorator(funk): def new_funk(): print('Запуск new_funk') return funk() + 1 return new_funk @decorator # Декорирование функции def some_funk(): print('Запуск some_funk') return max([1,...
4299cf6ae5a94e29f022391bfbe8b308c4ca91c3
fan-weiwei/algo-prep
/xin-era/codility/maximal_slice/max_slice_sum.py
1,307
3.71875
4
""" given an array A consisting of N integers, returns the maximum sum of any slice of A N is an integer within the range [1..1,000,000]; each element of array A is an integer within the range [−1,000,000..1,000,000]; the result will be an integer within the range [−2,147,483,648..2,147,483,647]. """ def solution(a...
4aa2308cc19e8637e6f055ab4b2279deb2c86f58
PeterSchell11/Python---Beginnings
/Bool_IfElse.py
275
3.796875
4
#boolean food = 'rice' if food == 'rice': print('ummm, my favorite!') print(100 * (food + '! ')) #if else x = 4 if x == 5 : print('x is equal to 5') print('canhave multiple lines here with same indentation') else : print('x is not equal to 5')
ced9cbb4cf8048edc70b5f98d8308025669061ac
afridhasuhaina/pythonprogramming
/alphabetornot.py
101
3.859375
4
ch=input() if(ch >='a'): print("Alphabet") elif(ch >='A'): print("Alphabet") else: print("No")
1117ff1264d3380b1a70e7a81ddf66d5fa62f848
reema-eilouti/python-problems
/CA11/problem10.py
4,039
4.25
4
# Define a class for the linked list from node import Node # Class for a simple Linked List class LinkedList: def __init__(self, data): self.start_node = Node(data) def traverse_list(self): pointer_node = self.start_node while pointer_node is not None: print(pointer_nod...
07363491eb30a5e49e5298ea9a979a18873f5f0c
xiaoliangL-12/driving
/driving.py
357
4.03125
4
country = input('请问你是哪国人: ') age = input('请输入你年龄: ') age = int(age) if country == '中国人': if age >= 18: print('你可以开车') else: print('你不能开车') elif country == '美国人': if age >= 16: print('你可以开车') else: print('你不能开车') else: print('你只能输入中国人或者美国人')
6fc98a5e4bab4129f4e92c60fc7389bb980699e6
devanshu464/devanshu
/Answer1(armstrong number).py
361
3.890625
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 22 19:09:19 2020 @author: HP """ num = int(input ("Enter an armstrong number\t")) tempv = num sum = 0 while tempv > 0: digit = tempv % 10 sum = sum + digit**3 tempv = tempv // 10 #print(sum) if sum == num: print("Armstrong number") el...
5da83da18aeff4df9b7dd7bf45073a9a275f455f
ckloppers/PythonTraining
/exercises/day1/wordsNum.py
118
3.6875
4
sentence = raw_input("Sentence: ") sentenceList = sentence.split(' ') print 'Number of words: ', len(sentenceList)
ebe40f17b7e85ff3c75d907998b9b4443bbecc65
marcuswyh/deep-learning-tensorflow
/Part A/Question1_3.py
8,039
3.5625
4
import tensorflow as tf from keras.utils import np_utils import matplotlib.pyplot as plt import numpy as np CPU, GPU = '/CPU:0', '/GPU:0' DEVICE = GPU def loadData(): fashion_mnist = tf.keras.datasets.fashion_mnist # load the training and test data (tr_x, tr_y), (te_x, te_y) = fashion_mnist.load_data...
4be4ff2e3d2d32e11e6849076f9ffe07623a2871
jose-brenis-lanegra/Verificadores-en-Python
/conversion-cadena.py
651
4.09375
4
#convertir la cadena 3.87 a cadena x="3.87" a=str(x) print(a) #convertir el flotante 34.78 a cadena x=34.78 a=str(x) print(a) #convertir el entero 324 a cadena x=324 a=str(x) print(a) #convertir el booleano 476>=587 a cadena x=476>=587 a=str(x) print(a) #convertir el booleano 64<67 a cadena x=64<67 a=str(x) print(a...
bd36a8a99fd2d3eae86da3fa0b115bd553f9a618
eidanjacob/advent-of-code
/2020/6.py
476
3.53125
4
s = 0 with open("./input.txt") as f: group = set() first = True for line in f: if line != "\n" and line != "": if first: first = False [group.add(c) for c in line if c != "\n"] else: newgroup = set([c for c in group if c in line...
1b01641db2b2553e3d92c21271a7f5d0afe10b12
All3yp/Daily-Coding-Problem-Solutions
/Solutions/137.py
1,258
3.921875
4
""" Problem: Implement a bit array. A bit array is a space efficient array that holds a value of 1 or 0 at each index. init(size): initialize the array with size set(i, val): updates index at i with val where val is either 1 or 0. get(i): gets the value at index i. """ class Bit_Array: def __init__(self, lengt...
2a19f35e570f3436b15cc980ece15fc8564d6aa2
jamesmcglone/dsp
/python/q8_parsing.py
748
4.34375
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
8cdc8f042c9ce47806a1a993a88e943e791a3a75
github-ygy/python_leisure
/py4/UseDeco.py
956
3.640625
4
#!/usr/bin/env python # author:ygy import time #使用高阶函数与嵌套函数实现装饰者模式 # def calTime(func): # def decoFunc(): # startTime = time.time() # func() # endTime = time.time() # print(" func takes time = %s" %(endTime - startTime)) # return decoFunc # # def test(): # time.sleep(3) #...
4cf8edb7c85a44b6ac8332ad283362f0a91fb3b1
Ablyamitov/Programming
/Practice/19/python/19.py
1,708
3.875
4
#алгоритм такой же, как и в с++, но не понимаю, почему не работает(согласен, код ужасный)??? import random f = 0 a = 1 check = True n = int(input()) allpassword = [] password = str(input()) notall="" size_password = len(password) notpassword =[size_password] for i in range (size_password): notpassword.append(0) alll =...
d1e5ab7bd3bd4df79f2d18969088f40eb357f019
LiLi-scripts/Python_Basic
/Homework3/op_repeat.py
562
3.890625
4
n = input ("Enter a 5-digit number: ") while True: try: k = int (n) except ValueError: print ("Input Number: ", n, " - is not a digit") break if 9999 < k <= 99999: # 99999 k1 = k // 10000 * 10000 # 90000 k2 = k // 1000 * 1000 - k1 # 9000 ...
a74dcbf05bd74239bad76737ff0c635b3325dbd7
MatthewJHolden/Connect4
/ConnectAI2.py
15,084
3.734375
4
import numpy as np import random import pygame import sys import math # https://en.wikipedia.org/wiki/Minimax#Pseudocode # https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning # BLUE = (0,0,255) BLACK = (0,0,0) RED = (255,0,0) YELLOW = (255,255,0) ROW_COUNT = 6 COLUMN_COUNT = 7 PLAYER = 0 AI = 1 PLAYER_PIECE ...