blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4042021f29297a2ce0a712e5295cb3f64f0d0f14
RishiNandhan/Pandas-Basics
/Pandas tutorial_Dataframe.py
2,143
3.796875
4
import pandas as pd import numpy as np ########Data Frame########## #create and empty dataframe d1=pd.DataFrame() print(d1) #create a dataframe using a list of 1D ar1=[1,2,3,4,5,6] d2=pd.DataFrame(data=ar1) print(d2) #create a dataframe using a list of 2D ar2=[['ram',10],['rishi',21],['ebin',30]] d3=pd.DataFrame(da...
f63f379ade21ef134bddebd0a5215920b7ac7834
jagdishbairagi/python
/enumerate.py
165
3.875
4
## Odd Even items a = ["Jagdish", "Bairagi", "vaishnav", "fsfsf"] for index, item in enumerate(a): if index%2 == 1: print(f"Please say hello to {item}")
c6b664dce1e8412e408cf00e9cb7d064f5e5fafc
tylerc-atx/script_library
/convert_tab_to_csv.py
1,113
3.640625
4
"""Converts a tab delimited file to a CSV BASH FORMAT: $ python convert_tab_to_csv.py input_file.txt output_file.csv Will OVERWRITE existing output file if one is present. NOTE: Will wrap fields in quotes to prevent comma-interference if commas exist within fields""" from sys import argv input_file, output_file...
011e4a3b74d5eab61c7449c8efbfeb8ce4075cdf
pushp360/Maze-VLSI-Routing
/Routing.py
2,135
3.859375
4
layer = input("Enter the no. layers: ") #Layers of the grid #Error Handling for layer Input while True: try: layer = input("Enter a number: ") layer = int(layer) break except ValueError: print("Invalid Input!") maze = [] #The final grid with all layers #Taking input as per num...
1c4002797948ec69c269a9863ae0031aef0ba0b5
erjan/coding_exercises
/namedtuple.py
841
4.1875
4
#I struggled greatly with this exercise - did not understand that headers can be simply read and put in as IS! ''' The first line contains an integer , the total number of students. The second line contains the names of the columns in any order. The next lines contains the ID, NAME ,MARKS and CLASS, under their respe...
7a3fd79250c32dcee342e17ede88e265e8784f06
ajn123/Python_Tutorial
/Python Version 2/Advanced/lamdaExpressions.py
1,459
4.65625
5
""" lambda expressions have special rules: 1) The body of a lambda expression can contain only a single line. 2) The body can only contain an expression, no statements or other elements 3) The result of the expression is automatically returned. The form of a lambda expression is: lamda arg_list: expression A lam...
570c182fc978efc91a468ed6574911dc263d86a2
zenithlight/advent-of-code-2017
/10a.py
693
3.8125
4
import sys string = list(range(256)) lengths = [int(digit) for digit in sys.argv[1].split(',')] def rearrange(string, start, length): # unshift the string so it starts at position denoted by `start` new_string = string[start:] + string[:start] # reverse the first `length` elements of string new_strin...
088d3d1de8543543ac42f7151423d7d550318ffb
stanilevitch/python_learning
/instrukcja_if.py
592
3.796875
4
number = 23 guess = int(input("Podaj liczbę całkowitą: ")) if guess == number: # Blok warunkowy zaczyna się w tym miejscu print("Gratulacje, zgadłeś tajemniczą liczbę!") print("Ale nie mamy nagrody :)") # Tu kończy się blok warunkowy elif guess < number: # Drugi blok print("Liczba powinna być w...
004b51cc4fb6820bb6485b7a0765efcfdf5a6cd9
0u714w/numseq-package
/numseq/prime.py
536
4.15625
4
#! python3 def primes(n): """returns prime numbers of given list""" all_primes = [] for possible_prime in range(n): prime = True for num in range(2, possible_prime): if possible_prime % num == 0: prime = False if prime: all_primes.append(po...
9c4c990db48543531948f27e85081a81437d2328
Valerich1804/python_lesson
/lesson3/hw03_normal.py
3,502
3.953125
4
# Задание-1: # Напишите функцию, возвращающую ряд Фибоначчи с n-элемента до m-элемента. # Первыми элементами ряда считать цифры 1 1 print(40*'=','\nЗадание-1:\n') from math import* def fibonacci(n, m): if n <=0: return "N должно быть больше 0!" if n > m: return if m < 4 and n < 3: return [1, 1, 2] fi...
88452914aeb87a2fdff5a02a820755dff4175f9c
ankitthakur94/MyPyPandas
/9_scales.py
3,417
4.46875
4
import pandas as pd import numpy as np ## Types of scales for data # 1) Ratio scale : # units are equally spaced. # mathematical operations (+ - * / ) are valid. # Ex : height and weight. # 2) Interval scale : # units are equally spaced. # * and / ...
62b580ebae4a3436a999e80d95bae6e153fe75ef
zac112/adventOfCode
/code2022/day21/p2.py
1,822
3.546875
4
monkeys = {} ops = {'+':lambda a,b:a+b, '-':lambda a,b:a-b, '*':lambda a,b:a*b, '/':lambda a,b:a//b} reverseOp = {'+':ops['-'], '-':ops['+'], '*':ops['/'], '/':ops['*']} with open("data.txt") as f: for line in f.read().splitlines(): match line.split(" "): ...
a2f7f1e92d8741bd797ecc350fcf1fce0ea3a993
zyarr-innovation/PythonTrainingCode
/FundamentalCode/Day 2/10.fun.py
393
3.90625
4
def billCalculator(costOfPizza,numberOfPizza,tax): totalCost = costOfPizza * numberOfPizza salestax = totalCost*tax/100 totalBill = totalCost + salestax return totalBill a = eval (input ("Enter the cost of the burger: ")) b = eval (input ("Enter the number of burger: ")) #sales tex is 2% c = 2 to...
06766075ac75d398d4fee998faa0b27500f687e5
kdaivam/data-structures
/linkedlists/zip_linked_list.py
1,508
3.859375
4
import sys import random from linked_list_prototype import ListNode #from reverse_linked_list_iterative import reverse_linked_list def reverse_print_list(self): prev = None current = self while current is not None: next = current.next current.next = prev prev...
2bfa2a229bd8187dd380d78b060d22a21104646e
acorrig5/Python
/IT5413Test1Question2PyCode_AmyCorrigan.py
1,121
4.375
4
# This program calculates the balance of a saving account after a period of several years. # This program asks for: # - initial saving amount # - interest rate (as percent) # - saving periods (in years) #Prompt user to enter amount they will deposit to start their account savingsAmt = float(input('...
5961b2e4eb4af0d31d3d1db80a687cf652e4626b
nirajs1089/Coding_Practice
/1 Prob.py
378
4.21875
4
# Get the sum of multiples of 3 and 5 within a range lower_no = int(input("Enter the lower number")) upper_no = int(input("Enter the upper number")) upper_range = int(input("Enter the range")) #get a var to get the sum sum = 0 #run a loop for the range for i in range(upper_range): print(i) if i % lower_n...
3c27b94f9c627ad6229f263e42929201a09af08a
StartAmazing/Python
/venv/Include/book/chapter7/whiledict.py
1,388
3.859375
4
# 首先,创建一个待验证的列表 # 和一个用于存储已验证用户的空列表 unconfirmed_users = ["Alice", "Cindy", "Marry"] confirmed_users = [] # 验证每个用户,直到没有未验证的用户为止 # 将每个经过验证的用户都迁移到已验证的用户列表中 while unconfirmed_users: current_user = unconfirmed_users.pop() print("Verifying user: " + current_user.title()) confirmed_users.append(current_user) # 显...
e9489b66fcc9774c08dcd103e2496244ec56a6c5
AveryRector/Basic-Python-Projects
/gpa.py
257
3.921875
4
total = 0.0; totalHours = 0.0; while True: grade = float(input('GRADE: ')) hours = float(input('CREDIT HOURS: ')) if(grade == -1): break else: total += (grade * hours) totalHours += hours print(total / totalHours)
e90cb55c54d240226c2926e4539ad92498ae07cc
DavidtheDJ/DSW-1-19
/Practice VERBOSE.py
1,170
3.78125
4
#David Justice #1-25-17 #Verbose Expressions import re pattern = """ [A-Z] #single letter #followed by either: ( [A-Z] #single character ...
5ef4ae7d2922a754fff1d99a543446476ec246a0
deepakdp1989/Python
/shell_sort.py
1,760
4.1875
4
""" ShellSort is mainly a variation of Insertion Sort. In insertion sort, we move elements only one position ahead. When an element has to be moved far ahead, many movements are involved. The idea of shellSort is to allow exchange of far items. In shellSort, we make the array h-sorted for a large value of h. We keep re...
102fd24e262e369144b1c3f96c5f547e68339383
skosantosh/python
/while_loop.py
431
3.578125
4
import random counter = 65 number_print = 0 while counter < 91: print(str(counter) + "=" + chr(counter)) counter += 1 print("All Done") print("Number that aren't evnely divisible by 5.") san = 0 while san < 10: number = random.randint(1, 999) if int(number/5) == number/5: break number_print...
01cf5ac109f01564705b01e9dfbb0904745e8be2
UdhaikumarMohan/ArrayQuestions
/Numbers/perfect_sq.py
657
4.03125
4
# Find the perfect squares in the given array: import math def Is_perfect_sq(X): flag=True M=math.sqrt(X) N=round(M) if not (M==N): flag=False return flag def perfect_sq_array(Array): sq_array=[] for a in Array: if (Is_perfect_sq(a)): sq_array.append(...
a32e4e8b5edfe69d917d88fc466404190488c7a6
amgerton/master
/SeatingChart App.py
1,388
4.375
4
# Seating Chart Application ''' # of guests are obtained from the user and so are the certain about of guests you must seat at each of the tables ''' def factorial(x): # factorial function x_fact = 1 i = 0 for i in range(1,x+1): x_fact = x_fact * i return x_fact n = int(inp...
aa7a877fb5450c27b78fbf7f026991d1e9289c7e
MiroVatov/Python-SoftUni
/Python Advanced 2021/EXAMS_PREPARATION/Exam 27 June 2020/02 snake.py
2,730
4.125
4
field_size = int(input()) snake_field = [list(input()) for _ in range(field_size)] def check_starting_position(field, start): for row in range(len(field)): if start in field[row]: return row, field[row].index(start) def is_outside(cur_row, cur_col, size): if 0 <= cur_row < size and 0 <= ...
f7e9c93b8657b4a2732d28a55040dc902ea62ef6
lisa0826/pyDataAnalysis
/02/ex-week2.py
5,862
4.0625
4
# -*- coding: utf-8 -*- # flag = False # name = 'python' # if name == 'python': # flag = True # print('welcome boss') # else: # print(name) # num = 2 # if num == 3: # 判断num的值 # print('boss') # elif num == 2: # print('user') # elif num == 1: # print('worker') # elif num < 0: ...
46e1d51fadca58a1593de9ad5123e367d479fcdd
guoyu07/CLRS
/LeetCode/BestTimetoBuyandSellStockII.py
759
3.875
4
__author__ = 'Tong' # Say you have an array for which the ith element is the price of a given stock on day i. # # Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one # and sell one share of the stock multiple times). However, you may not engage in multiple tran...
0d518e80b9c790349231b133e087444aeba5e24b
e7k8v12/ProjectEuler
/0001_0100/0009/0009.py
851
4.25
4
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a² + b² = c² # For example, 3² + 4² = 9 + 16 = 25 = 5². # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. # Тройка Пифагора - три натуральных числа a < b < c, для которых выполняется равен...
a26fc50d4dbc6600044883cca395b6cd998e5ced
dbetm/cp-history
/HackerRank/Strings/11_BeautifulBinaryString.py
501
3.875
4
# https://www.hackerrank.com/challenges/beautiful-binary-string/problem # Tag(s): strings def compute_cost(b, n): ans = 0 if n < 3: return ans patt = '010' i = 0 while (i + 2) < n: cont = 0 while patt == b[i:i+3]: i += 2 cont += 1 ans += co...
2917241f0a3995da2a40df839bca89307919e9bc
krtex/advent_of_code_2020
/day03/solution.py
673
3.90625
4
from math import prod def load_lines(input): with open(input) as file: lines = file.readlines() lines = [l.strip() for l in lines] return lines def count_trees(slope, right=3, down=1): tree_count = 0 for idx, line in enumerate(slope): if not (idx % down): if line[(right...
f2a7c0d1891a0e726728b177145f9239ecee0343
uliseshrrs/CYPUlisesHS
/Libro/problemas_resueltos/EJEMPLO_1.8.py
425
3.8125
4
print("ESTE PROGRAMA SIRVE PARA CALCULAR LA DISTANCIA DE 2 PUNTOS") X1 = float(input("INGRESA EL VALOR DE X1:")) Y1 = float(input("INGRESA EL VALOR DE Y1:")) X2 = float(input("INGRESA EL VALOR DE X2:")) Y2 = float(input("INGRESA EL VALOR DE Y2:")) DIS = ((X1 - X2) **2 + (Y1 -Y2) ** 2) ** 0.5 print(f" LA DISTANCIA...
3dea2b43087d861b238a749359dcee70d8faac29
pythonCore24062021/pythoncore
/HW/homework06/obartysh/hw06_07.py
283
3.96875
4
import random n = int(input("enter a number of elements in the list ")) random_list = [random.randint(-n, n) for i in range(n)] answ = [] for i in random_list: if random_list.count(i) == 1: answ.append(i) print(f'Random list: {random_list}') print(f'unique values: {answ}')
2130c1f81da3e5bcd29d14b6762ed08cffbdd675
CUNY-CISC1215-Fall2021/lecture-8
/palindrome.py
915
4.34375
4
def is_palindrome(string): """Determine if "string" is a palindrome. Returns True if it is a palindrome, False if not.""" # Base case: If the string is one character long or fewer, it's a palindrome. if len(string) <= 1: return True # Base case: If the first and last characters in the stri...
bf9ec3aa48291f919e97e8161a8fd58ae60f7d29
enthusiasm99/crazypython
/03/P57_reverse_sort.py
617
3.96875
4
a_list = list(range(1, 10)) print(a_list) #[1, 2, 3, 4, 5, 6, 7, 8, 9] a_list.reverse() print(a_list) #[9, 8, 7, 6, 5, 4, 3, 2, 1] b_list = [3, 4, -2, -30, 14, 9.3, 3.4] print(b_list) b_list.sort() print(b_list) # ['Erlang', 'Go', 'Kotlin', 'Python', 'Rubby', 'Swift'] c_list = ['Python', 'Swift', 'R...
809a6c878ee4f8257be1bfac577c2f4bae6ba9da
h4hany/yeet-the-leet
/algorithms/Hard/1516.move-sub-tree-of-n-ary-tree.py
3,708
3.609375
4
# # @lc app=leetcode id=1516 lang=python3 # # [1516] Move Sub-Tree of N-Ary Tree # # https://leetcode.com/problems/move-sub-tree-of-n-ary-tree/description/ # # algorithms # Hard (59.92%) # Total Accepted: 613 # Total Submissions: 1K # Testcase Example: '[1,null,2,3,null,4,5,null,6,null,7,8]\n4\n1' # # Given the roo...
4c3319acede6ed6aaf58f7c32f51f7ea709e80ee
J35P312/Garbage_heap
/general_vcf/chromosome_extract.py
510
3.75
4
import argparse parser = argparse.ArgumentParser("""this scripts prints every variant present on a chosen chromosome""") parser.add_argument('--vcf',type=str,required=True,help="the path to the vcf file") parser.add_argument('--chr',type=str,required=True,help="the chromosome") args, unknown = parser.parse_known_args(...
ebf00bd15f3f037ba12eb64fea248b0c08c6e314
CamilliCerutti/Python-exercicios
/Curso em Video/ex057.py
421
3.84375
4
# VALIDAÇÃO DE DADOS # Faça um programa que leia o sexo de uma pessoa, mas só aceite os valores ‘M’ ou ‘F’. Caso esteja errado, peça a digitação novamente até ter um valor correto. sexo = str(input('Digite o sexo: [M/F] ')).strip().lower() while sexo not in 'mf': sexo = str(input('Dados invalidos. Informe o sexo:...
db5c400a5b5a88d3c06da11963681d3d8e86e1fb
spirit1234/location
/python_work/基础/第三章 列表/pop删除元素.py
490
3.84375
4
#-*- coding:utf-8 -*- name = ['jing' , 'jian' , 'qiang'] print(name) #pop() ɾбĩβԪأ #ܹʹ ﵯ pop #Դȣ бһջ #ɾбĩβԪ൱ڵջԪء name_new = name.pop() print(name) print(name_new) motorcycles = ['honda' ,'yamaha' , 'suzuki'] last_owned = motorcycles.pop() print("The last motorcycles I owned was a " + last_owned.title() +'.')
8905e66f390a712c0bf2cf84a4c7857c21eb871f
khuang110/CS-362-Homework-4
/unitTest.py
1,929
3.65625
4
# Unit test for calculating cube volume # By: Kyle Huang import unittest from cube import calc_cube from avg_elem import avg_list from name import name # Test cases for cube.py class CubeTest(unittest.TestCase): # check for negative number # Edge case def test_negative(self): self.ass...
d7eebeba7268d482ddbcae72ef81bbf2fdec6e80
ricrui3/AnalisisDeAlgoritmos
/Fibonacci/FibonacciChido/fibonacciChido.py
973
3.625
4
__author__ = 'mrubik' def mult_matrices(matriz, matriz1): aux = [[0, 0], [0, 0]] aux[0][0] = matriz[0][0] * matriz1[0][0] + matriz[0][1] * matriz1[1][0] aux[0][1] = matriz[0][0] * matriz1[0][1] + matriz[0][1] * matriz1[1][1] aux[1][0] = matriz[1][0] * matriz1[0][0] + matriz[1][1] * matriz1[1][0] a...
ebb79c47a7d456ca2bca64315f886343b9e6728d
xerifeazeitona/PCC_Data_Visualization
/chapter_15/examples/scatter_squares_4_big_list.py
700
4.03125
4
""" Writing lists by hand can be inefficient, especially when we have many points. Rather than passing our points in a list, let’s use a loop in Python to do the calculations for us. """ import matplotlib.pyplot as plt x_values = range(1, 1001) y_values = [x**2 for x in x_values] plt.style.use('dark_background') fig,...
b5e083e33cf2b7ba7a0d47d1f589757af6b1685b
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/SLammertink/Lesson03/strformat_lab.py
2,257
4.5
4
#! /usr/bin/env python3 # UW Self paced Lesson 03 string lambda # Task 1 ''' Write a format string that will take the following four element tuple: ( 2, 123.4567, 10000, 12345.67) and produce: 'file_002 : 123.46, 1.00e+04, 1.23e+04' ''' StrList = (2, 123.4567, 10000, 12345.67) def Task1(): print(f"file_{StrLis...
e328856c43c7a120d3e6742ef04e03156ef71ed7
Aasthaengg/IBMdataset
/Python_codes/p02406/s335551620.py
127
3.734375
4
n = input() out = "" for i in range(1, int(n) + 1): if i % 3 == 0 or "3" in str(i): out += " " + str(i) print(out)
6aa58ffb48f7b8ff6f6d921bc67aaf54129d8514
nicoarato/Programando-con-Python
/08-condicionales.py
1,102
3.96875
4
balance = 5 if balance > 3: print('Se puede pagar') else: print('No puedes pagar nada') likes = 200 if likes == 200: print('buenos likes') # con letras lenguaje = 'python' if lenguaje == 'python': print('Excelente decision') #Evaluar boolean usuario_aut = True if usuario_aut : print('Acceso co...
2a512e30d4afbee794730c5ce49baf8ee583ce7d
MatrixMike/Python
/python9.py
261
3.78125
4
# 18/5/2013 import turtle l=1 turtle.shape() while True : print("in while loop",l) turtle.speed(1) # turtle.forward(50) # turtle.right(30) turtle.forward(25) turtle.right(-60) l=l+1 # l++ # if input()==" ": # break
7fca9719076a50f4cbbf8d94d2a643f4450a7240
royabouhamad/Algorithms
/Sorting/BubbleSort.py
303
3.734375
4
numbers = [11, 2, 32, 9, 29, 0, 15, 40, 8, 1, 37] swapMade = True while swapMade == True: swapMade = False for i in range(0, len(numbers) - 1): if numbers[i] > numbers[i + 1]: numbers[i], numbers[i + 1] = numbers[i + 1], numbers[i] swapMade = True print(numbers)
0725ec68c2a64acb71b141599901caee9dfff9dd
gnorgol/Python_Exercice
/Exercice 2.py
153
3.78125
4
a = int(input("Saisir un premier nombre : ")) b = int(input("Saisir un deuxieme nombre : ")) c = a+b plus = "+" print(str(a)+"+"+str(b)+"="+str(a+b))
91328c3f920e3eba7b5ccd5be982c8fbb0fd396b
Wdecibel/MyPythonProject1
/Week 4/day 1/集合.py
1,592
3.703125
4
#__author__: Han #__date__: 2019/1/3 a = set([1,2,3,4,5]) b = set([4,5,6,7,8]) # a = [1, 'www', 1, 1] # print(a) # s = set('alex li') # s1 = ['alvin', 'ee', 'alvin'] # print(set(s1)) # print(s) # s = {2, 3, 'alex'} # print(s) # s.update([12,'eee']) # print(s) # s.remove(2) # s.pop() # s.clear() # print(s) # print...
7c24e420381ee513a8d36d5bda321166f4bb5b8c
naveenailawadi/old
/reddit scraper/Tortilla/tortilla_info_entry.py
972
3.640625
4
import json print('Follow the instructions below to input the necessary information into a json for the bot to access.') data = {} data['keyword'] = input('What is the keyword or keyphrase that you are looking for? \n') data['message'] = input('What is the initial message? \n') data['winphrase'] = input('What is the ...
5acbf4dcd8226c11666e8dd3454563d49e2a3c06
MadmanSilver/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-read_lines.py
308
3.875
4
#!/usr/bin/python3 """ Contains the read_lines function. """ def read_lines(filename="", nb_lines=0): """ Reads n lines from a text file. """ i = 0 with open(filename) as f: for l in f: i += 1 print(l, end="") if i == nb_lines: break
c78afb3e755bf7da3d36056d448afa87d19d02c8
zhangkai98/ProgrammingForThePuzzledBook
/Puzzle17/anagrams-sort-char.py
1,573
4.03125
4
#Programming for the Puzzled -- Srini Devadas #Anagramania #Given a list of words, sort them such that all anagrams are grouped together #A more efficient algorithm though not efficient in terms of storage corpus = ['abed', 'abet', 'abets', 'abut', 'acme', 'acre', 'acres', 'actors', 'actress', 'airmen', 'ale...
07726bea4dd2ea64b79694c22dc2cb5a3f27b2e8
jpverkamp/schempy
/globals/mathematical.py
815
3.734375
4
from Decorators import Rename @Rename('+') def add(*args): '''Add numbers.''' result = 0 for arg in args: result += arg return result @Rename('-') def sub(*args): '''Subtract numbers.''' if len(args) < 1: raise ValueError('- expects at least 1 argument, given %d' % len(args)) result = args[0] for arg in a...
e5d16c0253c594742196b49e5e822015262a27ad
sarodp/mypg-nerdtutor
/nerd6.py
3,747
3.625
4
# http://www.nerdparadise.com/programming/pygame/part6 # # mouse input import pygame def main(): pygame.init() screen = pygame.display.set_mode((640, 480)) clock = pygame.time.Clock() radius = 15 x = 0 y = 0 cmodes = ["red","green","blue"] points = [] while True: pressed = pygame.key.get_pressed() alt...
5d7d4d0dc8822cc5cb0ddc487131b67ef6c97b57
yash-chandak/high-school-projects
/lab2.py
2,188
3.859375
4
import math from random import randint, sample def Cookout(): numPeopleInput = input('How many people will be coming to the cookout? ') numPeople = float(numPeopleInput) numHotDogsInput = input('How many Hot Dogs will each person eat? ') numHotDogs = float(numHotDogsInput) print('You will need to purchase ' ...
71dbea2a9270bf79db629b372ed75a8300adcb05
eric-baack/cs160
/projects/morse/morse2.py
7,494
3.875
4
"""Morse code encoding and decoding""" #!/usr/bin/env python3 # encoding: UTF-8 class BinaryTree: """Binary Tree implementation as nodes and references""" def __init__(self, key): self._key = key self._child_left = None self._child_right = None def get_root_val(self): """G...
8f5544320d097d2b1b992153056a74aeb648abb0
detukudo/banking-auth
/auth.py
4,271
4.1875
4
"""This is a banking app with capacity to do authorisation for users. METHODS: Init: Initializes the application Register: Enables new users open an account Login: Enables account holders access an account Bank Operation: Enables account holders carry out operation on account Deposit Operation: Enables account holders...
2f2c3db06feb29453269f2bdf2e2c8bb5923feb6
meenapandey500/Python_program
/program/file1.py
500
3.96875
4
'''t=open("hello.txt","w") t.write("Meena, How are you\n") t.write("I am fine and you") t.close()''' #write data in file with open("hello1.txt","w") as t : #with open("permanentfile.txt","mode") as temporary file t.write("Meena, How are you\n") ##here t temp file t.write("I am fine and you") ...
f99d432f622b453ee2789446ff76d644b47bec7f
elrapha/Lab_Python_03
/myPrime.py
332
4.0625
4
num=1 isPrime=True while True: i=2 stop=int(sqrt(num)) while i<=stop: if num%i==0: isPrime=False """ num=9 isPrime=True stop=int(sqrt(num))+1 #print 'stop', stop for i in range(2,stop): if num%i==0: isPrime=False break if isPrime: print num, 'is prime' count=...
67f8f3eac13ca6c99202fcc8e084b9149a4bc8e7
anarequena/ProgrammingChallenges
/13-09/problemG.py
270
3.96875
4
n_exp = int(input()) for i in range(n_exp): exp = input() if((exp == "1") or (exp == "4") or (exp == "78")): print("+") elif(exp[len(exp) - 2:] == "35"): print("-") elif(exp[:3] == "190"): print("?") else: print("*")
d60f2d3f02370be8ea0f3f6792f300ad17843d47
blackbat13/Algorithms-Python
/fractals/binary_tree.py
427
3.90625
4
import turtle def binary_tree(rank: int, length: float) -> None: turtle.forward(length) if rank > 0: turtle.left(45) binary_tree(rank - 1, length / 2) turtle.right(90) binary_tree(rank - 1, length / 2) turtle.left(45) turtle.back(length) turtle.speed(0) turtle.pen...
bfdb0e251c5e5086b06fab41c4ba0ddae56c670c
xxxzc/public-problems
/Unclassified/PythonCourse_rev/6/10_TwoNumSum/template.py
347
3.625
4
def twonumSum(l: list, n: int): # l 为有序整数列表,n 为目标两个数的和 # 返回 l 中和为 n 的两个数的下标 # 返回一组即可且要求其中的一个数尽量小 return None l = list(map(int, input().split())) n = int(input()) twonum = twonumSum(l, n) print(*twonum) if twonum else print('Not Found')
14dda65d858ebfa078bca09c3a87a1a1a4545665
y56/leetcode
/540. Single Element in a Sorted Array.py
1,020
3.75
4
""" 540. Single Element in a Sorted Array Medium You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once. Example 1: Input: [1,1,2,3,3,4,4,8,8] Output: 2 Example 2: Inpu...
c9160def37e7828b8fb689a95e7e0046d3521970
dabini/SWEA
/D4_5120_암호.py
1,295
3.765625
4
class Node: def __init__(self, d=0, p=None, n=None): self.data = d self.prev = p self.next = n class LinkedList: def __init__(self): self.head = None self.size = 0 def addLast(lst, new): #빈 리스트 일 때 if lst.head == None: lst.head = new new.prev = n...
6cea072de8dedb77b8b5e8493ac75f508354c76a
uvamiao/MyLeetcode
/486 Predict the Winner.py
2,580
3.765625
4
### Mock interview ### 486. Predict the Winner #Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of #the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number #will not be available for the next player. This ...
094458b0a607dd1c6b198da5e90032f69ae5fccb
jneug/schule-projekte
/Grundlagen/TigerJython/PlottingFractures.py
746
3.625
4
# inspired by # https://www.youtube.com/watch?v=kMBj2fp52tA from gturtle import * from math import degrees dist = 20 base = 10 ang = 360/base num = 1 den = 119 n = 10000 # https://stackoverflow.com/a/33699831 def infinite_divide(numerator, denominator, n): if numerator > denominator: raise ValueError(...
6b638d4bb9f8dc58ce2237ff632d4da9bef9e76a
jashjchoi/holbertonschool-higher_level_programming
/0x0F-python-object_relational_mapping/0-select_states.py
766
3.515625
4
#!/usr/bin/python3 """lists all states from the database hbtn_0e_0_usa:""" import MySQLdb import sys def get_states(): """takes 3 arguments to list from db argv[1]: mysql username argv[2]: mysql password argv[3]: database name """ db = MySQLdb.connect(host="localhost", ...
c90836a31745a92c698b3b4eb1993e08b6a43304
innalesun/repetition-of-the-material
/stepik/dict(возрастание по значению).py
764
3.9375
4
# Напишите скрипт Python для сортировки (возрастания и убывания) словаря по ключу d = {'n': 250, 'b': 100, 'a': 500, 'c': 400, 'm': 50} print(d) K = [] for i in d.keys(): K.append(i) print(K, type(K)) K_1 = sorted(K) d_1 = {el: d[el] for el in K_1} print(d_1) K_2 = sorted(K, reverse=True) d_2 = {el: d[el] for...
3d3d210dea4223a487c3d5265e7def6ead4be403
Suraj124/Rock_Paper_Scissors
/RPS_account_setup.py
697
3.8125
4
print("----------------------------") print("ROCK PAPER SCISSORS ACCOUNT") print('----------------------------') while True: username=input("Enter your Username : ") password=input("Enter your Password : ") password_comfirm=input("Confirm yous password : ") if password!=password_comfirm: print(...
8adb68493c4c32374f24f4adc6a44b75f6f88033
Phippre/New-2D-Game
/spritesheet.py
2,127
3.734375
4
import pygame import json #Spritesheet class, used for parsing through the JSON file to grab names and coordinates for the image in the spritesheet. #Then returns the requested sprite class Spritesheet: def __init__(self, filename): self.filename = filename #Setting the file path inputted (your spriteshee...
4714f3c64eaf3f562e3017b61c99a268790a9379
Kavikick/CarTracker
/ Python/src/Backend.py
1,010
3.53125
4
''' Car and Tracker classes for managing positions ''' from datetime import timedelta class Car: def __init__(self, number): self.number = number self.lapsCompleted = 0 self.time = timedelta() self.laptimes = [] def update(self, newtime): difference = newtime - self.ti...
9d19e7c75be3171d7279cf41b82c8c4e614d381f
jupyter-notebooks/data-descriptors-and-metaclasses
/notebooks/solutions/descriptors/ex4.py
912
4
4
"""A prices with VAT. """ class Total(object): """Allow only positive values. """ def __init__(self, rate=1.19): self.rate = rate def __get__(self, instance, cls): return round(instance.net * self.rate, 2) def __set__(self, instance, value): raise NotImplementedError('Ca...
b5ade724a90cb868f737a80bc9f91c258659e08b
danielscarvalho/FTT-MINICURSO-PYTHON-2021-2
/p2.py
164
3.640625
4
def calc(val): if (val % 2 == 0): val = val**2 else: val = 1/val*1000 return val print(calc(22), type(calc(22))) #print(calc("x"))
f8c433ce9c86ccc4a008308c3709adc8064eb88d
Chasinggoodgrades/pygame
/pygame/night _template.py
2,493
4.1875
4
# Computer Programming 1 # Unit 11 - Graphics # # A scene that uses loops to make snow and make a picket fence. # Imports import pygame import random # Initialize game engine pygame.init() # Window SIZE = (800, 600) TITLE = "Night" screen = pygame.display.set_mode(SIZE) pygame.display.set_caption(T...
5f613d5e94bb7c0277f587e94cf1b87b60e71508
Jorgefebres/python-tut-pildoras
/filter.py
963
3.71875
4
# def numero_par(num): # if num % 2 == 0: # print("ES PAR") # else: # print("NO ES PAR") numeros = [7, 8, 9, 1, 2, 55, 54, 15, 15, 85] print(list(filter(lambda numero_par: numero_par % 2 == 0, numeros))) print("_-------------------------------------_") class Empleado: def __init__(self, ...
e0257457ef7171a10e0e9a35da048aeff4a84605
drStacky/ProjectEuler
/119_DigitPowerSum.py
774
3.859375
4
''' Created on Jan 10, 2017 The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 8^3 = 512. Another example of a number with this property is 614656 = 28^4. We shall define an to be the nth term of this sequence and insist that a number must contain at lea...
d16042d78d6b34864bdb7cf569ad69804369cd00
danhpaiva/cfb-python-2020
/aula07/aula07.py
477
3.9375
4
# Strings Parte 02 texto = "Curso de Python" palavra = "python" resposta = palavra.upper() in texto.upper() print(resposta) resposta = palavra not in texto print(resposta) curso = "Python" canal = "CFB Cursos" resultado = curso + " do canal " + canal print(resultado) dia = 26 mes = "Agosto" ano = 2020 cidade = "Be...
9b2bbbe1166dde89e9db87ed11b722e0a1c385c1
paul-wie/Biologically_Inspired_Computing
/assignmnet1/hill_climbing.py
3,288
3.5625
4
from common import * from timeit import default_timer as timer import numpy as np import as rand import itertools as iter import sys #mainimizes the route length of a random route by swapping pairs of cities def hill_climbing(number_of_cities): data = import_data() cities = get_set_of_cities(number_of_cities,...
e381b07f7d861761a73092a8ec900ff8315230bf
HowardHung2/YoutubeCourse_Python_Basic_20210804
/basic_calculator.py
547
3.953125
4
# 建立一個基本計算機 from typing import AsyncGenerator name = input("請輸入您的名字 : ") print("哈囉, " + name + "\n歡迎體驗簡易計算機") print("====第一部分 整數計算機====") num1 = input("請輸入第一個整數數字 :") num2 = input("請輸入第二個整數數字 : ") print(int(num1)+int(num2)) print("====第二部分 小數計算機====") num3 = input("請輸入第一個小數數字 :") num4 = input("請輸入第二個小數數字 : ") print(...
f39e0bb7f528666917cd8d9f8542ca62a2e834aa
joycemaferko/Chinese-Chess-Xiangqi
/xiangQi.py
35,862
4
4
# Author: Matthew Joyce # Date: 12/23/2020 # Description: Implemenation of Chinese Chess (Xiangqi) in Python. The rules # can be found here (https://en.wikipedia.org/wiki/Xiangqi). # # This game is played using algebraic notation to represent the squares on # the board. For example, "a4" represents the piece in col...
badfd272acf2efa16e28d9190c3194ad47e964ec
ipero/python_learning_curve
/codecademy/lists_and_strings.py
4,787
3.921875
4
# slice strings and lists animals = "catdogfrog" cat = animals[:3] # The first three characters of animals dog = animals[3:6] # The fourth through sixth characters frog = animals[6:] # From the seventh character to the end print cat, dog, frog suitcase = ["sunglasses", "hat", "passport", ...
783d33e353be1a8fc9033731f1b998d2f378a9db
misaka-10032/leetcode
/coding/00025-reverse-nodes-k-group/solution_py2.py
1,656
3.65625
4
# encoding: utf-8 """ Created by misaka-10032 (longqic@andrew.cmu.edu). TODO: purpose """ # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def reverse_group(self, start, end): q, p = None, start...
90eea7c6c34a30facab61cff4541d07f8eaeeb0d
Davidhfw/algorithms
/python/sort/147_insert_linkedlist.py
1,552
4.09375
4
import time # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def insertionSortList(self, head): """ 例题演示 0: d -> 2 -> 1 -> 4 -> 3 1: d -> 2 -> 1 -> 4 -> 3 """ dummy = Li...
25eecba9beb66b05fc5a28d832e90045ed952274
azrap/Data-Structures
/binary_search_tree/binary_search_tree.py
5,679
3.890625
4
import sys from dll_queue import Queue from dll_stack import Stack from doubly_linked_list import * """ * Should have the methods `insert`, `contains`, `get_max`. * `contains` searches the binary search tree for the input value, returning a boolean indicating whether the value exists in the tree or not. * `get...
64e1e54e1d01b97b61b0c403c4ab393146eadcd4
AlchemistPython/chessgame_console
/board.py
1,215
3.5
4
# C = Castillo, N = Caballo, K = king, Q = Queen, P = Peon, B = Alfil # B = black, W = white # otra prueba xd class chessboard: def __init__(self): self.WIDTH,self.HEIGHT = 8,8 self.counter = 0 self.pieces = [chr(x) for x in range(97,105)] def create_board(self): board ...
4bf828d9e51222f56790ed9c8d0b6a5d79399098
moabdelmoez/road_to_pythonista
/Lec 5/for_statement.py
519
4.09375
4
#For Loop #-------- #friends = ['Mamdouh', 'Shaf3y', 'Masry'] #for friend in friends: # print('Eid Mubarak:', friend) #print('Done!') ########################################### #Counting loops #-------------- #count = 0 #for num in [3, 41, 12, 9, 74, 15]: # count = count + 1 #print('C...
1d69285362f9d653927fd943d9772c6f985be764
siddhiparkar151992/DataStrcucturesImpl
/PriorityQueue.py
822
3.71875
4
''' Created on May 20, 2016 @author: Dell ''' class PriorityQueue(object): ''' classdocs ''' def __init__(self): self.queue = [] def put(self, item): data, priority = item def is_empty(self): return len(self.queue) def insert(self, data):...
f0218a4ca7d7dcbabecda277d96f811781f7daa0
tintinrevient/methods-of-ai-research
/part-1/keywords.py
5,950
3.859375
4
""" Python code that implements a keyword matching baseline """ def utter(): """ Predict the user dialog act using a keyword matching baseline """ model = init_model() feedback = { "count": 0, "yes": 0, "no": 0 } try: while True: print("Please ...
e31cbbcf30028184ecfc6c3810cc46793b2b59ee
Irish-Life/Coding-Challenges
/Week 1/Charles/week1.py
601
3.71875
4
num_list = [1, 6, 5, 3, 5, 6, 10, 11, 3, 106, 8] k = 16 def list_check_sum(n: list, k: int) -> bool: i = 0 compare_num = n.pop(i) # pops first element from list and assigns to compare_num while i < len(n): if compare_num + n[i] == k: # if we find a match return True print(f"{compare_...
9a5af9b6461a764f88ec335cea7c146b7e180909
mauricioolarte/holbertonschool-web_back_end
/0x04-pagination/1-simple_pagination.py
1,615
3.96875
4
#!/usr/bin/env python3 ''' named index_range that takes two integer arguments page and page_size ''' from typing import List import math import csv def index_range(page, page_size): ''' takes two integer arguments page and page_size return a tuple of size two containing a start index and an end ...
7b554bd2f341945e7018eeda15b388f994fab52d
grigor-stoyanov/PythonOOP
/workshop/hashtable.py
4,344
4.09375
4
"""Implementing a dictionary with 2 lists""" from copy import deepcopy class HashTable: def __init__(self): """2 private empty lists""" # max_capacity increases to 8,16,32... when it exceeds capacity self.max_capacity = 4 self.__keys = [None] * self.max_capacity self.__valu...
401f3e12e9ba5f197490550abcecf3a5b8071b48
Junyang-chen/PythonLearning
/detectCyclesInGraph.py
1,211
3.5
4
""" Determine if a graph is DAG(Directed Acyclic Graph) """ from collections import OrderedDict def detect_cycle(inputs): if not inputs: return True graph = OrderedDict() for node_edge in inputs: node = node_edge[0] edges = node_edge[1] edge_set = graph.get(node, set()) ...
5d493ff6656049ec7d887620f6165b49adad155f
alvina2912/CodePython
/List/List_comprehension.py
378
4.21875
4
# Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. # Write one line of Python that takes this list a and makes a new list # that has only the even elements of this list in it. a=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100] result=[] for i in a: if i%2==0: result.appen...
ffb0309597f53693a767c60e2d191d4755760369
sineadcullinane/cs2016-2017
/semester1/cs2513/assignment5/squaregame.py
1,192
4.0625
4
"""Import random and tkinter from python library """ import random from tkinter import * #root = Tk() class SquareGame(object): """Class to represent the square game """ def __init__(self, root): """Constructor for square game """ self.canvas = Canvas(root, width=500, height=500)...
44bd914e2a0f950cb50f1bbd8f9d3e091d43a9cd
leehour/ProgramProblem
/LintCode/11_Search Range in Binary Search Tree.py
970
3.921875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/5/11 8:05 # @Author : leehour """ Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: param root: The root of the binary sear...
c13ac85109b3bd54f0387658f933d8ce65273adf
jflowaa/datastructures
/trie/trie.py
1,029
4.125
4
class Node(object): def __init__(self, letter): self.pointers = list() self.letter = letter self.end_of_word = False class Trie(object): def __init__(self): self.root = Node("") self.current_node = self.root def insert(self, word): self.current_node = self....
1f36ee222b2fc3c9203ea1a8d8a08efca3b5d6da
sharkwhite21/Desarrollo_web
/POO/Class.py
771
3.890625
4
'''class Curso(object): nombre= "Marlon" def Saludar(self,saludo): print( saludo + self.nombre) Marlon = Curso() Marlon.Saludar("Hola mi nombre es ") ''' class Usuario: """docstring for Curso.""" def __init__(self, nombre): #Metodo constructor self.nombre = nombre def Sa...
2cb22fdca571d5ba05460e5022005a4b6bb95996
pflun/advancedAlgorithms
/widthOfBinaryTree.py
981
3.703125
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def widthOfBinaryTree(self, root): self.mleft = 0 self.mright = 0 def helper(root, offset): if...
16ef6f37661875e6e533eeead7e35b72e2c680ef
plusyou13/py_tools
/acwing/python版本/下一个排列.py
1,266
3.90625
4
''' 31. 下一个排列 实现获取 下一个排列 的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 必须 原地 修改,只允许使用额外常数空间。 示例 1: 输入:nums = [1,2,3] 输出:[1,3,2] 示例 2: 输入:nums = [3,2,1] 输出:[1,2,3] 示例 3: 输入:nums = [1,1,5] 输出:[1,5,1] 示例 4: 输入:nums = [1] 输出:[1] 提示: 1 <= nums.length <= 100 0 <= nums[i] <= 100 ''' from typing ...
016a162c493568f6a56d1feef928629dc7faa3fc
vladandmir97/python-GB
/HW5.py
2,599
3.765625
4
#!/usr/bin/env python # coding: utf-8 # In[197]: #1 задача with open('dz5_1.txt','w') as file: while True: text = input('Введите текст для окончания введите пустую строку: ') if text!='': file.write(text+'\n') else: break # In[199]: #2 with open('lists.txt','r'...
339eff6de7a992653d8f6771b328bdaa4d288816
MtSopris/Python-Challenge-
/PyBank/Main.py
2,547
3.625
4
#This code calculates total months reviewed, the net total over that period, the avrage change in p/l, and the greatest increase/decrease import os import csv csvpath= os.path.join('Resources','budget_data.csv') csvpath_w= os.path.join('Analysis','PyBank.txt') with open(csvpath) as csvfile: with open(csvpath_w,'...
82f6ee4158f66524ead379157e221e2d1634cb3f
shifteight/python
/crashcourse/restaurant.py
683
3.53125
4
class Restaurant(): def __init__(self, name, type): self.restaurant_name = name self.cuisine_type = type self.number_served = 0 def describle_restaurant(self): description = self.restaurant_name + ' ' + self.cuisine_type print(description.title()) def open_...