blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
df8f3f5dbf5fdd876b5ee7e47b6f6acda6dbe4e6
habraino/meus-scripts
/_prog/_python/_aulas/_aida/_aulas/Aula_error.py
150
3.75
4
try: num = int(input("Informe um valor inteiro: ")) except ValueError: num = int(input("Informe um valor inteiro: ")) finally: print(num)
115e9805933caee8b0cc8203bac02057becaf9d0
wwwwodddd/Zukunft
/leetcode/find-all-the-lonely-nodes.py
634
3.671875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def getLonelyNodes(self, root: Optional[TreeNode]) -> List[int]: z = [] def dfs(x): ...
ff45c34657cc0eb23651cb2d56713be11086bd5e
MahmoudFayed/PWCT_Mirror_From_Sourceforge
/PWCT Project/First Generation/VPLs/PythonPWCT/Samples/Int.py
94
3.5625
4
num1,num2 = "5","10" v1 = int(num1) v2 = int(num2) print v1+v2 cOutput = raw_input()
485eb3be87360576309dc838fa4c0ac6bf94ebc6
szymonbalasz/Pybites
/096/wc.py
607
3.640625
4
def wc(file_): """Takes an absolute file path/name, calculates the number of lines/words/chars, and returns a string of these numbers + file, e.g.: 3 12 60 /tmp/somefile (both tabs and spaces are allowed as separator)""" with open(file_) as f: contents = f.read() lines_count = ...
096f4f45c408cf8d8f5a676c1dddb9bd17f7c276
maxbehr/diagram-detection
/detector/primitives/line.py
1,652
3.875
4
from detector.util import distance_between class Line: def __init__(self, point_a, point_b): self.point_a = point_a self.point_b = point_b def start(self): return self.point_a def start_xy(self): return self.point_a.x, self.point_a.y def end(self): return sel...
b88a717a892024791cb796dc5be54a429beaca0c
mufraswid/rsa-elgamal
/rsa.py
6,263
3.5
4
from Crypto.Util.number import getPrime from util import euler_totient, modular_inverse import math import random class RSA(): """ A class used as RSA (Rivest-Shamir-Adlemann) cipher Parameters ---------- p : int (first secret large prime) q : int (second secret large prime) n : int (product of p and q,...
0356653e285faeefe8a7a5e7c616a28b303aac9c
alejandrobalderas/MachineLearningCoursera
/machine-learning-ex2/ex2/ex2_LinearReg.py
4,576
3.6875
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 14 19:26:56 2017 @author: Alejandro """ import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset = pd.read_csv('ex2data1.txt', header = None,names = ['Exam 1','Exam 2','Admitted']) X = dataset.iloc[:,:-1].values y = dataset.il...
96c41ccf260be01362fcf32950d3d7797e551850
Staggier/Kattis
/Python/hiddenpassword.py
511
3.75
4
def hiddenpassword(): key, msg = input().split() key = list(key) c = 0 lst = [] for ch in msg: if ch in key: if ch == key[c]: c += 1 if c == len(key): return "PASS" lst.append(ch) else: ...
4b7538849328427680778d32ca146b1ab2cb6ff5
GGjin/algorithm_python
/easy/01.两数之和.py
734
3.703125
4
""" 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。   示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] """ from typing import List def twoSum(self, nums: List[int], target: int) -> List[int]: length = len(nums) for ...
e137360df40803b69a273226d61e60e26b32360f
myeon44/Python-Projects
/project1/mileage.py
362
4.1875
4
#This program helps to calculate miles per gallon (MPG) s_mile = input("Please input in a number for starting mileage. ") e_mile = input("Please input in a number for ending mileage. ") gas = input("Please input a number to take in as ____ gallons consumed. ") total = (float(e_mile) - float(s_mile))/float(gas) print ...
2ec070bb74265decb5c7f13559c89c5c17ca2450
quantacake/Library
/Library.py
6,731
3.84375
4
# Archive Application (Frontend/GUI) from backend import Database from tkinter import * """ Frontend: A program that stores this book information: title, Author Year, ISBN (id for books) User can: View all records Search an entry Add entry Update entry Delete Close Need:...
d925afaa7bc06e022cc0a065ac40bc65e4d4e35e
michaelworkspace/Algorithms
/longest_substring_without_repeats.py
783
4.1875
4
""" Given a string, find the length of the longest substring without repeating characters. Examples: "abcabcbb" -> "abc" -> 3 "bbbbb" -> "b" -> 1 "pwwkew" -> "kew" -> 3 "abcadcbf" -> "adcbf" -> 5 Restrictions: Time complexity has to be O(n) linear time. """ def longest_substring_without_repeats(s: str) -> int: ...
05ca95d0857ef90fe1b7b33b77e3f786061d498c
mike1130/01-Basico-Python
/prueba_primalidad.py
616
3.859375
4
def es_primo(numero): # contador = 0 # for i in range(1, numero + 1): # if i == 1 or i == numero: # continue # elif numero % i == 0: # contador += 1 # if contador == 0: # return True # else: # return False if numero % 2 == 0 or numero % 3 ==...
9d5573763dc4e5f2efdfc69983c7f4da80233be6
boutboutnico/PyEvol
/graph.py
3,309
3.546875
4
import pygame class Axis: def __init__(self, r): (self.x_min, self.x_max, self.y_min, self.y_max) = 0, 10 + 1, 0, 10 + 1 (self.x_origin, self.y_origin) = r.left + r.w / 10, r.bottom - r.h / 10 x_px_length = r.right - self.x_origin self.x_px_step = x_px_length / (self.x_max - self....
a99b7765d2a08b06d21192ab5838b806a3e4248b
chrifl13/is105
/lab/python/exercises/ex3.py
793
3.8125
4
print "i will now count my chickens:" print "hens", 25 + 30 / 6 print "roosters", 100 - 25 * 3 % 4 print "now i will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print "is it tru that 3 + 2 < 5 - 7?" print 3 + 2 < 5 - 7 print "what is 3.0 + 2.0", 3.0 + 2.0 print "what is 5 - 7?", 5 - 7 print "oh, ...
4d769583c78babd4d8f3dfc178210d654055c11a
artabramov/geekbrains
/algorithms/hw2/4.py
189
3.765625
4
i, j = int(input("input the number: ")), 0 number = 1 repeat = True while repeat: print(number) number = -1 * number / 2 j += 1 if j == i: repeat = False
8ad147fc5b9e2758588a938b95c96b280342e4ee
Carleton-Autonomous-Mail-Robot/WebServices-Client
/src/cipher.py
956
3.9375
4
import Crypto from Crypto.PublicKey import RSA from Crypto import Random """ Cipher is a class which creates a cipher object The cipher object is responsible for encrypting and decrypting messages @Author Gabriel Ciolac """ class Cipher: def __init__(self): self.__privateKey = self.__generateKeys() ...
b0c70359660d07603b3097536ac582e8fb7aeeb2
AOlorunf/Programming-Projects-
/BasketballStatsProjectTests.py
1,214
3.90625
4
from BasketballStatsProject import read_file, subset import pandas as pd def dataframe1(filename): """Function that takes in a csv file (testfile.csv) and also creates a small dataframe. Returns both the csv dataframe and the newly created dataframe""" testdf = {"Column 1": ["a"], "Column 2": ["b"], "Colum...
aea3c2e856ea55ae3d4f39708d3923d2e2f93318
Gobaan/FLowField
/model.py
1,873
3.640625
4
# Logic: # Split the screen into N squares # Calculate the vector of each square # Make particles flow from square to square class Source(object): def __init__(self, r, c): self.r = r self.c = c class Grid(object): def __init__(self, width, height): square_size = 2 self.r...
c975c109e5751b0bed20f96de40c24eb90961262
AkihikoTakahashi/ProjectEuler
/Problem046.py
675
4.21875
4
# coding: utf-8 # n = p * 2 * q^2 (p: 素数, q: 自然数) # と書けない <=> # すべての q (1<=q<=√(n/2)) に対して, # p = n - 2 * q^2 がすべて合成数. from itertools import count def is_prime(n): if n <= 1: return False elif n <= 3: return True elif n % 2 == 0: return False else: return all(n % i !...
a4666e9e267d7d3f3cacb41b0516c5d06da45467
Edison199902222/Leetcode_note
/leetcode/Array/134. Gas Station.py
942
3.6875
4
''' 这道题 sums 记录 总共车走完全程 从第一个到最后一个 剩下多少汽油 如果大于等于0 说明肯定可以走完 current 意思是 走到第i个站 有多少汽油 如果 剩下的汽油 加上第i个站的汽油 小于下个站的汽油的话 说明走不过去了 需要跳过 ''' class Solution(object): def canCompleteCircuit(self,gas,cost): if sum(gas) - sum(cost) < 0: return -1 sums,current,index = 0,0,0 for i in range(len(ga...
e33cd67f1394232fcffa2d1a9a17c8e4fe037ce0
GitZW/LeetCode
/leetcode/editor/cn/day_038.py
1,112
3.953125
4
""" 无重复字符串的排列组合。编写一种方法,计算某字符串的所有排列组合,字符串每个字符均不相同。 示例1: 输入:S = "qwe" 输出:["qwe", "qew", "wqe", "weq", "ewq", "eqw"] 示例2: 输入:S = "ab" 输出:["ab", "ba"] 提示: 字符都是英文字母。 字符串长度在[1, 9]之间。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/permutation-i-lcci """ class Solution(object): def permutation(self, S): ...
3dddbf4b8c124704033175286f8459104305dd23
arisberg/pythonpractice
/stringmultiply.py
283
3.921875
4
user_string = raw_input("whats the word") user_num = input("what number?") try: our_num = int(user_num) except: our_num = float(user_num) if not '.' in user_num: print(user_string[our_num]) else: ratio = round(len(user_string)*our_num) print(user_string[ratio])
f8fcfedfdd3a3f02b867612c796540ee57ff6e1e
petreflorina/Python
/Exercitii Curs/1/1-9.py
175
4.15625
4
def is_palindrom(word): second_word = "" for elem in reversed(word): second_word += elem if word == second_word: print True else: print False is_palindrom('mama')
d08676538787786fbd1512a1a7bf897167cc6aa2
KevinHenneberger/CS110
/classwork/exceptions2.py
493
3.65625
4
class WrongAnswerError(Exception): pass class NoAnswerError(Exception): pass def isValid1(food): if (food == ""): raise NoAnswerError def isValid2(food): if (food != "pizza"): raise WrongAnswerError def main(): food = input("Enter your favorite food: ") try: isValid...
c8a55c014b85c26ee68b116041babaad2879d4ea
Amirosimani/Unpacking_machine_learning
/Ridge_Regression/ridge_rigression.py
1,219
3.546875
4
import numpy as np from numpy.linalg import inv import math import matplotlib import matplotlib.pyplot as plt get_ipython().magic('matplotlib inline') def fit(x_train, y_train, lmda): """ Fit Ridge Regression. This function takes 3 inputs. `x_train`, `y_train`, and `lmda`. Parameters ---------- ...
843291cf73e0df86bb483207b4f09a9971253e62
sunlingyu2931/Tensorflow-
/example 1.py
1,092
3.609375
4
import tensorflow as tf import numpy as np x_data = np.random.rand(100).astype(np.float32) # create data y_data = x_data * 0.1 +0.3 # 真实值 # create tensorflow stracture (start) Weight = tf.Variable(tf.random_uniform([1],-1,1)) # weight 一般用variable inpout output 神经元等用constant biases = tf.Variable(tf.zeros([1])) # 和上面的y...
97486b592e6f057904118dd9ad67258f8b960be7
CRingrose94/ProjectEuler
/problems_000_099/Euler 057.py
422
3.5625
4
from math import log10 as log # (2 * 2) (6 * 6) (10 * 10) (14 * 14) # ----------------------------------- ~= root 2 # (1 * 3) (5 * 7) (9 * 11) (13 * 15) def compute(limit): numer, denom = 3, 2 for n in range(2, limit + 1): numer, denom = numer + 2 * denom, numer + denom if int(log(numer...
5fdf4325b02cf067e7f3f3b4ee6d94e5eac2f01f
praveena2mca/pravimca
/pro23.py
490
3.65625
4
N = 0 E = 1 S = 2 W = 3 def circle(h): a = 0 b = 0 dir = N for i in xrange(len(h)): move = h[i] if move == 'R': dir = (dir + 1)%4 elif move == 'L': dir = (4 + dir - 1)%4 else: if dir == N: b += 1 elif dir == E: a += 1 elif dir == S: b -= 1 else: a -= 1 return (a == 0 an...
d7112fddf3de998c1462b3001a7a832a2ffa9cbb
mrxandejp/nonlinear-model-predictive-controller
/diffAngle.py
409
4
4
# -*- coding: utf-8 -*- import math PI = math.pi #VERifICAR O QuE Foi uSAdONA CadeiRa e ROboTIcA def diffAngle(a1, a2): ang = a1-a2 if ang < 0: ang = -((-ang/(2*PI))-math.floor((-ang/(2*PI)))*2*PI) if ang < -PI: ang = ang + (2*PI) else: ang = ((ang/(2 * PI)) - math.floor((a...
79cc14fff852fae7122de51f7abb345c7ec4a69c
CS7591/Python-Classes
/5. Python TKINTER/18. Scroll Bar.py
2,182
3.734375
4
"""Construct a scrollbar widget with the parent MASTER. Valid resource names: activebackground, activerelief, background, bd, bg, borderwidth, command, cursor, elementborderwidth, highlightbackground, highlightcolor, highlightthickness, jump, orient, relief, repeatdelay, repeati...
60ee39674cd82c0aad4d3b36ed47c9a51650676c
Julialva/HowToSnake
/Encrypter.py
1,804
3.984375
4
import string def personal_crypt(some_dict): for char in string.ascii_uppercase: crypto_key_char = (str(input("What letter should replace {}: ".format(char)))).lower() some_dict[char] = crypto_key_char return some_dict def encrypt(some_string,some_dict,second=False): some_string = list(som...
4f4bf0349ff0bdba5ba17451e8b60634c7dcdaa5
kaunta/IONs
/src/Level2/w.py
271
4.25
4
## w.py # We begin with the program we left off with at the end of # Level 1. This program notates ω, the smallest infinite # ordinal. We would like to move beyond ω. How can we go # beyond infinity? X="" while True: output(X) X = "output('" + escape(X) + "')"
d3bc2366c8a653e42d659a7f41bae81fe44be73d
amarsyelane/pythonprograms
/python/bubblesort.py
379
3.984375
4
lst = [] l = int(input("enter the length of list : ")) for i in range(l): n = int(input('Enter the number : ')) lst.append(n) print('Before sorting elements : ',lst) for i in range(len(lst)): for j in range(len(lst)): if lst[i] >= lst[j]: temp = lst[i] lst[i] = lst[j] ...
97f13b5b29461bf7b99cfcd9454e2c7900832e8b
Neves-Roberto/python-course
/maior_primo.py
1,241
3.734375
4
''' Exercício 2 - Primos Escreva a função maior_primo que recebe um número inteiro maior ou igual a 2 como parâmetro e devolve o maior número primo menor ou igual ao número passado à função Note que maior_primo(100) deve devolver 97 maior_primo(7) deve devolver 7 Dica: escreva uma função éPrimo(k) e faça um laço p...
e442ab73a36a60d9203887e178d7e6f8137d3c92
MehemmedMehdiPY/WebsiteBlocker
/Website_Blocker/functions.py
5,043
3.515625
4
import os import json from time import sleep import ctypes def isAdmin(): return ctypes.windll.shell32.IsUserAnAdmin() def MENU(websites_file, blocked_websites): menu = """1 --> Set timer for productive working 2 --> See the list of websites you prohibited 3 --> Change your websites list q --> Finish the...
dbb182bc1922f438a53ca5ad299d4085b0204982
stanfeldman/samples
/python/visit.py
972
3.59375
4
from abc import ABCMeta, abstractmethod class Visitor(object): def visit(self, node, *args, **kwargs): method = None for cls in node.__class__.__mro__: method = getattr(self, "visit_" + cls.__name__) if method: break if not method: method = self.generic_visit return method(node, *args, **kwargs) ...
6a1a5484bc200ddd33a536c758b32cd9d46abb14
DylanGuidry95/Python-Examples
/AStarDrawing/Grid.py
2,548
3.75
4
'''All modules that modify the graph visualy and the information in it''' from Node import Node from Node import NodeInformation class Graph(object): '''Object that stores nodes and assigns them position values''' def __init__(self, width, height): self.width = width self.height = height ...
3c88d7b41bfc69e7182a1f7bec615e7916c89843
MrBreakIT/MyAlgoFolder
/Python_Algos/stackFromRob.py
1,972
3.953125
4
class Node: def __init__(self, value): self.value = value self.next = None class Stack: def __init__(self): self.top = None def push(self, value): #create a new node newNode = Node(value) if self.top == None: self.top = newNode else: ...
c7498992ac3e5cd81f97526d45f8b96c1bec7375
ysandeep999/fads-nltk-villy-2014
/fads 2104/final_project.py
1,155
3.671875
4
# Sandeep Yalamanchili # FADS final Project import nltk from nltk import word_tokenize from nltk.util import ngrams def make_grams(tokens,num): return ngrams(tokens,num) def stop_test(word): global stopwords if word not in stopwords: return 1 else: return 0 def main(): text = "...
7754e95597636f134594f126659a08608b460589
serdarcw/DevOps_Professors_01
/Proje_calc.py
1,161
3.921875
4
c = int(input('''Please chose your operation :\n1.addition\n2.substraction 3.Multiplication\n4.Division\n5.Fibonacci number up to your number 6.Summation of integers that are divided by 3 or 5 up to your number(inclusive)\n\n''')) if c < 5: a = int(input("Welcome to calculator:\n\nPlease enter your first number : "...
d8f636c4dc7515976c431e51923d37a5c992c578
voodoo888/python-git
/less6_#3.py
925
3.828125
4
class Worker: def __init__(self, name, surname, position, wage, bonus): self.name = name self.surname = surname self.position = position dict_income = {'wage': wage, 'bonus': bonus} self._income = dict_income class Position(Worker): def __init__(self, name, surname, pos...
b3706cdefa526778ffdb88e8a8594ad20b5388c8
HeimerR/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
302
4.25
4
#!/usr/bin/python3 """module append to a text file """ def append_write(filename="", text=""): """ appends a string to a text file (UTF8) and returns the number of characters added """ with open(filename, encoding="utf-8", mode="a") as my_file: return my_file.write(text)
362dc26036211d81df72a2f02a2481a99b05b7bc
Devanand12/Python_April
/LearnInheritance/learn_inheritance.py
450
3.578125
4
class A: def __init__(self,a): print("from Class A __ init__") def first_class(self): print("i'm from Class A") def sec_class(self): print("i'm also from Class A") class B(A): def __init__(self): print("from class B __init__") super().__ini...
6e0cc4283791631c1d2d24ddfd151b8ae7ed0de3
Dharm3438/Problem-Solving
/1.DSA/Implementation/1.Recurssion/21.binary_search.py
395
3.75
4
def bin_search(arr,l,r,x): if(l<=r): mid = l+(r-1)//2 if(arr[mid]==x): return mid elif(arr[mid]>x): return bin_search(arr,l,mid-1,x) else: return bin_search(arr,mid+1,r,x) else: return -1 # Driver Code arr = [ 2, 3, 4, 10, 40 ] x = 10 ...
db4cda0f49450ff01e9837aa924160240b8e30d8
MikhailRyskin/Lessons
/Module20/03_function/main.py
626
3.828125
4
def func_2003(inp_tuple, element): if element not in inp_tuple: new_tuple = () else: start_index = inp_tuple.index(element) if inp_tuple.count(element) == 1: new_tuple = inp_tuple[start_index:] else: end_index = start_index + 1 + inp_tuple[start_index + 1:...
3b57c4dd64acf608355305affc4046a43f8632f0
Guoli-Zhang/Code
/HelloWorld/Day8/07-私有属性与私有方法.py
600
3.828125
4
class Father: def __init__(self): self.__name = "父亲" def show_name(self): print(self.__name) # father = Father() # father.show_name() # class Son(Father): # def __init__(self): # self.__name = "仔仔" # 不能被改 # # # son = Son() # son.show_name() # son = Son() # son.show_name() #...
c31e443a16ac4d6b097407428e618294f34218f5
jasrajput/Python-Projects
/discount.py
467
3.578125
4
import decimal def total_cart_item(cart): total = 0 for val in cart.values(): total = total + val print('Total: ' + str(total)) return total cart_items = { 'shirt': 1, 'jean': 1, 'shoes': 498, } full_total = total_cart_item(cart_items) def calc_discount(price, discount): to...
e1c8a9ef0c102d2b15bf0856895a89981d3207e5
maddymz/Data-Structures
/queue.py
1,152
3.96875
4
class QueueNode: def __init__(self, data): self._data = data self._next = None class Queue: def __init__(self): self.head = None self.tail = None def isEmpty(self): if self.head == None: return True else: return False def...
279fbad02a7785e37ffa80367cf6677faad1c447
SergioJune/leetcode_for_python
/array/offer_03.py
1,638
3.9375
4
""" 找出数组中重复的数字。 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。 示例 1: 输入: [2, 3, 1, 0, 2, 5, 3] 输出:2 或 3   限制: 2 <= n <= 100000 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/shu-zu-zhong-zhong-fu-de-shu-zi-lcof 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ # 在链表中寻找环的...
17af7d4f8f0ed218b970c159e8ee228ffa8e2b15
femkepiepers/Informatica5
/06- Condities/Monsters en hoeden.py
766
3.828125
4
# invoer p_1 = input('Persoon 1 draagt: ') p_2 = input('Persoon 2 draagt: ') omg_antwoord = input('Welke persoon antwoord omgekeerd? ') # uitvoer if p_1 == 'zwart' and p_2 == 'zwart' and omg_antwoord == '1' or p_1 == 'wit' and p_2 == 'wit' and omg_antwoord == '2': print('wit') print('zwart') if p_1 == 'zwart' ...
a2baeb6cdee3fdf8d7373df34c8444337687648b
HotsauceLee/Leetcode
/Categories/No_Fucking_Clue/R__L_626.Rectangle_Overlap.py
1,587
3.90625
4
""" Given two rectangles, find if the given two rectangles overlap or not. Notice l1: Top Left coordinate of first rectangle. r1: Bottom Right coordinate of first rectangle. l2: Top Left coordinate of second rectangle. r2: Bottom Right coordinate of second rectangle. l1 != r2 and l2 != r2 Have you met this questio...
96fbdee907a7676586d82b94cc304cc5c28c9917
ngr/sandbox
/python/asteroids.py
15,950
4.1875
4
# "ASTEROIDS" # Nikolay Grishchenko, 2014 # web@grischenko.ru # # PLEASE BE AWARE THAT THIS CODE IS ADOPTED ONLY # FOR CODESKULPTOR IN COURSERA CLASS. # IT DOES NOT COMPILE AS IS! # import simplegui import math from random import random, randrange, choice # Game settings. Constants. LIVES = 3 # Default lives WIDTH =...
8ec2d007af175ee72035cf3a9dae45e881c23166
nasermograbi/BullsAndCows
/BullsAndCows.py
6,861
3.53125
4
import random from random import choice all_numbers = [] guessNumber = 1234 # guess remaining_count = 0 # remaining possible numbers old_count = 0 # temp value for the remaining possible numbers outputString = "" def check_for_zero(num): if get_first(num) == 0 or get_second(num) == 0 or get_thi...
707a87e0bbd5056941a7dc691dc1abe23aa60304
rohit679/Pygame-Projects
/pygame project/tron/tron.py
2,707
4.0625
4
"""Tron, classic arcade game. Exercises 1. Make the tron players faster/slower. 2. Stop a tron player from running into itself. 3. Allow the tron player to go around the edge of the screen. 4. How would you create a computer player? """ """ Rule:- 1. we have blue & red snake and they are operated by di...
1faf6e1d018017e02e3be762fc9c0bb9abdf6150
amymainyc/introcs-python
/4.25(basel)/4.25(basel).py
1,160
3.609375
4
import sys import math def basel(numbers): result = '''<html> <body> <center> <h3>The Basel Problem Calculations</h3> <table border="1"> <tr><b> <td>N</td><td>Sum</td><td>pi*pi/6</td><td>Difference</td></b></tr> ''' for x in range(len(numbers)): if x < 2: pass elif numbers[x].isdigi...
832c27e95642eb63c3f3bd828e5b2da51615cdcf
rajulun/Algorithms_in_python
/Lesson_1.py
7,043
3.875
4
#1. Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь. a = input("Введите трехзначное число: ") # проверять на корректность ввода данных не буду sum_a, proiz_a = 0, 1 for i in a: sum_a += int(i) proiz_a *= int(i) print("Сумма цифр введенного числа = %d" % sum_a) print("Произведени...
a7b273ae170ac3f9db8aebf2aa3ef1dfd25af962
easyawslearn/Python-Tutorial
/#5_Python_Logical_Operator.py
1,102
4.375
4
# Operator Description Example Try it # and Returns True if both statements are true x < 5 and x < 10 # or Returns True if one of the statements is true x < 5 or x < 4 # not Reverse the result, returns False if the result is true not(x < 5 and x < 10) a=0 print ("If variable value is equal to 0 then True else ...
74fbb59e578455874d05d3aee8799874ef7b205e
Vigyrious/python_fundamentals
/Lists_Advanced-Exercise/Inventory.py
1,043
3.84375
4
collection = input().split(", ") command = input() stringings = [] final = "" while command != "Craft!": splitted = command.split(" - ") if splitted[0] == "Collect": item = splitted[1] if item not in collection: collection.append(item) elif splitted[0] == "Drop": item = s...
43ea03ea1d693d03366841964a2808e64626c414
MihaiRr/Python
/lab11/Recursion.py
1,335
4.46875
4
# The main function that prints all # combinations of size r in arr[] of # size n. This function mainly uses # combinationUtil() def printCombination(arr, n, r): # A temporary array to store # all combination one by one data = [""] * r # Print all combination using # te...
716a4af6ef787fa4030578df8cf4ffb1b57c9a2b
MdGolam-Kibria/python
/LetterGradeProgram.py
158
3.921875
4
marks = 75 if marks >= 80 <= 100: print("A+") elif marks >= 70 <= 80: print("A-") elif marks > 75: print("Wrong marking") else: print("Null")
3c9a8e8cdcd8d2b58a82de8746f835f7965ee480
realmichaelye/3D-Game-From-Scratch-With-Python
/RenderUtils.py
9,110
3.578125
4
################################################################### #Purpose: This is the RenderUtils class, it handles all of # #the rendering processes: Buttons, Fonts... Along with other game # #mechanics such as keeping scores # ################################################...
624064ff206942a0634033503e36b9f7eecd3c3f
ConnerFlansburg/WeatherData
/formatting.py
1,945
4
4
def printWarn(message: str) -> str: """ printWarn is used for coloring warnings yellow. :param message: The message to be colored. :type message: str :rtype: str """ return f"\033[33m {message}\033[00m" def printSuccess(message: str) -> str: """ Colors a string green & returns it."...
44f4213d82415e2ee78fe2c6acc2955a4ec40baa
mh453Uol/PythonLearning
/learning/helloworld.py
3,139
4.09375
4
print("Hello World!"); print(1+1-2); # In python we dont need to specify the type answer = 42 print(answer); # This function adds two type however # not specifying types has its flaws def add_numbers(a, b): print(a + b) add_numbers(10, 10) add_numbers("Majid is ", "life") #add_numbers(11,"Majid is "); doesnt wo...
7f0c8962888864d1c614b6c8d4c8c832c8e17bf8
priyadharshini18996/bankaccount
/diagnal_difference.py
597
4.0625
4
def diagonalDifference(arr): primary_diagonal = 0 secondary_diagonal=0 length = len(arr[0]) for count in range(length): primary_diagonal += arr[count][count] secondary_diagonal += arr[count][(length-count-1)] return abs(primary_diagonal-secondary_diagonal) print (ab...
6c2870859909dcdfd03967a3ef3c410ca098a364
Sanjeev589/HackerRank
/Python/What's Your Name.py
316
3.953125
4
''' You are given the firstname and lastname of a person on two different lines. Your task is to read them and print the following: Hello firstname lastname! You just delved into python. ''' def print_full_name(a, b): print("Hello %s %s! You just delved into python."%(a,b)) print_full_name(input(),input())
beb81d11f39ed2a1826460de1c8f4ebe51885044
amolkokje/coding
/python/interview_problems.py
10,341
3.828125
4
import sys, os, copy # Knapsack Problem: (NP complete) # Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in # the knapsack. In other words, given two integer arrays val[0..n-1] and wt[0..n-1] which represent values and weights # associated with n items r...
c038aeea58af447662f9ad545af895de499adc9a
Nityam79/pythonPractice
/prac6/numtopan.py
207
3.53125
4
import numpy as np my_list = [11, 12, 13, 14, 15, 16, 17, 18] print("List to array: ") print(np.asarray(my_list)) my_tuple = ([18, 14, 16], [11, 12, 13]) print("Tuple to array: ") print(np.asarray(my_tuple))
18fddcc8c512cfbb9c3d13c63b66c4155b9eb1cf
crash-bandic00t/python_dev
/1_fourth/algorithm_python/lesson2/task9.py
859
3.765625
4
# Среди натуральных чисел, которые были введены, найти наибольшее по сумме цифр. Вывести на экран это число и сумму его цифр. numbers = input('Введите натуральные числа через пробел: ') listNumbers = numbers.split(' ') dictionary = {} for i in listNumbers: # составляем словарь ключ - число, значение - ...
a458e1461bbef418621a04dcb572944c37fe4249
Ars187/Data-structures
/De-queue.py
1,443
4.15625
4
#De-queue class Dequeue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def addFront(self, item): self.items.append(item) def addRear(self, item): self.items.insert(0,item) def removeFront(self): return self.i...
d7155c6363d84a429e5b7b528aae0d0e9efbe786
padelstein/LexicalSimplify
/code/python/simpleFrequencyCounter.py
787
3.640625
4
# frequency-calc.py # a word frequency calculator # Patrick Adelstein, Middlebury College Summer 2012, Prof. David Kauchak import sys wordFreq = {} corpus = open(sys.argv[1]) normalToTopSub = open(sys.argv[2]) simpleWordsHash = {} cnt = 0 normFreq = 0 simpFreq = 0 numSent = 0 for line in corpus: (article, paragrap...
2a9eba84bf17be98fb003c842b07ec6b85f8139b
SebastianG343/Preinforme-Week-5
/Promedio de 3 numeros.py
263
3.9375
4
print("Digite 3 numeros para hallar el promedio, pls digite un numero y enseguida pulse \"Enter") lal=int(input("Digite un numero")) lel=int(input("Digite otro numero")) lil=int(input("Digite un ultimo numero")) wea=lal+lel+lil xD=wea/3 print("El promedio es",xD)
be7542e8417255a19993b02e06703aeaa8651d91
liupy525/LeetCode-OJ
/61_Rotate-List.py
1,346
3.9375
4
#!/usr/local/env python # -*- coding: utf-8 -*- ''' Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL. ''' # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x ...
e434aaab09316125c2b6f4599759d48d0809bb77
tinxo/Tutorias-PL-SEM1-TTI
/Clase #1/funciones.py
450
3.8125
4
# Código empleado en el tratamiento del tema funciones. # Definición de la función def suma(a, b): # Devuelve la suma de dos valores que se ingresan como parámetros return a + b # Invocación o llamada a la función print('Se solicitan dos valores y se realiza la suma') valorA = int(input('Ingrese el primer va...
5f55ceae5f5c93464c3a46c4c4c0d9aeb3f6e72f
saisooraj/python-ws
/armstrong_number.py
199
4.0625
4
num = int(input("enter the no :")) res = 0 while num!=0: res += ((num%10) ** 3) num=num//10 if num==res: print("the no is amstrong:") else: print("the no is not an amstrong:")
ca4e8334ebca921b348d0b358bf21374e78ed495
Sullivannichols/csc221
/labs/lab8/test_lab8_unittest.py
1,059
3.5625
4
import unittest from lab8 import ( count_letters, reverse_string, is_palindrome, match_ends, front_x, sort_last, ) class TestLab8(unittest.TestCase): def test_count_letter(self): self.assertEqual(count_letters('hello', 'l'), 2) def reverse_string(self): self.assertTrue(r...
7d18316ebb3af73ccf1584237829a21820e5f7b0
krenevych/programming
/P_05/ex_3.py
693
4.1875
4
""" Приклад 5.3. Написати програму, що переводить маленькі латинські літери у відповідні великі літери (у верхній регістр). Помітимо, що різниця кодів між символами маленької і великої літери однакова і становить ord('A') – ord('a') == ord(' ') == 32 """ Ch = input("Задайте символ ") if Ch >= 'a' and Ch <= 'z':...
edcd9fb844febd16daf803c54d59031cf580ef98
Aayushdh99/Python-Stuff
/OOP/03_Abstraction_And_Encapsulation.py
3,680
4.34375
4
''' ##1 Implement a Library management system which will handle the following tasks; 1. Customers should be able to display all the books in the library. 2. Handle the process when a customer requests to borrow a book. 3. Update the library collection when the customer returns a book. ''' class Library: ...
3497d6bb963cd0b4c017537db5fa2fcc76b8ee28
YoyinZyc/Leetcode_Python
/Google/Outbound Sprial Output.py
567
3.78125
4
''' 题意: 給一個String 用outbound spiral方式輸出 (ex. abcde -> cdbae) 思路: 先中 然后右左左右为一个周期 ''' def output(l): center = l[len(l)//2] print(center) i = len(l)//2-1 j = len(l)//2+1 while j < len(l) or i >= 0: if j < len(l): print(l[j]) j+=1 if i >= 0: print(l[i]...
8bc8b90f1f40f163210dde37429b7c4ec8249cab
boonchu/python3lab
/coursera.org/python3/quiz/homework4/quiz8-3.py
1,429
4.375
4
#! /usr/bin/env python """ A set S is a subset of another set T (mathematically denoted as S suset of T) if every element x in S (mathematically denoted as x subset in S) is also a member of T. Which of the following sets are subsets of the set {1,2}? """ def subset_of_set(sets): ''' just generate a power se...
e9c9c7e9a732a76b90bb783ec7a5262b31c944fd
alexzhf/kid-training-python
/ch7/1.py
343
4.09375
4
dan_age=12 eric_age=13 if dan_age==eric_age: print("Dan and Eric are at the same age!") elif dan_age>eric_age: print("Dan is older than Eric") print("Their age gap is: "+str(dan_age-eric_age)) else: print("Eric is older than Dan") print("Their age gap is: "+str(eric_age-dan_age)) print("The is the...
fec2860b9181ee61e992eec792b0a35bbe4bbb4f
Pavlo-Olshansky/Python_learns_2
/7_Sort Dictionary by Value or Key/7_main.py
366
3.640625
4
epic_dict = {'Jack': 5, 'Bill': 14, 'Kat': 3, 'Jess': 33, 'Alex': 4} def sort_by_key(dict_): sorted_by_key_dict = sorted(dict_.items(), key=lambda t: t[0]) print(sorted_by_key_dict) def sort_by_value(dict_): sorted_by_key_dict = sorted(dict_.items(), key=lambda t: t[1]) print(sorted_by_key_dict) so...
00e28c366b685aeb71c1d2491297b604f8ea80ca
hsj321/algorithmPython
/다이나믹 프로그래밍/2193.py
129
3.59375
4
n = int(input()) arr = [] arr.append(1) arr.append(1) for i in range(2, n): arr.append(arr[i-1] + arr[i-2]) print(arr[n-1])
b2c60654b8a8e7ccec9393e849565928d17e1d74
syed-ashraf123/deploy
/General Mini Programs and Competitive codes/Python/OOP1Class.py
265
3.890625
4
class user: def __init__(self): print("User has been made") new=user() print(type(new)) new1=user() print(type(new1)) class user2: def __init__(self,first): self.name=first new3=user2("Hey") new4=user2("Who") print(new3.name) print(new4.name)
a0b7b00922b422daf1e7ddf5be85cbb50b2d2a57
behnamasadi/PythonTutorial
/Machine_Learning/nn/scripts/nn.py
9,014
3.84375
4
import numpy as np import mnist_loader import matplotlib.pyplot as plt class Network(object): def __init__(self, sizes): self.num_layers = len(sizes) self.sizes = sizes self.biases = [np.random.randn(y, 1) for y in sizes[1:]] self.weights = [np.random.randn(y, x) for x, y in zip(siz...
174efd5d41345b38f72c2e931ce8f1f0ef31acb7
arjunbabu1998/practical
/Python basic/anonymousfunc/cirperi.py
128
4
4
radious=float(input("enter the radious of circle : ")) result=lambda radious:2*3.14*radious print("perimeter= ",result(radious))
a073c919a3d59dc6cf38d8a2ade36be198eda93e
TheWizard91/TheNimGame
/Nim.py
8,175
3.578125
4
class Nim(): def __init__(self): """This is the class where the set up is being made""" self._pilesAndStones = {} self._player1 = "" self._player2 = "" self._numberOfPiles = 0 self._currentPlayer="" def setName(self, name, one=True): """Set the...
6ef1cb55c8b0b82f1ed5f00231b5d7c8e832b481
newtonkwan/royal-game-of-ur
/basic_one.py
1,095
3.71875
4
# BasicOne # In order of options: # 1) Prioritize getting a piece into the end tile import random def choose_move_num(board, player, moves, roll): if len(moves) <= 1: move_num = random.choice(range(len(moves))) + 1 # choose the move number. + 1 b/c human input 1 -> 0 for machine W3 = board[0,2] W2 = board[0,3] ...
77b6cace6cfdb4b46b1828a28e82ee2d83cd7d32
gokuljs/python-rev
/solv2.py
260
3.671875
4
# we are going to create acronym generater # Random Acces Memory =RAM print("building a acronym generator") i=input("enter the string for generating acronym ") i=i.upper().strip() print(i) k=i.split() print(k) s="" for j in k: s=s+j[0] print(i+"="+s)
fe96486194f187a1e4e9ca836b912766de8e7c22
iota-cohort-dc/Daniel-Perez
/Python/Python_Fun/list.py
490
4.0625
4
str= "if monkeys like bananas, then i must be a monkey!" print str.find("monkey") str= "if monkeys like bananas, then i must be a monkey!" print str.replace("monkey!", "alligator") x = [2,54,-2,7,12,98] print min(x) print max(x) x = ["hello",2,54,-2,7,12,98,"world"] print x[0] , x[len(x)-1] newx = [19,2,54,-2,7,12...
56b4fd8e7322331fa95b56be9b3c9f66398c68ea
MIT-Tab/mit-tab
/mittab/libs/outround_tab_logic/bracket_generation.py
870
3.96875
4
import math # Recursive function that generated bracket def branch(seed, level, limit): # Level is how deep in the recursion basically # Limit is the depth of the recursion to get to 1, ie, for 8 teams # this value would be 4 (dividing by 2) level_sum = (2 ** level) + 1 # How many teams there a...
a7ee18799da0abd3c9a0eb1795d724f24b9c95a8
dianjulyanaputri/CodeAbbeySolutions
/SelectionSort.py
824
3.734375
4
#input # 120 # 55 21 102 38 114 63 131 194 198 115 48 108 80 170 12 37 74 47 154 157 6 188 191 8 61 179 155 60 111 138 132 41 152 46 104 84 40 88 10 78 59 22 69 86 26 75 17 2 135 195 106 95 109 62 145 124 141 143 151 70 173 136 42 67 118 162 119 98 79 77 93 185 171 3 24 107 64 146 32 153 43 174 113 13 110 35 121 164 72...
7b07afb64fb599678f88db8b107d0c50a43418e0
ivan-yosifov88/python_fundamentals
/list_advanced_lab/even_numbers.py
182
3.890625
4
list_of_nums = input().split(", ") num_list = [int(num) for num in list_of_nums] even_list = [index for index in range(len(num_list)) if num_list[index] % 2 == 0] print(even_list)
1c990786b09382998bcbe64210b2d6960dcbb44f
dadi-vardhan/SDP
/SDP_Assignments/Game_of_life/game_of_life_vishnu/GolLogic.py
1,224
3.734375
4
import time import numpy as np import matplotlib.pyplot as plt class Logic(object): def __init__(self, console): self.state = console.state def neighbour_cell_count(self): ''' Counts the number of cells present at time 't' on the console and returns it. Parameters: n...
7623c836ab0e4ebc61e712efabff46827cb5c7d3
andyly25/Python-Practice
/p34_employeeTestcase.py
695
3.671875
4
import unittest from p33_employeeClass import Employee class EmployeeClassTest (unittest.TestCase): def setUp(self): ## This is my first attempt, pretty bad # self.first = 'Bob' # self.last = 'Marley' # self.salary = 60000 # # self.aRaise = None # # self.aRaise = 1...
87731c95a0b403c1e3df27e76ba9d43b3e2324ce
digvijay-16cs013/FSDP2019
/Day_02/pattern.py
242
4.1875
4
# -*- coding: utf-8 -*- """ Created on Wed May 8 16:56:03 2019 @author: Administrator """ val = int(input('Enter value to construct the pattern : ')) for i in range(val): print('* ' * i) for i in range(val): print('* ' * (val - i))
7decff344b42ecb714fa9c9200f7d3407c0e373d
Aasthaengg/IBMdataset
/Python_codes/p03456/s867751530.py
168
3.765625
4
import math a, b = input().split() ab = int(a + b) result = math.sqrt(ab) value = result % 1 if result * result == ab and value == 0: print('Yes') else: print('No')
879229ab0fc6172d8c959e84aa79895b88546b88
TaigoFr/Finetics
/code/gp_edit.py
3,580
3.609375
4
import random import sys from inspect import isclass #genGrow and generate function copied from gp.py #genGrow changed to simply calling another generate function (generate_edit) #generate_edit created so that when the program tries to add primitives and there are none, it then tries to add terminals (and vice-versa) ...
85f7159feaf97b2aafb41e41a5d6917879db6deb
2019jrhee/FINAL
/colorcode.py
707
3.984375
4
#ohms_color = [] #ohms_str = input # while ohms_str.hasNext() # ohms_color(ohms_str.getNext()) #copying into array #for x in ohms_str: #ohms_color.append(x) def ohms(str): colors = { "0": 'black', "1": 'brown', "2": 'red', "3": 'orange', "4": 'yellow', ...
fcd9f775ea0924982e29daa3c7d61153625e652a
pestana1213/LA2
/labirinto.py
2,024
4.0625
4
''' Implemente uma função que calcula um dos caminhos mais curtos para atravessar um labirinto. O mapa do labirinto é quadrado e representado por uma lista de strings, onde um ' ' representa um espaço vazio e um '#' um obstáculo. O ponto de entrada é o canto superior esquerdo e o ponto de saída o canto inferior...