blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
72cead464e68b21bcca85049040de31f3846a331
Mahpare/ETL
/extract.py
857
3.546875
4
# a class that handles different data sources for extraction purpose. # OOP’s methodology = keeping our code modular or loosely coupled. import pandas as pd import json import requests class Extract: def __init__(self): # opens file and returns A JSON object contains data in the form of key/value pair. ...
d91838f23315a1b1dd03972cbe33492906445b4b
Austin-Ayers-1997/Tic-Tac-Toe
/gui_representation.py
1,022
3.75
4
import Tkinter as tk import tic_tac_toe as ttt from PIL import ImageTk, Image # Main code to start and place features in the GUI root_window = tk.Tk() def startGameHandler(): """ Method to handle button clicks from the user in the program """ ttt.play_game() # List of strings used in the...
5cfaffbbf1a5c10125b699f208258411e9165646
whitneytlarsen/lab-4
/linked_list.py
5,195
4.0625
4
import sys sys.setrecursionlimit(1000100) # an AnyList is one of: # - None # - Pair(Any, AnyList) # a first is a value of any type and makes up the first part of Pair # a rest is an AnyList and makes up the rest of Pair class Pair: def __init__(self, first, rest): self.first = first # any type ...
2ff343c91342b32581d3726eb92c6570eb4c049e
forgoroe/python-misc
/5 listOverLap.py
1,102
4.3125
4
""" ake two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists of diffe...
1e138a3770218338f66b78f14945e0508c1041a4
forgoroe/python-misc
/3 listLessThan.py
912
4.375
4
""" Take a list, say for example this one: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a program that prints out all the elements of the list that are less than 5. Extras: Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out t...
7c57689eac501ab4bc6da1e8c17a5c7abe1dd58b
forgoroe/python-misc
/14 removeListDuplicates.py
771
4.21875
4
""" Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates. Extras: Write two different functions to do this - one using a loop and constructing a list, and another using sets. Go back and do Exercise 5 using sets, and write the s...
d6623703be95a97d397ef543f61c495a436a352b
vpoletae/prog_school_SB
/Linked_list/linked_lists_comp.py
555
3.78125
4
from Linked_list import Node, LinkedList def linked_list_compare(obj_1, obj_2): if obj_1.len() == obj_2.len(): obj_1_list = [] node = obj_1.head while node is not None: obj_1_list.append(node.value) node = node.next obj_2_list = [] node = obj_2.head ...
83afa2e93802e4c4c87a6a7114be8e0aeebdcb62
vpoletae/prog_school_SB
/BinarySearch/BinarySearch.py
2,131
3.65625
4
class aBST: def __init__(self, depth): # правильно рассчитайте размер массива для дерева глубины depth: tree_size = 0 for i in range(depth + 1): tree_size += (2 ** i) self.Tree = [None] * tree_size # массив ключей def FindKeyIndex(self, key): # ищем в массив...
a3426b09dd657346a43b64f9887008e486f2e944
vpoletae/prog_school_SB
/Balanced_BST/Balanced_BST.py
649
3.59375
4
def GenerateBBSTArray(a): if a == []: return [] a_sorted = sort_array(a) empty = create_empty_array(a) balanced = fulfill_empty(a_sorted, empty, index=0) return balanced def sort_array(a): return sorted(a) def create_empty_array(a): return [None] * len(a) def fulfill_empty(a, empt...
39bac3aead0b6e19b9887cf7ec4cd9e1f32ba9d7
vpoletae/prog_school_SB
/Black_Tree/Black_tree.py
7,402
3.796875
4
class SimpleTreeNode: def __init__(self, val, parent): self.NodeValue = val # значение в узле self.Parent = parent # родитель или None для корня self.Children = [] # список дочерних узлов self.Level = None class SimpleTree: def __init__(self, root): if root is not None...
6f55f38b1f45879a0f5baa3d201f8ec626f70d11
glebvi1/Sudoku
/SudokuSolver.py
3,196
3.546875
4
import copy from Sudoku import Sudoku class SudokuSolver(Sudoku): def __init__(self, sudoku: Sudoku): super().__init__() self.sudoku = sudoku self.solved_sudoku = copy.deepcopy(sudoku) # Метод решает судоку def solve(self): # Возможные варианты цифры для соот...
0113970875c4c916832c3945921f01bca1447f61
flozender/Codechef
/Beginner/NDIFFPAL.py
127
3.703125
4
for _t in range(int(input())): s = 'abc' n = int(input()) extra = n%3 st = s*(n//3) + s[0:extra] print(st)
5020140fc07d1bc4eea696e1605fce30435f76b8
flozender/Codechef
/Beginner/BST.py
229
3.53125
4
class Node: def __init__(self, val): self.val = val def addLeft(self, left): self.left = left def addRight(self, right): self.right = right a = Node(12) print (a.val) b = Node(13) a.left = b
31ee7fbdde7f20645f9521fe64821aff5436c9aa
vjsaxena/python-challenge
/PyPoll/main.py
1,978
3.859375
4
#Necessary Import import csv #Define files to be used in the program poll_csv = "Resources/election_data.csv" result_file = "Analysis/election_analysis.txt" #Define Variables vote_count=0 candidate_dict={} output_str="" output_line="-------------------------\n" #Open the file with open(poll_csv, newline='') as poll_...
a887c6ab4061e0612287b80ee5da84fec65d8dfd
SirJimPanse/Bachelor-HSRM-Medieninformatik
/Programmieren3/Python/OnlineTest/OnlineTestSummary/a1_lists.py
536
3.75
4
l = [1,2,3,4,5,1,2,3,6,6] l2 = [1,2,3,4,5,1,2,3,6,6] l3 = [1,2,3] l4 = [3,4,5,6] def del_double(l): z = 0 s = l for i in l: for x in s: if x == i: z += 1 if z > 1: s.remove(i) z = 0 return s def del_double_rev(l): l.reverse() l = ...
18c01fd44b3dd32e5861dc1c79b8b765a8a0d88c
SirJimPanse/Bachelor-HSRM-Medieninformatik
/Programmieren3/Python/Blatt3/menge.py
2,779
3.671875
4
class Set(object): def __init__(self,l=None): if type(l) == list: self.list = l elif type(l) == int: self.list = [] self.list.append(l) else: self.list = [] def add(self,elem): self.list.append(elem) def union_update(self,...
55cdbdeabb1c5a6fbe8bd8734ca49e7e0269f454
SirJimPanse/Bachelor-HSRM-Medieninformatik
/Programmieren3/Python/Blatt1/a9.py
1,199
3.96875
4
#Abschnitt 3 "An Informal Ontroduction to Python" print 2+2 print (50-5*6) print 7/3 print 7/-3 width = 20 hight = 5*9 print "width = 2,hight =5*9 -> width * hight =",width * hight print 3 * 3.75/1.5 print 7.0/2 print 1J * 1j print 3+1j * 3 print (3+1j)*3 print (1+2j)/(1+1j) a=1.5+0.5j print a.real print a.imag a=3.0+4...
9d18e9c95683a0e0b67eae025988f4b91cfa2361
SirJimPanse/Bachelor-HSRM-Medieninformatik
/Programmieren3/Python/WDH/a1.py
1,007
3.515625
4
import string buc = string.lowercase + string.uppercase # oder buc ='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' lis = range(10) """ Liste mit allen Elementen von lis ausser dem ersten und dem letzten""" print "Liste mit allen Elementen von lis ausser dem ersten und dem letzten:" print lis[1:-1],"\n" """ Li...
8f96539158e970745c060c799ba367ce7f5885fe
JohanEddeland/advent_of_code
/2017/09/aoc_09.py
1,221
4.0625
4
""" aoc_09.py Solution for Advent of Code 2017 day 09 """ import aoc_09_input def calculate_score(stream): ''' calculate_score(stream) Given a stream, calculate the score according to the rules from: http://adventofcode.com/2017/day/9 ''' nested = 0 total = 0 ignore = False...
525e95abba33737a9d27b85a28d90d8ebe4530ca
becgabri/CryptoPals
/crypto_pals/set1/CryptoPals2.py
834
3.53125
4
#!/usr/bin/python import sys import binascii import base64 def hexToRaw(hex_str): raw = binascii.unhexlify(hex_str) return base64.b64encode(raw) # supports regular string arguments OR byte arguments NOT regular string args # returns a byte string def hexXOR(arg1, arg2): if len(arg1) != len(arg2): ...
3644001e79bd1cc2580917be54d8bcef2ee9248b
k2works/study_for_math_python
/3/functions.py
4,750
3.984375
4
# coding=utf-8 ''' 平均を計算 ''' def calculate_mean(numbers): s = sum(numbers) N = len(numbers) # calculate the mean mean = s/N return mean ''' 中央値を計算 ''' def calculate_median(numbers): N = len(numbers) numbers.sort() # 中央値を求める if N % 2 == 0: # if N is even m1 = N/...
a84a5f900d9f30b9fb25c993dcde236e95bb1c8d
agdsouza/donation-analytics
/src/data_outputer.py
752
3.96875
4
class DataOutputer: ''' Takes calculated outputs and formats it into a text file ''' def __init__(self, result_list, output_name): self.result_list = result_list self.output_name = output_name def format_line(self, record): ''' Takes one record, delimits it with the | character, and returns that record as a ...
8b427cc486f4826826a497ca59ed1a94d058c648
aarong1/TCD_Ising_Model
/functions.py
2,773
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This file stores all the funnctions needed. @author: aarongorman """ h=0 import numpy as np import matplotlib.pyplot as plt from numpy.random import random as rand #function to initialise a random matrix with collinear spins randomly distributed def init(N): s...
c45559cbf2cd3491aa031ec9116ba6d2478dace9
notontilt09/Intro-Python-I
/src/prime.py
294
4.125
4
import math x = input("Enter a number, I'll let you know if it's prime:") def isPrime(num): if num < 2: return False for i in range(2, math.ceil(math.sqrt(num))): if num % i == 0: return False return True if isPrime(int(x)): print('Prime') else: print('Not prime')
77be91ca98f8875696a0b3116b0ad154ef92d235
foxytone/3a_for_SAP
/tests.py
1,241
3.515625
4
from main import Weather import unittest from main import KEY from datetime import datetime class WeatherTest(unittest.TestCase): def test_key_exists(self): self.assertNotEqual(KEY, None, 'key does not exists') def test_init_with_default_city(self): weather = Weather() self.assertEq...
25acc164afae5074ce07b84eea4514e09a258b2c
may-tech/python3
/opt/practice.py
334
3.6875
4
print('Hello World') nunber = '3+7' print(nunber) x=10 print(x) x*=20 print(x) name='may' print('My name is '+name) price=100 print('りんごの価格は'+str(price)+'円です') count='4' price=100 total_price=price*int(count) print(count+'個買ったら¥'+str(total_price)) # game = 3 # if game == 3 # print(3です):
c10c9203d96b14f450e09bdffa8fe236c573bafe
NightFuryNis13/nis13
/lab1.py
274
3.953125
4
print ("nis") print (4+5)#to print sumof 4 and 5 a=15 b=15 c=a+b print("a") print ("c") a=input("enter a value for a=") b=input("enter a value for b=") c=float(a)+float(b) print(c) import turtle for(i=(int)0;i<6;i++) {turtle.forward(100) turtle.right(120) }
b4aa3ebf9450838146b1460ab2b78f5620dfe021
Abdullah99044/nogmaals-
/duizelig/project1.py
134
3.59375
4
import time a = 30 while a < 31: print(a) a = a - 1 if a == 0: break time.sleep(1) print("lanceer de raket!!")
bdede4c266f5cf6e34a8da2ed5cd661db1ac7315
Abdullah99044/nogmaals-
/duizelig/project5.py
372
3.8125
4
while True: print("................................") answer = int(input("Schrif een nummer:")) print("................................") quit = 5 if answer == quit: print("Goed gedaan!") break else: print("..........................") print("fout! doe het nog een...
4d343fedf8584b93d3835f74851898c2bbff0e8c
Tanner-Jones/Crypto_Examples
/Encryption.py
696
4.15625
4
from cryptography.fernet import Fernet # Let's begin by showing an example of what encryption looks like # This is an example random key. If you run the file again # you will notice the key is different each time key = Fernet.generate_key() print(key) # Fernet is just a symmetric encryption implementation ...
7bd0129d9ab6395d2899538ac9828529e3a35131
jaanos/operacijske-raziskave
/vaje/Zahtevnost/zahtevnost.py
1,579
3.796875
4
# -*- coding: utf-8 -*- def zrcaliMatriko(A): """ Prezrcali vsebino matrike A dimenzij n×n pod diagonalo na ustrezno mesto nad diagonalo. Originalna vsebina nad diagonalo se izgubi. Po izvajanju je A simetrična matrika. Časovna zahtevnost: O(n^2) """ n = len(A) assert all(len(l) ==...
934219505186bb0deee06450ecd9e3990c71155c
aszalosl/aima-extra
/jealous3.py
3,130
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Three married couples must cross a river using a boat which can hold at most two people, subject to the constraint that no woman can be in the presence of another man unless her husband is also present. The boat cannot cross the river by itself with no people on board....
7aab1a4b1a35fdcd17b3eed72c830ef92bd6ffb9
tecnic08/CURobocovid-Tablet-Stock-App
/SetShipPrintApp.py
14,759
3.515625
4
#!/usr/bin/env python3 import tkinter as tk import tkinter.font as tkFont import time import gspread from oauth2client.service_account import ServiceAccountCredentials from print import * from config import * print("Connecting to Google Drive API...") # use creds to create a client to interact with the Google Drive ...
6c23ffc602f351f9f1d4a412eb8bb7f668236d58
joc44/PtyhonPractice
/4.7.py
309
3.640625
4
#Írjon egy programot, ami kiíratja a 7-es szorzótábla első 20 tagját, csillaggal jelölve azokat, #amelyek 3-nak többszörösei. #Példa : 7 14 21 * 28 35 42 * 49 count = 0 while count < 20: count +=1 print(count, count * 7) if count % 3 == 0: print("*")
d71a0a65028aa14102ee618c784b078f2a39ecc5
oryoruk/Rosalind
/examples.py
1,549
3.921875
4
#!usr/bin/python #Python Examples #+++++++++++++++ #STRINGS stringA = "012345678" listA = list(stringA) print "----Strings 1----" print stringA print listA print "----Strings 2----" print (stringA+"-")*3 print "----Strings 3----" print stringA[3:8] print stringA[8:0:-1] print stringA[::-1] print "----Strings ...
7ad4de354506328459bc7786cf19c61542050725
RishiKuls/turtle-programing-python
/3.py
52
3.609375
4
name=input("what is your name?\n") print("hi",name)
e1c873f93b1b4bc23944700bb2ac08f795bdff9d
elhamchg/lecture2
/4_1_comparison_operator.py
328
4
4
########################## ## compare two variables # ########################## i=5 j=6 print("i < j --> {0}".format(i<j)) print("i > j --> {0}".format(i>j)) print("i <= j --> {0}".format(i<=j)) print("i >= j --> {0}".format(i>=j)) print("i is equal to j --> {0}".format(i==j)) print("i is not equal to j --> {0}".forma...
92243f7c15930dc0d9cae34bbc09f1f4f17e88f7
gerffson/design-patterns-python
/factorymethod/concrete_product.py
371
3.546875
4
from abstract_product import AbstractProduct class ConcreteProduct(AbstractProduct): """ Concrete implementation of products interface. Modify it in order to instantiate your own ones! """ def __init__(self): print("Created: concrete product instance") def feature(self):...
e5f18d7951345bce874f5306d587dde44a1bfd29
gerffson/design-patterns-python
/abstractfactory/abstract_factory.py
476
3.640625
4
from abc import ABCMeta, abstractmethod class AbstractFactory(): """ This is the abstract factory class, grouping together the creational methods for each product in the product family. Note that the created products are returned with their asbtract interfaces. Modify it as needed! """ __m...
1929309257b96b56590185b3a0205ea45a075876
gerffson/design-patterns-python
/abstractfactory/concrete_factory.py
718
3.828125
4
from abstract_factory import AbstractFactory from concrete_product_X import ConcreteProductX from concrete_product_Y import ConcreteProductY class ConcreteFactory(AbstractFactory): """ Concrete implementation for AbstractFactory class: this class implements the creational methods for all the products of a ...
09fb93f0febad6a9097fc5500837e26ae505e514
Raiser93/curso-python-Ubaldo-temas-basicos
/05-ciclos/ciclo-while.py
160
4.03125
4
# condicion = False # while condicion: # print("Ejecutando ciclo while") # else: # print("Fin ciclo while") i = 0 while i <= 2: print(i) i += 1
04a6f23c3a433c703ff67771c4d90147b3a59c08
rahulbh123/python-practicals
/triangle.py
185
3.84375
4
a=int(input("enter the base number:- ")) b=int(input("enter the height number:- ")) def triangle(a,b): return(1/2*a*b) print("the area of triangle is",triangle(a,b))
d337dff4b4895be03919604f2b501f5cda598fb0
jonaskas/Programa-o
/7_colecoes-master/G_set2.py
637
4.15625
4
""" Sets - Allow operations based on set theory. """ set1 = {'a', 'b', 'c', 'a', 'd', 'e', 'f'} set2 = set("aaaabcd") print() print("intersection:", set1 & set2) # same as print(set1.intersection(set2)) print("union:", set1 | set2) # same as print(set1.union(set2)) print("diference: ", set1 - set2) # same as print(s...
4b772bd2b3e80c5efb292bfedf7e74908aae1d7a
jonaskas/Programa-o
/7_colecoes-master/C_mutability2.py
489
4.15625
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print...
416476483e88c28599ab7669f2315eabca009661
jonaskas/Programa-o
/Fichas Praticas/Ficha prática 3/exercicio2.py
192
3.9375
4
""" Exercicio 2 """ munero1 = int(input("Introduza um número inteiro: ")) numero2 = int(input("Introduza outro número inteiro: ")) for i in range(numero1, numero2): print(i, end=" ")
d0e2f442df784f29d935aa30daf03b53e56fc523
jonaskas/Programa-o
/3_repeticao-master/4_range.py
326
3.9375
4
""" range([start], stop[, step]) """ print("range(5):") for i in range(5): print(i, end=" ") print("\nrange(2, 10):") for i in range(2, 10): print(i, end=" ") print("\nrange(2, 20, 2):") for i in range(2, 20, 2): print(i, end=" ") print("\nrange(20, 0, -1):") for i in range(20, 0, -1): print(i, end...
390d233fa7d6782527a0770df8bb17aaa61ba00e
jonaskas/Programa-o
/Fichas de avaliação/Python_fp_6_aval/exercicio2.py
448
3.90625
4
""" Exercicio 2 """ def quantidade(carater): teste = input('Introduza 1 caratere: ') contar = carater.count(teste) print("A letra {} existe: {} vezes.".format(teste, contar)) for i,j in enumerate(carater): if j == teste: print("A letra {} encontra-se na posição {}.".format(j,i)) ...
4723bf1c627ab59ae4c67fc21a4188aa8373d9a9
jonaskas/Programa-o
/7_colecoes-master/C_mutability1.py
415
3.96875
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print_mem...
2720a7b9f29a071198ff393ed95006ec885b068c
jonaskas/Programa-o
/5_dados_estruturados-master/1_Classes/E_rectangle2.py
658
3.9375
4
""" Example """ from C_point import Point class Rectangle(): def __init__(self, point1, point2): self.point1 = point1 self.point2 = point2 def get_size(self): """ returns the rectangle size as the distance from origin """ return Point(abs(self.point...
431f245b3bf0073f7bff288979b1b364ce932415
jonaskas/Programa-o
/Fichas de avaliação/Python_fp_5_aval/exercicio1.py
3,000
3.609375
4
""" Exercicio 1 """ from random import randint import time import re ''' def isValidEmail(email): if len(email) > 7: if re.match("^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$", email) != None: return True return False if isValidEmail("my.email@gmail.com") == True : print(...
9d5b5473bf15be9bfd6c04f7d76f804d213218f4
jonaskas/Programa-o
/9_librarias-master/Modules/_string.py
593
3.71875
4
""" string """ import string in_char = "aeiou" trans_char = "12345" text = "Ullamco et duis ad cupidatat cillum ullamco ipsum ut nulla." print(text.translate(str.maketrans(in_char, trans_char))) text = "Laborum quis amet eu culpa sunt deserunt proident laboris enim et esse eu. Aliqua proident magna dolor aliqua lab...
3939d09d42684a7b934c5d81820cb8153b8c4b29
jonaskas/Programa-o
/7_colecoes-master/C_mutability4.py
684
4.3125
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print...
62fb02699f26a16e7c18ba5d70b234068c05b0ee
jonaskas/Programa-o
/7_colecoes-master/C_mutability3.py
474
4.125
4
""" Mutability - Python is strongly object-oriented in the sense that everything is an object including numbers, strings and functions - Immutable objects: int, float, decimal, complex, bool, string, tuple, range, frozenset, bytes - Mutable objects: list, dict, set, bytearray,user-defined classes """ def print...
8ef675ee4fb4d8670cb89b90c94f47e9cac1b98f
jonaskas/Programa-o
/Fichas de avaliação/jogo_do_galo_aval.py
6,438
3.84375
4
""" Jogo do Galo """ class Tabuleiro(): #Guardar as coordenadas def __init__(self): self.lista = [ [None, None, None], [None, None, None], [None, None, None] ] #Foi buscar a internet (https://github.com/Armindo123/prog1/blob/master/trabalhopratico/jogod...
6c18f05b4474cea87fd85e6cb1b8e52f61452a7b
jonaskas/Programa-o
/4_funcoes-master/1_Functions/11_return.py
876
4
4
""" return """ def my_max(*numbers): max = None for value in numbers: if max is None or max < value: max = value return max def is_greater_v1(value1, value2): if value1 > value2: return True else: return False def is_greater_v2(value1, value2): if value1 > ...
f96e74da178bdc7726d12016c6557ff421cac013
jonaskas/Programa-o
/Fichas de avaliação/Python_fp_1_aval/exercicio3.py
214
3.84375
4
""" Exercicio 3 """ massa = float(input('Introduza o seu peso: ')) altura = float(input('Introduza o sua altura: ')) alt = altura ** 2 imc = massa / alt print('O seu Indicede massa corporal é de {}'.format(imc))
17cc8a1f42f3bf8237a422b50339e5cef13db9d4
jonaskas/Programa-o
/Fichas Praticas/Ficha prática 4/exercicio1.py
148
3.921875
4
""" Exercicio 1 """ def print_line(): print("*" * numero) numero = int(input('Introduza quantas vezes queres que apareça: ')) print_line()
be723351917e32a4902c471fe34b8fdfa97ebece
jonaskas/Programa-o
/6_listas-master/F_arraysDT.py
408
3.859375
4
""" Array of Class """ class Student(): def __init__(self, name, grade): self.name = name self.grade = grade def __str__(self): return "{}: {}".format(self.name, self.grade) students = [ Student("Student1", 10), Student("Student2", 15), Student("Student3", 12), Student("Student4"...
20491591465562211b615e1b330fc72cd6622be9
jonaskas/Programa-o
/Fichas Praticas/Ficha prática 1/exercicio1.py
143
3.734375
4
""" Exercicio 1 """ a = 1#int(input("Introduza o primeiro numero:")) b = 2#int(input("Introduza o segundo numero:")) soma = a + b print(soma)
f3676f0236a0597d6e7800e755a9f6b3875024d4
fachrizalmr/TA-Behavior-2021
/Flask/cloud.py
553
3.640625
4
plus = 0 count = 0 for i in range(24): counter = "elif jam == " for j in range(12): test = i if plus == 55: print(counter, test, "and menit >= ", plus, " and menit <= ", 0, ":") plus = 0 print(" now = ", count+1, "\n") count =...
19135b831f06e908e883b069caf3b57ff8ffbf7a
gesijiang/Patterns
/adapter.py
841
4.0625
4
# -*- coding: UTF-8 -*- # 场景:跑和跳是不能更改的函数,但客户端只会用execute调用 class ExA1: def __init__(self, name): self.name = name def run(self): print self.name+'run' class ExA2: def __init__(self, name): self.name = name def jump(self): print self.name+'jump' class A3: def __...
bf3d424b413a5ca135f0579aaaefeef0d5b4764c
akula-haripriya/Priya_8032
/problems.py/3rd promlem.py
196
4.09375
4
a=input("Enter any string: ") b=int(input("Enter a key value: ")) s="" for i in a: s+=chr(ord(i)+b) print(s, " is the Encrypted form with key",b) print(a, " is the Decrypted form with key",b)
d94cd5a551d8b7b41a5e06a7dc4f949698b36081
Kaik-a/Algorithme
/bubble.py
254
3.59375
4
"""Création d'algorithme de tri à bulles""" tab = [12, 0, 74, 5, 17, 20, 1] i = 0 while i < len(tab)-1: if tab[i] > tab[i+1]: print(tab[i]) tab[i], tab[i+1] = tab[i+1], tab[i] i = 0 else: i = i+1 print(tab)
d05003a259c2b5693b88338c908b7f7ec5e82c33
volactina/Python-learn
/coursera-nanjing-20190303-ex9.py
1,367
4.03125
4
''' 用字典创建一个平台的用户信息(包含用户名和密码)管理系统, 新用户可以用与现有系统帐号不冲突的用户名创建帐号, 已存在的老用户则可以用用户名和密码登陆重返系统。 建议基本框架为: ''' userinfo={} def newusers(): username=input('create your user name:') if username in userinfo: print('name has been used, try another!') else: password=input('type your password...
1c5b9dbdc50f6e0afd0cc1e2fc6f4a1e86d0b748
nathanaelbayle/kattis-submissions
/Submissions/namethatpermutation.py
703
3.609375
4
import sys def factorial( n ): res = [ 0 ] * n for i in range( n ): if i == 0 or i == 1: res[ i ] = 1 continue res[ i ] = res[ i - 1 ] * i return res def euclidian( x, y ): return ( x // y, x % y ) while True: data = sys.stdin.readline().rstrip('\n') if...
dc16578b618987274f0f5c1ee798c5d86c4d9d53
fukunarihiroshi/Python_tkinter_basicgames
/list0803_2_test.py
607
3.84375
4
# 入力キーを調べるプログラム import tkinter key = "" # null を代入 def key_down(e): global key key = e.keysym def main_proc(): if key == "a": label["text"] = "apple" elif key == "b": label["text"] = "bee" elif key == "c": label["text"] = "cash" else: label["te...
318404114d1bf2cf6d8654b25fa23066821dbd4d
dabelt-msft/algorithms_datastructures_python
/del_middle_node.py
441
3.96875
4
"""Delete the middle item from a linked list. Takes a head node and returns the head node with the middle item deleted. """ def del_middle_node(node): head = node f = node s = node tick = False while f.next: f = f.next if tick: b_s = s s = s.next ti...
17e874f196f784a97ff0e36e4cde4003220cd7a6
dabelt-msft/algorithms_datastructures_python
/reduce_string_using_stack.py
1,736
4.0625
4
# Steve has a string, , consisting of lowercase English alphabetic letters. In one operation, he can delete any pair of adjacent letters with same value. For example, string "aabcc" would become either "aab" or "bcc" after operation. # # Steve wants to reduce as much as possible. To do this, he will repeat the above...
6d0ba83adfc6b7adcceaaa977423ff6275ba1288
dabelt-msft/algorithms_datastructures_python
/playing_w_linked_lists.py
1,292
3.9375
4
class Node: def __init__(self, val, next=None): self.val = val self.next = next class Linked_List: def __init__(self): self.node = None self.head = self.node def insert_front(self, data): temp = Node(data) temp.next = self.head self.node = temp ...
8917105bdaebf91d19fa99d50eb189529688c1a5
dabelt-msft/algorithms_datastructures_python
/binary_search_recursive.py
492
3.84375
4
def binary_search(nums, start, end, item): index = (start + end - 1)//2 if end - start == 1: return index try: if nums[index] == item: return index elif nums[index] > item: return binary_search(nums, start, index, item) else: return binary...
48b07a2a4e6a2a3f921f3b45c80dae387c6c9b4e
zishanjawed/Python-codes
/function.py
687
3.875
4
import math """ program : Calculate the sum of the area of a regular polygon and square of it's perimeter @author : ZISHAN JAWED """ def polysum(n, s): """ input : Number of sides 'n ', lenght of sides 's' output : return sum of the area and square of perimetrer which is round by four decimal places ...
e5ad7f82077fed8ae9ed1962d79f8baf9216798c
2013056497/ValensPracticalExam
/ValensPracticalExam.py
4,767
3.546875
4
#!/usr/bin/python # Castillo, Justin S. class Car: def __init__(self): self.carTable = [] # Car table | unique key: name | (ex. tuple: ["A", "Red"]) def store_car(self, name, color): self.carTable.append([name, color]) def query_car(self): return self.carTable def query...
097d0fa9f605e825e29b8c950ea11e69cb2bf0c5
axefx/cs-module-project-hash-tables
/applications/word_count/word_count.py
662
3.8125
4
import re def word_count(s): d = dict() s = s.lower().split() tokens = [] for word in s: word = word.replace('"',"").replace(",", "").replace(".","") word = re.sub("[\W]+[\'\W]",'',word) if word: tokens.append(word) for token in tokens: if token not in d:...
b272092c16b6920963fab9d9eac0ceaff38445af
KeithDeRuiter/CS430_Tiger
/blue/homo.py
1,315
3.5625
4
import random import copy class Homophonic: #list of the alphabet + punctuation for decrypting alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ','.','!','?'] homophonic = [] def __init__(self): self.alphabet=['a','b','c','d','e','f','g','h','i'...
81539856a2828b07d21f2043a79b2427b6f8834e
Jithin2002/pythonprojects
/FLOW CONTROLS/FOR/pattern7.py
87
3.5625
4
for i in range(5,0,-1): for j in range(0,i): print(5,end=" ") print()
0eb5530450687bb5eb5384dede39a6effaa0a281
Jithin2002/pythonprojects
/REGULAR EXPRESSION/upplow.py
161
3.828125
4
import re data=input("enter the data") rule="^[A-Z][a-z]+$" matcher=re.fullmatch(rule,data) if matcher is not None: print("valid") else: print("invalid")
fc4d8ce6b8a8bcd523d3a605837d4b91f62f83ba
Jithin2002/pythonprojects
/FLOW CONTROLS/Decision Making/example.py
140
4.1875
4
num1=int(input("enter number") if(num1>0): print("positive") elif(num1<0): print("negative") else: print("neither positive nor negative")
be97486516cb9f37a7a29d7643d25d408d3b297e
Jithin2002/pythonprojects
/FUNCTIONS/demo.py
770
4.09375
4
#inbuilt functions #print() input() type #Normal Syntax def functionname(arguments): function definition function call #using fn name #3 methods for function call #1. Function without an arguments and no return type #2. Function with arguments and no return type #3. Funtion with arguments and return type ...
d158a03978a4911d8b4ee5f8fef5f0b7bacf26d5
Jithin2002/pythonprojects
/FUNCTIONS/sum using 3 method.py
80
3.5
4
def sum(num1,num2): sum=num1+num2 return sum data=sum(15,35) print(data)
293ec2b59b638d9421824738351b80e44ea918b0
Jithin2002/pythonprojects
/REGULAR EXPRESSION/startaendb.py
150
3.546875
4
import re n= input("enter") rule="(^a[a-zA-Z0-9\W]*b$)" match=re.fullmatch(rule,n) if match is not None: print("valid") else: print("invalid")
74494d848957c254dea03530e1cabe13b1b399b1
Jithin2002/pythonprojects
/List/element found.py
384
4.125
4
lst=[2,3,4,5,6,7,8] num=int(input("enter a number")) flag=0 for i in lst: if(i==num): flag=1 break else: flag=0 if(flag>0): print("element found") else: print("not found") #this program is caled linear search # we have to search everytime wheather element is thereor not # drawbac...
8dcb9f799a1bc3814a4483126356fc6cb18fdffe
Jithin2002/pythonprojects
/FLOW CONTROLS/FOR/nextedforloop.py
138
3.671875
4
for i in range(1,4): #(1,2,3) 2 3 for j in range(1,4):#(1 2 3) (1 2 3) (1 2 3) print(j,end=" ") #1 2 3 1 2 3 1 2 3 print()
c4b00499f46bbfddebfe2916635b8690b84047f3
Jithin2002/pythonprojects
/FLOW CONTROLS/Decision Making/example1.py
185
3.6875
4
sal=int(input("enter your salary")) year=int(input("enter your year of service")) if(year>5): amount=(.05*sal) print("net bonus amount",amount) else: print("no bonus",sal)
7dba4a29b68eba17c808f3f76e322ca809ca55c4
Jithin2002/pythonprojects
/List/sum.py
265
3.796875
4
lst=[10,15,20,25,41,42,47,80,100] # sum=0 # for i in lst: # sum=sum+i # print(sum) # # in built functions in list # sum print(sum(lst)) # greatest element in list print(max(lst)) # smallest element inlist print(min(lst)) #to print length of list print(len(lst))
4c86c8ea339580edf905627fbe7550e108ee62a0
Jithin2002/pythonprojects
/FUNCTIONS/example1.py
156
4.15625
4
#5! #5*4*3*2*1 def factorial(): num=int(input("enter number")) fact=1 for i in range(1,num+1): fact=fact*i print(fact) factorial()
66798da0490efb5eb5030e0e9564c9313e758de5
scsmith2/coursera
/BrownCodingMatrix/matrix/inverse_index_lab.py
3,128
4.25
4
# version code d345910f07ae coursera = 1 # Please fill out this stencil and submit using the provided submission script. from random import randint ## 1: (Task 1) Movie Review ## Task 1 def movie_review(name): """ Input: the name of a movie Output: a string (one of the review options), selected at rando...
13855e86f7bd49606518e03996877927ed450c8a
katkalouckova/my_vocabulary
/my_vocabulary.py
3,496
3.796875
4
import json class Dictionary: """ A class for storage and manipulation of used dictionary. Instance attributes: * self.content: words from used dictionary """ def __init__(self): self.content = {"být": "be", "bít": "beat", "stát se č...
82da6e1e9fcd619d60f6084e80f3913ede9e6f44
azltv/eller-py
/002.py
564
3.5625
4
# http://euler.jakumo.org/problems/view/2.html # Каждый следующий элемент ряда Фибоначчи получается при сложении двух предыдущих. Начиная с 1 и 2, первые 10 элементов будут: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # Найдите сумму всех четных элементов ряда Фибоначчи, которые не превышают четыре миллиона. fn1 = 0 fn2 ...
d60187af4bd5762fdb2ee1a6e67730fb082f6ba6
jolks/distributed-systems-playground
/python/parallel_operation_with_multiple_args.py.bak
811
3.78125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from multiprocessing import Pool import math def f(x, y, z): # (x + 2y)^z return math.pow(x + 2*y, z) # In Python 3.3, can use starmap() method instead def f_star(multiple_args): # Changes e.g. f([1,2,3]) to f(1, 2, 3) return f(*multiple_args) # Set no....
eb3a3f2de109fd9ee3e4ecc00b2411391e162cb2
sanathkumarbs/coding-challenges
/recursion/basic/endx.py
695
3.953125
4
"""End X. Given a string, compute recursively a new string where all the lowercase 'x' chars have been moved to the end of the string. endX("xxre") > "rexx" endX("xxhixx") > "hixxxx" endX("xhixhix") > "hihixxx" http://codingbat.com/prob/p105722 """ def endx(input, index=0, ch="", x=""): if index == len(input):...
901ef0e33b34d388d48e16ecd4b1ec216f7e37d3
sanathkumarbs/coding-challenges
/arrays/jumpgame.py
509
3.59375
4
import sys https://leetcode.com/problems/jump-game/description/ https://leetcode.com/problems/jump-game-ii/description/ # This is a DFS approach # Very expensive def minjumps(arr, mins, jumps=0, index=0): if index >= len(arr): return jumps for n in range(1, arr[index] + 1): res = minjumps(arr...
89845b6e41eb23e936941db20c81b0eb57a0c907
sanathkumarbs/coding-challenges
/arrays/palindromerecursive.py
1,813
4.09375
4
"""Valid Palindrome. Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: Input: "race a car" Outpu...
f69e34570a60bea6a95f1450caeaeb49f07b6e9a
sanathkumarbs/coding-challenges
/recursion/hard/groupsum.py
1,264
4.09375
4
"""Group Sum. Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target? This is a classic backtracking recursion problem. Once you understand the recursive backtracking strategy in this problem, you can use the same pattern for many problems to searc...
60831729f58dc649fa5cefbd16fef9264041e824
sanathkumarbs/coding-challenges
/recursion/basic/fibonacci.py
912
4.0625
4
"""Fibonacci. The fibonacci sequence is a famous bit of mathematics, and it happens to have a recursive definition. The first two values in the sequence are 0 and 1 (essentially 2 base cases). Each subsequent value is the sum of the previous two values, so the whole sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on...
df8e11bc71bf65cea0bb900297cc54ab102ac312
sanathkumarbs/coding-challenges
/linkedlists/splitoddeven.py
3,248
3.84375
4
"""Split List Odd Even. Given a singly linked list with integer data, create two lists, one with all odd elements, and one with even. """ from lib.linkedlist import LinkedList def splitoddeven(head): oddhead = head evenhead = None oddcur = oddhead evencur = evenhead oddprev = None while odd...
0f9f547ba6ba680f69873cc53e3b20490021d5de
sanathkumarbs/coding-challenges
/recursion/basic/count7.py
740
3.5625
4
"""Count 7. Given a non-negative int n, return the count of the occurrences of 7 as a digit. So for example 717 yields 2. (no loops). Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). count7(717) > 2 count7(7) > 1 count7(123)...
5ff8e625de91d3b9ba1abf73b4d4c6e6f3e2dd55
sanathkumarbs/coding-challenges
/recursion/basic/count8.py
883
3.640625
4
"""Count 8. Given a non-negative int n, compute recursively (no loops) the count of the occurrences of 8 as a digit, except that an 8 with another 8 immediately to its left counts double, so 8818 yields 4. Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmos...
ea95285c51c22e4bff52e2a925df19fa87eeef0a
sanathkumarbs/coding-challenges
/recursion/hard/split53.py
1,193
4.03125
4
"""Split 53. Given an array of ints, is it possible to divide the ints into two groups, so that the sum of the two groups is the same, with these constraints: 1. All the values that are multiple of 5 must be in one group 2. All the values that are a multiple of 3 (and not a multiple of 5) must be in the other. ...
b5fd18e128f5acd90d8744cbf7a60219c845b63f
lijiali1226/Code
/leetcode/python/P104MaximumDepthOfBinaryTree.py
609
3.984375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def maxDepth(self, root): """ :type root: TreeNode :rtype: int ...
7b17274aac6c92a871ea055d36c1922566b19615
samuelbeaubien/FrozenLake_OpenAI
/tests.py
163
3.515625
4
# Test getting inputs from the user move = input("Enter a move (0, 1, 2, 3): ") print (type(move)) move_int = int(move, 10) print (move_int) print (type(move_int))