blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4fe7620c64941ffbb1750f42401ecb586791c798
MANOJPATRA1991/Cracking-the-coding-interview-solutions-in-Python
/Arrays and Strings/Problem 2/main.py
724
4.28125
4
# Implement a function to reverse a string def rev(s): """ A function to reverse a string Args: s(string): The string to reverse Returns: string: The reversed string """ # SOLUTION I return ''.join(reversed(s)) # SOLUTION II # return str[::-1] # SOLUTION III ...
6e396f5676f54017f5f2f18db5eb630181170f10
Alastair-Revell/process_exercises
/middle_character/character.py
179
3.6875
4
import math def middle_characters(string): x = len(string) / 2 if x.is_integer(): return string[int(x)-1:int(x)+1] else: return string[math.ceil(x)-1]
54f566972e5d57208ea0d44a4a1c36343237f420
Yoo-su/python-algorithm
/이진 검색/이진 검색_LeetCode_704.py
468
3.6875
4
from typing import List class Solution: def search(self, nums: List[int], target: int) -> int: left,right=0, len(nums)-1 while left<=right: center=(left+right)//2 if nums[center]>target: right=center-1 elif nums[center]<target: le...
f715b75010c3f8c85653caec44b7402489dc5e71
felipemcm3/ExerPython
/Pythonexer/ExerPython/aprendendopython/ex011.py
293
3.984375
4
largura = float(input('Informe a largura em metros da parede')) altura = float(input('Informe a altura em metros da parede')) area = largura * altura tinta = area / 2 print('A área da metragem informada foi {} metros ' 'quadrados você gastará {} litros de tinta'.format(area, tinta))
40c93ab9008bcdcf5d1fa187b2ef6944f92adf42
Saelind/code-snippets
/Largest palindrome product.py
534
3.8125
4
__author__ = 'Saelind' def palindrom(): palin_list = [] for i in range(100, 999): for s in range(100, 999): product = i * s product_string = str(product) product_string_reverse = product_string[::-1] if product_string == product_string_reverse: ...
b868615cde78c08e8a6a45e6173997569b3aa404
x4teen/pythondev
/fundamentals/dictionaryExercise.py
923
4
4
cities = {"New York": 9000000, "London": 4000000, "Tokyo": 38140000, "Mumbai": 21357000, "Beijing": 21500000, "Istanbul": 14000000, "Shanghai": 24000000, "New York": 10000000} print(cities) print("=" * 50) for city in cities: print(city, "\t", ci...
239153fdb9055bc22df223fe0298d0721f459b5a
zeddinarief/pemjar
/palindrom.py
2,554
3.65625
4
angka = 923325595 # mengubah integer menjadi string terlebih dahulu strangka = str(angka) def palindrom(x): # membuat array untuk menyimpan string angka yang nantinya akan menyimpan hasil akhir palindrom arr = [] for x in strangka: arr.append(x) # menyimpan angka-angka yang berpasangan ke dalam array a...
155dac96efc18077250f72924dc4ddbf1f2d46bc
nielsonnp/LivroPython_Exerc
/Capitulo_03/exercicio_3.14.py
610
3.859375
4
'''3.14 - Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado pelo usuario, assim como a quantidade de dias pelos quais o carro foi alugado. calcule o preço a pagar, sabendo que o carro custa R$60 por dia e R$0.15 por km rodado''' km_perc = float(input('Quantos km foi percorrido? ')) d...
d306a4d33f33ea4664b490df15e6ca2b5914771c
rmuppala113/ntpdemy
/pig_latin_translator.py
258
3.75
4
user_inpt = input("Please enter you sentence: ") words_list = user_inpt.strip().split() myword = [] for i in words_list: latin = i[:2] pig = i[2:] mylang = pig + latin + "ay" x = myword.append(mylang) print("\n{}\n".format(" ".join(myword)))
d474296d274d537144051cf77a59fa0a92b3dd55
MandragoraQA/Python
/DZ_16.py
740
4.03125
4
#пользователь вводит числа через пробел spisok = [] chislo = input("Введите числа через пробел: ") for a in chislo: if a != " ": spisok.append(a) def sort(spisok): spisok.sort() print ("Отсортировано методом Питон:", spisok) def puzir(spisok): sorti_on = True while sorti_on: ...
87c7d285fff79c4a57e690b52db01793cf4f08ef
umian/testing99
/random01.py
364
3.859375
4
import random random.seed() print("100 random numbers between 1 and 10") for x in range(0,100): print(random.randint(1,10),end=" ") print("") for x in range(1,21): print("move",x, end="") myrandomnum = random.randint(1,5) if myrandomnum ==1: print(" - moving down",myrandomnum) else: ...
3d9fd48a75def45c0110e44b74231b59fd513019
DilyanTsenkov/SoftUni-Software-Engineering
/Python_Advanced/04_Comprehensions/Lab/05_filter_numbers.py
174
3.65625
4
start = int(input()) end = int(input()) numbers = [i for i in range(start, end + 1) for x in range(2, 11) if i % x == 0] numbers = set(numbers) print(list(numbers))
3902fa6f4d9bf70101771cadb6ebb1456ae29fed
karthikeyanthanigai/polynomial-regression
/poly.py
2,029
3.703125
4
# Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('insurance.csv') #this function will provide the descriptive statistics of the dataset.(only int value) dataset.describe() #There are 4 independent variables and 1 dependent ...
6748cd89b5badb0b49fdea11cb2bf4d6da707500
Siddhesh-3/Python
/GUI/Tkinter/canvas.py
650
3.78125
4
from tkinter import * root = Tk() canvas_width = 800 canvas_height= 400 root.geometry(f"{canvas_width}x{canvas_height}") can_widget = Canvas(root, width=canvas_width, height=canvas_height) can_widget.pack() # The line goes from the point x1,y1 to x2,y2 can_widget.create_line(0,0,800,200) can_widge...
fdde1b74f5445cd5a102f92103f11062134c3065
daniel-reich/ubiquitous-fiesta
/yXZhG7zq6dWhWhirt_1.py
224
3.59375
4
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if not n%i: return False return True ​ def filter_primes(num): return [i for i in num if is_prime(i)]
8236587be254235eac3dea7d8c5f2f7d36d809d9
Duckiemaster2022/Joshua_TCSPY3
/opening first file.py
152
3.53125
4
mynewhandle = open("text.txt", "r") while True: theline = mynewhandle.readline() if len(theline) == 0: break print(theline, end="")
6c06b2fd4c5c0c793dcf2f90301ed30e72f18e26
S-J-Kim/Python
/참고 자료/IF_홀짝/홀짝 -최민식.py
352
3.8125
4
# 짝수 구별 x=int(input("숫자를 입력하세요: ")) if x %2 == 0: print('{}는 짝수입니다.'.format(x)) else: print('{}는 홀수 입니다.'.format(x)) a=(input("숫자를 입력하세요: ")) x=[2,4,6,8,0] if int(a[-1]) in x: print('{}는 짝수입니다.'.format(a)) else: print('{}는 홀수 입니다.'.format(a))
6536fbd1e570c931cd6f326e927b3d031e502bf9
siddarthjha/Opencv
/Image Processing/02_Thresholding.py
2,874
4.125
4
""" The function used is cv2.threshold. First argument is the source image, which should be a grayscale image. Second argument is the threshold value which is used to classify the pixel values. (For Otsu Binarization pass 0) Third argument is the maxVal which represents the value to be given if pixel value is more tha...
f3d1ac078838ea8ca9b31d5ed0ea10fd61327982
radu-cernatescu/shopping-cart-python
/shopping_cart.py
3,999
4.25
4
#Cart class is defined class Cart(object): #__init__ method is defined def __init__(self,customer): #self.customer is defined using the user defined input self.customer = customer #if the customer country is Canada, a tax of 13 percent is added to the price along with free shipping...
019ad5304ff494dc5aa8df8284fcccc3e9b4981a
Troublesm1/JsonToCsvConverter
/jsonToCsv.py
892
3.578125
4
import json import csv def json_to_csv(file_path, csv_name) -> None: with open(file_path) as json_file: data = json.load(json_file) headers = data[0].keys() with open(csv_name, 'w') as csv_file_local: writer = csv.writer(csv_file_local) writer.writerow(headers) ...
36f9a3eeb3a4f824077994a162f364e9c4129ae9
kylerbrown/stoc-pong
/pong_alpha/center/game/geometry.py
1,229
3.625
4
# GEOMETRY.PY - defines necessary geometric operations import math, random class Geometry(): def __init__(self,constants,*args,**kwargs): # import game constants self.centerX = constants.centerX self.centerY = constants.centerY # returns the smallest representable number [UNUSED] ''' def eps(self): x = ...
274b33b9601b58c89d9dd0a16435bb091a0163cd
JaiBalaj/Programs-Practiced
/SOD.py
169
3.625
4
'''if __name__=="__main__": n=int(input()) while(n>9): sum=0 while n: sum+=n%10 n=n//10 n=sum print(n)'''
dddc0bdaadc131a4b17a9781f08163d50d059e01
Baltiyski/HackBulgaria
/Programming0-1/week04/09-1-People-at-Concert/people_count.py
507
3.625
4
from random import randint, shuffle def get_people_activity(activity): list = []; for name in activity: if name not in list: list += [name]; return len(list); #Test######### def generate_test(count): names = ["Ivo", "Maria", "Anetta", "Philip", "Rado", "Gergana"] result =...
33b6e77236cf3982ba6c651d3d144ee0f223b7db
monishnarendra/Python_Programs
/Bineary_Search.py
728
4.125
4
import time def Bineary_Search(list1,e): found = False h = len(list1) l = 0 while l <= h and not found: mid = int((h+l)/2) if list1[int(mid)] == e: found = True elif list1[int(mid)] < e: l = mid + 1 else: h = mid - 1 re...
2b2ed12a76904fa2b6d2e2efe91c056324ce2b7b
darshan937/LabExercise
/LabOne/qn9.py
267
4.40625
4
'''8. Write a Python program which accepts the radius of a circle from the user and compute the area. (area of circle = PI * r2)''' radious= float(input("enter the radious of the circle: ")) pie= 22/7 area= pie * radious ** 2 print(f"the area of circle is {area} ")
11f1d96dca2229ce95eebde04364325416d9f712
AmRiyaz-py/Python-Arsenal
/String Operations/problem2B3CO.py
332
3.9375
4
''' Program :- Given a string as input. Remove all a's and b's from the string. Author :- AmRiyaz LastModified :- April 2021 ''' st = "abracadabra" len1 = len(st) newSt = "" for i in range(0,len1): ch = st[i] if(ch != "a" and ch != "b"): newSt = newSt + ch print(newSt) ''' Output...
12b5ceeb4735fb5a4bb43561215257dd12ca02d9
Gene-loss/Newick-validator
/Newick_Validator.py
5,013
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Newick format validator # imported in CLI.py # imports from re import split # returns true if the given input is a number def is_number(string): try: float(string) return True except ValueError: return False # returns the index of th...
e05222da233443b2c309906d2d22d42f2f044f40
DharmendraB/Python_Code
/time_Module_use.py
403
3.84375
4
print("jai mataji") import time initial1 = time.time() k = 0 while (k<45): print("This is Gohil DB") k +=1 print("while loop run in ",time.time()-initial1," Second") initial2 = time.time() for i in range(45): print("This is Gohil DB") print("while loop run in ",time.time()-initial2," Second") # local ti...
be3d010d24ec82183280cc2e011a1db5b2001c38
BreenIsALie/-Python-Hello-World
/ex13.py
497
3.734375
4
__author__ = 'BreenIsALie' # Exercise 13, Exercises taken from http://learnpythonthehardway.org/book/ # Parameters, unpacking and Variables # import the argument variable (argv) for use. This is a MODULE (IMPORTANT TO REMEMBER) from sys import argv # Take input from argv and assign it to variables script, first, sec...
245fdcca04944de42725a61c05c6cd70c966aa6f
Rich43/rog
/albums/3/challenge169_easybonus/code.py
2,179
4.28125
4
''' Given a NxN size 2D array of numbers. Develop a way to rotate the data as if you rotated the data by 90 degrees clockwise. Example: N = 3 Data: 1 2 3 4 5 6 7 8 9 Rotate 90 degrees: 7 4 1 8 5 2 9 6 3 Rotate it again 90 degrees: 9 8 7 6 5 4 3 2 1 Challenge Input: N = 10 1 2 3 4 5 6 7 8 9 0 0 9 8 7 6 5 4 3 2 1 1 3 5...
ea17d2a53c8f7c4405bfd34ceecb3b794ee01504
TrendBreaker/project-euler-python
/problem_32.py
917
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Problem 32 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplica...
b9d8d684ecde55a8b1a945f04e5a230600d8c989
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/mnhper001/question1.py
352
3.953125
4
def main(): year=eval(input("Enter a year:\n")) answer1=year/400 answer2=year/4 answer3=year/100 if answer1 == int(answer1): print(year,"is a leap year.") elif answer2 == int(answer2) and answer3 !=int(answer3): print(year,"is a leap year.") else: print(yea...
46c5dc88be69961881931747fe1587b3d7178fae
ricomoss/coding-campus-november-2015
/profiling/not_optimized.py
1,420
4.03125
4
#! /usr/bin/env python import sys import os def fib_help(): """ Simple helper to explain how to use the script. """ print('{}'.format('*' * 62)) print('* Provide an integer index to get the nth Fibonacci number.{}*'.format(' ' * 2)) print('* Example: python not_optimized.py 8{}*'.format(' ' * ...
3fb0a30c7d2381b3b7ed6d81a74ab122b2cb76da
Ruchitghadiya9558/python-program
/collection/list/list5.py
216
3.90625
4
# list for the max and min number mylist=[10,20,30,40,80,40,70,85,65,45] max = 0 min = 90 for i in mylist: if i > max: if i < min: min = i max = i print("max=",max) print("min=",min)
66f4767484bd346606d71857e14ce5615d0c6505
issackj1/CompetitiveProgrammingClub
/robot.py
1,392
3.5
4
num = list(map(int, input().split())) width = num[0] length = num[1] xcoord = 0 ycoord = 0 thinksx = 0 thinksy = 0 while(num[0] != 0 and num[1] != 0): segments = int(input()) maxdown = num[1] maxright = num[0] for i in range(segments): movement = input().split() direction = movement[0] ...
4299cf6ae5a94e29f022391bfbe8b308c4ca91c3
fan-weiwei/algo-prep
/xin-era/codility/maximal_slice/max_slice_sum.py
1,307
3.71875
4
""" given an array A consisting of N integers, returns the maximum sum of any slice of A N is an integer within the range [1..1,000,000]; each element of array A is an integer within the range [−1,000,000..1,000,000]; the result will be an integer within the range [−2,147,483,648..2,147,483,647]. """ def solution(a...
cb23a3127f0949d327b84bf5965d98af993884f5
PepAnalytics/Python
/homework4/second.py
216
3.765625
4
def choice_number(): numbers = [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55] result = [numbers[i] for i in range(1,len(numbers)) if numbers[i] > numbers[i - 1]] return result print(choice_number())
a76a1b4d56d5fba5e1e0c1ffaa6a0756d9196de7
jdtully/coursera-python
/printdouble.py
258
4.125
4
def double_word(word): double = word + word length = len(double) doubled = double + str(length) return doubled print(double_word("hello")) # sb hellohello10 print(double_word("abc123")) # sb abc123abc12312 print(double_word("")) # sb 0
95b406131a6ac14eccc6ecc8b51d56a66a123f8f
JRChow/my-decision-tree-and-random-forest
/decision_tree.py
6,258
3.5625
4
from collections import Counter import numpy as np from math import sqrt from sklearn.base import BaseEstimator class DecisionTree(BaseEstimator): """The Decision Tree classifier.""" class Node: """Inner class: tree node.""" def __init__(self, split_rule=None, left=None, right=None, label=No...
f17b7ccd0568e987f56c80643be463df93e933ba
Rozdrigo/python
/fatorial.py
101
3.921875
4
n = int(input('O fatorial de: ')) f = 1 for x in range(n): f = f * (x+1) print('É igual a: ', f)
e607af239dcec0e1da423771aeb17baf4600dce7
wineone/analise-de-dados
/data_science_from_scratch/capitulo-3-vizualização/exemplos.py
284
3.671875
4
from matplotlib import pyplot as plt years = [1900,1910,1920,1930,1940,1950] lucro = [10,20,10,30,40,20] plt.plot(years,lucro,color="green",linestyle="solid",marker="o") plt.title("lucro de uma empresa através dos anos") plt.ylabel("lucro em bilhoes de dolares") plt.show()
bd0632dc66a377ea1df046b5773c276e7fa195ab
LCDG-tim/pgm-revision-voc
/UIvoc.py
24,051
3.578125
4
# -*- coding: utf-8 -*- # le \ permet de continuer la ligne précédentes à la ligne suivantes # les il signifie le programme """ interface pour vocabulaire.py """ import tkinter as tk import random from vocabulaire import voc def swicth_variables(a, b) -> tuple: return b, a class List_button: def __in...
073e1927f34f37b55d3dc78544bcd8a8cbb945b4
tomwhi/snpCrmAnnotation
/seq_utility.py
11,630
3.796875
4
#!/usr/bin/env python from utility import FormatError import fileinput, sys, string, sequence, math, random def read_prob_matrix(filehandle, alphabet): """Read a matrix from the specified input source, and return its transpose, as a list of lists. Each row of the input matrix must contain an entry for eac...
4e834addd04c7f05d3b48079913a96b4e57a6451
santoshbebe/Pylearning
/LearningPrograms/GuessSecretNumberFunction.py
998
4.09375
4
def take_input(): var1 = eval(input("Guess the number")) return var1 def compare_guess_number(guess_number, secret_number): if (guess_number < secret_number): print("Enter number is less than the secret number") return False elif (guess_number > secret_number): print("Enter num...
5257553d3c163205f228efbd85550aedd5fa8e8e
satyapatibandla/Patterns-for-Coding-Interviews
/03_Fast_and_Slow_Pointers/08_circular_array_loop_exists.py
1,136
3.59375
4
# Time O(N) | Space O(1) def circular_array_loop_exists(nums): for i in range(len(nums)): if nums[i] == 0: continue direction = nums[i] > 0 slow = fast = i while True: slow = get_next_idx(nums, slow, direction) fast = get_next_idx(nums, get_next_...
b78f1f32875aabc5447d670e45bde616064d04a5
abcapo/Practica-Parcial
/tool_string.py
218
3.546875
4
class ToolString(): def is_palindromo(self, phrase): return list(reversed(phrase.replace(" ", ""))) == list(phrase.replace(" ", "")) def is_upper(self, phrase): return phrase == phrase.upper()
b15b859c5be4544912111cff03a957ac9446bd43
lee-qinghua/Official-python-study
/爬虫部分2/code2/demo0_正则表达式.py
164
3.625
4
import re # 正则表达式 str = 'abbbc' # *? 是非贪婪模式,尽可能少的匹配 最少0 pattern = re.compile('ab*?') a = pattern.findall(str) print(a)
f032b7a16b414afe2cf894f64c7198b6b22cd009
aakashb95/leetcode-june
/1106_SortColors.py
508
3.640625
4
class Solution: def sortColors(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ i, j, mid = 0, len(nums) - 1, 0 while mid <= j: if nums[mid] == 0: nums[mid], nums[i] = nums[i], nums[mid] ...
c8924b2b694b42ff705eaa2318df811a1a948f03
Aendera/Programming-Workthroughs
/Python/AutomateTheBoringStuffWithPython_NoStarchPress/C3_PracticeProjects/collatz.py
340
4.3125
4
def collatz(number): if number%2: result=3*number+1 else: result=number//2 print(result) return result if __name__=="__main__": try: number=int(input('Enter number: ')) while number!=1: number=collatz(number) except ValueError: print('Must...
14bd5d73a5c6cd21cd423671a842b44cddb2ed8b
ShaktiGit/ShaktiPython
/csvViewerGui.py
687
3.53125
4
import tkinter import csv from tkinter import * from tkinter import messagebox root=tkinter.Tk() def onclose(): if messagebox.askokcancel("Quit Window","Do You Want To Quit?"): root.destroy() lbl1=Label(root,text="Enter Loc:") lbl1.pack(side="left") txt1=Entry(root) txt1.pack() def display(): str1=txt1....
72d78457615b5ed8be57dac554305823a507603a
osktgui/algorithms
/book/Introduction-to-Algorithms-3rd-Edition/chapters/2 Getting Started/insertion-sort.py
215
3.703125
4
lista = [5, 2, 4, 6, 1, 3] print(lista) for j in range(1,len(lista)): key = lista[j] i = j-1 while i >= 0 and lista[i] > key: lista[i+1]=lista[i] i= i-1 lista[i+1] = key print(lista)
6a3a993b43123847f12e0166e7ffef238453ff6e
htmercury/codingDojoAssignments
/python_stack/python_fundamentals/hello_world.py
69
3.703125
4
y = 0 while y > 0: print(y) y = y - 1 else: print("test")
010f67de45562123b07bc7c0f5da85cde6b20c2d
TongDist666/test
/quick_sort.py
646
3.734375
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 13 14:51:55 2019 @author: TongDist """ def quick_sort(nums): # 封装一层的目的是方便用户调用 def qsort(lst, begin, end): if begin >= end: return i = begin key = lst[begin] for j in range(begin+1, end+1): if ...
64363b98b6350c251541d2c9b8bb0ddd82223844
IrshaadS/LearnPython
/IteratorsAndGenerators.py
1,116
4.28125
4
# Iterators and Generators #Iterator class Reverse: """ Iterator for looping over a sequence backwards """ def __init__(self, data): self.data = data self.index = len(data) def __iter__(self): return self def __next__(self): if self.index == 0: ...
f71562f031826890e297e338419c96666685eba8
martinwangjun/python_study
/00_codewars/title-case.py
820
3.984375
4
# https://www.codewars.com/kata/title-case/train def title_case(title, minor_words=''): minor_words = minor_words.lower().split(' ') title = title.split(' ') for i, word in enumerate(title): if i == 0 or word.lower() not in minor_words: title[i] = word.title() else: title[i] = word.lower() ...
53675392b5bf130d24bcb5bb0ee3773aa4db75d7
thehungrysmurf/list_assignment
/skills1.py
3,350
4.1875
4
# Things you should be able to do. # Write a function that takes a list and returns a new list with only the odd numbers. def all_odd(some_list): odd_list = [] for i in some_list: if i % 2 != 0: odd_list.append(i) return odd_list # Write a function that takes a list and returns a ne...
9e0dc50601a03cc3eea9e6eadb88fc38f8e956cb
Talon1989/MIT-6.00.2x-python-data-science
/src/UNIT-1/lecture-2/lect2.py
3,629
3.6875
4
import lect1 from Food import Food import random import sys # BRUTE-FORCE ALGORITHM def maxVal(toConsider, available): """ :param toConsider: list of items :param available: a weight :return: tuple of total value of a solution to 0/1 knapsack and the items """ # print('toConsider len:', len(t...
44e81075aac8ad0182d4bdafed39ae719811d354
jgambhir/treemap
/tile.py
2,464
3.78125
4
import pygame from tree_file import * def draw_tiles(screen, x, y, width, height, directory): '''(Surface, int, int, int, int, Directory) -> NoneType Draw a treemap on a pygame surface showing the relative sizes of files and sub-directories within a given directory. Files are depicted as colored recta...
351e86c74d5aa764f5e817671dabf10ce4fe369e
garnan92/praticas_python
/session2/actividad1.py
302
3.765625
4
def agregar(alumnos,alumno): alumnos.append(alumno) alumnos.sort() return alumnos def main(): alumnos = [] while 1: nombre = input("nombre del alumno: ") if(nombre == "exit"): break alumnos = agregar(alumnos,nombre) print(alumnos) main()
3a9bac500546530e276c927c9216ead6721f1840
hmp36/python_aug_2017
/kevin_schmitt/compareArrays.py
443
3.96875
4
list1 = [1,2,5,6,2] list2 = [1,2,5,7,11] elems_in_both_lists = set(list1) & set(list2) print elems_in_both_lists if list1 == elems_in_both_lists: print 'These are the same list' else: print "THESE AIN'T THE SAME" # # list1 = [1,2,5,6,2] list2 = [1,2,5,7,11] def compareArrays(list1,list2): ...
d4644ce73dc2480ef45f0431c33eacf524d3b4b5
pratiktest/problems
/assignCookies.py
2,117
3.953125
4
def bruteForce(): greed_factor = [2, 7, 5] cookie_size = [3, 9] greed_factor.sort() cookie_size.sort() """ [2,5,7] and [3,9] after sorting we can be greedy as 9 biggest size will be given to most greediest child simplest case is -> [1,2,3], [1,1] give 1 to 1 and thats all we can do...
ddf448c8da2ea7f87142fb9b65013095f6d470ee
guobaozhu/fullstack
/week4/day1/深浅拷贝.py
493
3.703125
4
#!/usr/bin/env python # _*_coding:utf-8_*_ # author : duke # date : 18/12/2019 11:55 AM # filename: menu3_plus.py # IDE : PyCharm # s = [[1, 2], 'duke', 'goods'] # s1 = s.copy() # # # s1[1] = 'helllo' # # print(s) # # print(s1) # # s1[0][1] = 3 # print(s1) # print(s) import copy a = ['AAA', 123, [20...
a1f4b1addcf7af23b961a1a560c0fdc5fcbc1ce0
Kamata-kun/Nomads
/04_06_while.py
155
4.09375
4
''' Use a "while" loop to print out every fifth number counting from 1 to 1000. ''' i = 1 while i <= 1000: if i % 5 == 0: print(i) i+=1
9fe4cc3d2c0a9d48e98aa13a7dd3fcebe6535261
kipyin/phanpy
/interface.py
8,821
3.8125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """A simple user interface simulating Pokémon battles. Currently only support 1-on-1 battle, and the Pokémons are limited to Generation 3 & 4. """ from os import sys, path file_path = path.dirname(path.abspath(__file__)) root_path = file_path.replace('/phanpy', '') sys.p...
0f912a52cc066038c3db0b31f58a76c30d1f20f1
itsmohamedghouse/Software-Testing-Lab-Programs
/1-triangle.py
993
4.03125
4
# Program Number 7 in Manual # Design and develop a program in a language of your choice to solve the triangle problem # defined as follows: Accept three integers which are supposed to be the three sides of a # triangle and determine if the three values represent an equilateral triangle, isosceles triangle, # sca...
ab23f8281bf9d1d7b7b365533fc008cabb2f90e9
borislavstoychev/Soft_Uni
/soft_uni_fundamentals/Basic Syntax, Conditional Statements and Loops/EXERCISE/07_maximum_multiple.py
216
3.71875
4
from sys import maxsize num_1 = int(input()) num_2 = int(input()) max_num = -maxsize for i in range(num_1, num_2 + 1): if i % num_1 == 0: if i > max_num: max_num = i print(max_num)
2da8e27c9e9ad8464f301311964c10efb66cf8a4
JonathanHHenson/CACI-Persona
/persona_api/db/db_operations.py
5,371
3.8125
4
from . import db from .model import Person, Location, Website from sqlalchemy.orm import Session def import_person_from_json(person_item: dict): """Imports person either by updating an existing record or by inserting a new record :param person_item: A dictionary object that represents a person :returns: ...
939b086755eb6bc9c503ea3c8f75c26a80f1cb9d
chakilamnaresh/pythonlearning
/Nested_if_else_greatest_3.py
320
4.125
4
a=int(input("Enter the number for a:")) b=int(input("Enter the number for b:")) c=int(input("Enter the number for c:")) if(a>b and a>c): print("The greatest of 3 numbers is ",a) else: if(b>a and b>c): print("The greatest of 3 numbers is ",b) else: print("The greatest of 3 numbers is ",c)
82908d7e8d10e454d99101207636aaa973cfe388
vuminhph/randomCodes
/powerOfThree.py
227
4.1875
4
def power_of_three(num): if num % 3 != 0: return False while num != 0: if num == 1: return True if num % 3 != 0: return False num //= 3 print(power_of_three(9))
dcf8233b88f61f3cd21088360192cd737e91cda0
shruthipv96/CarND_Udacity_Lane_Detection
/CarND_FindingLanesP1_Shruthip.V.py
21,771
3.859375
4
#!/usr/bin/env python # coding: utf-8 # # Self-Driving Car Engineer Nanodegree # # # ## Project: **Finding Lane Lines on the Road** # *** # In this project, you will use the tools you learned about in the lesson to identify lane lines on the road. You can develop your pipeline on a series of individual images, and...
bd42ef55788ba2f50ddd189fa49265473e394101
Hehwang/Leetcode-Python
/code/112 Path Sum.py
892
3.828125
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 __init__(self): self.res=False def helper(self,total,root,sum): if not (root.right or root.left):...
e977c13cca4f741e29e404a5473154a0b4cb1403
mrtbeheshti/quera
/khoshGhalb/khoshGhalb.py
64
3.734375
4
num = int(input()) for i in range(num): print("man khoshghlab hastam")
fa1bbe74a798890a9ba5a9533926ea480cddc78c
SBNoor/Machine-Learning
/handin-4/final_handin.py
12,553
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 5 11:01:45 2017 @author: AU """ import os import numpy as np %matplotlib inline import matplotlib.pyplot as plt from scipy.stats import multivariate_normal # Load the Iris data set import sklearn.datasets X, y = sklearn.datasets.load_iris(True) X = X[:,0:...
5f9b7e130457b068ae36757ac5516f94b02578cd
Issyk/usefl
/shift cypher.py
1,099
4.125
4
# Shifting Code alphabet = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ') tr = False # main prg while not tr: str = raw_input('Enter a word to conwert: ') str_lo = str.lower() # conwer all letters in lower case key = int(raw_input("Enter a sh...
f4b889acd30a0d9896bc74eac262ef67edcb2294
avelikev/Exercises
/data_structures/dictionaries_and_arrays/1.Insert_element/Solutions/solution.py
223
3.8125
4
from array import array arr = array('i', [1, 2, 3, 4, 5]) ins_pos = int(input("enter the position where value to be inserted")) ins_val = int(input("enter the value to be insterted")) arr.insert(ins_pos,ins_val) print(arr)
b1377fbc408ca21ea1b6a1fd8776dac8ec647c89
pedrolisboaa/curso_python
/1_python_basico/4-primitivos.py
296
3.9375
4
""" Tipos de dados em python str - string "é isso aqui" int - integer float - real ou ponto flutuante bool - booleano - True our False """ # print(10 == 10) # print(10 == 11) print(type('Pedro')) print(type(13)) print(type(1.12)) print(type(True)) print(type(10 == 15)) print(type(15 != 1))
8f3d75cd0b26ca39c4194b4ba79706b4dee26d5d
cortelucas/logica-python
/estrutura-sequencial/exe_13.py
225
4.03125
4
print('----- Cálculo de peso ideal -----') height = float(input('Insira sua altura, ex = 1.89: ')) print(f'Se for homem, seu peso ideal seria de {(72 * height) -58:.2f} kl. Já se for mulher {(62.1 * height) -44.7:.2f} kl')
645516497d7392147ef2742c88b1d56724da0111
finnhacks42/causality
/causalpy/causalpy/bandits/enviroments.py
32,872
3.59375
4
# -*- coding: utf-8 -*- """ The classes in this file model the enviroment (data generating process) and store the true value of the reward distribution over actions. The true reward distribution is not known to the algorithms but is required to calculate regret. Models should extend the Model class and must implement:...
8c11daba9dbaffa71648afdd618a5b6cbf11b764
dieman20067/laba1
/Lab1.py
384
3.921875
4
print("Hello Python from Visual Studio!") # Дана строка. Если она начинается на 'abc', то заменить их на 'www', иначе # добавить в конец строки "zzz" text = input('your last word: \n') if text[0:3] == 'abc': text = "www" + text[3:] else: text = text + "zzz" print(text) input('Press <ENTER> to exit.')
c70408a13be182fdf5869ba5d53142567a877422
danielabrca/python-programming
/unit-4/files.py
727
4.40625
4
''' #how to read a file my_file = open('lines.txt', 'r') data = my_file.read() my_file.close() #you should close a file after using it print(data) #how do we write to a file my_file = open('lines.txt', 'w') #OVERWRITES THE CONTENT OF THE FILE, IF IT EXISTS - BE CAREFUL!!!! my_file.write('Please add this new line') m...
3fb6f57215bef339a9e4cad37e2c419e734a79ab
limapedro2002/PEOO_Python
/Lista_05/Marilia Gabriela/Pessoa.py
1,183
4.0625
4
class Pessoa: def __init__(self, nome, idade, altura): self.nome = nome self.idade = idade self.altura = altura def info(self): print("Nome: {}".format(self.nome)) print("Idade: {}".format(self.idade)) print("Altura: {}".format(self.altura)) def dormir(self)...
f285ce6e110f521daba0a867e8bc09ba326184c5
szendrot/Various_exercises
/Various_exercises/Deque_exercise_1.py
248
3.578125
4
from collections import deque for i in range(int(4)): my_queue = deque() my_input = 'ENQUEUE 1'.split() if my_input[0] == 'ENQUEUE': my_queue.append(my_input[1]) else: my_queue.pop() for i in my_queue: print(i)
251765c9c8eb1f4ac996412586a43f36ffc5d61e
asemfahad/python
/opretors.py
327
3.890625
4
age = 11 age1 = 6 # print(age > age1) # print(age < age1) # print(age == age1) # print(2 == 2) # print(age != age1) # print(age >= age1) # print(age <= age1) # print(True and True) # print(True and False) # print(False and False) print(True or True) print(True or False) print(False or False) print(not True) pri...
37987419c4e40be53b447a00b1a0f680a554d611
maodunzhe/clean_code
/array/moveZeroes.py
225
3.5625
4
def moveZeroes(nums): pos = 0 for i in range(len(nums)): if nums[i] != 0: nums[pos], nums[i] = nums[i], nums[pos] pos += 1 return nums print moveZeroes([1, 0, 2, 2, 3, 0, 1, 0, 2])
a605e02af26dfeaeceef9ced00b17139621112e8
ethanrweber/ProjectEulerPython
/Problems/1-100/31-40/Problem38.py
1,261
4.15625
4
from HelperMethods import is_pandigital def method(): print("find the largest 1-9 pandigital, 9-digit number that can be formed as the concatenated product " "of an integer with (1,2,...,n) where n > 1") # ex: 192 # 192*1 = 192, 192*2 = 384, 192*3 = 576 # 192_384_576 contains all digits 1-9...
33a5f179e25767129b8ded0b53df34ce3d6f10a3
ethanplee14/backtester
/opt_utils/selectors.py
1,189
3.5
4
from dateutil.relativedelta import relativedelta from utils.math import nearest_number def select_option_expire(trade_date, option_chain, **kwargs): """ Select nearest option chain from time until expiration :param trade_date: date option chain is traded :param option_chain: Option chain to select fro...
d307ea48ff89cdf619dc578148932363bae4b152
seoyeonhwng/algorithm
/BJ/2810.py
556
3.5625
4
N = int(input()) seats = input() cups, i = '*', 0 while i < N: if seats[i] == 'S': cups += 'S' i += 1 else: cups += 'LL' i += 2 cups += '*' M = len(cups) check = [False] * M answer = 0 # 왼쪽에서부터 최대한 컵홀더를 나눠줌 -> 그리디 for i in range(M): if cups[i] == '*': continue ...
1f75e0df9204a7efc8db0ac04f03c33ebd6d31a6
mindnhand/Learning-Python-5th
/Chapter38.ManagedAttributes/4-getattr-v-getattribute.py
1,649
3.734375
4
#!/usr/bin/env python3 #encoding=utf-8 #---------------------------------- # Usage: python3 4-getattr-v-getattribute.py # Description: compare the __getattr__ and __getattribute__ #---------------------------------- ''' To summarize the coding differences between __getattr__ and __getattribute__, the following ex...
b0e3e35cb641f31829c56b4c2819f8f64878d388
liangjisheng/data-science-from-scratch
/mycode/chapter3/3_2.py
852
3.640625
4
# -*- coding:utf-8 -*- """ @project = 0521-1 @file = 3_2 @author = Liangjisheng @create_time = 2018/5/21 0021 下午 19:01 """ from matplotlib import pyplot as plt from collections import Counter grades = [83, 95, 91, 87, 70, 0, 85, 82, 100, 67, 73, 77, 0] decile = lambda grade: grade // 10 * 10 histogram = Counter(decile(...
46609705ba41b80188eba6689810124e665b9ac8
brunopmvs/Coursera
/ICC_USP_2/semana4/exercicio1.py
506
3.96875
4
""" Exercício 1: Lista ordenada Escreva a função ordenada(lista), que recebe uma lista com números inteiros como parâmetro e devolve o booleano True se a lista estiver ordenada e False se a lista não estiver ordenada. """ def ordenada(lista): ordem = True tamanhoLista = len(lista) i = 0 while (i < ta...
0e5872d06eadc41b9c391b64f917d2ca126267fe
tr1503/LeetCode
/arrayAndString/majorElement_II.py
1,372
4.15625
4
'''Use Boyer-Moore Majority Vote algorithm to set two candidates and two counts. After first loop, need to have a second loop to check if it appears more than n/3 by using list.count(). Time Complexity is linear and space is O(1). Check https://gregable.com/2013/10/majority-vote-algorithm-find-majority.html''' class S...
5ffd99870cabba2c6c745b6549257f8c76fa0d6c
olinkaz93/Algorithms
/BST.py
3,482
4.34375
4
#implementation of binary search tree #insert and lookup class Node(): def __init__(self, value): self.value = value self.left = None self.right= None class BinarySearchTree(): def __init__(self): self.root = None def insert(self, value): node = Node(value) ...
16bbe8e32e44e1c3d7f59622d1430d8d96f030f3
Alireza-Helali/Design-Patterns
/Observer.py
785
3.859375
4
""" Observer: observer is a behavioral design pattern and is a object that wishes to be informed about events happening in the system. the entity generating the events is an observer. """ class Event(list): def __call__(self, *args, **kwargs): for item in self: ...
f2d4b7a88994567509860fe8aef2d895b527ef75
mrinalraj2809/SummerCoding
/LeapYear.py
142
4.03125
4
year = int (input("Enter the year \t:")) if(year % 4 == 0): print(year, " is a leap year") else: print(year , " is not a leap year")
fd29594bcb703cf22449c6c69ef5315bb3ebbc71
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/cf141978606a46838224aad0ed4eb1dd.py
734
3.96875
4
def hey(what): """Based on what was said to Bob, return verbal reply.""" # Dict keys: what was said. Dict values: Bob's replies reply_to = { 'nothing said': 'Fine. Be that way!', 'yelling': 'Whoa, chill out!', 'question': 'Sure.', 'anything else': 'Whatever.', } ...
3de09572fc9cd295c7416329ba2b9d491591d2b0
shakanen1512/phamquynhchi-lab-c4e20
/Lab03/calc.py
210
3.859375
4
x = int(input("x = ")) op = input("Operation(+,-,*,/) ") y = int(input("y = ")) from eval import calc result_2 = calc(x, y, op) print("* " * 30) print("{} {} {} = {}".format(x,op,y,result_2)) print("* " * 30)
060e56d67616b9c826473c1843b75c33afae0262
PigsGoMoo/LeetCode
/strobogrammatic-number-ii/strobogrammatic-number-ii.py
1,092
3.828125
4
class Solution: def findStrobogrammatic(self, n: int) -> List[str]: # Helper func to insert combo values in the middle of the dest values def insert(combo, dest): # Initialize res = [] # Since we always use the last even number, we can just use floor divi...
38989903722955831da041a63d73354b6c61339a
leilalu/algorithm
/链表/92.反转链表.py
416
3.890625
4
""" 反转从位置 m 到 n 的链表。请使用一趟扫描完成反转。 说明: 1 ≤ m ≤ n ≤ 链表长度。 示例: 输入: 1->2->3->4->5->NULL, m = 2, n = 4 输出: 1->4->3->2->5->NULL """ class ListNode: def __init__(self, x): self.val = x self.next = None # class Solution: # def reverseBetween(self, head: ListNode, m, n): # # first.next = sec...
c283352398331af36ba6ebbaae543f69ce62a61f
mehmetyilmaz0/MachineLearningProjects
/voicePrediction-master/logisticRegression.py
3,583
3.515625
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 27 07:45:44 2019 @author: mehmet.yilmaz """ # %% info # 1- read Data # 2- define y ve x # 3- make normalizasyon # 4- define test ve train data # 5- set initalize values # 6- define sigmoid function # 7- define forward and backward function # 8- update method for w and b ...
1de3de8578853a86e0e24d14d2341343e9f66652
iamveekthorr/SandBox
/Test.py
544
3.546875
4
def test(): weldon = 'this is a string' print('welcome back ', weldon) # Practicing closures in Python '''Closure is a JavaScript Concept that allows functions to inherit variables from outer functions even after the function has been executed keeping the variables in a memory heap ''' ...