blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0ac775e8fe4d6aee8d106f6ea70be39aa0230277
pstorozenko/YP2019L-PythonPodstawy
/Zajecia_6/zajecia/klasy.py
596
3.71875
4
from math import sqrt class Punkt: def __init__(self, a, b): self.x = a self.y = b def wypisz_punkt(self): print("Jestem punktem:") print(self.x, self.y) def odleglosc_od(self, drugi_punkt): dx = self.x - drugi_punkt.x dy = self.y - dru...
09cf444756d9e53e2b38f198feb20b4b5105a17f
abdallawi/PythonBasic
/data-structures/functions/ZipFunction.py
1,157
4.46875
4
# We will make 2 lists to play around with: list1 = [1, 2, 3, 4] list2 = [10, 20, 30, 40] # If wanted to combine them in a single list holding Tuple values: # [(1, 10), (2, 20), (3, 30)] # taking the first element out of both list combine them in a Tuple, etc...: # We can't use the map function or list comprehensio...
ebd9de58b203c0cb97b8cdf68e2a8a7509e44e10
aquatiger/LaunchCode
/string count another.py
651
4.03125
4
# Write a program that allows the user to enter a string. # It then prints a table of the letters of the alphabet in alphabetical order # which occur in the string together with the number of times each letter occurs sentence = input("Please enter a sentence: ") sentence = sentence.lower() def counter(text): alph...
3141cb5fc150260142cdbcc7d21b235401da38df
DunDunDunDone/Jigga-Jigga
/SampleAIs2021.py
4,390
3.53125
4
import random def HelterSkelter(board, turns_left, previous_move): # Plays randomly # "I could be playing the perfect game; you never know..." return (random.randint(0, 24), random.randint(0, 24)) def IllegalIllia(board, turns_left, previous_move): # Only plays the same illegal move over and o...
a79f0920c16d411d2de09c250a67d38f821b6387
RamonAlves1357/CryptoCesar
/CryptoCesar.py
1,645
4.125
4
""" Instituição: INSTITUTO FEDERAL DA PARAÍBA - Campus Sousa @utor: Ramon Alves Data de inicio: 03/06/2019 Professor: Victor Disciplina: Tópicos Especiais & Segurança da Informação Objetivo: Implementar o Criptograma de Cesar tanto para encript...
3e7395c918a277baded77f2ab821cf8e1baa0aab
jainrahul5977/python
/ques5_1.py
147
3.734375
4
from math import pow count=0 for i in range(1 , 100): sq=i**2 if sq%10 == 1: count=count+1 print(count , "square are ends with 1 ")
a444907448a093d557ed5d454b0106d793f605d0
tudorciobanu99/Bacteria_Data_Analysis
/data_graph.py
2,561
4.34375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Mon Oct 29 11:49:10 2018 @author: ciobanutudor """ import matplotlib.pyplot as plt import numpy as np def dataPlot(data): # Number of bacteria plot # This array holds the possible names for bacterias bacteria = np.array(["Salmonella enter...
6f9a82356e6b2a9c9b0d8372d788302e157ee3fb
sendurr/spring-grading
/submission - lab4/set2/LUCKE OLIVEIRA LUZ_7457_assignsubmission_file_Lab4_Lucke_Oliveira_Luz/lab4/lab4_ex2.py
217
3.71875
4
# Name: Lucke Oliveira Luz Assignment: Lab 4 Exercise: 2 M = range(1,11) s = 0 for k in M: s += 1/float(k) print "SUM_FOR =", s s = 0 k = 1 M = 10 while k <= M: s += 1/float(k) k += 1 print "SUM_WHILE =", s
9d3f6f8d2143fbfc802ad8aac67bcecf5ac342a5
ritwiktiwari/AlgorithmsDataStructures
/archive/searching/orderd_seq_search.py
353
3.8125
4
def search(arr,key): i = 0 found = False stop = False while i < len(arr) and not found and not stop: if key == arr[i]: found = True else: if key >= arr[i]: i += 1 else: stop = True return found array = [1, 2, 4, 5...
b67f7ba6ea231c774c2c9a9ef7cf48c56981a170
NolanMcD/ClassWork
/Homework8.py
3,838
3.546875
4
import matplotlib.pyplot as plt #map plotting import numpy as np # Array def GenerateDrifterFileName (location): #file name given tag fname = "VirginiaKey8723214_meantrend.txt" print (fname) # show name before positions ...
a957f504dca1220fe1865657689c2d4b818da22c
Beckyme/Py104
/ex33add.py
306
3.921875
4
# -*- coding:utf-8 -*- i = 1 numbers = [] while i < 100: print "At the top i is %d" % i numbers.append(i) n = int(raw_input("Give me a number")) i = i + n print "Numbers now: ", numbers print "At the bottom i is %d" % i print "The numbers: " for num in numbers: print num
885811fc28487f8fc3fe4f6ec08c665b7b2217a2
Acid170/homework
/db.py
7,147
3.5625
4
import mysql.connector mydb = mysql.connector.connect( host = "localhost", user = "root", password = "GracE-1056", #Connecting to a specific database database="mydatabase" ) mycursor = mydb.cursor() #Create a database #mycursor.execute("CREATE DATABASE mydatabase") #Show list database...
dfedf11d4fefb0e9109ed47033de6aa336eeb2b0
bushra57/Python-assignment
/week 2 Task 2.2/module_man_dis.py
734
3.59375
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 25 12:06:46 2018 @author: bushra """ def manhattan (length_1,length_2,list1,list2): print("") print("Considering list 1 as X and list 2 as Y for finding predictive vale of Y") m=len(list1) n=len(list2) total_man_dis=0 for i in range(m-1): ...
e89f36c093461351f991f04123ab488e7920f26d
TheCharlatan/PHY125
/week2/prime_sieve.py
562
3.578125
4
from pylab import * upper_bound = int(input("Input an upper bound for the prime number. ")) integer_list = [0] * upper_bound stop_number = int(sqrt(upper_bound)) + 1 prime_list = [] for i in range (2, stop_number): if integer_list[i] != 1: integer_list[i] = i prime_list.append(i) print (...
6d85feb327e5a33b364943aa0b7b0fdb7f1fa18e
johnswyoon/Algorithms
/Combinatorial search/Constraint Satisfaction problem/8 Queen Problem.py
1,508
3.71875
4
''' Author: Sofen Hoque Anonta Problem: Find all posible arrangements in which 8 queens can be placed in an 8 by 8 chess board such that no queen is under attack ''' import sys def readBoard(readable): board = [] for r in range(8): board.append(readable.readline()) return board # hold true fo...
793724b0ff270dd3fdb770bec11364195d4e761f
zhaolijian/suanfa
/leetcode/mianshi_01_02.py
1,481
3.8125
4
# 判定是否互为字符重排,即两个字符串中的字母重新排列后是否能一样 # 方法1 转换成数组中sort # class Solution: # def CheckPermutation(self, s1: str, s2: str) -> bool: # array_1, array_2 = [], [] # for i in range(len(s1)): # array_1.append(ord(s1[i])) # for i in range(len(s2)): # array_2.append(ord(s2[i])) # ...
57d8d5b07d1591ccfb4000b0c70a291e5c204857
mauriciozago/CursoPython3
/Exercicios/ex056.py
643
3.671875
4
soma = 0 cont = 0 velho = 0 nome_velho = '' for c in range(1, 5): nome = str(input('Entre com o nome da pessoa {}: '.format(c))).strip() idade = int(input('Entre com a idade da pessoa {}: '.format(c))) sexo = str(input('Entre com o sexo da pessoa {} (M ou F): '.format(c))).upper().strip() soma = soma + ...
a1a18dbe1e2377c38148b22b46618858209f2885
Nirol/LeetCodeTests
/Algorithms_questions/med/sortColors.py
1,354
3.828125
4
class Solution(object): def sortColors(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ zero_count = nums.count(0) one_idx = zero_count one_count = nums.count(1) two_idx = one_count + zero_co...
1580e53231ebc42ca7a1b8eea89cf4b6282db49a
MagatteTop/GestionPersonne
/divisions.py
659
3.984375
4
# -*-coding:Latin-1 -* import os num = input("entrer le numerateur:") try: # On essaye de convertir l'année en entier num = int(num) except TypeError: print("La variable numerateur recoit un type incompatible avec la division.") den = input("entrer le denominatuer") try: # On essaye de convertir l'année en en...
6d858079ffc64c5d06bf9b5669518f566d72f552
Jef808/TicTacToePython
/src/Agent.py
1,106
3.515625
4
from random import randrange as rand # from random import choice class Agent(): def __init__(self, token='X'): self.token = token def agent_to_play(self, game): return self.token == game.current_player() def eval_game_over(self, game): score = 0 if game.won...
93cf0e36fdd54716ab924a7fc469214374811ccc
rafael1717y/repo-python
/deep_dive_python/27.secao_6_lambda_sorting.py
961
3.890625
4
import random l = [1, 5, 4, 10, 9, 6] print(sorted(l)) l = ['c', 'B', 'D', 'a'] print(sorted(l)) # Na ordem lexográfica 'A' vem antes de 'a'. print(ord('a')) print(ord('A')) # Usando um ordem que é case insensitive. print(sorted(l, key=lambda s: s.upper())) d = {'def': 300, 'abc': 200, 'ghi':100} print(d) for e...
6c59b244a7b01d24f769d09de191d02b855d50fe
Keshav1506/competitive_programming
/Tree_and_BST/020_geeksforgeeks_Print_All_Leaf_Nodes_Of_Binary_Tree_Right_To_Left_and_Left_To_Right/Solution.py
14,750
3.828125
4
# # Time : O(N); Space: O(H), where H is height of the tree # @tag : Tree and BST # @by : Shaikat Majumdar # @date: Aug 27, 2020 # ************************************************************************** # # Geeks for Geeks - Print All Leaf Nodes of a Binary Tree from left to right # # Description: # Given a Binary ...
8bbcac71e39f33be01174c697c6dee7e0c7b96b7
aymane081/python_algo
/arrays/random_pick_index.py
986
3.65625
4
import random from collections import defaultdict class Solution: # O(1) space and time in initialization. O(n) time and O(1) space when getting the rand index def __init__(self, nums): self.nums = nums def get_random_index(self, target): result, count = None, 0 for i, num in enum...
8df5edf3f2a2a993a6d49f809f6446f985a51074
Susensio/aim.101p
/puzzle-3-you-can-read-minds/helpers.py
2,069
4.03125
4
"""Helper functions implementing basic alogrithms used across several sandboxes.""" from typing import Iterable def indexes_if_sorted(elements: Iterable): """What would the indexes of each element would be in a sorted version of itself >>> data = ['a', 'c', 'b'] >>> indexes_if_sorted(data) (0, 2, 1)...
fb32d8f1e5ae527d94007d3bdb65a10ad860d9b3
ck-unifr/leetcode
/快手/1405-longest-happy-string.py
2,040
3.890625
4
""" https://leetcode-cn.com/problems/longest-happy-string/ 1405. Longest Happy String A string is called happy if it does not have any of the strings 'aaa', 'bbb' or 'ccc' as a substring. Given three integers a, b and c, return any string s, which satisfies following conditions: s is happy and longest possible. s c...
8b209901642df10e919c6542711a5efff41ea480
sandymnascimento/Curso-de-Python
/Aula 17/ex082.py
465
3.90625
4
num = list() nump = list() numi = list() while True: x = int(input('Digite um valor: ')) num.append(x) if x % 2 == 0: nump.append(x) else: numi.append(x) res = str(input('Deseja continuar? ')).strip()[0] if res in 'Nn': break nump.sort() numi.sort() print(f'A lista dos va...
70f4f209fb816917920cac155cc22911243308c4
poweihuang17/epi_python_practice
/Hash/nearest_repeated_12_6.py
499
3.5
4
def find_nearest_repitition(paragraph): word_to_latest_index, min_distance={}, float('inf') for i, word in enumerate(paragraph): if word in word_to_latest_index: latest_index=word_to_latest_index[word] min_distance= min( i-latest_index, min_distance) #print "present" word_to_latest_index[word]=i #...
a890b73c31aba311eb20ee07459814d1dc1e9194
mhems/polyBST
/python/bst.py
1,833
4.1875
4
#!/usr/bin/env python3 class BST: """Binary Search Tree container""" def __init__(self, comp): """Initialize empty BST""" self.comp = comp self.node = None self.left = None self.right = None def __len__(self): """Return number of elements in BST""" ...
2f2a706f84be2c098bf1c1c825a6803d49b7c99e
Ichigo-lab/PythonBegins
/Data Structure/sets.py
558
4.375
4
numbers = [1, 1, 1, 1, 2, 2, 3, 4] set_item = set(numbers) # set is list with unique item # methods are same as list add, remove, append # but they are unordered list so we cannot access item like list # Doesnt support indexing new_set = {1, 2, 6} # defining set # All mathematical set operations can be used in set...
404d9f40658d5d12bfeb4fea06fe2a08dd2cb0bd
elcol49/FIT1045
/FIT1045- workshop/FIT1045- workshop 9/w9t3.py
242
3.953125
4
n = int(input("Please enter a positive integer n ")) L = [] def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) def printL(n): for i in range(1, n+1): print('*'*factorial(i)) printL(n)
5d37fcc467e71d2d8d7f37bedbb4f5bf66b83d8b
AP-MI-2021/lab-2-radusabina
/main.py
2,807
3.984375
4
import math def get_leap_years(start, end): """ Afișează toți anii bisecți între doi ani dați (inclusiv anii dați). :param start: primul an introdus :param end: al doilea an introdus :return: anii bisecti dintre cei doi ani introdusi, inclusiv anii dati. """ rez = [] for i in range(s...
5cb875c250f9e337d9e4298db283f47432d1734c
Selvapeace/python-introduction-turtle-myNote
/课时9/2.py
242
3.890625
4
bingo = "hahaha" answer = input("How to laugh?") while True: if answer == bingo: break answer = input("How to laugh?") print("game over") # break:终止并跳出循环体 # while True:耍诈,必须进入循环体
7e389af18fc192766e814e1cb8d0824cb3d7ff65
stroll-c/study
/python3/test.py
202
3.625
4
#! /usr/bin/env python3 # -*- coding:utf-8 -*- def test_while(): x = 0 while x < 9: print(x) x += 1 else: print ('end') if __name__ == '__main__': test_while()
e513e1b500d6fe9034ad04be964fb16307b88384
shakfu/polylab
/py/finance/finance.pyx
2,624
3.6875
4
#!/usr/bin/env python ''' A set of functions for quick financial analysis of an investment opportunity and a series of projected cashflows. For further details and pros/cons of each function please refer to the respective wikipedia page: payback_period http://en.wikipedia.org/wiki/Payback_period...
93bc7496fd29bad242cc6bc5ab5e621d43bc4d1f
madhurgupta10/Python-BETA-ND
/starter/database.py
2,319
3.578125
4
from models import OrbitPath, NearEarthObject import csv class NEODatabase(object): """ Object to hold Near Earth Objects and their orbits. To support optimized date searching, a dict mapping of all orbit date paths to the Near Earth Objects recorded on a given day is maintained. Additionally, all un...
a32e6a17e437bdf836f2cacf61ce1d858a3713aa
RahulSurana123/40-challenging-program-python
/quadratic-equation-solver.py
1,075
4.09375
4
import math import cmath print("Welcome to Quadratic Equation Solver App") print("\nA Quadratic equation is of form ax^2 + bx + c = 0") print("Your solution can be real or complex number") print("A Complex number has two part: a + bj") print("Where a is the real part and bj is the imaginary part of the number") n = in...
5b0164b8c907060f30bc088ffa9ab3fee333b312
jsMRSoL/dotfiles
/scripts/.local/usr/bin/refilerenumber.py
2,836
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' A script to rename files with a stem and incrementing number. E.g. image_001.jpg, image_002.jpg, image_003.jpg. ''' import sys import logging from pathlib import Path IMAGE_HOME = '/home/simon/vcol' logging.basicConfig(level=logging.DEBUG) # logging.disable(logging.CR...
6f4a211ab18801523e65004398938087f583e617
goosen78/simple-data-structures-algorithms-python
/binary_search.py
1,571
4.46875
4
#!/usr/bin/env python3 """ Binary Search Script """ def binary_search_iterative(lst, value): """ Searches for an value within a given list. This algorithm uses binary search in an iterative way. @param lst: a list containing numbers @param value: value to be found @return: T...
0cc3ed9f26b2007f6f21c9534a608908aefaf8de
idoleat/NCTU-CS-Introduction-To-Computer-Science-HOMEWORK
/python/10/0411275_hw10-1-1.py
1,303
3.609375
4
import socket import re mysoc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) countt=0 IsPrint=True while True:#This section will keep looping when th input is improper. try: url=input("please input the web page : ") test=re.search("http:\/\/.*\/",url) #checking url format. if test=...
2583f30a53b0bc98f75758440117600087375c01
ramyasutraye/Guvi_Python
/set6/53.py
83
3.765625
4
a=int(input("Enter a number:")) b=0 while a>0: c=a%10 b=b+c a=a//10 print(b)
d63aa167926b91a246b0219af06e6ffec803a944
SahityaRoy/get-your-PR-accepted
/Sorting/Python/Insertion_Sort.py
532
4.21875
4
# Python program to implement Insertion Sort def insertion_sort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and key < arr[j]: arr[j + 1] = arr[j] j = j - 1 arr[j + 1] = key # Driver function if...
0de1c5b9a5e3b39c4ee09bbc5822eb1af60c7956
Jamietseng/finals
/計算權重.py
7,341
3.578125
4
debug = True # 計算總時間權重 weighting_list = [] # 科目 subject_list = input().split(',') # 上課效益(1~5) on_class_utility_list = [int(s) for s in input().split(',')] # 各科學分數 credit_list = [int(i) for i in input().split(',')] # 考試占比 exam_percentage_list = [int(i) / 100 for i in input().split(',')] # 各科讀書效率 efficiency_list = ...
ca77c8c0894441cfeb42eee8f21d9438296080c4
HoussemCharf/adventcode2016
/day 21/x.py
2,484
3.5
4
import re, itertools swapl = r"swap letter (.) with letter (.)" swapp = r"swap position (.) with position (.)" rotl = r"rotate left (\d+) steps?" rotr = r"rotate right (\d+) steps?" rot = r"rotate based on position of letter (.)" rev = r"reverse positions (.) through (.)" move = r"move position (.) to position (.)" de...
f448c3ab46ad03ad4c5298d7a6feb1fd2ced3058
stevalang/Data-Science-Lessons
/statistics/21_basic_prob.py
856
3.953125
4
from random import choice def coin_flip(): flip = ['H', 'T'] return choice(flip) def series_of_flips(n): return [coin_flip() for _ in range(n)] # print(series_of_flips(5)) def four_flip_samp_space(): flips = ['H', 'T'] out = [] for i in flips: for j in flips...
5bb48e5e275e0d9b85cb39c7599cd74b5d865656
lpervak/IT_HW_3
/Task_3/scripts/script_4.py
406
3.8125
4
def dec_num(list_nums): def wrap(*args, **kwargs): list_numbers = list_nums(*args, **kwargs) nums_to_str = [] for i in list_numbers: nums_to_str.append(str(i)) print(nums_to_str) return list_numbers return wrap @dec_num def list_nums_(): num = int(input(...
b6e8852f424a675e3ac1550eca2b7607c3f40ae8
shrutirajani/Python_Practice
/sort.py
1,126
4.3125
4
#!/usr/bin/python3 # Read the lines of the input file and sort them in various ways. import sys def prlines(label, lines): print(label+":") for x in lines: print(" "+x) print() lines=[] while True: line = sys.stdin.readline() if not line: break lines.append(line[:-1]) prlin...
1085025abb9961e15a91a558626985cc4e8c9a0e
jeudyx/ExerciseSession
/Exercise1.py
1,484
3.953125
4
''' Exercises for session 1. Jeudy Blanco - 02/21/2012 ''' import sys import os #This will be the program's entry point def main(argv): path = argv[1] filelist = getFileNames(path) for filename in filelist: fixDataFile(path, filename) #This function returns the content of a directory in a list def getFileN...
8e9eb8962a278b6184afaaf8d1d75c50d5b5d220
Anisha2001/21_days_of_programming_solutions
/21 days of programmin (software)/Question 8.py
536
3.84375
4
#Finding Runners up import array as arr arr_num = arr.array('i',[]) n=int(input("Enter no. of scores: ")) for x in range(0,n): a=int(input("Enter score : ")) arr_num.append(a) print("SCORES: "+str(arr_num)) for i in range(0, len(arr_num)): for j in range(i+1, len(arr_num)): ...
b2e36ef5ce31629fb47c16671256e4b858896e5b
HarryLawes/utils
/utils/weather.py
1,416
3.5
4
# pylint: disable=missing-docstring import sys import requests BASE_URI = "https://www.metaweather.com" def search_city(query): url = BASE_URI + '/api/location/search/?query=' + query response = requests.get(url).json() if not response: city_details = None elif len(response) > 1: for...
1b9c8d21837eedab72e55b0a441ca098bee50357
Developerdanish/CodeChef
/Beginner/Small_factorial.py
274
3.875
4
def fact(num): if num==1: return 1 else: return num*fact(num-1) def fact(num): res = 1 for i in range(1, num+1): res *= i return res test_case = int(input()) for i in range(test_case): num = int(input()) print(fact(num))
5bb080155976c567b466a8be0856ccedc7375b8e
napoleonOu/Introduction_to_Algorithms_in_action
/quicksort/quicksort.py
1,135
3.90625
4
def quick_sort(array, l, r): if l < r: ret = partition(array, l, r) quick_sort(array, l, ret-1) quick_sort(array, ret + 1, r) def partition(array, l, r): solder = array[r] i=l j=l while j< r: if array[j] >= solder: j+=1 else: array[j],...
e340055c13a62a57e1e7619e58d6bc0e17e536f4
yamada46/Python_class
/hw6.py
4,502
4.40625
4
#! /Users/gailyamada/PycharmProjects/ITFDN2018/venv/bin/python3 ''' hw6.py This python script will calculate the cost of pizza for movie night. Get user input for the following: Number of people who want pizza Average number of slices per person You can store these as a single integer, or use a dictionary to map name...
3a32ab6b9446d86302935124a354a9e9d2c77d70
dslwz2008/pythoncodes
/algorithms/stack.py
5,930
3.59375
4
#-*-coding:utf-8-*- __author__ = 'shenshen' from node import Node class Stack(object): def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(s...
6bc194dd9b453e45933ba4e3901364d8378c0973
Joe-Demp/leetcode
/python/coin_change_2.py
1,427
4.09375
4
from typing import List import random # Not an original answer, guidance taken from YouTube class Solution: """ You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infi...
725566f48af2e67fb6a751840076cc8cf2d1966f
nicky-ru/encryptor_des
/encryptor.py
3,526
3.53125
4
# encryptor.py from filters import ip, pc1, pc2, p, e_bit, ip_minus_1, s_boxes def do_permutation(str_, filter_): """ The function applies permutation to a given binary string :param str_: (str) binary string to alter :param filter_: (list of int) permutation filter :return: (str) altered binary ...
e8a3da99b159afd464d02280526176d294d9da63
Anuragjain20/Data-structure-and-algo
/graph/ssspbfs.py
751
3.6875
4
class Graph: def __init__(self,gdict = None): if gdict is None: gdict = {} self.gdict = gdict def addEdge(self,vertex,edge): self.gdict[vertex].append(edge) def bfs(self,start,end): queue = [] queue.append([start]) while queue: pat...
972929f6b47d01b317726d528699351c74aa7a3e
Abhyudaya100/my-projects-2
/stringpattern3.py
142
3.84375
4
string = input("enter a string :") strlen = len(string) for index in range(strlen,0,-1): print(" " * (strlen - index) + string[:index])
f338549b7d73f0b3e49ce92adeac69f1e5fdbd74
harihavwas/pythonProgram
/OOP/Polymorphism/Overriding/per_child.py
199
3.84375
4
class Person: def set(self,name): self.name=name print(self.name) class Child(Person): def set(self,age): self.age=age print(self.age) o=Child() o.set("Hari")
07f8303fd45b7a2b1d903af64025aeaceea613a5
ganeshk1928/page-rank
/pagerank.py
3,510
3.765625
4
#Program To find Page Rank of a given web graph usng Matrix Multiplication #Implemented in Python by Ganesh Katakam #Function to display given matrix def display(matrix, nodes): for i in range(nodes): for j in range(nodes): print("{: >10}".format(matrix[i][j]), end = " ") print("\n") #Function to upda...
581468fa1cb9e32d6ee6936f02f60fd247c65468
Frenchhorn/leetcode-python
/#118 Pascal's Triangle.py
653
4.0625
4
''' Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ] ''' class Solution(object): def generate(self, numRows): """ :type numRows: int :rtype: List[List[int]] """ ...
8953c9e98de9fbab88dc52585c1620cebf9e2ba2
wagolemusa/python
/loopsletter.py
101
4
4
thing = "spam!" for c in thing: print c word = "egga!" for letter in word: print(letter)
f6d3866cba382df8a8e1ebbb15f8adfd0580fec8
DavidLupea/introCS2
/David,Lupea_p05_hw26.py
464
4.1875
4
#David Lupea #IntroCS2 pd5 #HW26 -- MapsMaps #2018-4-16 def mymap(f,L): '''Assume f is a function and L is a list Returns a list''' returned = [] for i in L: returned += [f(i)] return returned print mymap(lambda x: x**2, [1,2,3]) print mymap(lambda s: len(s) , ['cat...
dbaee35ae5019c1126574bc64bfaa052820156e3
TheSharonStephenGitHub/python-challenge
/PyBank/main.py
2,093
3.65625
4
import os import csv #opened the csv file budget_csv = os.path.join("Resources", "budget_data.csv") with open(budget_csv, 'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') #excludes the header row next(csvreader) #initializes all of the variables used total_months = 0 total =...
36f1f61fe819cdad5f07c03ed4ec9dfc30aa74fa
nischal321/testing
/functions_practice.py
677
3.65625
4
# #Block of code, which run it is called and can pass date, known as parameter. # #example # def play(): # print("i play candy crush") # play() # #Arguments: An argunenr is the value # #parameter : # def function2(firstname): # print(firstname) # function # def function3(firstname,lastname): # print(f...
f99a4e81ef15541978aecafb12351d4c376cda58
Alexisd00/Text-Adventure
/play.py
1,714
4.46875
4
print("Hello World!") start = ''' As you were taking a hike, you realized that you had gone off the trail. You begin to walk back when all of a sudden, you stumble across a river which holds a bridge. It's up to you to find your way back. You could either walk straight across the bridge or swim across the river. ''' ...
f2a485408a573df5bd66b56a60cb5233e68321cc
carolgcastro/Curso_Python
/Mundo 3/ex101.py
369
3.90625
4
from datetime import datetime def voto(ano): idade = datetime.now().year - ano if idade < 16: return f'{idade} anos: NÃO VOTA' elif 16 <= idade < 18 or idade > 65: return f'{idade} anos: VOTO OPCIONAL' else: return f'{idade} anos: VOTO OBRIGATÓRIO' res = voto(int(inp...
d4becfc525ae5649e60802cf82af2d6a4f7761d0
iattilagy/orto
/orto.py
3,770
3.578125
4
#!/usr/bin/env python3 '''This script goes along the blog post "Building powerful image classification models using very little data" from blog.keras.io. It uses data that can be downloaded at: https://www.kaggle.com/c/dogs-vs-cats/data In our setup, we: - created a data/ folder - created train/ and validation/ subfold...
720008eca3144f159aaf019eb562a78496f38b04
rabira-hierpa/python-bootcamp
/excercise/3-rock_paper_scissors.py
3,567
4.3125
4
from random import randint print("Welcome to the game!") print("ROCK PAPER SCISSORS") ## constatns __rock__ = "rock" __paper__ = "paper" __scissors__ = "scissors" computer_wins = 0 player_wins = 0 draws = 0 while True: print("Please choose your game mode ") print("\t 1. Play with the computer") print("\t 2...
15adce7e3b0a0b6a4ede3e652c0d3497e09e561b
kals0390/Project-Euler
/question7.py
434
4.09375
4
'''By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number?''' def is_prime(n): if n == 1 or n == 2 or n ==3: return True else: sq_num = int(math.sqrt(n)) for i in xrange(2,(sq_num+1)): if n %i == 0: return False return ...
8cc8aa18e8faeb751fe39f280441cb5fe959fed0
pdinkins/AV_terminal_ui
/ui/menu.py
1,118
4.3125
4
''' ##MENU #Parker Dinkins #Python 3.6 This is a simple module for displaying a menu, making a choice, and calling the linked function. USE: 1. import menu 2. define menu choice functions 3. define menu dictionary {'menu choice label': corresponding function} 4. menu.initialize...
d7dfa23d31cfb5430e776da55f050ba33e66b45d
jasdepw/online-judge
/Stack&Queue_Question_3.py
942
3.671875
4
from collections import deque def solution(bridge_length, weight, truck_weights): answer = 0 bridge = deque([0] * bridge_length) #다리 위에 있는 트럭 하중의 합 bridge_weight = 0 #대기 중인 트럭들 waiting_trucks = deque(truck_weights) while bridge: bridge_weight -= bridge[0] bridge.popleft...
23bc16f4cd8626790f088116fb613742e25f13c3
yostane/python-paradigmes-et-structures-de-donnees
/structures_de_donnees/tableau/insertion_liste_deque.py
1,136
3.765625
4
import time, collections N = 1000000 for p in range(0, 3): print("passage ", p) print(" insertion en fin") li = list() a = time.perf_counter() for i in range(0, N): li.append(i) b = time.perf_counter() print(" list", N, "éléments, temps par éléments :", (b-a)/N) ...
185ef9156db3c2e58503ffb0f0cb33b6e68dd6b8
itoyan/ProjectEuler
/source/prob053.py
294
3.5
4
# -*- encoding: utf-8 -*- import math def nCr(n, r): return math.factorial(n) / math.factorial(r) / math.factorial(n-r) num = range(1, 101) total = 0 for n in num: for r in range(n): # n+1は考慮の必要なし if nCr(n, r) >= 1000000: total += 1 print total
9a888f5572c3d5b4b72bd298a8054267a61631dd
ddilarakarakas/Introduction-to-Algorithms-and-Design
/HW2/findPairs.py
1,181
4.09375
4
def mergeSort(arr): if len(arr) > 1: r = len(arr)//2 leftArr = arr[:r] rightArr = arr[r:] mergeSort(leftArr) mergeSort(rightArr) merge(leftArr,rightArr,arr) def merge(leftArr, rightArr, arr): i = j = k = 0 while i < len(leftArr) and j < len(rightArr): ...
b58e1ff0fb886bfb2bd5287762fa262f3e1d3b5e
drkwons/study
/1.py
611
3.53125
4
class Cal(object): _history = [] def __init__(self, v1, v2): self.v1 = v1 self.v2 = v2 def add(self): result = self.v1+self.v2 Cal._history.append("add : %d+%d=%d" % (self.v1, self.v2, result)) return result @classmethod def history(cls): for r...
60defe0ed9825742878ab88ad35758a24a327225
foxface-ap/CTCI-solutions
/Chapter 2 - Linked Lists/Partition/partition.py
1,136
3.828125
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def push(self, new_data): new_node = Node(new_data) new_node.next = self.head self.head = new_node def printLL(self):...
99936fbd018e7a9073bee8bf513534805080dc9c
IvamFSouza/ExerciciosPython
/Exercicio-14.py
525
4.125
4
# Faça um programa que leia um ângulo qualquer e mostre na tela # o valor do Seno, Cosseno e Tangente desse ângulo. import math angulo = float(input('\nDigite o ângulo que você deseja: ')) seno = math.sin(math.radians(angulo)) cosseno = math.cos(math.radians(angulo)) tangente = math.tan(math.radians(angulo)) print(f...
b2bbf5f6cf402037517b9fc1d3043700138d7236
hyunjun/practice
/python/problem-graph/redundant_connection.py
1,369
3.59375
4
# https://leetcode.com/problems/redundant-connection # https://leetcode.com/problems/redundant-connection/solution from collections import defaultdict class Solution: # runtime; 216ms, 2.69% # memory; 11.5MB, 100.00% def findRedundantConnection(self, edges): if edges is None or 0 == len(...
fdaf5a7f3965b87f2d1c7cf525a7e0ec316a7afd
Ahmed201002/python
/challenge/challenge1.py
484
3.671875
4
ipAdress=input("pleas enter the ip address= ") if ipAdress[-1]!='.': ipAdress+="." numberOfSegements=1 lengthOfSegment=0 # i="" for i in ipAdress: if i==".": print("segment number is {} contains character{}".format(numberOfSegements,lengthOfSegment)) numberOfSegements+=1 lengthOfSegmen...
f4782c825e4309fc2b17a07a762a6d0aeccd4602
Th3Lourde/l33tcode
/problemSets/top75/283.py
771
4
4
''' Given an integer array nums, move all 0's to the end of it while maintain the relative order of the non-zero elements do in place. Ok so modified bubble-sort. Loop through list, whenever you see a zero, bubble the zero to the end of the list. ''' class Solution: def moveZeroes(self, nums): l = 0 ...
cdcc3603fcf1b13b9088d343cd28a063bd9e345e
cheahjs/adventofcode
/2021/20/code-2.py
1,941
3.625
4
#!/usr/bin/env python3 import re import collections import itertools import functools from collections import defaultdict def print_grid(grid): lowest_x = min([x for x, y in grid]) highest_x = max([x for x, y in grid]) lowest_y = min([y for x, y in grid]) highest_y = max([y for x, y in grid]) for ...
caa5406a64166d7b516373f064e5f330724de0ea
albytennis/PyCharmOne
/vinny.py
1,546
3.9375
4
body_part1 = input("Enter a body part ") adjective1 = input("Enter an adjective ") noun1 = input("Give me a sexy noun ") body_part2 = input("Give me another body part ") noun2 = input("Give me another noun ") body_part3 = input("Enter a body part ") verb1 = input("Verb ending in s ") body_part4 = input("Give another bo...
1536adcadfe73a3200126bce00eadadac8ff3726
AlefAlencar/python-estudos
/python_curso-em-video_guanabara/Mundo 2/a15_ex069.py
855
3.6875
4
# ANÁLISE DE DADOS DO GRUPO # LEIA: idade, sexo de x pessoas # Pergunte se o usuário quer continuar após cada pessoa # RETORNE: quantas pessoas +18anos; quantos homens; quantas mulheres <20anos # Não permita entrada de dados inválidos sexo = resp = ' ' maiores18 = homens = mulheres20 = 0 while True: print('-'*10, '...
58125dd4c016a756c120e5c4fd3ab4d6256352ca
0Magnetix0/Kaggle
/competition/Python/0001check.py
160
3.578125
4
mystery = print() print(mystery) print("How to use sep in python") print(1,2,3,4,5, sep = ' * ') print("By default the value of sep is ' '") print(1,2,3,4,5)
44b00916e36f4ff75fd2da78c2a82f2474d58a19
raseribanez/Pen-Testing
/generate_wordlist_basic.py
297
3.765625
4
#1/usr/bin/env/python # Ben Woodfield # A simpler list generator...creates as many possible instances of 'abc' # Without re-using letters import itertools res = itertools.permutations('abc',5) # 5 is the length of your results characters (5 letters long) for i in res: print ''.join(i)
4c9cd6e358ef525757839d60c364f311cdbce6f3
ShehanAT/PythonMiniProjects
/tetris/tetris/main.py
9,213
3.65625
4
import pygame, sys, os, random from pygame.locals import * colors = [ (37, 235, 11), (160, 154, 143), (139, 176, 186), (57, 217, 227), (82, 30, 24), (13, 216, 46), (198, 39, 57) ] WHITE = (255, 255, 255) GREY = (128, 128, 128) BLACK = (0, 0, 0) level = 1 lines_to_clear = 1 ''' Tet...
d8de6b327b771b3c95623e81892091f946923992
judening/leetcode
/stack/inorderTraversal.py
661
3.765625
4
class Solution: def inorderTraversal(self,root): stack = [] output = [] if not root: return output while True: if root: #This makes sure we get the deepest level of left subtree #before we pop anything stack.app...
91d9205d38f30902161e8535f72c86cbc9abc236
pty902/Resume
/Algorithm/Algorithm Basic/Samename/test_3.py
275
3.65625
4
def two_name(a): n = len(a) for i in range(0, n-1): for j in range(i + 1, n): print(a[i], "-", a[j]) name = ["Tome", "Jerry", "Mike"] two_name(name) print() name2 = ["Tome", "Jerry", "Mike", "John"] two_name(name2)
337af6ea6c39f48803adc778358438f044c3fb81
griffinashe/griffinRepo
/Number_Projects/prime.py
238
4.03125
4
"""Find all the Prime Numbers up to a given number. """ n = raw_input("Give me all the primes up to: ") num = int(n) for p in range(2, num+1): for i in range(2, p): if p % i == 0: break else: print p
e000d49f0938c83af1003b2c0aa46b4e181e8105
maldonadojsm/Drake
/input.py
1,275
3.6875
4
#!/usr/bin/env python # Created by zahza at 3/11/20 import pyautogui class InputHandler: """ The Input Handler class processes automated mouse and keyboard input using the PyAutoGUI library. """ @staticmethod def control_mouse(coordinates: tuple, flag: int): """ Controls mouse using X/Y coordinates @para...
fcff5fbb92cb34855b0329f36282c222f394922c
601824142/HelloPython
/基本操作案例/wan_01_买苹果案例.py
500
4.0625
4
# 1、输入苹果单价 # app_price = input("输入苹果单价:") # 2、输入苹果购买重量 # app_weight = input("输入苹果重量:") # 3、计算金额 # (1)将苹果单价转换成小数 price = float(input("输入苹果单价:")) # (2)将苹果的重量转换成小数 weight = float(input("输入苹果重量:")) # (3)计算付款金额 money = price * weight print("苹果单价:%.02f元/斤,苹果重量:%.02f斤。共需要支付:%.02f元。" % (price, weight, money))
35178636b324559eded8515712a57c6a146ab28c
abawchen/leetcode
/solutions/152_maximum_product_subarray.py
741
3.859375
4
# Find the contiguous subarray within an array (containing at least one number) which has the largest product. # For example, given the array [2,3,-2,4], # the contiguous subarray [2,3] has the largest product = 6. class Solution: # @param {integer[]} nums # @return {integer} def maxProduct(self, nums):...
2eacf92ad5b914de0b126bbe3277f70c546f38ad
c0untzer0/StudyProjects
/PythonProblems/interestcalc.py
1,323
3.75
4
#!/usr/local/bin/python3 #-*- coding: utf-8 -*- # # interestcalc.py # PythonProblems # # Created by Johan Cabrera on 2/15/13. # Copyright (c) 2013 Johan Cabrera. All rights reserved. # #import os #import sys #import re import math #import random #def newfunction(*arg): ## ## Insert function definitions in here. #...
140b1472ac6a7367394ab1686d59808cd821b3df
zhongshun/Leetcode
/124. Binary Tree Maximum Path Sum/solution 1.py
1,231
3.546875
4
class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def maxPathSum(self, root): """ :type root: TreeNode :rtype: int """ return 0 def ChildNodeMaxValue(root): if not root: ...
7482644e0d30a77dccb6e4d28c168e866d15406d
adelfazel/AllOnlineCourses
/course1/week1_programming_challenges/2_maximum_pairwise_product/max_pairwise_product.py
160
3.90625
4
# python3 a=int(input()) b=int(input()) def gcd(a,b): if b==0: return a; else: rem= a % b return gcd(b,rem) print(gcd(a,b))
25c85aac615310ce3bed2905484cac34fd8dc3ab
verdouxscience/advent-of-code
/2017/17/solver.py
810
3.765625
4
from collections import deque STEPS = 344 class Lock: def __init__(self, steps): self.q = deque() self.steps = steps def insert(self, value): self.q.rotate(-(self.steps + 1)) self.q.appendleft(value) def after(self, value): index = self.q.index(value) r...
f0ba150c30c855882c87b8f177d5333919cea993
bimri/learning-python
/chapter_30/strrepr.py
3,032
4.375
4
"String Representation: __repr__ and __str__" class adder: def __init__(self, value=0): self.data = value # Initialize data def __add__(self, other): self.data += other # Add other in place (bad form?) if __name__ == '__main__': x = ad...
f84af958752b6de03dc53cb62f2d66e47012919c
csontoskristof/python
/harmadikfeladat.py
601
3.75
4
#F0003a: Írj programot, amely külön-külön megkérdi a vezeték- és a keresztneved, majd kiírja őket egy mondatban, pl: A te neved Kovács Boldizsár.(A pontot se felejtsd el!) #F0003b: Bővítsd az előző programot úgy, hogy a kiírás előtt kérdezze meg a születési évedet és a csillagjegyedet, és az előző feladatban megadott ...
0fe3887c420cf412b6e68ce07aed22c4e86bf137
superpupervlad/ITMO
/4 Семестр/Прикладная математика/Lab2/DescentFunction.py
559
3.578125
4
from abc import ABC, abstractmethod class DescentFunction(ABC): def __init__(self): self.calls = 0 @abstractmethod def run_once(self): pass @abstractmethod def run(self, func, x): pass @property def name(self): raise NotImplementedError # Это не надо...
29ee3dd02bf64acc3d3740bf1b9c55955d65e242
manikshahkataria/codes
/w6.py
337
3.625
4
n=int(input()) k=0 f=1 b=n*n+1 for i in range(n): for j in range(k): print('-',end='') k=k+2 for j in range(i+1,n+1): print(str(f)+"*",end='') f=f+1 for j in (range(i+1,n)): print(str(b)+"*",end='') b=b+1 print(b) b-=2*((n-i)-1) p...