blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2707f60adcc158eda014907fd5addbb6c3e4a1cd
saikiran335/python-projects
/atm.py
1,148
3.96875
4
P="123456" AB=500.00 b=input("PLEASE INSERT THE CARD('Y'/'N'): ") if b == "N": print("insert card correctly") else: while True: p=input("Enter Your Pin") if p != P: print("Enter Correct pin") break while True: print("1. WITHDRAW") print("2. DEPOSI...
1405622802d8d4b5d3c91328636f36e066c170ed
saikiran335/python-projects
/inheritance exe.py
483
3.65625
4
class profile: age=20 name=input("enyter name:") def __init__(self): print("this is my profile") def first(self): self.name=self.name print("my name is:",self.name) class pro(profile): name="kiran" def __init__(self): print(" started") def second(self): ...
945f5f8d410c551b2fe8ee14d2e211e249d9234c
Prudhvik-MSIT/cspp1-practice
/m8/Is In Exercise/is_in.py
970
4.125
4
''' Author: Prudhvik Chirunomula Date: 07-08-2018 ''' # Exercise: Is In # Write a Python function, is_in(char, a_str), that takes in two arguments # a character and String and returns the is_in(char, a_str) which retuns a # boolean value. # This function takes in two arguments character and String and returns...
a60aa799c7efd7c995d5a76398ef17759a926e4d
jolinux11/Python
/prime.py
201
4.09375
4
n=input('Enter any num:') flag=True count=2 while count < n: if n % count == 0: flag=False count+=1 if flag == True: print ('n is prime num') else: print ('n is not prime num')
4c29190b5ea41ce60c34ffc1d6b05452b9affb27
jolinux11/Python
/shop.py
749
3.671875
4
product={1:'cpu',2:'monitor',3:'mouse',4:'keyboard',5:'ram',6:'nic',7:'usb',8:'hdd',9:'speaker',10:'smps'} price={1:10000,2:3000,3:199,4:299,5:3499,6:699,7:499,8:3700,9:1500,10:1500} cart=[] bill=[] count=0 total=0 addition=[] c=[] x=0 while count < 100: n=input("To add product to the cart press 1 or press 0 to exi...
4f260f3a2f6186c42fdf433a4ad8073bc0bbb3de
Choonky/Python_Assignments
/guess_a_number.py
314
3.875
4
in the list or not. num = [1,15,65,2,6,9,10] print('Type q to quit.') while True: input_num = int(input('Enter a Number: ')) if input_num in num: print('You have successfully guessed a number.') continue elif input_num not in num: print('Try Again.') continue
71e578244bc39d7e9a2ebaff46f7b1531a0e211d
neilweidinger/Ascii-Art
/search.py
1,330
3.71875
4
import math def binarySearch(ray, target): l = 0 r = len(ray) - 1 while l <= r: m = int((l + r) / 2) if ray[m] > target: r = m - 1 elif ray[m] < target: l = m + 1 else: return m return -1 def leftmost(ray, target): l = 0 # ...
98c79c10189fba35deb816b7321d82cb62710577
txemavs/adata
/src/adata/sqlite.py
4,280
3.546875
4
# adata.sqlite ''' Local SQLite3 databases on file Do not use this, please. ''' import sqlite3, os, sys #---------------------------------------------------------------------------- #--- DB def sql_get_table(sql): l=sql.split(" ") return l[l.index("FROM")+1] #---------------------------------------------...
441693ee7979ead79d9d22bef53eb12447e9e0e4
programmer-1/Algorithms
/rsa.py
1,894
3.96875
4
import sys #----------------Encryption part---------------------# #public key(n,e) is used for encryption #encryoted = ((message)*e)% n #----------------------------------------------------# def Encrypt(n ,e,targettext): j = 0 chipertext = [] chipher = "" for i in targettext: c...
3d6245890ed3837b32e9ba4cff8f15bca72296ae
zadrozny/algorithms
/sorting/selection_sort.py
690
4
4
#!/usr/bin/python2 # -*- coding: utf-8 -*- from random import shuffle def selection_sort(array, index=0): '''Sort a list of integers using selection sort''' if index == len(array): return array else: smallest = None current = None for i, e in enumerate(array[index:]...
512e66ca004ab67b720b2a9a39c3e3e664e89c72
zadrozny/algorithms
/sorting/merge_sort.py
1,903
3.96875
4
from random import shuffle test_list = range(100) shuffle(test_list) def partition(a_list): #Partition original list into lists of lists, each with one element #Can this be sped up by creating a new list? for i, val in enumerate(a_list): a_list[i] = [val] return a_list def merge_two(a, b): #Takes t...
6790bb3767cd7f282d41e1e3e3ca45e96204834a
zadrozny/algorithms
/longest_palindrome.py
1,287
4.21875
4
#Author: Matthew Zadrozny #Date: 2014-10-18 '''My friend David Branner posed the following questions...''' ''' Problem 1: Check whether a string contains a palindrome and if so, return the length of the longest palindrome within that string. ''' tests = { "123456789": None, # No palindrome "abahey": 3, # One pali...
8da60d363cdd7d853ee0e7e13717d417cc424733
HtetoOs/Practicals
/Prac_04/no.py
176
3.828125
4
numbers = [3,1,4,1,5,9,2] numbers.remove(3) numbers.insert(0, 10) print("1.",numbers) numbers.pop() numbers.append(1) print("2.", numbers) print("3.",numbers[2:7])
ce7be0cb6459cb95e337f8b3df575a576d786bf3
HtetoOs/Practicals
/Prac_04/QuickPick.py
385
3.8125
4
import random picks = int(input("How many quick picks?>>>")) for i in range(picks): pick1 = random.randint(1, 10) + random.randint(1,7) pick2 = pick1 + random.randint(1, 7) pick3 = pick2 + random.randint(1, 7) pick4 = pick3 + random.randint(1, 7) pick5 = pick4 + random.randint(1, 7) prin...
e75a374de0aef5546764312f7fc85fdc14dd3938
jiminkk/geneAggregationMatrix
/agg_genes.py
5,484
3.5
4
#!/usr/bin/python """ Algorithm used: Read the entire csv file (self_score.csv) Store keys and values into dictionary: Compound as key Cell value (connectivity score) and column index as values """ import csv import itertools from collections import defaultdict calc """ *** Use compoundList.txt under gene_...
5785404571ddcae70b17dc2daca2854839dd7f82
yd1992/Data_Analysis_Using_Python
/assignment2/analysis2.py
1,045
3.515625
4
import json def countRetweets(teamName, date): results = [] f = open("../assignment2/" + teamName + "/" + date + "/output.json", "r") json_file = json.load(f) for record in json_file: results.append(record.get("retweet_count")) print("Team " + teamName + " popularity based on Retweets on " + date + " : " + s...
be3bc897a0900ff2322f3e5a7d07a1411b5633ab
bboychencan/Algorithm
/google/codejam/2020/round1/test.py
204
3.59375
4
import math def get_ele(r, k): return math.factorial(r - 1) // math.factorial(k - 1) // math.factorial(r-k) res = 0 while True: r, k = list(map(int, input().split())) res += get_ele(r, k) print(res)
252a6379cf248a16ff081496f41c69cce3d1ce40
sarat21/Projects-in-Python
/Project4/HW8_sarat.py
6,427
3.734375
4
import math import MyClasses import random ## Hint: After you changed/added something in MyClasses.py, make sure that you have ## saved if before running the code in main file so it knows about your changes. ## WingIDE is usually pretty good about this but other IDE's may not notice this ## change automatic...
61138821b6bce37bf19ffb6e6d7a15e20e4beaf9
arthurbragav/Curso_udemy
/Aula 26 - Loop for.py
1,943
3.921875
4
""" Loop for Loop - Estrutura de repetição For - Uma dessas estruturas C ou Java for(int i=0;i<10; i++){ //excecução do loop } Python for item in interavel: //execução do loop Utilizamos loops para iterar sobre sequências ou sobre valores iteráveis Exemplos de iteráveis - String nome = 'Geek University...
cd3fc52467debac696b5d25d864487764c8d4be5
aturcino/chatbot
/main.py
1,345
3.515625
4
from __future__ import print_function from nltk.chat.util import Chat, reflections # a table of response pairs, where each pair consists of a # regular expression, and a list of possible responses, # with group-macros labelled as %1, %2. pairs = ( (r'I need (.*)', ( "Why do you need %1?", "Would it really hel...
3780db3f38af0f826f5f87e12a9843820d92cc9b
GrayTzar/Python-Has-Power-TM
/westworld.py
307
3.96875
4
error = "I don't understand." print("Welcome to Westworld!") answer = input("Do you watch it or do something better with your time? watch/live \n") if answer == "watch": print("Baaad choice...") elif answer == "live": print("Good idea. Do something better with your time.") else: print(error)
15fc1ce908093c5b8ac8a1a7faf42f09e947798d
Abhiseksah/Tic-tak-toe-2
/game.py
4,959
3.65625
4
from Tkinter import * import tkMessageBox global temp temp=0 t=0 global still_running still_running=True root= Tk() root.geometry("200x500") root.maxsize(200,200) root.minsize(200,200) root.title("Tic-Tak-Toe") board=["-","-","-", "-","-","-" ,"-","-","-"] def change1(): global temp temp+=1 if temp%2==0: ...
1cbca531da545dfa00037d5f6a3b5c1534588d75
tee24/LeetcodeProblems
/Misc/bfs graph.py
758
3.875
4
from queue import Queue adj_list = { "A":["B", "D"], "B":["A", "C"], "C":["B"], "D":["A", "E", "F"], "E":["D", "F", "G"], "F":["D", "E", "H"], "G":["E", "H"], "H":["G", "F"] } visited = {} level = {} parent = {} bfs_traversal_output = [] queue = Queue() for node in adj_list.keys(): visited[node] = False pa...
0dafac4c64decd8655252c6bb4105e2b216de3da
tee24/LeetcodeProblems
/Aug 2020/8.08.2020 - 437. Path Sum III.py
1,046
3.5625
4
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def pathSum(self, root: TreeNode, sum: int) -> int: if not root: return 0 count = 0 nodes = [] def traverse(ro...
65d7cb777f269e200e71b95ec4616aee26bca8c6
tee24/LeetcodeProblems
/Aug 2020/11.08.2020 - 274. H-Index.py
819
4.09375
4
class Solution: def hIndex(self, citations: List[int]) -> int: if not citations: return 0 citations.sort() citations = citations[::-1] if citations[-1] >= len(citations): return len(citations) for i in range(1, len(citations)+1): ...
8987a422dabd45902ec9fede982165289f7d4162
pasberth/python-vector
/sample.py
252
3.625
4
# coding: utf-8 from vector import vector v1 = vector([3,1]) v2 = vector([3,-2]) v3 = vector([1,4,2]) print str(v1) print str(v1 + v2) print str(v1 - v2) print str(v1 * 3) print str(v1 * v2) print abs(v1) print str(v3) print abs(v3) print str(v1 * v3)
f9045b0aa38a401685e92e1eb11ce565be54bb1c
kosuzuk/Ear-Training-Game
/TP/chordProb.py
1,729
3.53125
4
import random def oneProb(): num=random.randint(1,100) if num<21: return 'two' elif num<22: return 'three' elif num<47: return 'four' elif num<68: return 'five' elif num<83: return 'fsev' elif num<86: return 'six' elif num<90: return 'seven' elif num<96: return 'fof' else: retur...
a3cc76217caf26427136540314bc919937b404b7
alexmjn/Intro-Python-II
/src/adv.py
1,573
3.9375
4
from room import Room from player import Player from room_setup import setup_rooms import textwrap # Declare all the rooms room_map = setup_rooms() #dictionary earlier sets up a bunch of room objects, # we call the room object we need player = Player("Alex", room_map["outside"]) user_is_playing = True while user_is_...
96f7f8aa81feca7c089970348bc02f7e6c5a3d8e
Al153/Programming
/Python/Cellular Automata and FSMs/Test for turing machine.py
260
3.765625
4
x = [1,1] t = type(x) print t print type(t) if isinstance(x,list): print 'x = list' mylist = (1,2) if isinstance(mylist,list) or isinstance(mylist,tuple): print'True' tape = (1,2,3) tape2 = list(tape) print tape2 for i in range (3): print i
fa66239fd7ee7967cc269b8b9dffb709850466fb
Al153/Programming
/Javascript/spellcheck.py
2,635
3.53125
4
import re, collections, json #from http://norvig.com/spell-correct.html def words(text): return re.findall('[a-z]+', text.lower()) def train(features): #generates probability data from a large text sample model = collections.defaultdict(lambda: 1) #default dict means that any novel word has been seen once for f ...
5466a3da4d9b0a1d5221f0381ec290f18b91e860
Al153/Programming
/CPU 10/Compilers/CLL/Compiler/CLL 1.0/code_generator.py
39,873
3.796875
4
import sys def process_snippets(filename): '''generates a list of snippets objects''' snippet_text = open(filename,"r").read() snippets_dict = parse_snippets(snippet_text) # print snippets_dict snippets_dict = {name:snippet(name,snippets_dict[name]) for name in snippets_dict} #print [name for name in snippets_dict...
ff2441f145b0e4b2d638bbb5ce0ce577fc6fb225
Al153/Programming
/CPU 10/Prototyping/Python test/heapsort.py
829
3.8125
4
def add_to_heap(heap,i): if heap[(i-1)>>1] < heap[i] and i != 0: heap[i],heap[(i-1)>>1] = heap[(i-1)>>1],heap[i] heap = add_to_heap(heap,(i-1)>>1) return heap def remove_top(heap,target): heap[0],heap[target] = heap[target],heap[0] heap = work_down(heap,0,target) return heap def work_down(heap,i,limit): if...
542a463f11a9999c2d04abe685c35c05d0b9b50e
Al153/Programming
/Python/Cryptography/vignere cracker.py
756
3.65625
4
def parallel_sort(labels,data): '''parallel_sort(labels,data)''' for return (newlabels,newdata) def gcd(a,b): if a>b: temp = a a = b b = temp while 1: if a == 0: return b break elif b == 0: return a break ...
5225bb2457b76d221e873cb2f30e7012a63d99e1
Al153/Programming
/Python/Misc/test area.py
153
3.75
4
mylist = [0,1,2,3,1,2,3] i = 0 while i < len(mylist): if mylist[i] == 1: mylist.append(2) i += 1 print mylist end = raw_input("press enter to close")
41b457e0fcb22235686ef2aef4e7f020215f84dd
Al153/Programming
/Python/Cryptography/Hill_climbing_algorithm.py
9,292
3.828125
4
import simple_substitution as cipher #put in here name of file for particular cipher, must have a "decrypt" function "decrypt(ciphertext,key" import cipher_text_analyser as analysis import random import cipher_tools key_length = cipher.Properties.key_length #cipher file needs a properties class instance with a val...
8c3631242f4b40d87240466aa67030343b6f9550
Al153/Programming
/Python/Cryptography/Minecraft RNG.py
750
3.578125
4
class Register: def __init__(self,value): self.value = value def read(self): return self.value def write(self,value): self.value = value class Bus: def __init__(self): self.data = 0 class ALU: def __init__(self): self.Accumulator = Register(0) self.inputBus = Bus() self.regBus = RNG.readBus self...
7e775be9e72e68e510bc4277faba3949960c17e6
Al153/Programming
/Python/CPU project/CPU 8/combined sign/assembler.py
644
3.5
4
import assemblerTools def assemble(): file_object,file_name = assemblerTools.extract_program_prompt() assemblerTools.assemble_program(file_object,file_name) def pretokenize(): file_object,file_name = assemblerTools.extract_program_prompt() assemblerTools.pretokenize(file_object,file_name) def User_prompt(): error...
a83778f4838372834918b5b9db07510f57c276c6
Al153/Programming
/Python/Misc/Connect n/Connect_4_game.py
1,511
3.65625
4
import os import connect_n #A really really really general connect 4 style game. #customisable: # No. of players # player pieces # grid size # length to win class Game: def __init__(self,player_lookup,size,length_to_win): self.player_lookup = player_lookup #in form {0:"x"} self.reverse_player_lookup = {...
740631bca67fe530a0df514a5586801ff6330c96
pedrillogdl/hello-world
/Lab7.0/profit.py
1,833
4.1875
4
print("Program for calculating the total profit on the sales of a product\r\n") count = 1 products = {} propertiesproduct = {} answer = "yes" while answer != "no": if count < 1: print(f"We are going to start with product {count}\r\n") else: print(f"Now, please enter the values for product {cou...
884e82dd163238bf1d57e784a2a408ea26e21141
pedrillogdl/hello-world
/Lab6.1/findNumber.py
1,795
4.125
4
import random def guessNumberOp(customNumber): if customNumber < surpriseNumber: message = "The Number is too low" if customNumber > surpriseNumber: message = "The Number is too High" if customNumber == surpriseNumber: message = "The Number is exactly right!" return message p...
d73b637339368142c94baa6e61b5bf48b0d06dd9
yasminewalidi98/Python_Programming_Challenges
/Basics/basic003.py
227
4.28125
4
# Basic 003 # Write a Python program to display the current date and time. # Sample Output : # Current date and time : # 2014-07-05 14:34:14 from datetime import datetime print(datetime.today().strftime('%Y-%m-%d %H:%M:%S'))
e0f7f4ac056917c7c7d667b3d164c4b67f8896e7
andreww/cmb_summer_project
/tools/geographical.py
8,159
4.34375
4
#!/usr/bin/env python # # Key primitives for cartesian to geographical # coordinate transforms # # Copyright (C) Andrew Walker, 2010, 2011 # <andrew.walker@bristol.ac.uk> import math as m def geog2cart(r, lat, lon): """Converts from geograpical to cartesian coordinates. Input lat and...
c8c12a5740cc298cdc1928aef39ee700e0519d0b
okoibraun/pyscripts
/binflip.py
718
4.09375
4
#!/usr/bin/python # Binary Flip # Author: Ben0xA # Description: Flips a binary file from it's last byte to it's first. import sys def main(): #get the file to flip and file to save as fin = sys.argv[1] fout = sys.argv[2] #read in the file as binary b = bytearray(open(fin, "rb").read()) #clone the ...
247de67099260f9ec6c605d34cb2094be6274521
Rudra705/oop_in_python
/function.py
298
4.28125
4
def count(): file_name = input("Enter the file name\n") file = open(file_name,'r') num_of_words = 0 for line in file: words = line.split() num_of_words = num_of_words + len(words) print("Number of words : ") print(num_of_words) count()
13e4484f241281668f0b4a8c59d01ddfccd5e714
hwfan/DriveDownloader
/DriveDownloader/pydrive2/fs/utils.py
1,640
3.6875
4
# Credit: https://github.com/iterative/PyDrive2 import io class IterStream(io.RawIOBase): """Wraps an iterator yielding bytes as a file object""" def __init__(self, iterator): # pylint: disable=super-init-not-called self.iterator = iterator self.leftover = b"" def readable(self): ...
d8d9ba066b6c196116d03696b902ca1b24a31ab5
Adheethaov/InfyTQ-Python
/_01_ProductOfIntegers.py
1,193
4.40625
4
'''Problem Statement: Write a python program to find and display the product of three positive integer values based on the rule mentioned below: It should display the product of the three values except when one of the integer value is 7. In that case, 7 should not be included in the product and the values to its left...
bf8f7706bb6d0425e978be433b93e6e1c6f5677a
Factotum8/connect4
/connect/connect.py
6,270
3.796875
4
#!/usr/bin/env python3 # coding=utf-8 """ The main executable file """ class Cell: """ The size one cell on the field """ width = 4 height = 1 def __init__(self, width=4, height=1): self.width = width self.height = height class Game: """ Main class """ sequen...
66a4ffa6b3c8387ce19a9f11b954866dc6e1581e
SibiSagar/codekata
/problem6.py
126
3.9375
4
# leap year or not year=input() year=int(year) if year%4==0 or year%400==0: print("yes") else: print("no")
a0e8df008ac22427c320a0d16af5e7fbc11a5637
SibiSagar/codekata
/problem17.py
426
4.0625
4
'''Simi is learning about palindromic numbers. Her teacher gave him the task to count all palindromic numbers present in that range. Simi has told you about this and want your help. You design an algorithm in order to help simi.''' n=input() n=int(n) count=0 def palin(i): i=str(i) if i==i[::-1]: return...
3096ccc1b2bbf9a19d065f157ee2cb11baa66a5f
SibiSagar/codekata
/problem11.py
99
3.671875
4
#power of number N with given exponent(k) n,k=input().split() n=int(n) k=int(k) print(n**k)
7f1921a614df71ed20cd1d2560f7a3c5b5a34378
q--/electricitymap-contrib
/validators/lib/config.py
1,374
3.8125
4
from typing import Callable, List def validator( kind: str, zone_keys: List[str] = None, not_zone_keys: List[str] = None ) -> Callable: """ Decorator function to mark a function as a validator. The backend will run all functions marked as validators. A validator function is expected to return as ...
247fd81446a5294a46edc2fbd3cb76bad4effeb9
alexscar99/python_interpreter
/interpreter/interpreter.py
1,446
3.75
4
class Interpreter: def __init__(self): self.stack = [] self.environment = {} def STORE_NAME(self, name): val = self.stack.pop() self.environment[name] = val def LOAD_NAME(self, name): val = self.environment[name] self.stack.append(val) def LOAD_VALUE(s...
360db6ab243c3af8fec6d32582cab1187bacb57e
QU35T5/pronu
/1.9.3.py
663
3.65625
4
# Kapitel 1: Grundläggande Python # Delkapitel 1.9 Funktioner del 1 # Uppgift 1.9.3 def primtal(n): # Först kollar vi om värdet av n är mindre än 2, ett primtal är inte 0 och 1. if (n<2): return False # Är talet större än eller = 2 kör loop for i in range(2,n): # Om talet ger rest som är ==...
5191fb2eb2402294bb948bf37772bf59bf31e991
zhuny/Codejam
/solution/L/LD/EmacsPP/__main__.py
3,866
3.5625
4
from dataclasses import dataclass, field from typing import List def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [ int(i) for i in input().split() ] @dataclass class Interval: start: int = 0 end: int = 0 parent: 'Interv...
2c631ae4ffbf3da77f4d7765fd0b553809be7a67
zhuny/Codejam
/solution/E/EE/Hex/__main__.py
4,690
3.734375
4
import collections from typing import Dict, Any class SolutionBase: # internal code for @staticmethod def read_int(): return int(input()) @staticmethod def read_ints(): return [int(i) for i in input().split()] @staticmethod def read_line(): return input().strip() ...
92584ca430015c586d39d8c47e2d70a6c38a4bc2
zhuny/Codejam
/solution/P/PR/RobotProgrammingStrategy/__main__.py
1,378
3.671875
4
def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [int(i) for i in input().split()] def get_pos(seq, pos): return seq[pos % len(seq)] def get_pos_all(seqs, pos): return [get_pos(seq, pos) for seq in seqs] def get_better2(possible): if "R" ...
2cc0c425af39e2e30fdb57a6bec253edd8150a14
zhuny/Codejam
/solution/N/NM/BitParty/__main__.py
1,484
3.765625
4
import collections from typing import List def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [ int(i) for i in input().split() ] Robot = collections.namedtuple("Robot", "robot bit cashier") Cashier = collections.namedtuple("Cashier",...
e0624ff7293515c9d728a51616f3266d342d0993
zhuny/Codejam
/solution/U/US/Workout/__main__.py
990
3.671875
4
def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [ int(i) for i in input().split() ] def diff_far(start, end): return ( end is None or end - start > 1 ) def get_middle(start, end): if end is None: ...
a9b7418570fea10cb377f325e04a3f79fcbd8824
zhuny/Codejam
/solution/R/RM/YouCanGoYourOwnWay/__main__.py
535
3.578125
4
def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [ int(i) for i in input().split() ] def do_one_step(): N = get_int() path = get_line() if len(path) != (N-1)*2: return "" my_path = [ 'S' if p == 'E' el...
bf1eb031798bd495e313b795d819588fa7b924c5
zhuny/Codejam
/solution/A/AQ/Transmutation/__main__.py
1,490
3.515625
4
import collections import itertools from typing import List def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [ int(i) for i in input().split() ] def get_shortage(remains): for i, v in enumerate(remains): if v < 0: ...
1cc9fc10fbf840b3a71a693d000bf3361272daa5
zhuny/Codejam
/solution/J/JU/Subtransmutation/__main__.py
1,456
3.59375
4
import collections def get_int(): return int(input()) def get_line(): return input().strip() def get_ints(): return [ int(i) for i in input().split() ] def is_valid(a, b, needed, start): made_from = collections.defaultdict(int, {start: 1}) needed_dict = collections.defaul...
c06c0edb02f59cfa056e35cc214a4365b564e73c
MaisenRv/EjerciciosCiclo1
/eje1.py
134
3.65625
4
# Autor: Santiago Mancera # Fecha: 25/05/2021 x = 2 y = 3 print("el valor de las variables es",x + y) input("oprima Enter para continuar....")
e6f02cb638061bccbb62e55ebc6992a474f9a4aa
MaisenRv/EjerciciosCiclo1
/eje65.py
504
3.59375
4
cedula = input("Cedula: ") f = open("salida.txt","r") encontro = False data = [] #Borra un registro de el archivo plano for linea in f: lista = linea[:-1].split("\t") #l = f.readlines() #lee todas las linesas y me devuelve una lista if lista[0] != cedula: data.append(linea) else: ...
e6ce6c89424803016018d8b6a06cfbbe1a1529ec
MaisenRv/EjerciciosCiclo1
/eje8.py
635
4.1875
4
tipoEstudiante = input("Tipo estuddiante (A:Alto, M:Medio, B:Bajo): ") nota = float (input("Escriba nota: ")) if tipoEstudiante == "A" and nota == 5: print ("gana una beca") elif tipoEstudiante == "A" and nota < 5 and nota >= 3: print ("Gana media beca") elif tipoEstudiante == "M" and nota == 5: print("Ga...
60b4b82862fef1da1707206cd48ecfe95af3d5c0
MaisenRv/EjerciciosCiclo1
/eje26_in_en_el_if.py
269
3.671875
4
from os import system system("cls") #la cadena queda en minuscula cadena = input("cadena: ").lower() contador = 0 #cuenta las bocales for x in cadena: #si x esta dentro del conjunto de letras if x in "aeiou":# <---- in contador += 1 print(contador)
487148ec8db443b307ba959ce28e648e2145ac67
MaisenRv/EjerciciosCiclo1
/eje64.py
333
3.6875
4
cedula = input("Cedula: ") f = open("salida.txt","r") encontro = False for linea in f: lista = linea[:-1].split("\t") if lista[0] == cedula: encontro = True print("Nombre: " +lista[1]) print("Correo: " + lista[2]) break if not encontro: print("No esta registrada la cedula"...
ef009c04090e9cf4907712b4243cb8f367870b38
MaisenRv/EjerciciosCiclo1
/eje51.py
240
3.953125
4
d = {"C001":"Juan","C002":"crema dental"} codigo = input("Codigo: ") if codigo in d: print("ese codigo ya existe") exit() producto = input("Producto: ") #Inserta un nuevo elemento y una nueva llave d[codigo] = producto print(d)
5ce018b66022cd5e3cda1d22f026391821574d39
MaisenRv/EjerciciosCiclo1
/eje49_metodos_diccionarios.py
1,163
3.9375
4
productos = {"c001":"Atun","c002":"Maiz","c003":"Aguacate","c004":"Aceite"} print(len(productos)) #borra el diccionario (elementos) #--->print(productos.clear()) #hace una copia del productos x = productos.copy() #pasar una lista de tuplas a un diccionaario l = [(10,"juan"),(20,"luisa"),(30,"raul")] dict(l) #b...
821d185ea6d591566627f13c7f4db0b700d50ff8
MaisenRv/EjerciciosCiclo1
/eje6_cilindro.py
518
4.25
4
#Clcula el area y el volumen de un cilindro. # Autor: Santiago Mancera # Fecha: 25/05/2021 from math import pi h = float (input ("Introdusca la altura del cilindro: ")) r = float (input ("Introdusca el radio del cilindro: ")) #formula para calcular el area del cilindro. area = 2 * pi * r *(h + r) #formula para calc...
f1fffca0f5ba91515d9008501be1532f3ad45e1a
MaisenRv/EjerciciosCiclo1
/eje37_metodos_tuplas.py
1,143
4.375
4
#las tuplas no se pueden modificar # se crean para elementos que novarian en el tiempo #tuplas son mas rapidas en ejecucion que las listas tupla = ("cali", "bogota", "cucuta") notas = (12,3,14,54,23,54,3,1,1) #devuelve la posicion del elemento print(tupla.index("bogota")) #cuentas los elementos iguales print(tupl...
bb85451212285548a0476764418bae6789aded76
MaisenRv/EjerciciosCiclo1
/eje33_pi.py
136
3.625
4
#calcula el numero pi. n = int(input("terminos: ")) suma = 0 for i in range (1, n+1 ): suma += -(-1)**i / (2*i - 1) print(4 * suma)
23d0698ad8b7305d697154ad34d954ed99e96401
samuelguegon89/Boletin_1
/ejer3.py
202
3.515625
4
usuario1=str(raw_input("Introduzca usuario: ")) contr=int(raw_input("Introduzca password: ")) if usuario1 == "pepe" and contr == 1234: print "\n" "EL USUARIO Y LA PASSWORD SON CORRECTA" else: exit()
45b2639b58c47125be37d7fb5cafa9ddba7a1d3c
SystemicCypher/Useful-Code
/Algorithms/Minimax_AlphaBetaPruning.py
1,440
3.65625
4
#Enumerates all nodes and picks the best valued one def minimax(node, depth, maximizing_y_or_n): if(depth == 0 or node.terminal_node()): return heuristic() if(myPlayer): bestValue = -infinity for move in possibleMoves: value = minimax(move_node, depth-1, False) b...
a676354830f11f71cbaeb47abc050cdfada6538b
gallettilance2/CS506-Spring2020
/01-python/infrastructure/road.py
519
4.09375
4
def draw_road(length=10, axis="horizontal"): VALID = ["horizontal", "vertical"] if axis not in VALID: # raise error raise ValueError("your axis is undefined") if length <0: raise ValueError("your length is undefined") if axis=="horizontal": return draw_road_horizontal(le...
492050ef4dacf672e5142605dea214e2c3863af6
lisy14liz/BaseCode
/leetcode/297_serialize-and-deserialize-binary-tree.py
2,050
3.578125
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None from collections import deque class Codec: def serialize(self, root): """Encodes a tree to a single string. :type root...
2718138b675aa6d438641572f1cc41d01fafaf3f
lisy14liz/BaseCode
/trie.py
2,361
3.921875
4
from collections import defaultdict class TrieNode: def __init__(self): self.childs = defaultdict(TrieNode) self.isEnd = False class Trie: def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def insert(self, word: str)...
108eb335ce0e3ee6bc9be8e849acacf79c4ca80e
ctneal91/python_practice
/loop.py
131
3.53125
4
def main(): data="this is where I want to break" for char in data: if char=='b': break print(char) main()
f71f3649a3589feb7e958d74dc70f78cc63496e0
samerd/seng560-assignment02
/src/pycalc/calculator.py
3,714
3.515625
4
''' Created on Nov 7, 2019 @author: samerd ''' import re import pycalc from pycalc.menu import MenuItemHandler class Calculator(MenuItemHandler): """ Calculator menu handler. handles 'Calculate' user menu @cvar BINARY_OP_REGEX: regular expression for catching binary operations @cvar UNARY_OP_RE...
03c6982305545dd5ba200a7437210e0bf12143b0
AsisRai/210CT---Programming-Algorithms-and-Data-Structures
/Week-3/Week 3, Q3 (Remove Vowels).py
994
3.515625
4
""" recursive function (pseudocode and code) that removes all vowels from a given string""" #pseudocode """ GLOBAL A ←(input) //input word to remove vowels REMOVEVOWELS(B) if length(B)=0 return B else C ← B[1:length(B)+1] D ← B[0] if D in "a,e,i,o,u,A,E,I,O,U" ...
efac62771c325c43fe5df676297911fc720c83de
AsisRai/210CT---Programming-Algorithms-and-Data-Structures
/Week-5/Week 5, Q1 (Sub-Sequence of maximum length).py
1,534
4.0625
4
""" Given a sequence of n integer numbers, extract the sub-sequence of maximum length which is in ascending order. Example input: L = [1,2,3,4,1,5,1,6,7] Output: [1,2,3,4] """ import sys sequence = [1,2,3,4,1,5,1,6,7] newsequence = [1] #initial temporary output def SUBEXTRACTOR(sequence, newsequence): #Th...
372c954ba5c39164f594b4e934fba08a4ce0a401
rohankumar10/CISCO-TEST-
/Exercise 1/draw_shape.py
906
4.1875
4
import turtle # Initalize the turtle library so we can use it safely turtle1 = turtle.Turtle() turtle1.up() turtle1.goto(-50, 0) turtle1.down() def draw_square(): # Since we need the square to at an angle 90 turtle1.left(50) # FOR LOOP to make 4 sides of square for _ in range(4): turtle1.f...
1ee5339efbbaea6140057642243ce9d7b6acfe50
serjikisa/algorithms
/maxheap.py
2,209
3.828125
4
''' heappush, heappop, heapsort, heapify implementation pos of element starts from one, to easily calculate, root, left child and right child elements To access array element, just (pos - 1) will be used ''' def heappush(heap, item): heap.append(item) _siftup(heap, len(heap)) def _siftup(heap, pos): # pos...
244a001ef0473af830747db978d55e2853b1710e
ShivaniBhalerao/Twitter-Bot-Python
/Python Seminar/ten.py
1,007
4.03125
4
# map and filter function # filter # takes in function and list as arguments and returns list of items for which the function evaluates to true #retireve odd nos list1 = [1,2,3,4,5,6,7,8,9] #normal filter def odd(num): return num%2!=0 list2 = list(filter(odd,list1)) print(list2) #filter using lambd...
d68365d33fcd7827a54d2d2fc0d47bafe0986922
victormmp/graph_em
/graph_em/graph/base.py
3,256
3.953125
4
import click import numpy as np from typing import List, Tuple, Any class SimpleUndirectedGraph: """ A simple undirected graph class for easy instantiation and implementation of graphs. Attributes __________ _points: numpy.ndarray The nodes location of the graph. _distances: numpy.nda...
923df697f5c420f009fa41bfc6b5922939f66c9a
carneirosarah/MLP_CreditCardFraud
/main.py
4,081
3.640625
4
''' Projeto 2 - Sistemas Inteligentes MLP - Predict credit card frauds Sarah R. L. Carneiro ''' import pandas as pd from sklearn import preprocessing from sklearn.neural_network import MLPClassifier from sklearn.metrics import classification_report, confusion_matrix from confusion_matrix_pretty_print import plot_confu...
5253b1eab01fa8319ea51b4ad3037676274dc0c6
robeertgr/Python_study
/Functions.py
1,838
4.03125
4
# Funções recebem alguma entrada e em seguida produzem alguma saída ou alteração # É um pedaço de código que você pode reutilizar # Você pode implementar sua própria função, mas em muitos casos você usa as funções de outras pessoas # Função Len - Retorna o tamanho de uma lista, set ou tupla. album_ratings = [10.0, 8....
68bec1f7021d104358ebff1b5c962d9744bb3ffa
robeertgr/Python_study
/Loading_Data_With_Pandas.py
2,298
3.5625
4
""" importa a biblioteca pandas > import pandas as anyname guarda o valor de file1.csv na variável > csv_path = 'file1.csv' o método head() exibe as 5 primeiras linhas do arquivo > df.head() df = pd.DataFrame({'a': [11, 21, 31], 'b': [21, 22, 23]}) print(df.head(3)) xlsx_path = 'file1.xlsx' df = pd.read_excel(xlsx_pa...
7bb7b6ed6dc11bba1d4456e9bf26e25373b72197
joaquinlpereyra/uno
/exceptions.py
1,117
3.90625
4
"""Some exceptions used on the game. """ class WrongUserInput(Exception): def __init__(self, reason): self.reason = reason def __str__(self): return ("Program failed because the input was wrong. The suspected reason is " "{0}".format(self.reason)) class DeckError(Exception): ...
2544d74796bf704a934f637ee5e59ef15282b0ae
NRDRNR/Lesson2
/learn-homework-1/for.py
1,375
3.84375
4
""" Домашнее задание №1 Цикл for: Оценки * Создать список из словарей с оценками учеников разных классов школы вида [{'school_class': '4a', 'scores': [3,4,4,5,2]}, ...] * Посчитать и вывести средний балл по всей школе. * Посчитать и вывести средний балл по каждому классу. """ def main(): data_storage = [{'sc...
fffdeef7b9c4e5eb9f37182bc21e109556b8a909
soundarya784/5th-sem
/ADS/Open ended questions/open_ended1.py
229
3.890625
4
def biggest_nos(a): a.sort() for i in range(len(a) - 2): print(a[i]) n = int(input("enter length of the array")) a = [] for i in range(n): a.append(int(input("enter array values:"))) biggest_nos(a)
6e81eece82af5b57ca8be2b1e21e3cef0879fbe7
ModelEngineering/advancing-biomedical-models
/archived_lectures/Fall_2019/common_python/common_python/types/extended_list.py
876
3.875
4
'''Extends list.''' class ExtendedList(list): def removeAll(self, element): while self.count(element) > 0: self.remove(element) def unique(self): """ Returns a list of unique elements. Does not preserve order. """ new_list = ExtendedList(list(set(self))) [self.pop() for _ in ran...
e9278df4c06410a28dfe42cb3f83084b000e47f8
ModelEngineering/advancing-biomedical-models
/archived_lectures/Fall_2019/common_python/common_python/util/persister.py
824
3.890625
4
'''Persists an object as a Pickle file.''' import pickle import os class Persister(object): """ A light wrapper around pickle to persist an object. """ def __init__(self, path): """ :param str path: path for the pickle file persistence. """ self._path = path def __repr__(self): return...
14032ea1546855888ac6ad359ecf7e7d46fa6223
jtschidaTechtonic/daily-code-challenges
/May/17-monday/kebabize.py
219
3.75
4
import re def kebabize(string): no_ints = ''.join(char for char in string if char.isalpha()) lower_words = [word.lower() for word in re.split("([A-Z][^A-Z]*)", no_ints) if word] return '-'.join(lower_words)
e23c46d2e88aac6ad6e15be0d7168d091674a807
Larionov0/Denis_Lessons
/Stage1/Lesson2/while/3/lists/1.py
121
3.5625
4
numbers = [8, 6, 4, 7, 3, 4, 6, 2] i = 0 while i < len(numbers): print(str(i) + ' - ' + str(numbers[i])) i += 1
00ed235ebe2dd1a35b8a21b7d0984f25261bd1dd
Larionov0/Denis_Lessons
/Stage1/Lesson2/if_elif_else/1.py
150
3.84375
4
a = int(input()) if a > 10: print(':)') print('Число большое') else: print('Число маленькое') print('The end')
5689e05a9414879864c5a0cf6c370b0dca052803
rosalia200/python-basic
/task5.py
485
3.734375
4
def divide_into_2(d): part1=(d[0:int((len(d)) /2)]) part2=(d[int((len(d) )/2):]) return str(part1) + "\n" + str(part2) a=(1,2,3,4,5,6,7,8,9,10) #part1=divide_into_2(a) print(divide_into_2(a)) #print("\n") #wendy"s tpl1,tpl2 = [], [] s= tpl2.append() for i in range (0,5): tpl1.append(a[i]) for i in r...
ada88a95b41edcdd883e487a1175d847ee8173b9
ejm2024/comp110-21f-workspace
/exercises/ex03/tar_heels.py
295
3.75
4
"""An exercise in remainders and boolean logic.""" __author__ = "730329515" # Begin your solution here... a = int(input(" Enter an int ")) if (a % 2) == 0 and (a % 7) == 0: print("TAR HEELS") elif (a % 7) == 0: print("HEELS") elif (a % 2) == 0: print("TAR") else: print("CAROLINA")
fd6e6edefea142bfeae9763b24e492ac67821eda
ejm2024/comp110-21f-workspace
/projects/cyoa.py
1,859
4
4
"""Import Random Int.""" from random import randint """Guess a random number. """ __author__: str = "730329515" points: int = 0 player: str = "" NAMED_CONSTANT: str = "\U0001F920" correct_number = (randint(1, 100)) def main() -> None: """Main Function.""" greet() playing = True version: str whi...
540e9d7560ed91f17de24d07fed6dd5d073df323
dhrumilp15/cs50
/pset6/credit/credit.py
1,218
3.765625
4
from cs50 import get_int def main(): card_int = get_int("Card number: ") while not (card_int > 0): card_int = get_int("Card number: ") card = str(card_int) if len(card) < 13 or len(card) > 16 or len(card) == 14: print("INVALID") return checksum = 0 fo...
9c87c6f39df2b5d3d9169e0ea4db601365feea5b
arminale/ProjectEuler
/96_Suduko/p96.py
2,522
3.734375
4
# https://projecteuler.net/problem=96 Sudoku # This program solves Sudoku puzzles using a brute force algorithm. # A Sudoku grid is represented in a 1D list where board[0] is the top left element in the board, and the element in the # i-th row and the j-th column of the board is stored in board[(i-1)*9 + (j-1)]. Note t...