blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9bd8ea39e983b8f79ee563c5bfd4d644f0ff0c7e
SHANK885/Python-Basic-Programs
/q60.py
427
4.1875
4
''' The Fibonacci Sequence is computed based on the following formula: f(n)=0 if n=0 f(n)=1 if n=1 f(n)=f(n-1)+f(n-2) if n>1 Please write a program to compute the value of f(n) with a given n input by console. ''' def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return fibonacci(n-1)+fibona...
c11d24c911c55f0fc82c35943c41313700225fe3
mavb86/ejercicios-python
/seccion7/ejercicio03.py
1,061
4.09375
4
# Ejercicio 3 # # Crear una función que calcule la temperatura media de un día a partir de la temperatura máxima y mínima. # Crear un programa principal, que utilizando la función anterior, # vaya pidiendo la temperatura máxima y mínima de cada día y vaya mostrando la media. # El programa pedirá el número de días que s...
21875d46b665535e010a8af7c750aeb7b1c438e3
fdima/GB-algAndStructData
/HW1/task3.py
1,245
3.734375
4
# Написать программу, которая генерирует в указанных пользователем границах: # случайное целое число; # случайное вещественное число; # случайный символ. import string import random as rnd action = input("Введите желаемый тип данных:\ \ni: целое\ \nf: вещественное\ \nl:...
cad343ca66cd0bf75460ed0bdbaa5e0d5c78ac3f
meening42/ProjectEuler
/19_sundays.py
286
3.921875
4
import calendar # How many Sundays fell on the first of the month # during the twentieth century # (1 Jan 1901 to 31 Dec 2000)? sum =0 for year in range(1901,2001): for month in range(1,13): if (calendar.weekday(year, month, 1) == 6): sum = sum +1; print(sum)
78ff5601cbcf854c770130de391ca8da6b735406
zzong2006/coding-problems-study
/pythonProject/leetcode/maxWidthOfVerticalArea.py
547
3.59375
4
from typing import List class Solution: def maxWidthOfVerticalArea(self, points: List[List[int]]) -> int: points.sort(key=lambda x: x[0]) answer = 0 start = points[0][0] for i in range(1, len(points)): answer = max(answer, points[i][0] - start) start = point...
496c8756ea4d1ba523773376c7ba87fdb2c43dc2
sgscomputerclub/tutorials-python
/Week 1/Tutorial Walkthrough/4-StringManipulation.py
1,975
4.46875
4
''' Basic Manipulation of Strings ''' text = "Hello World" # Note: You Cannot Perform the integer manipulation on strings as you can't add numbers to a phrase! num = str(23) # This is equivalant to num = "23", 23 is a string now, not a number, that means you can't add to it numerically but it's the same as any oth...
b63de08ac96ffeec4d95d487323bcb1499b76676
barawalojas/Python-tutorial
/Season 06 - Files in Python/Episode 03 - Project - Quiz System/app.py
815
3.65625
4
# read from questions.txt and append each line into a list questions = open("questions.txt", "r") # read from questions.txt # read all lines and get rid of line break for each line, then append each stripped line to a list question_list = [line.strip() for line in questions] questions.close() score = 0 # initialize...
03f914ee534f50bfff73a5212de0c7e569ee8b38
TejaswitaW/Advanced_Python_Concept
/OOP11.py
750
3.84375
4
#use of has-A relationshhip class Car: def __init__(self,model,price,name): self.model=model self.price=price self.name=name def getinfo(self): print("Car model is: ",self.model) print("Car Model name is: ",self.name) print("Car price is: ",self.price) class Emp: ...
1812ca099320378a53c6ee90fb8d5a9b8a2850a1
LitaiRenGit/FullTime-coding-test
/compressed.py
875
3.578125
4
# -*- coding: utf-8 -*- """ Created on Wed Aug 12 10:13:01 2020 @author: renli """ def compress(chars) -> int: if not chars: return 0 char_ptr=chars[0] write_index=0 char_counter=0 chars.append(None) for i,char in enumerate(chars): if char==char_ptr: char_count...
f6a3cd8e1fb7bbd9844605533012f56196e597ba
tohungsze/Python
/other_python/prime_numbers.py
3,026
3.75
4
# tries to compare time difference when calculating prime numbers in 1-1000 # first method is brute force (somewhat optimized) # second method tries to eliminate all numbers which are multiple of previously # calculated numbers (Sieve of Eratosthenes) # strangely, Sieve of Eratosthenes is slower than the first meth...
4de8893d396fac7adc1b53e836426432a8f094a7
sunchit17/Tkinter-Apps
/calc.py
3,087
4.09375
4
from tkinter import * root = Tk() root.title("Calculator App") e = Entry(root, width=50, borderwidth=5) e.grid(row=0,column=0,columnspan=3,padx=10,pady=10) def btn_click(number): current=e.get() e.delete(0,END) e.insert(0,str(current)+str(number)) def button_add(): first_num = e.get() ...
83e50ef167f364ab8834278567b66338c23f5873
alokpawar/alokpawar.github.io
/CODE/multiple_of_3.py
159
4.1875
4
def multiple_of_3 (n): return (0 if (n % 3) else -1) n = 7 ret =multiple_of_3 (n) if ret: print("multiple of 3") else: print("not multiple of 3")
d7af8fcb0c84cf4aad88bd45fd63ddd3533026c9
nopomi/hy-data-analysis-python-2019
/hy-data-analysis-with-python-summer-2019/part03-e09_multiple_graphs/src/multiple_graphs.py
403
3.65625
4
#!/usr/bin/env python3 import matplotlib.pyplot as plt import numpy as np def main(): a = np.array([2,4,6,7]) b = np.array([4,3,5,1]) c = np.array([1,2,3,4]) d = np.array([4,2,3,1]) plt.plot(a,b) plt.plot(c,d) plt.title("Strange snakes seen from above") plt.xlabel("other fence wall") ...
e7c317a2c9357c88ddd33419c994154646315bce
soohyunii/algorithm
/mailProgramming/algorithm09_none.py
576
3.5625
4
inarray = list(input("Input : ")) temparray = [] outarray = [] inarray.sort() keyarray = list(set(inarray)) for i in range(0, len(keyarray), 1) : if (keyarray[i] + 1) in keyarray : temparray.append(keyarray[i]) elif (keyarray[i] -1) in keyarray : temparray.append(keyarray[i]) temparray.append('Blind') else ...
308337308ea91ffbca58999fe73ef587cd53eae1
mikolajmarcinkiewicz/Zadania-zaliczeniowe
/zad 31.py
390
3.515625
4
#31. Korzystajac z instrukcji np.random.choice # oraz reshape z pakietu numpy stworzyc funkcje # generuja macierz kwadratowa stopnia N wypelniona wartosciami 0 i 255 w losowy sposób import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation def randomGrid(N): return np.random.cho...
94abbb5a551adcfff60eb893952eee8eaa00d2d4
dltkqnr/algorithm
/coding_test/Binary_Search/basic/sequential_search_186.py
800
3.5625
4
# 순차 탐색 소스 코드 구현 def sequential_search(n , target, array): #각 원소를 하나씩 확인하며 for i in range(n): # 현재의 원소가 찾고자 하는 원소와 동일한 경우 if array[i] == target: return i + 1 # 현재의 위치 반환 (index는 0부터 시작하므로 1 더함) print('생성할 원소 개수를 입력한 다음 한 칸 띄고 찾을 문자열을 입력하세요.') input_data = input().split() n = int(...
56250de5a69f1488bd7a14206a158c3d351a3f97
James-E-Sullivan/BU-MET-CS521
/Module-1/HW_1.5_Sullivan_James.py
241
3.9375
4
''' (Compute expressions) Write a program that displays the results of ((9.5 * 4.5) - (2.5 * 3)) / (45.5 - 3.5) ''' # Assigns expression to variable x x = ((9.5 * 4.5) - (2.5 * 3)) / (45.5 - 3.5) # Result of expression is printed print(x)
9ce41ae0a81ff8dddcfc81d47623f0852275bd01
mrklyndndcst/100-Days-of-Code-The-Complete-Python-Pro-Bootcamp-for-2022
/Beginner/D005_Python_Loops/ProjectD5_Password_Generator.py
1,596
3.828125
4
#Password Generator Project import random let = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] num = ['...
8e25b4c525b8f542fa555ee8295748a4e3db989c
DaviMoreira58/PythonExc
/exc033.py
921
3.890625
4
# Faça um porgrama que leia tres numeros e mostre qual é o maior e qual é o menor ''' a = int(input('Primeiro valor: ')) b = int(input('Segundo valor: ')) c = int(input('Terceiro valor: ')) if a<b and a<c: menor = a if b<a and b<c: menor = b if c<a and c<b: menor = c if a>b and a>c: maior = a if b>a and...
500ffd367f4d58ea15ee421e87e825e6fc117eee
HannaRoesener/LPTHW
/EX11/ex11-myquestions.py
439
3.65625
4
print "What is your name?", name = raw_input() print "What is your favourite colour?", colour = raw_input() print "Would you like to have some apple crumble?", answer = raw_input() print "What are you studying?", subject = raw_input() print "Hello %r" % name, print "I like the colour %r, too." % colour print "Good dec...
e9faff86f1d78ea07bd30c2678129ba902e8c311
mauriliobenevento/Phyton
/Algoritmo060.py
373
3.96875
4
# Algoritmo060.py # # Quebrando palavras espaçadas de uma string # Após a quebra é gerado um indice como na lista # - aqui começa um pouco sobre DS e sentimental analysis # # By Maurilio Benevento - 08/07/2019 string = 'Um dia eu vou voltar para a minha cidade' quebra = string.split() print(quebra) print(len(quebra...
67749d30f6d27cad1429273cb596112859ba41e4
checonunez74/testAccount
/testAccount.py
1,481
4.53125
5
''' This program demonstrates the Account class. creates an Account object with an account id of 1122, a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000, and print the id, balance, monthly interest rate, and monthly interest. ...
0521225e2cf01df9e4269818b08a0f473fc2f512
ellecodes/hackbright-exercises
/Ex08_markov_chain/markov_v1.py
2,712
3.890625
4
import sys import random def main(): args = sys.argv # Change this to read input_text from a file script, filename = args f = open(filename) input_text = f.read() f.close() return make_chains(input_text) def make_chains(text): """Takes an input text as a string and ...
1287da98bc760526dcacbd048b3ca938e1595fee
cherumanoj05/password-generator
/passgnrtr.py
1,343
3.9375
4
# password generator import random password_dict = {} numbers = [0,1,2,3,4,5,6,7,8,9] letters =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] sym...
5ac40959948b4cba82e4e470a01ac5aa3acfeb05
namnamgit/pythonProjects
/par_ou_impar.py
162
4.21875
4
while True: numero = int(input('Digite um numero inteiro: ')) if numero % 2 == 0: print('Este número é par!\n') else: print('Este número é ímpar!\n')
b6ab1d2dcab1f154738ce66ff0bd9e08b3c58e38
ChaeMyungSeock/Study
/Algorithm/Beakjoon/1053.py
1,774
3.734375
4
string_a ="babacvabba" # string_a = list(string_a) # string_a.reverse() # print(string_a) from collections import Counter string_a = list(string_a) cnt = 0 b = len(string_a) print(b) if(b%2==1): string_b = string_a[:b//2] string_b.reverse() string_c = string_a[b//2+1:] print(string_b)...
3dfc1ab132e6fc1dc02653396fe488e2c48f4eda
Ramc23/hackerrank_problems
/plusminus.py
783
3.90625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'plusMinus' function below. # # The function accepts INTEGER_ARRAY arr as parameter. # def plusMinus(arr): # Write your code here plus = 0 minus = 0 zero = 0 n = len(arr) for x in arr: if (x...
2b809a96a197c4ca51b8bb9e7674553171087914
jiudianren/mypy
/pycom/pycom/flowControl.py
965
3.71875
4
import time import random TIME_UNIT = 10 CNT_UNIT = 100 total_cnt = 0; last_time = 0; cur_time = 0; def flowContral( cnt): global last_time global cur_time global total_cnt if last_time == 0 : last_time = time.time() cur_time = time.time() total_cnt += cnt if total_cnt...
f4d1152387d76f6f631865466d389e9eeb73cec6
asikurr/Python-learning-And-Problem-Solving
/15.Chapter fifteen - OOP in Python-/price_discount.py
1,187
3.765625
4
# Price discount # Using class variavle class Laptop: p_discount = 10 # Class Variable def __init__(self,brand_name,model_name,price):#__init__ is a constructor self.brand_name = brand_name self.model_name = model_name self.price =price self.name = brand_name+ '-'+model_name ...
31733112eb8c85f67ecc29305bb972ff8b9a6280
Gopichand184/python-basics
/bin/w1_day2.py
1,840
4.0625
4
# reversing the tuple Tuple = (10, 20, 30, 40, 50) tuple1 = Tuple[::-1] print(tuple1) Tuple = ("Orange", [10, 20, 30], (5, 15, 25)) print(Tuple[1][1]) # swapping tuples tuple1 = (11, 22) tuple2 = (99, 88) tuple1,tuple2 = tuple2,tuple1 print(tuple1) print(tuple2) # copiying elements into another tuple tuple1 = (11, 2...
f98ea4ca9dc7bce8d2920af8ffcc33d4b12a3e05
CDL-Project-Euler/solutions
/076-100/p081/inle/inle.py
688
3.640625
4
def get_array(file_name: str): with open(file_name) as f: array = [[int(x) for x in line.split(",")] for line in f] return(array) def min_path_sum1(array): #row 0 for x_pos in range(1, len(array[0])): array[0][x_pos] += array[0][x_pos - 1] #column 0 for y_pos in range(1, len(a...
5ee26f1a23ffb9cd3f2b41bcfb709e24c998d31d
Jiun-Jie/guess_number
/guess_number.py
459
3.671875
4
import random start = input('請決定隨機數字範圍開始值: ') end = input('請決定隨機數字範圍結束值: ') start = int(start) end = int(end) r = random.randint(start, end) count = 0 while True: count += 1 x = input('請輸入數字:') x = int(x) if x == r: print('你共猜了', count,'次,終於猜對了!') break elif x < r: print('比答案小!') elif x > r: print('比答案大!'...
772d24943557d8ef4aa2f3db24a514ac2ea725e4
pratikshirsathp/YTseries-dsalgo
/linear_search.py
377
3.75
4
def linear_search(list, target): for i in range(0,len(list)): if list[i] == target: return i return None def verify(index): if index is not None: print("target found at index",index) else: print("target not found") numbers = [1,2,3,4,5,6,7,8,9,10] result =linear_search(numbers,12) verify...
0e026cf3bedadc9accc31c8c19bd418900044a06
practicallypredictable/litecore
/src/litecore/irecipes/misc.py
4,870
3.84375
4
"""Miscellaneous functions acting on iterators and iterables. """ import itertools from typing import ( Any, Callable, Iterable, Iterator, Optional, ) def force_reverse(iterable: Iterable[Any]) -> Iterator[Any]: try: return reversed(iterable) except TypeError: return reve...
114c137fde08b6542220e6b8c04256fefdc3d41b
rui725/save22-calib-test
/calculator/calculatorv2.py
988
4.0625
4
def add(num1,num2): return num1 + num2 def subtract(num1,num2): return num1 - num2 def multiply(num1, num2): return num1 * num2 def divide(num1, num2): return float(num1) / float(num2) def inputOne(input = raw_input): return int(input("First number: ")) def inputTwo(input = raw_input): ret...
07529b8bd96bcf999451bd98f59ceece81a5845c
zhangxingru/Python_learning
/d25_4_Rlock.py
1,234
3.921875
4
import threading import time #参数定义了最多几个线程可以使用资源 semaphore = threading.Semaphore(3) def func(): if semaphore.acquire(): for i in range(2): print(threading.current_thread().getName() + "get semapore") time.sleep(5) semaphore.release() print(threading.current_thread().getN...
96f3ed58b3662a9d716609d64464593a6963933d
ypeels/python-tutorial
/3.1.2-strings.py
3,206
3.984375
4
# The string printing rules at the beginning of 3.1.2 only apply in INTERACTIVE mode?? # print "\n\n" # print "Strings are printed as they would be typed with SINGLE QUOTES on the outside:" # print 'asdf' # 'asdf' # print "asdf" # 'asdf' # print '"asdf"' # '"asdf"' # print "\'asdf\'" # # '"asdf without print"' ...
9c4528ae03e58bbb43af60d36cb29d6e882563f7
qizongjun/Algorithms-1
/CrackingTheCodingInterview/字符串/基本字符串压缩/main.py
1,022
3.828125
4
# coding=utf-8 ''' 利用字符重复出现的次数,编写一个方法,实现基本的字符串压缩功能。 比如,字符串“aabcccccaaa”经压缩会变成“a2b1c5a3”。若压缩后的字符串没有变短, 则返回原先的字符串。 给定一个string iniString为待压缩的串(长度小于等于10000), 保证串内字符均由大小写英文字母组成,返回一个string,为所求的压缩后或未变化的串。 测试样例 "aabcccccaaa" 返回:"a2b1c5a3" "welcometonowcoderrrrr" 返回:"welcometonowcoderrrrr" ''' ''' 没有难度 ''' # -*- coding:utf-8...
a15f5cfa404cc6ea54eb765f4ce458b52e7aa999
1050669722/LeetCode-Answers
/Python/problem0073_temp.py
830
3.53125
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 6 17:02:15 2019 @author: Administrator """ class Solution: def setZeroes(self, matrix: list) -> None: """ Do not return anything, modify matrix in-place instead. """ d = {} d['R'] = [] d['C'] = [] for r, val in...
c77a978c2dd379229f971b9973c6499879228ff8
LieChe/1
/test-1.py
79
3.53125
4
age = int(input()) if age>18: print('成人') else: print('青年人')
0964904bd82e51eb4ee5a1124f95f588023cc397
rleaf/Acadamia
/110/In_Class/Module4_L1.py
983
4.21875
4
# Ryan Lin, CSC 110, 15 October 2019, Prof Ali # Task 1 # max_temp = 102.5 #Get the temp temperature = float(input("Enter the substance's Celcius temperature: ")) while temperature > max_temp: print('The temperature is too high.') print('Turn the thermostat down and wait') print('5 minutes. Then take th...
f32deef1d9a71bdad29b89dc928bda1b963b0bb3
SamelaBruna/Curso-Python
/ex061.py
241
3.890625
4
p1 = int(input('Digite o primeiro termo: ')) r = int(input('Digite a razao: ')) contador = 0 termo = p1 nTermos = 10 while contador <= 10: print('{}'.format(termo), end=' -> ') termo += r contador += 1 print('FIM')
448a2c0a1c833b493a7a3bc068e499d7f02692b1
avachen17/coding_projects2017
/groups.py
444
3.59375
4
def groups_of_3(list): leftover_list = [] leftover = 0 result = [] if len(list) % 3 != 0: leftover = len(list) % 3 index = len(list) - leftover leftover_list = list[index: len(list)] i = 0 while i != len(list) - leftover: result.append(list[i: i+3]) i += 3 if len(lefto...
b3be3a09077d17b32039daf7df891944234ace87
babouchboy/ESD11
/test.py
852
3.640625
4
################################################ # title - Hello World python # # date - 04/09/2017 # ################################################ ############### function ####################### ############### body ########################### import random r = random.randi...
310be0ffa4b91b076ea3b7072c33f51fa82745f2
jayfranklin-wgu/python
/loops2.py
207
3.828125
4
myNames = 'Bridget', 'Britani', 'Jay', 'Jessica' for name in myNames: for x in range(1,4): # print "Hi {}! ".format(x) % name * x print "Hi %s! " % name * x # expand to tuple, dict, and strings.
061a20b9848b85db47c16e8673ceb3e950ca7e80
jackonii/us-states-game
/main.py
1,123
3.59375
4
import turtle import pandas as pd # pip install pandas import csv FONT = ("Arial", 8, "normal") screen = turtle.Screen() image = "blank_states_img.gif" screen.bgpic(image) screen.title("U.S. States Game") pen = turtle.Turtle() pen.hideturtle() pen.penup() quiz_data = pd.read_csv("50_states.csv") ...
6e8b55b5a0484944686ab75c1eb563d1c6da221e
VladBarbak/kolokvium
/37.py
1,025
3.625
4
""" Розсортуйте заданий лінійний масив по зростанню. Барбак Владислав Дмитрович 122В """ import numpy as np while True: masive = np.array([int(input(f"Введіть число масиву: ")) for i in range(int(input(f"Введіть довжину масиву: ")))]) # Створюємо масив print("Створений масив: ", masive) def bubbleSort(arr)...
6642a7b77ea8ea1a046fb78e32ff11bc811dda93
rohanwarange/Python-Tutorials
/Object Orianted Programing/inheritance.py
787
3.828125
4
class Phone: def __init__(self,brand,name,price):#base class/parent class self.brand=brand self.name=name self.price=price=max(price,0) def make_a_call(self,number): return f"calling..........{number}" def full_name(self): return f"full name is {self.brand}....
4a1642339f7897965acda84dbb7ee622bade1673
drunkwater/leetcode
/hard/python3/c0138_753_cracking-the-safe/00_leetcode_0138.py
1,114
3.59375
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #753. Cracking the Safe #There is a box protected by a password. The password is n digits, where each letter can be one of the first k digits 0, 1, ..., k...
ade2b44b23736d229e85f8d5520204e54e5f4757
bethewind/pylite
/tests/loop/for.py
166
3.59375
4
def f(): for i in [11, 22, 33]: print i f() for i in [-2, -1, 0, 1, 2, 3, 4, 5]: if i < 0: continue print i if i >= 3: break
66015d124050fa912e57201fb4543a9af8cf5657
zcyroot/ImageReader_w_data_augmentation
/Transformer.py
2,645
4.03125
4
import numpy as np class Transformer(object): """ This class provides callable instances that apply specified transformations to images. The instances take as argument an image and return the transformed image. By default, all the transformations in the list 'transforms' will be applied to an image. ...
5d63f16f2d1630ebc136c9fcdcd2e82b7c1a835d
NatielSanti/pythonMLStudy
/regression/nonlinear.py
1,795
3.578125
4
import matplotlib.pyplot as plt import numpy as np import pandas as pd from scipy.optimize import curve_fit from sklearn.metrics import r2_score def sigmoid(x, Beta_1, Beta_2): y = 1 / (1 + np.exp(-Beta_1 * (x - Beta_2))) return y if __name__ == '__main__': # Non - Linear df = pd.read_csv("../resour...
4edb216e176d912b6d169efdfa12511328e5540d
donwb/mlm
/lesson2.py
203
3.640625
4
import numpy import pandas myar = numpy.array([[1, 2, 3], [4, 5, 6]]) rownames = ['a', 'b'] colnames = ['one', 'two', 'three'] df = pandas.DataFrame(myar, index=rownames, columns=colnames) print(df)
dda5c4e07fc09a304fe992bc7734b5b72ba1246c
picardcharlie/python-201
/04_functions-and-scopes/04_06_sandwich_stand.py
548
4.125
4
# Write a function called `make_sandwich()` that sticks to the following: # - takes a type of bread as its first, required argument # - takes an arbitrary amount of toppings # - returns a string representing a sandwich with the bread on top # and bottom, and the toppings in between. def make_sandwich(bread = "Sourdo...
dec51bbaffe3a504c31aa0f79a6dd6608951208f
takeo-yb/theselftaught
/stack.py
1,168
4.0625
4
class Stack: def __init__(self): self.items = [] def is_empty(self): # return self.items == [] return not self.items def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): last = len(self.items) - 1 return self.items[last] # return ...
c9a6eafea2f23d504866196c66165ff398b5fc39
Jaidev810/Competitive-Questions
/CodeWars/CamelCase.py
444
4.15625
4
def CamelCase(string): newstring = '' for i in range(0, len(string)): if i == 0: newstring = newstring + string[i].upper() elif string[i-1] == " ": newstring = newstring + string[i].upper() elif string[i] == " ": continue else: ...
3d81fde69b050d51ac9caa6cb76d02fe0a7a3e83
Jaco5/mac_manipulator
/mac_manipulator.py
1,846
3.921875
4
#!/usr/bin/env python # Media Access Control (MAC) address changer. # This program prompts the user for a new MAC address and what interface to assign it to. # This helps maintain anonymity and allows impersonation. # Input interface type using -i or --interface. # Input a mac address or leave input blank to generate ...
f59fa5933e9b041d2770ca8b94a30d7ad423b91f
hanchaa/Korea_Univ_2020_2
/COSE156/Final exam/HW1.py
248
3.5
4
def cal_sum(para): hap = 0 for i in para: hap += int(i) return hap input_list = input("더할 수를 입력하시오 (여러개 입력가능) > ").split() total = cal_sum(input_list) print('입력한 수의 합계: ', total)
b06fbebf7b7e6746da82a27d4a9421362452ae11
sureshanandcse/Python
/nestedif.py
80
3.859375
4
i =0 while(i<=10): print("i = ", i) i=i+1 print("out of while loop")
4fb7cd26921728707a0509a5b004210c4bb25bcc
Timurdov/Python3.Advanced
/les_8/lab_8a/00-inheritance.py
576
4.0625
4
# -*- coding: utf-8 -*- """ Пример наследования классов """ class Figure(object): def __init__(self, side): self.side = side class Square(Figure): def draw(self): for i in range(self.side): print('*' * self.side) class Triangle(Figure): def draw(self): ...
aafdce0c389502a80723dce8919a0487accaf89e
josdyr/dyrseth_jostein_set09117
/main.py
539
3.546875
4
import game as g from player import Player BOARD_SIZE = 8 NUM_PIECES = 12 debug = False def map_to_point(arg): abc_map = { 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7 } x = int(arg[1]) - 1 y = abc_map[arg[0]] r...
51fbea55c5da86e4d19975fba92e014f0a49af39
wesfox/gotCrawler
/src/helper/date.py
710
3.609375
4
from datetime import datetime def str_to_datetime(str_to_cast: str): if str_to_cast is None: return None try: return datetime.strptime(str_to_cast, "%Y-%m-%d %H:%M:%S") except ValueError: try: return datetime.strptime(str_to_cast, "%Y-%m-%d") except ValueError: ...
7ff4a8da2ec05c27aacb8850eb60c43264122189
sumalatha2020/Assignment-2.1
/PrintListFromCommaSeperatedValues.py
215
4.15625
4
#Accepts comma,seperated values from user values = input("Input comma seprated numbers : ") #split with "," and stores the values in list variable as list of values list = values.split(",") print('List : ',list)
9b6745751e34dc1bb9177d946eb847fabfc0a25b
GlaucoPhd/Python_Zero2Master
/TernaryOperator62.py
308
3.828125
4
#Ternary Operator #ShortCut #condition_if_true if condition else condition_if_else is_friend = False can_message = 'message allowed' if is_friend else 'not allowed to message' print(can_message) is_friend = True can_message = 'message allowed' if is_friend else 'not allowed to message' print(can_message)
b8488b6bcd5673e101281fed7f25304eebac5721
dsperax/dasxlib
/FizzBuzz.py
1,368
3.5
4
#Problema "FizzBuzz" #Para cada um dos numeros de 1 a 100 escreva: #"Fizz" se divisivel por 3, #"Buzz" se divisivel por 5, #"FizzBuzz" se divisivel por 15, # apenas o numero nos outros casos. from typing import List import numpy as np from dasxlib.train import train from dasxlib.nn import NeuralNet from dasxlib.laye...
08de3777d551de46503117f68beeff246eea6038
binkesi/leetcode_easy
/python/n290_WordPattern.py
920
3.59375
4
# https://leetcode-cn.com/problems/word-pattern/ class Solution: def wordPattern(self, pattern: str, str: str) -> bool: strs = str.split(" ") str_dict = {} if len(pattern) != len(strs): return False for i in range(len(pattern)): if pattern[i] not in str_dict.k...
07c62e75d0b02545143cc2c1bb811cfc7407ad2a
nkyono/PE
/lvl_01/prob_042/prob42.py
1,439
4.03125
4
''' The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... By converting each letter in a word to a number corresponding to its alphabetical position and adding these values we form a word value. For example, the wo...
a7a30a5eadb26d657a582f33b580f1f0f661b10c
Sniper970119/Algorithm
/chapter_8/LinearSort.py
2,336
3.59375
4
# -*- coding:utf-8 -*- class LinearSort(): def __init__(self): pass def count_sort(self, init_list): """ 计数排序 :param init_list: 需要被排序的列表 :return: """ max_num = max(init_list) # 初始化辅助列表,为了对齐排序元素,0 index不用,所以+1 assist_list = [0 for _ in ran...
ac067029ee67bc1e7af45789fbf190aaddcad634
WangsirCode/leetcode
/Python/minimux-index-sum-of-two-lists.py
1,222
3.890625
4
# Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. # You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, output all of them with no order requirement. You co...
9c3bff7a92896ef3a110ac1fc5f797e4a213391b
Zahidsqldba07/PythonPrac
/PyPrac5.py
1,312
3.984375
4
#!/usr/bin/env python # coding: utf-8 # # When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return True if the party with t...
e4f6fc135ff9988c01083461040b80d90b1ed7c2
bomin0830/python
/ToKnow.py
2,206
3.546875
4
"""파이썬 문법 할때 알아둬야 할 것들을 적어보자""" """ 1. 연산자 1) +,-,*,/ 2) % : 나머지 3) //: 몫 4) **:제곱 2. 복합대입 연산자 1) a+=1 -> a=a+1 2) a-=1 -> a=a-1 3) a*=1 -> a=a*1 4) a/=1 -> a=a/1 5) a//=1 -> a=a//1 6) a%1=1 -> a=a%1 3. 자료형 1) 자료형 반환 함수 : type(argument) 2) string의 일부분 추출(slice) - [n...
7b5cef673b2a590841428ff4f17db6baefa897fe
manurua123/python2020
/Practica2/ejercicio3.py
304
3.703125
4
original = ['Auto', '123', 'Viaje', '50', '120'] lista_int = [] lista_string = [] for i in original: if i.isdecimal(): lista_int.append(i) else: lista_string.append(i) print('Lista original:' , original) print('Lista enteros:' , lista_int) print('Lista palabras:' , lista_string)
55db9115c6d9e319f2a32922a466cba835bf84cd
KingSpork/sporklib
/algorithms/search_and_sort_algorithms.py
2,377
4
4
import random '''Binary Search''' def binarySearch(someList, target): lo = 0 hi = len(someList) while lo+1 < hi: test = (lo + hi) / 2 if someList[test] > target: hi = test else: lo = test if someList[lo] == target: return lo else: return -1 '''Find duplicates in array/list'''...
9b49288adaac3713d95e6eefc2c2929bcb40626d
shrutikiran/datastructures-algorithms-practice
/bubble-sort.py
455
4.03125
4
import sys def bubbleSort(arr): l = len(arr) for i in range(0, l): for j in range(i + 1, l): if (arr[i] > arr[j]): print('swapping indicies [' + str(i) + ', ' + str(j) + ']') temp = arr[i] arr[i] = arr[j] arr[j] = temp ...
d1e6a3e70ebca573ca782a33d9b748d686143b45
saulgmendieta/talk_python
/random_number_game.py
599
4.125
4
import random print('------------------------------------------') print(' GUESS THE PROGRAM') print('------------------------------------------') random_number = random.randint(0, 100) guess_number = -1 while guess_number != random_number: guess_number = int(input('Guess a number between 0 and 100: '...
3d4bc26fbad824064f3dedf7d06b857b3d2a1655
Ismaelsj/Linear-Regression
/utils/train.py
751
3.703125
4
from predict import predict from cost import cost def fit_with_cost(x, y, theta, alpha, num_iters): m = len(y) cost_history= [] for index in range(num_iters): som = 0 for i in range(m): som += (predict(x[i], theta) - y[i]) t0 = theta[0] - (alpha / m) * som som = ...
9c8dd8c1dd5433494e3eddeb548bd40614f23e15
sibrajas/objCandLinuxKernel
/objCandLinuxKernel/pyth/hello.py
426
3.921875
4
def fib(n): print("hello world") print 'Hell' a,b = 0,1 while b<100: print(a) a,b = b,a+b #print ("Last line") #c = 0 #while c<10: # print (c) # c = c+1 #print("Again last line") fib(5) fib(5) fib(5) fib(5) age = int(input("Enter your age")) if age in range(15,20): print("you are 15 to 20") el...
e0bc5556cd3da31ea81599cf6cde9cf7f34cb934
linzimu/sword2offer
/linked_list/sword2offer_3.py
570
3.90625
4
# py3 class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # 返回从尾部到头部的列表值序列 def printListFromTailToHead(self, listNode): _stack = [] while listNode: _stack.insert(0, listNode.val) listNode = listNode.next retur...
0ebcd9bd8d643b688af0019441a4a7f288a166a2
mitsuk-maksim/tg_mpei_course
/653. Two Sum IV - Input is a BST.py
663
3.546875
4
# https://leetcode.com/problems/two-sum-iv-input-is-a-bst/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def findTarget(self, root: TreeNode, k: int) -> bool: if not root: ...
77a21b90479d8f81b4cb89f0c8057aba7c61b984
manimaran89/python_script
/pract/1.py
136
3.5
4
def incr(x): return x+1 def decr(x): return x-1 def operate(func,x): result = func(x) return result operate(incr,3)
d8939f509039b6acf3000a01b025bf778551e566
rmanovv/python
/simple_currency_converter.py
960
4.28125
4
#Discription: Convert USD to EU or vice versa #Find out what the users whants to convert USD->UU or EU->USD USD = 0.7617 # 1 EU EU = 1.3812 # 1 USD def currency_converter(): user_choice = input("What Do you wont to convert? (1) USD->EU (2) EU->USD \n") if user_choice == "1": user_usd = input("Enter ...
2493b489579535585b3a9d1ff6fce19c43a32333
ghazi-naceur/python-tutorials
/1-data_structures/sets.py
332
3.625
4
if __name__ == '__main__': new_set = set() new_set.add("one") new_set.add("one") new_set.add("one") new_set.add(2) new_set.add("three") new_set.add("three") new_set.add("three") print(new_set) my_list = [1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2] print(set(my_list)) # Casting a l...
93964d1743322a3fb4c77db73f30846201f26b8e
shribadiger/CPPStudy
/LeetCode/PythonCourse/bytes.py
445
3.6875
4
# codeing the functionality of the bytes and how that each bytes are going to work in the each object # let check the functionality of each charector which are assigned to the variable and that is going to data = 'my user data going to encode by encoding technique' encodedData = data.encode('utf-8') print(encodedData) ...
d558ef32513ffa956133fb9153d3cb0ba92ac48d
zhlinh/leetcode
/0345.Reverse Vowels of a String/solution.py
1,028
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-05-24 Last_modify: 2016-05-24 ****************************************** ''' ''' Write a function that takes a string as in...
986e853141151abfa5e6c48cdd4e0db3d4d9c331
Nimble-Jack/python
/python_practice/enumerate.py
758
3.515625
4
def ace_value(a_list): for index, item in enumerate(a_list): if 'A' in a_list[index] and item[1] == 11: item[1] = 1 break return a_list def points(a_list): value = 0 for index, item in enumerate(a_list): value += a_list[index][1] return value ace_count = 0...
70e482d30d9175d7f54c9ba8712aa2567c1ea8c1
maelstrom9/DS-and-Algorithms
/EPI/Linked lists/7.4 overalapping lists.py
925
3.84375
4
class Node: def __init__(self,val=None): self.val = val self.next = None ## checks for overlap,.. ## returns bool overlap? and first overlap node.. def overlap(l1,l2): h1, h2 = l1, l2 ## first l1 and l2 are to be checked as well.. assuming they are not None m = 1 while l1.next: ...
04c73e289bf122b43780e4fcfc70c9940b5b7eb1
devendra3583/Python
/D_Day1/d1.py
697
3.921875
4
print 'Hello World!' print ('Hello World!') # t = 6, y =9 Throws error in python a,b=3,5 print a+b t=6 y=9 print t+y print 'sum of %d & %d = %d'%(a,b,a+b) print 'sum of {1} & {0} = {2}'.format(a,b,a+b) h='hello {}' print h.format('hi') t=7 type(t) #tells type of t in python shell a=raw_input('Enter name:...
92046b9f034b6a40796dafbfc374320eac1c8233
justinchang0630/python
/hw/7/最小公倍數.py
218
3.6875
4
x = int(input("please input a number:")) y = int(input("please input a number:")) if x > y : c = x else: c = y m = x *y + 1 for k in range(c, m): if k % x == 0 and k % y == 0: print(k) break
3d28ff6a4441e378203162af456882ca8450714c
derekpankaew/battlechess
/step_through_game.py
2,341
3.515625
4
import time import chess import chess.engine import pandas as pd import numpy as np from pandas import DataFrame from FEN_to_Array import FENtoArray board = chess.Board() class dataFrameCreator(): def __init__(self): self.result = 0 def addToDataFrame(self,input,winner): ...
7a866c95599bc7ad6b1a9e01103b07e5bdffbf7f
avenet/hackerrank
/algorithms/implementation/kangaroo.py
410
3.765625
4
def kangaroo(x1, v1, x2, v2): value = v1 - v2 diff = x2 - x1 if not value: return 'NO' is_divisible = abs(diff) % abs(value) == 0 return ( is_divisible and diff / value > 0 ) and 'YES' or 'NO' x1, v1, x2, v2 = input().strip().split(' ') x1, v1, x2, ...
03abef20530c9d7a8e5b21b5abb660d9d4aa00bd
vyasakanksha/robot-ludo
/tic_tac_toe/agent.py
7,355
3.765625
4
import ast import numpy as np from utils import log class Agent(object): def __init__(self, sym, exploration_rate=0.90, decay=0.01, learning_rate=0.5, discount_factor=0.01): """ An agent is a problem solver. It should perform actions like: - plotting a symbol on the tic-tac-toe...
a5acef73a01dc09ff8e05700514f4ae57a7ca421
mgbo/My_Exercise
/Python-sqlite-database/employee.py
511
3.703125
4
class Employee: def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay @property def email(self): return '{}.{}@gmail.com'.format(self.first, self.last) @property def fullname(self): return '{} {}'.format(self.first, self.last) def __repr__(self): return 'Employe...
f9f54fb0380cf97f131c1dede8f706ae0be597bb
Audarya07/99problems
/P31.py
548
4.34375
4
# Determine whether a given integer number is prime. from math import sqrt def isPrime(num) : '''A function to check whether a number is Prime or not.''' if num > 1: for i in range(2, int(sqrt(num))+1): # If num is divisible by any number other than itself, return False. if nu...
098c8501227983782167611e802d527742ce29f0
arunabeyaantrix/pythonpractice
/pattern/patterntriangle.py
462
3.859375
4
n = int(input()) k = 2*n -2 for i in range(n): for j in range(k): print(end=" ") k = k-1 for j in range(i+1): print('* ', end = "") print("\r") def triangle(n): k = 2*n - 2 for i in range(0, n): for j in range(0, k): print(end=" ") k = k - 1 for j in range(0, i+...
60225a58098e9cceadbdd187e80eaf10af987495
DmytroGrek/itstep
/lesson5/rainbow.py
338
3.96875
4
rainbow_colors = ("RED", "ORANGE", "YELLOW", "GREEN", "BLUE", "INDIGO", "PURPLE") user_color = (input("Введите цвет: ")).upper() if user_color in rainbow_colors: index = rainbow_colors.index(user_color) if index != 0: print(rainbow_colors[index - 1]) if index != 6: print(rainbow_colors[index...
5eb0f98dcaef568fc22d26341f78748fc27785c7
Mongosaurusrex/mongoChess
/Chess/ChessMain.py
3,874
3.53125
4
""" This is our main driver file. It will be responsible for handling user input and displaying the current GameState object. """ import pygame as p import pygame.display from Chess import ChessEngine WIDTH = HEIGHT = 512 # 400 is another option DIMENSION = 8 # A chessboard is 8x8 SQ_SIZE = HEIGHT // DI...
b2b4c2c27647c54513f183d6fe5d1b64dbb9ecd2
c-hernandez/coding-interview-6e
/02 - Linked Lists/2-4 Partition.py
1,818
3.625
4
from SLL import SLL import unittest def partition(sll, pivot): node = sll.head before_list = None after_list = None while node is not None: # This would be way more efficient if we kept track of list tail # currently it makes an O(n) call to insert every run through the # loop....
f33a2cf00371e3e8bb6924dc07d3d9e04fc167c0
backtothefuture3030/algorithms
/백준10870.py
361
3.90625
4
def pibonacci(n): a=[0,1] b=[] i=0 if n==0: print(0) exit() while i<=n-2: i+=1 a.append(sum(a)) del a[0] print(a[1]) pibonacci(int(input())) ''' def fib(n): if n == 0: return 0 elif n == 1 or n == 2: return 1 else: r...
8179233e4260f04c600e348512aa3de48d30368b
mrcrdg/atividades_iniciais_HUB
/ex09.py
1,690
4.03125
4
#!/usr/bin/env python3 #9 Se o valor gasto por um cliente em um determinado dia for maior ou igual à 2x despesa mediana do cliente por um número final de dias, isso é considerado uma fraude potencial e um alerta é emitido. #Dado o número de dias finais e as despesas diárias totais de um cliente por um período de dias,...
3d5d9fea5c02be37ae8b4db95b1e54eff1138c23
lamdevhs/s4-algo
/syntax.py
274
3.546875
4
from copy import deepcopy # Ex 7 def q1(): m = [[0,1],[10,11]] mc = m[:] mc[0][0] = 4 print m, mc q1() def q2(): m = [[0,1],[10,11]] mc = deepcopy(m) mc[0][0] = 4 print m, mc q2() def q3(): L0 = [0,1] L1 = [10,11] m = [L0,L1] mc = [L0[:],L1[:]] mc[0][0] = 4