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
dec7d56b4aacbaab3ef75d25b55657db2ac0d936
yodigi7/kattis
/encodedMessage.py
731
3.828125
4
import math # TODO: Make it rotate the correct way so we don't have to rotate it three times def rot90(array: list) -> list: return list(zip(*array[::-1])) def solve_problem(): encoded_message = input() square_size = int(math.sqrt(len(encoded_message))) encoded_square_message = [] for i in range...
76896ff501fc9d4e027af78d2784b575aa0e6ec1
yodigi7/kattis
/kitten.py
631
3.625
4
def get_branches(): ret_dict = {} inp_list = input().split() while not inp_list[0] == "-1": to_branch = int(inp_list[0]) from_branches = inp_list[1:] for branch in from_branches: ret_dict[int(branch)] = to_branch inp_list = input().split() return ret_dict if...
2f8ad304092af59ebedc4124b4c81af19a47863d
yodigi7/kattis
/JohnnyApplesack.py
300
3.765625
4
from math import ceil def advOneKilo(numApples, sackSize): return numApples - ceil(float(numApples)/sackSize) numbers = input().split() apples = int(numbers[0]) sackSize = int(numbers[1]) mile = 0 while apples > 0: apples = advOneKilo(apples, sackSize) mile += 1 mile += 1 print(mile)
8749084205b9d9a0de0fc80974f4087f81faeff4
yodigi7/kattis
/securedoors.py
1,209
3.90625
4
def convert_action(action): if "entry" in action: return "entered" return "exited" def is_anomaly(inside, outside, person, action): if "entry" in action: if person in inside: return True else: if person not in inside: return True return False def ...
b0db5ed72b0b63835a095a2c297679109b51d2dc
yodigi7/kattis
/JuryJeopardy.py
3,128
3.640625
4
def outputMaze(maze): for i in maze: holder = '' for j in i: holder += j print(holder) holder = '' def addBot(array): width, height = getWidthHeight(array) row = [] answer = [] answer.append(row) for i in array: answer.append(i) for i in r...
5d1c9d554cc276071e838ffdbbea88c076b5f126
yodigi7/kattis
/ferryloading3.py
2,147
3.828125
4
from queue import Queue class CarData: def __init__(self, arrival_time, arrival_side): self.arrival_time = arrival_time self.arrival_side = arrival_side def __str__(self): return f'Arrival time: {self.arrival_time}, arrival_side: {self.arrival_side}' def __repr__(self): r...
d3027da42c657c6df5bce65badfbf3ce59ddfec4
yodigi7/kattis
/beavergnaw.py
511
3.59375
4
import math def findDiam(vol): return ((vol/math.pi)**(1/3))*2 def cylVol(diam): return (((diam/2)**3)*math.pi) ##info = input().split() ##info = [float(x) for x in info] ##while not (info[0] == float(0) and info[1] == float(0)): ## print(findDiam(cylVol(info[0])-info[1])) ## info = input().split() ## ...
e5ac4d172711219f23fa9fff2c3cba0833a1f7f9
yodigi7/kattis
/4thought.py
1,639
3.5625
4
from itertools import combinations_with_replacement from operator import add, mul, sub, floordiv text_mapping = { 0: "+", 1: "-", 2: "*", 3: "/", } mapping = { 0: add, 1: sub, 2: mul, 3: floordiv, } def partial_solve(nums, fns, mult_or_div=True): if mult_or_div: while mul ...
412ef48c1caf857d3c0403b006065fcb35d7c3d8
yodigi7/kattis
/zoo.py
390
3.5625
4
numAni = int(input()) counter = 0 while numAni: counter += 1 print("List {}:".format(counter)) animals = {} for i in range(numAni): aniName = input().split() aniName = aniName[len(aniName)-1].lower() if aniName in animals.keys(): animals[aniName] += 1 else: animals[aniName] = 1 for k, v in sorted(ani...
4991ecf29ba080b62dd88a5de2c8a0fcabf2f318
yodigi7/kattis
/A+B problem.py
391
3.609375
4
numbers = input() numbers = input().split() numbers = [int(x) for x in numbers] counter = 0 numbersLen = len(numbers) for i in range(0, numbersLen): for j in range(0, numbersLen): for k in range(0, numbersLen): if i == j or j == k or i == k: pass elif numbers[i] +...
dfc7ab54e5baf0dfcee1a3f48a2743dc3020dea2
yodigi7/kattis
/recount.py
349
3.5625
4
from collections import Counter if __name__ == "__main__": counter = Counter() votes = [] while True: name = input() if name == "***": break votes.append(name) first, second = Counter(votes).most_common(2) if first[1] == second[1]: print("Runoff!") e...
3617252a007ced30d36002adfbe5812950f50fa5
yodigi7/kattis
/3dPrintedStatues.py
116
3.640625
4
toPrint = int(input()) printers = 1 day = 1 while not printers >= toPrint: printers *= 2 day += 1 print(day)
4d0592b77d6b9a1d0d6dd520f4dfcebd59611883
bsdharshini/Python-exercise
/bubble sort.py
214
3.71875
4
#using for loop def sort(n): for i in range(len(n)-1,0,-1): for j in range(i): if n[j]>n[j+1]: n[j],n[j+1]=n[j+1],n[j] num=[5,1,2,10,4] sort(num) print(num)
7c2857757fa116cf6785619dc2e8d377b0682de4
bsdharshini/Python-exercise
/6)list.py
4,769
4.0625
4
#Take 10 integer inputs from user and store them in a list and print them on screen. """ l=[] for i in range(10): s=int(input()) l.append(s) print(l) """ #Take 10 integer inputs from user and store them in a list. #Again ask user to give a number. #Now, tell user whether that number is present in ...
33a7477b0c51e7f8a4750b3ba62a8902b52f9313
bsdharshini/Python-exercise
/5) While.py
1,837
4.125
4
''' Take 10 integers from keyboard using loop and print their average value on the screen. sum=0 for i in range(0,10): n=int(input()) sum=sum+n print(sum) ''' ''' Print the following patterns using loop : a. * ** *** **** n i star 4 0 1 4 1 2 n=int(input()) for i in range(0,n): ...
2abdecd0c2820f8db9ae2efc4252f9815c80d18d
bsdharshini/Python-exercise
/1)printprintprint.py
1,189
4.375
4
#https://www.codesdope.com/practice/python-printprintprint/ #1)Print anything you want on the screen. print("hello") # 2) Store three integers in x, y and z. Print their sum x=10 y=20 z=30 sum=x+y+z print(sum) #3) Store three integers in x, y and z. Print their product. x,y,z=10,20,30 print(x*y*z) #...
d2cca2eb2df16526b300815938ce34c247cb19dd
michelr/advent-of-code-2020-python
/2/day2.py
982
3.5
4
def create_item(row): items = row.split(" ") pwd_pattern = items[0].split("-") return { "first": int(pwd_pattern[0]), "second": int(pwd_pattern[1]), "character": items[1].replace(":", ""), "password": items[2], } def in_range(min, max, character, password): no_of_ti...
a5f983092af6561c534bc99ce7244cac9e801268
Snowmaniac80/pcc_aliens
/comet.py
1,158
3.546875
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 1 12:30:18 2016 @author: pilgrim """ import pygame import random from pygame.sprite import Sprite class Comet(Sprite): def __init__(self, params, screen): '''init comet and starting position''' super().__init__() self.screen = screen ...
8afad7a986c6e347a306104db92c567ae754ccee
paulorec/income-predictor
/main.py
8,341
3.828125
4
# -*- coding: utf-8 -*- # Importe as bibliotecas necessárias para o projeto. import numpy as np import pandas as pd from time import time from IPython.display import display # Permite a utilização da função display() para DataFrames. from sklearn.preprocessing import MinMaxScaler from sklearn.cross_validation import tr...
3bc8f36532050d2f38b6d066ccf64eab0642a174
stephnec/ExerciciosLista01-Python
/Ex10.py
891
3.953125
4
a = int(input("Digite quantos votos recebeu o candidato A: ")) b = int(input("Digite quantos votos recebeu o candidato B: ")) c = int(input("Digite quantos votos recebeu o canditdato C: ")) branco = int(input("Digite quantos votos foram em branco: ")) nulo = int(input("Digite quantos votos foram nulos: ")) total = a +...
c981521386abc3e50a3c80c8cf97f9684ed89082
eliasepe/cse210-student-hilo
/hilo/player.py
1,226
3.734375
4
import random class Player: present_card = 0 future_card = 0 total_points = [300] def __init__(self): pass def draw(self): self.present_card = random.randint(1, 13) self.future_card = random.randint(1, 13) def guess(self): print(f"The card is {self.pres...
bf794f5e450f517f9aa56012b18298c471d68999
Kapiszko/Learn-Python
/ex11.py
426
4.15625
4
print("How old are you?", end=' ') age = int(input("Please give your age ")) print("How tall are you?", end=' ') height = int(input("Please give your height ")) print("How much do you weigh?", end=' ') weight = int(input("Please give your weight ")) print (f"So, you're {age} old, {height} tall and {weight} heavy.") s...
17bdf51995dce316b441187b102a98746ce99a73
Kapiszko/Learn-Python
/ex21.5.py
398
3.921875
4
def add(a, b): print(f"ADDING {a} + {b}") return a + b def subtract (a, b): print(f"SUBTRACTING {a} - {b}") return a - b def multiply (a, b): print(f"MULTIPLYING {a} * {b}") return a * b def divide (a, b): print(f"DIVIDING {a} / {b}") return a / b question = 21 + 33 * 14 / 16 print(q...
29122bf9362a8e25f45910cacb0815aa4a556f37
AnastasiaSusciuc/ConsoleSnakeGame
/src/service/service.py
6,869
3.75
4
import random import copy class Service: def __init__(self, board): self.__board = board def place_initial_snake(self): """ places the initial snake on the middle of the board :return: - """ middle = self.__board.dimension // 2 self.__board.set_cell_val...
97ab36cdd7292d71b9cf14bb180d342590d582b1
lyndsiWilliams/Intro-Python-II
/src/player.py
500
3.65625
4
# Write a class to hold player information, e.g. what room they are in # currently. class Player: def __init__(self, name, current_room, items=[]): self.name = name self.current_room = current_room self.items = items def introduce_character(self): print(f'You hear a distant voi...
43ede108414b9faed7f979408418ec0e253bed32
WayneGoodwin95/pong
/bat.py
1,803
3.6875
4
import pygame as pg class Bat(): """Bat class""" def __init__(self, game): # Initialise bat properties self.game = game self.height = self.game.DISPLAY_H / 70 self.width = self.game.DISPLAY_W / 15 self.color = self.game.bat_color self.moving_right = False ...
4a0a8d57837b68fdd96568b2ad9ac814c7384963
MustafaSarimesinli/GlobalAIHubPythonHomework
/Project.py
7,819
4.0625
4
import time import random print(""" ------------------------------------- Simple Student Management System ------------------------------------------ """) student_inf = ("Mustafa","Sarımeşinli") right_of_entry = 3 while True: input_name = input("Please enter your name: ").title() input_surname = input("Plea...
742d3e9ac1758c97141f0485009f158e88f1c81d
PolarizedIons/text-game
/Location.py
652
3.5625
4
class Location: def __init__(self, game): self.game = game self.name = '' self.navigation = {} self.stats = LocationStats() def handle_movement(self, command) -> bool: if command not in self.navigation: return False location = self.navigatio...
63af870ce993a6e62f37f78ef29e3793d74416c3
Tomfif/advent-of-code
/Day_1/solution.py
511
3.625
4
with open("./advent-of-code/Day_1/input.txt") as f: inputs = [ int(line) for line in f.read().splitlines() ] def two_entries(numbers): for i in numbers: for j in numbers: if i + j == 2020: return i * j def three_entries(numbers): for i in numbers...
86dbed8f6e9a1c498936ba30958d84a7f2c5a15e
mohi048/Python-Parallel-Programming
/code/2.1/defining_a_thread.py
308
3.671875
4
import threading def function(i): print("function call by thread %i\n" %i) threads = [] for i in range(5): t = threading.Thread(target=function, args=(i,)) threads.append(t) t.start() # thread calling the function t.join() # telling the thread to wait until threads finished execution
a6f925314d5a899d61f168020c33f35550b5eeb8
ruslan-rv-ua/python-essential
/docs/exceptions/examples/context_manager.py
505
3.796875
4
file = open('some_file.txt', 'w') try: file.write(...) finally: file.close() with open('some_file.txt', 'w') as file: file.write(...) # __enter__(self) # __exit__(self, exception_class, exception_obj, exception_traceback) import os class cd: def __init__(self, path): self.path = path def __enter__(self): ...
1aab76ae977a7b2c73a41b787ce3068512d0f921
ruslan-rv-ua/python-essential
/source/functional_programming/examples/lambda_ex.py
600
3.703125
4
def add(x, y): return x + y add = lambda x, y: x + y (lambda x, y: x + y)(5, 7) hello = lambda name, time='morning': 'Good ' + time + ', ' + name hello('Jane') hello('Jane', 'afternoon') func = lambda *args: args func(1, 2, 3, 4) mymin = lambda x, y: x if x < y else y mymin(1,3) --- authors = [ "Edgar Allan P...
62a0585bea3b9a97119dba5afeb0c6ad2729a7da
ruslan-rv-ua/python-essential
/source/functional_programming/examples/calc_ex.py
353
3.875
4
def add(a, b): return a + b def sub(a, b): return a - b def mul(a, b): return a * b def div(a, b): return a / b operators = { '+': add, '-': sub, '*': mul, '/': div, } n1 = float(input('Enter first operand: ')) op = input('Enter operator: ') n2 = float(input('Enter second operand: ')) res = operators[...
8a40c99753156bf6bc047fedcd3337fcf38452d9
ruslan-rv-ua/python-essential
/source/functions/example_strategy.py
212
3.8125
4
def double(obj): print(f'До: {obj}') obj = obj * 2 print(f'Після: {obj}') x = 1 x = [1] double(x) def append(obj): print(f'До: {obj}') obj.append(7) print(f'Після: {obj}') x = [1] append(x)
6ce6ee46df1f1a977c941126ec05b222e61e7d07
FabianTauriello/Problem-Solving-And-Programming-Textbook-Problems-Python-
/while structure.py
437
4.09375
4
import random number = random.randint (1,10) print ('Random number is: ', number) guess = int(input('please enter your guess: ')) print ('you guessed: ', guess) while number != guess: if guess < number: print ('Too low') elif guess > number: print ('Too high') guess = int...
f2b9ab6a402bfc38b784c2981ea4502378991e5d
Mark841/Portfolio-Work
/Python/Cat Food Dispenser/CONTROLLING MOTOR2.py
877
3.5
4
import RPi.GPIO as GPIO import time from time import sleep count = 0 while count != 25201: if count == 25200: GPIO.setmode(GPIO.BOARD) Motor1A = 16 Motor1B = 18 Motor1E = 22 GPIO.setup(Motor1A,GPIO.OUT) GPIO.setup(Motor1B,GPIO.OUT) GPIO.setup(Motor1E,GPIO....
e3f355d718a8540ae33d0c125b8f3ac5fa8b5775
Mark841/Portfolio-Work
/Python/School System/oop_validation.py
593
3.828125
4
import re def length_check(string, min_length): return len(string) < min_length def digit_check(string): digit_check = True for i in ['0','1','2','3','4','5','6','7','8','9']: if i in string: digit_check = False return digit_check def upper_lower_case(string): ...
fc41dcd6953857498946355e64e58b32429fcc45
YashMistry1406/Competitve_Coding-
/sde problems/Array/sort color.py
1,119
4.15625
4
# Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, # with the colors in the order red, white, and blue. # We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively. # You must solve this problem witho...
927d0f8068fc18569aeeab6dbba3b95d59534504
YashMistry1406/Competitve_Coding-
/march long challenge 2021/Interesting XOR.py
1,283
3.703125
4
def binary(n): #converting the list to a biary number result = 0 for digits in n: result = (result << 1) | digits return result for t in range (int(input())): c=int(input()) stack1=[] stack2=[] temp=list(map(int,bin(c).replace("0b",""))) #print(temp) for i in range...
1b1002a81a4321f915347aa70d8c98664027d4fa
YashMistry1406/Competitve_Coding-
/march long challenge 2021/test.py
181
3.859375
4
dict1 = {1: 1, 2: 9, 3: 4} sorted_dict = {} sorted_keys = sorted(dict1) # [1, 3, 2] print(sorted_dict) #for w in sorted_keys: # sorted_dict[w] = dict1[w] # #print(sorted_dict)
4a96f7c36e897f6af65eaa60077bd988d9b7e34b
serubirikenny/Shoppinlist2db
/shop.py
1,043
4.125
4
class ShoppingList(object): """class to represent a shopping list and CRUD methods""" def __init__(self, name): self.name = name self.items = {} def add_item(self, an_item): if an_item.name in self.items: self.items[an_item.name] += an_item.quantity else: ...
12682f41edb0a57e5774e5404b11b7a72c1698a8
aarushikool/CrypKool
/OTP.py
2,228
4.3125
4
from random import randint import matplotlib.pyplot as plt #string alphabet is declared here to convert ALPHABET into numerical values #ALPHABET[0] is a blank space ALPHABET = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' def encrypt(text, key): text= text.upper() cipher_text = '' for index, char in enumerate(text): ...
2d20cb1354a7d5c1463dbe7199dbcaa5f4bd665a
SnjLy/source_code_repo
/python/python_learn/python_tip_oj_25.py
486
3.546875
4
''' 格式化时间串 ''' t = {'year': '2013', 'month': '9', 'day': '30', 'hour': '16', 'minute': '45', 'second': '2'} print '%s-%s-%s %s:%s:%s' % ( t.get('year'), t.get('month'), t.get('day'), t.get('hour'), t.get('minute'), t.get('second')) print '%s-%s-%s %s:%s:%s' % (t['year'], t['month'], t['day'], t['hour'], t['minute'], t...
cc9caf4d73ee3d43b06d3698abc27888924ac923
garymorrissey/Programming-And-Scripting
/collatz.py
537
4.125
4
# Gary Morrissey, 11-02-2018 # The Collatz Conjecture program i = int(input("Please enter any integer:")) # Prompts you to choose a number, with the next term being obtained from the previous term while i > 1: if i % 2 == 0: i = i / 2 # If the previous term is even, the next term is one half the previo...
47da7c028509f8f036b1bfaa48b2dea328f492f1
tidarren/CDS-Final
/TravelerSalesmanProblem/Tabu_TSP.py
6,734
3.734375
4
import copy import argparse import sys import pickle import logging import utils import numpy as np from number_to_store_name import showStoreName from os.path import dirname, join def find_neighborhood(solution, dict_of_neighbours): """ Pure implementation of generating the neighborhood (sorted by total dist...
ea67dcf9cf653d14d14fb3554a6b408ef3fabad2
athoma16/Course-Explorer
/course.py
473
3.5
4
from typing import List class Course(object): """ Members are purposely left vague -- just a starting point. """ id: int = None code: str = None title: str = None description: str = None prerequisites: List[str] = [] credit: float = 0.0 semesters: List[str] = [] department: str = None equate: List[str] = ...
889a8999815b56c280ff3597004a4e812db8badf
isaacfelipe1/Estrutura_De_Dados_Um_UEA
/001/exercicio1.py
291
4.03125
4
#Ler uma lista de 5 números inteiros e mostre cada número juntamente com sua posição na lista. i=0 list=[] while i<5: valor=int(input("Informe o valor:" )) list.append(valor) i+=1 for i, word in enumerate(list): print('na posição',i,'foi digitado o número ',word)
a52d67cf9c4a94f1deeb70a3c0bc4f9483d7fe88
isaacfelipe1/Estrutura_De_Dados_Um_UEA
/001/exemplo.py
230
3.96875
4
list=[0,1,2,3] list[0]='janeiro' print(list) #por indice #for i in range(0,len(list)): #print(list[i]) #pelo for in #for i in list: #print(i) #pela função enumerate() #for i, p in enumerate(list): #print(i+1,'=>',p)
2a644c18c9c67dda6b3e60c24c709b68ff0acec3
Rizvix0/inet-dsme
/utils/active_scan_probability.py
2,685
3.578125
4
#!/usr/bin/env python3 import math import random import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit def p(n, d): '''Return the probability that the first active scan is performed on the n-th attempt. Arguments: n -- number of the current attempt ...
b357dab83a4337b76d7563405b6c42732d15ab4d
AmaanHUB/IntroPython
/python_tdd/test_simple_calc.py
1,193
3.71875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Tests for the simple calculator # import the class from simple_calc from simple_calc import SimpleCalc # import requiring testing frameworks import unittest import pytest # create a class to write tests input # unittest.TestCase works with the un...
28346a11a805fe9323eb66b1074ca028b747446c
AmaanHUB/IntroPython
/python_databases/Pyodbc-Task/pyodbc_task.py
4,370
3.625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 """ Task: - Create a new file and a class with function to establish connection with pyodbc - create a function that create a table in the DB - create a function that prompts user to input data in that table - create a new file called PYODBC_TASK.md and d...
2b2bdc77c6e116371e56d5df4bb7699bc2dff31a
AmaanHUB/IntroPython
/variables_types/python_variables.py
847
4.34375
4
# How can we create a variable? # variable_name = value # creating a variable called name to store user name name = "Amaan" # declaring a String variable # creating a variable called age to store user age age = 23 # Integer # creating a variable called hourly_wage to store user hourly_wage hourly_wage = 15 # Intege...
1fb6f8241700a14d8914c61ac982763829b0dbc7
AmaanHUB/IntroPython
/python_fizzbuzz/fizzbuzz_interactive.py
982
4.03125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # Class to hold the fizzbuzz function class FizzBuzz(): # Initialise the class, no arguments since hardcoded def __init__(self, fizz_num, buzz_num): self.fizz_num = fizz_num self.buzz_num = buzz_num def fizzbuzz(self): ...
b58f658f3bcc2d5ec165cdef906013e45497088d
AmaanHUB/IntroPython
/python_databases/python_sql.py
2,122
3.53125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Connection to an SQL DB from Python using pyodbc # import the module # # driver from Microsoft helps us to connect to an SQL instance # # unixodbc driver needs to be installed on Linux beforehand import pyodbc # # Connect to Northwind DB which we h...
626004e73b3c764589b289905933cd190bf87c0c
AmaanHUB/IntroPython
/python_databases/Pyodbc-Task/nw_products.py
2,714
3.703125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # create an object that relates only to the products table in the Northwind database. The reason for creating a single object for any table within the database would be to ensure that all functionality we build into this relates to what could be defined ...
4b56d91db370b97639403ca590056b1a2414b721
clowe88/Code_practicePy
/string_reversal.py
168
3.53125
4
a = ("This is a reverse string.") b = [] c = ("") i = len(b)-1 for x in a: b.append(x) for x in b: c = c + b[i] i -= 1 print(b) print(c)
520109491737fb20e9187b07fd73c4146ae47e36
clowe88/Code_practicePy
/Widget_gen.py
241
3.5625
4
from tkinter import * import random root = Tk() i = 0 x = 0 y = 0 while i < 15: if x == 5: x = 0 y +=1 Button(root, text ="button" + str(i)).grid(row=x, column=y) x += 1 i += 1 root.mainloop()
19387eba9e667955c01c4fe19571af19b890c1d8
clowe88/Code_practicePy
/simple_cipher.py
277
4.15625
4
phrase = input("Enter a word or phrase to be encrypted: ") phrase_arr = [] finished_phrase = "" for i in phrase: phrase_arr.append(i) for x in phrase_arr: num = ord(x) cipher = chr(num + 12) finished_phrase += cipher print (finished_phrase)
daac0e1aeec8cca802590038d591cee8c4b7ec98
aliayoubi/scripts
/general/passgen.py
1,247
3.59375
4
#!/usr/bin/env python # requires Python 2.7+ or the argparse module to be installed import argparse import string import random cmd_parser = argparse.ArgumentParser(description="Generates random passwords for you") cmd_parser.add_argument('-l', '--length', type=int, metavar='num', defa...
babc6e62dfc0b6435cc431ddb0d66a8314a26925
manasmishracse/Selenium_WebDriver_With_Python
/PythonTesting/Demo Code/ReverseString.py
182
4.59375
5
# Taking User Input For Reversing the String Str = input("Enter the String You want to reverse!") rev = "" for i in Str: rev = i + rev print("Your Reversed String is " + rev)
087bc5cc5c04f905117e7950cfd64b1b927a01f9
manasmishracse/Selenium_WebDriver_With_Python
/PythonTesting/Demo Code/ReadFile.py
305
4.1875
4
# Reading a File Line by Line in Python and reverse it in o/p. lines = [] rev = "" file = open('File_Demo.txt', 'r') lines = file.readlines() print("{}{}".format("Content in File is ", lines)) for i in lines: rev = i + rev print("{}{}".format("Reversed Content of the File is:", rev)) file.close()
110f5101b1bf242f03c7b84bce79e1be207f784d
gkaur37/Chem160moldule5
/integral.py
225
3.75
4
def prints(x): print(x) y=10 prints(y) ## Inside prints() the value in y is assigned to x from math import exp def f(x): return x*exp(-x) f(0.1) f(10) #f(0.1)= 0.09048374180359596 #f(10)= 0.0004539999299762484856
25ea1006bb289b24667e1bd935e38bb67a560608
chyngaraev/part2
/part2/task11/task2.11.py
174
3.625
4
word = input() print(word[2]) print(word[-2]) print(word[:5]) print(word[-2: -1]) print(word[0::2]) print(word[1::2]) print(word[::-1]) print(word[::-2]) print(len(word))
81f10e8f388fd4e8fdafe1112cae12560c0e0676
chyngaraev/part2
/part2/task9/task2.9.py
124
3.6875
4
list = [] sum = 0 for x in range(10): number = int(input()) list.append(number) sum = sum + number print(sum)
e0a020d4cd1034d481455f4892fce23092210755
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-5(Day-8)/3.Print bottom 5 elements of the series created in question 2.py
195
3.796875
4
# Print bottom 5 elements of the series created in question 2. import pandas as pd i=list(range(101,111)) data=['A','B','C','D','E','F','G','H','I','J'] s=pd.Series(data,index=i) print(s.tail())
a7e708c106dc18cdd1b222f807dc6225cb2a2347
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-3(Day-6)/4.Circle.py
428
4.25
4
# Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle. class Circle: def __init__(self,r): self.radius=r def area(self): return 3.14*self.radius**2 def perimeter(self): return 2*3.14*self.radius c...
14746feb3f6c2ef1b1487b1c772a1d17be4e8a8f
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-1(Day-3)/5.Write a Python program to interchange first and last elements in a list.py
277
4.34375
4
# Write a Python program to interchange first and last elements in a list. # Logic-1 l=[1,2,3,4,5] print(f'List: {l}') l[0],l[-1]=l[-1],l[0] print(f'List: {l}') # Logic-2 # l=[1,2,3,4,5] # print(f'List: {l}') # l.insert(0,l.pop()) # l.append(l.pop(1)) # print(f'List: {l}')
5aa478055b9109df4e9b32ddf801473d80399148
satyam-seth-learnings/machine_learning
/Machine Learning using Python(NIELIT Lucknow)/My Code/Assignments/Assignment-2(Day-4)/8.Find cube of all numbers of list and find minimum element and maximum element from resultant list.py
309
4.28125
4
# Using lambda and map calculate the cube of all numbers of a list and find minimum element and maximum element from the resultant list. l=[1,2,6,4,8,9,10] cubes=list(map(lambda x: x**3,l)) print(f'Cube of all numbers: {cubes}') print(f'Minimum element: {min(cubes)}') print(f'Maximum element: {max(cubes)}')
7d98f229c8c8a8d38b388acd10e61694580069da
silvanalope/python
/while.py
92
3.875
4
rep = 1 while rep <= 3: print ("mensaje") rep += 1 print ("el ciclo se terminp")
968e4121a772836dbcf49900a12283d26050b909
ChristianSF/Algoritmos_Bioinformatica
/Lista2/ChristianFreitas_Ex_01.py
479
3.921875
4
#Ex1 """ Desenvolva um programa que solicite o primeiro número de uma PA e sua razão. O programa deve imprimir os 10 primeiros termos. """ def calcula_PA(r, n): print("O valor do termo 1 é de: {}".format(n)) for i in range(9): n = n * r print("O valor do termo {} é de: {}".format(i+2, n)) ...
00644bcdaf5ace5d86d25b253ff8115c14b35567
ChristianSF/Algoritmos_Bioinformatica
/Lista3/ChristianFreitas_Ex_01.py
405
4
4
#Christian Silva de Freitas #RA: 140193 #1 Escreva uma função chamada fatorial para calcular o #fatorial de um número inteiro. def fatorial(fat): if fat == 0: return 0 elif fat == 1: return 1 else: return fatorial(fat - 1) * fat if __name__ == '__main__': a = int(input("Digite o ...
69913574525c2fb66b95150d6474057c0c4c119c
ChristianSF/Algoritmos_Bioinformatica
/Lista3/ChristianFreitas_Ex_04.py
987
3.921875
4
#Christian Silva de Freitas #RA: 140193 '''4 Crie um programa que leia nome, sexo, peso e altura de várias pessoas. guarde os dados de cada pessoa num dicionário individual e acrescente o IMC da pessoa. Organize todos os dicionários em uma lista. No final mostre a. Quantas pessoas foram cadastradas b. Qual é o...
6234da5e03adfb6a2e6ae2cae7099c78a29751b5
roycrippen4/python_school
/Assignments/groceries.py
3,034
4.1875
4
# Python Assignment 6 # Roy Crippen # ENG 101 # Due 11/20/2019 # The goal of this code is to define two functions. The first function receives either a list or a single item from # the user and computes the total cost of that single item or list of items. It also will update the amount of stock # related to those item...
0afc2bd9622c2a0a32a3c369733d6df66d8284ce
roycrippen4/python_school
/Assignments/triangle.py
928
4.625
5
# Python Homework 1 - Triangles sides and angles # Roy Crippen # ENG 101 # Due 11/18/2019 # The goal of this code is to take three sides of a triangle from a user and to compute the angles of said triangle. from math import degrees from math import acos # First I will receive the sides of the triangle from the user s...
7a2f401aa2849192a444bd7d82fe38ee11931a7b
Jjoclas/Trabalho_AED_TAD
/python/menu.py
4,999
3.5
4
import re import sys from contaBancaria import ContaBancaria def menu (lista): print('APK Investimentos') print('1- Criar Conta') print('2- Realizar Deposito') print('3- Realizar Saque') print('4- Transferencia entre contas') print('5- Consultar conta') print('0- Sair') escolha...
c5a4266543935a473e048a50217cc2f8d9cbcacb
abhitrip/scratchpad
/LeetCode/connectedComponent.py
1,214
3.609375
4
class Solution(object): def explore(self,v): print self.graph[v] if len(self.graph[v])==0: self.visited[v] = True return self.visited[v] = True for u in self.graph[v]: if self.visited[u]==False: self.explore(u) self...
d14696c696a726ca642f282d416eb6d8d0488b43
abhitrip/scratchpad
/LeetCode/3rdMax.py
1,220
3.71875
4
class Solution(object): def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums)<3: a = Set(sorted(nums)) if len(a)<3: return list(a)[-1] maxSet = set() i = 0 while i<len(nums) and len(max...
3c338864e3213fb6687a748d7a2585d7385625e1
abhitrip/scratchpad
/LeetCode/pythonSols/hackerrank/zerosOnes.py
560
3.625
4
def countSubstrings(s): if not s: return 0 l = len(s) count = 0 i,j,k=0,0,0 zeros,ones=0,0 while i<l: j = i zeros = 0 while j<l and s[j] ==s[i]: j+=1 zeros+= 1 count+= min(zeros,ones) k = j ones = 0 while k<l...
77d92e5441919f3986726286b1f7cf615c298376
abhitrip/scratchpad
/LeetCode/pythonSols/findMinRotated.py
1,021
3.578125
4
class Solution(object): def findMin(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums)<1: return 0 elif len(nums)==1: return nums[0] """ left,right = 0,len(nums)-1 while left<right-1: mid ...
4d5e8f63012df79330cf4331b56154f1fc745a46
LVrecar/Tic-tac-toe
/tic-tac-toe.py
4,341
3.546875
4
import algorithm from tkinter import * def change(x): if not gameOver.get(): if x.get() == "": x.set(turn.get()) turn.set("O") if turn.get() == "X" else turn.set("X") board = updateBoard(rows) winner = checkForVictory() if winner != "": endGame(w...
4f31f5abd90c70192ef089ae9e6fb44626f8fc1b
Umit8098/Python-Excercises
/HACKER_RANK/RepeatedString.py
360
3.796875
4
def repeatedString(s, n): if s == 'a': return n else: while len(s) <= n: for letter in s: s += letter s = s[:n] # print(s) num_a = s.count('a') return(num_a) print(repeatedString('aba', 10)) print(repeatedString('aba', 12)) print(repeatedString('...
ae25862d24c2384008192ee0b0dd5031f5f8b2c6
Umit8098/Python-Excercises
/CLARUSWAY/FibonacciList.py
246
3.640625
4
# 55 e kadar olan Fibonacci listesini verir. fibonacci_list = [1, 1] toplam = 0 for i in range(100): toplam = fibonacci_list[i] + fibonacci_list[i + 1] fibonacci_list.append(toplam) if toplam == 55: break print(fibonacci_list)
483bf1553331ec2fcde2207212613e0bead61c49
DominiqueOyco/Symmetric-Cryptography
/ngrams.py
1,683
3.828125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 26 13:37:26 2019 @author: Dominique Oyco (014605758) LAB ASSIGNMENT 1 SUPPLEMENTARY FILE - ngrams """ """ Courtesy of http://practicalcryptography.com - however some parts were modified to cooperate with the part 1 decryptor file Allows s...
5cb65fec6acb74bd10a891441d98e1c5a51bda80
4bd3ss4m4d/Hangman
/main.py
4,299
3.828125
4
import random # Function definitions # Function index that determines character's index def index(userchar, randomlist): randomlist = randomlist indices = [] for i in range(len(randomlist)): if randomlist[i] == userchar: indices.append(i) return indices #Hangman ASCII Art abdessamad...
6b47c5254cee29f96045124913f14fee0f53b3c8
lazumbra/Educative-Data-Structures-in-Python-An-Interview-Refresher
/LinkedList/Doubly Linked Lists/main.py
1,673
4.125
4
from LinkedList import LinkedList from Node import Node def delete(lst, value): deleted = False if lst.is_empty(): print("List is Empty") return deleted current_node = lst.get_head() if current_node.data is value: # Point head to the next element of the first element ...
ccc00ddfbb483dfbb61fdf68cf2b43dec3c0c371
lazumbra/Educative-Data-Structures-in-Python-An-Interview-Refresher
/LinkedList/Challenge_6/main.py
366
3.90625
4
from LinkedList import LinkedList minha_lista = LinkedList() minha_lista.insert_at_tail(1) minha_lista.insert_at_tail(2) minha_lista.insert_at_tail(3) minha_lista.insert_at_tail(1) minha_lista.print_list() print(minha_lista.detect_loop()) # minha_lista.delete_at_head() # print(minha_lista.delete(9)) # minha_list...
8dc0dd611b0c3e3b1a42585d6f96bc349381d730
hypo123/python_EX
/test2.py
204
3.859375
4
classmate = ['Mick','Sany','Bush'] classmate.append('Tom') for name in classmate: print(name) print(len(classmate)) classname = ('Som','Lei','White') for n in classname: print(n) print(len(classname))
9d1775a047b3e2d85b481a37a567957e6bea6ec8
AngiiRamosS/Quiz2
/5.py
252
3.75
4
No = input("ingrese un numero de 1 a 7") if No == 1 : print "lunes" if No == 2 : print "martes" if No == 3 : print "miercoles" if No == 4 : print "jueves" if No == 5 : print "viernes" if No == 6 : print "savado" if No == 7 : print "domingo"
a1e5cfbda64f8286772938bd41a4be914709c949
IrinaTelegina/pythonProject
/11.7.4Процент.py
207
3.71875
4
summ = float(input('Введите сумму ')) mes = int(input('Введите количество месяцев ')) i = 0 while i < mes: summ += summ * (0.0418 / 12) i += 1 print (int(summ))
0233c42568c2877cd6f04551ca96568eec99f841
xorms8/pythonPractice
/web/3_beautifulsoup_class/Ex02_seletor.py
873
3.5
4
""" BeautifulSoup 모듈에서 - HTML의 구조(=트리구조)에서 요소를 검색할 때 : find() / find_all() - CSS 선택자 검색할 때 : select() / select_one() id = # class . """ from bs4 import BeautifulSoup html = """ <html><body> <div id='course'> <h1>빅데이터 과정</h1> </div> <div id='subjects'> ...
cdfd52dbcc81909707ee6e0a107ffee80d991145
xorms8/pythonPractice
/pythonBasic/e_file_class/Ex01_readFile_exam.py
851
3.515625
4
""" [연습] 함수 정의 : count_words 인자 : filename 인자로 받은 파일명을 open 하여 파일을 읽어서 단어를 수를 출력한다. 존재하지 않는 파일명으로 예외가 발생해도 아무런 일을 하지 않는다 """ def count_words(filename): try: with open('./data/{}'.format(filename), 'r', encoding='utf-8') as f: # with을 쓰는이유 -> close를 안해도 됨 contents = f.read() ...
657c7fddd1cc5d6f102bb8b55548aec1e18db0a7
xorms8/pythonPractice
/pythonBasic/02.control_class/Ex05_function.py
10,051
4.15625
4
""" [ 함수 ] - 반복적인 구문을 만들어 함수로 선언하여 간단하게 호출만 하고자 한다 - 역할별 구문을 작성한다 def 함수명(매개변수): 수행할 문장들 """ #() 인자도 없고 리턴값도 없는 함수 # def func(): # print('inside func') # # func() # result =func() # 리턴값이 없으니 None을 출력 # print(result) #(1) 리턴값이 여러개인 함수 def func(arg): return arg*2, arg+20 result = fu...
ef828379bc3adf933bdfac4f8c4272cec4ff680d
fengmm521/okex_robot
/test.py
751
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2018-05-24 15:13:31 # @Author : Your Name (you@example.org) # @Link : http://example.org # @Version : $Id$ #创建SocketServerTCP服务器: import os,sys import curses def main(): stdscr = curses.initscr() pad = curses.newpad(100, 100) # These loops fill th...
29b35069d6e8011b92ad03a40b97f97b4c092811
sarincr/Python-Simple-GUI-calculator
/main.py
6,176
3.53125
4
import tkinter from tkinter import * from tkinter import messagebox root = tkinter.Tk() root.geometry("250x400+300+300") root.resizable(0,0) root.title("Calculator") X = "" A = 0 operator = "" def button_1_isckd(): global X X = X + "1" data.set(X) def button_2_isckd(): global X X = X + "2" ...
cd6dfb1ffeceec8b0122b6f01216a5c73ac1efe2
kotesh-arya/HacktoberFest2021
/python/Guessing Game.py
3,208
4.15625
4
import random import time class Tries(Exception): pass class RangeError(Exception): pass print("Welcome to Number Guessing Game\n\n") time.sleep(0.8) choice = int(input("Press 1 to Guess a number\n" "Press 2 to make computer guess a number:")) if choice == 1: num ...
e10ece2962fbed94d34c6b2cb12d218f719b7c13
piyushgaikwad/recruiting-exercises
/inventory-allocator/src/Warehouse.py
2,186
3.96875
4
# inp = {"apple": 15, "banana": 10} # warehouse = [{"name": "owd", "inventory": {"apple": 11, "banana": 3}}, # {"name": "fine", "inventory": {"apple": 5, "banana": 3}}] ans = [] # This list to store final shipping result n = int(input("Enter a order Number:")) # number of Orders inp = {} # input for ord...
685742df63deb187d5e150bf9a08c9a1ee14cb00
sammffl/pythonPractice
/advanced_feature/Generator.py
338
3.796875
4
# -*- coding: utf-8 -*- # 生成器 generator # 一个接一个生成 next g = (x * x for x in range(10)) print g.next() g = (x * x for x in range(10)) for n in g: print n def fib(max): n, a, b = 0, 0, 1 while n < max: yield b a, b = b, a + b n = n + 1 print fib(6) for g in fib(6): print g
b6fc36d089220a854938be9ef9e1e2db57aeb47e
ubqai/seesun_crm_services
/application/utils.py
2,717
3.609375
4
import datetime import calendar def add_months(sourcedate, months): month = sourcedate.month - 1 + months year = int(sourcedate.year + month / 12 ) month = month % 12 + 1 day = min(sourcedate.day,calendar.monthrange(year,month)[1]) return datetime.date(year,month,day) def is_number(s): try: ...
51f497fa15c6f77934f98cf1595b66cb7a455ae7
charleycodes/hb-code-challenges
/concatenate-lists-2-13.py
872
4.3125
4
# Whiteboard Easier # Concepts Lists def concat_lists(list1, list2): """Combine lists. >>> concat_lists([1, 2], [3, 4]) [1, 2, 3, 4] >>> concat_lists([], [1, 2]) [1, 2] >>> concat_lists([1, 2], []) [1, 2] >>> concat_lists([], []) [] """ ...
00391d3fc0c9dfb4561db37abcf549798d3baaa6
Marciocasteloo19/POO-repositorio
/atv2-calc/calculadora.py
916
3.5625
4
class Calc: def __init__(self): self.bat = 0 self.bat_max = 0 def gastbat(self): if self.bat == 0: print("fail: bateria insuficiente") return self.bat -= 1 return def soma(self, a, b): if self.gastbat(): print(a + b) de...