blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
abf2ee9430a0fefeb216ecb81909376215a8cbc8
lost-osiris/bzcompliance
/libs/Compliance/req_functions.py
5,600
3.515625
4
import re, inspect, sys, types from datetime import datetime format_string = "%Y%m%dT%H:%M:%S" user_format = "%Y-%m-%d" user_format_time = "%Y-%m-%dT%H:%M:%S" def __lower(data, params): if type(data) is list: data = [str(element).lower() for element in data] else: data = str(data).lower() param...
9747e966aeece1e1e1ecd2c4c1cb37fb6952717e
sd691876/Python_YL
/Code/平方相加.py
218
3.9375
4
#1 + 2 + ... + n的每個平方相加 n=0 sum_1=0 sum_2=0 i=0 n=int(input("please input the n:")) for i in range(n+1): sum_2=i*i sum_1=sum_1+sum_2 print("1^2 + 2^2 + 3^2 + ... + %d^2 = %d" %(n, sum_1))
d7ac48c9c1182c6c5cbdfc55a9f2e8c84baaf545
nin9/CTCI-6th
/Chapter08/5-recursiveMultiply.py
497
3.921875
4
""" Time Complexity O(logs), where s is the smaller number Space Complexity O(1) """ def minProduct(smaller: int, bigger: int) -> int: if smaller == 0: return 0 if smaller == 1: return bigger ans = 0 if smaller % 2 == 1: ans += bigger halfPord = minProduct(smaller>>1, bigger) return ans + ha...
f32289a1f66325e441455e6c07747d69e880144b
pratyusa98/Open_cv_Crashcourse
/opencvbasic/27. Image Contours P-3.py
1,563
3.53125
4
# Approximation and Convex hull import cv2 #Find countour area , aprroximation and convex hull img = cv2.imread("resources/shapes.png") img = cv2.resize(img,(600,700)) img1 = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) ret,thresh = cv2.threshold(img1,220,255,cv2.THRESH_BINARY_INV) cnts,hier = cv2.findContours(t...
f48ccf7a1c13b6f9842f892f3a52b9b9f7f431b1
yugarsi/IQ
/2D-Array/max_sub_array_sum_DP.py
1,545
4.03125
4
''' Maximum Sum Submatrix You're given a two-dimensional array (a matrix) of potentially unequal height and width that's filled with integers. You're also given a positive integer size. Write a function that returns the maximum sum that can be generated from a submatrix with dimensions size * size. For example, co...
641806751609863aa4aa32d696fc96313e2ae8df
ChenYenDu/LeetCode_Challenge
/01_BinaryTree/01_Traverse_A_Tree/01_Binary_Tree_Preorder_Traersal.py
721
3.796875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def preorderTraversal(self, root: TreeNode) -> List[int]: if root == None: return [] else: rst =...
8bf474eb7cb4c7a20e28091486f107dd489edf74
lowell1/Algorithms
/rock_paper_scissors/rps.py
1,463
3.65625
4
#!/usr/bin/python import sys # def recurse(n, idx): # new_combos = [] # if idx == n - 1: # arr = ["rock"] * n # for text in ["rock", "paper", "scissors"]: # new_combos.append(arr[:-1] + [text]) # else: # print(idx) # last_combos = recurse(n, idx + 1) # for combo in last_combos: # ...
944624a0990b6696cd3f8ae891504c38b3e01911
alexYooDev/pythonSyntax
/func_ex/def_lambda.py
560
3.921875
4
arr = [('jason', 28),('park', 40), ('ken', 45)] def key_val(x): return x[1] #정렬 기준 값 설정 => 배열 안 튜플의 1번째 값 print(sorted(arr, key=key_val)) #배열, 정렬기준(함수) print(sorted(arr, key=lambda x: x[1])) list1 = [1,2,3,4,5] list2 = [6,7,8,9,10] # lambda expression executing addition between the elements in each array in the s...
378016e1b88fe1e1a28ad46a0273b8d712c09ccf
GabrielOduori/Codewars-Python
/palindrome_checker.py
406
3.921875
4
from collections import deque def is_palindrome(characters): character_deque = deque(characters) while len(character_deque) > 1: first_char = character_deque.popleft() last_char = character_deque.pop() if first_char != last_char: return False return True print(is...
06c1bc4e3c4c4931dc01f81f9701062e798a0deb
SrVladyslav/Algorithms
/python/hamiltonian_cycle.py
1,109
3.734375
4
from graph import Graph from random import sample class HamiltonianCycle: def __init__(self, E): self.E = E self.G = Graph(E= self.E) def solve(self): def backtracking(path): if len(path) == len(self.G.V): if (path[-1], path[0]) in G.E: # ...
5efacc19ca8fdd92aaed771a3e7e88755e9e94a2
leilacey/LIS-511
/Chapter 3/names.py
443
4.28125
4
# 3-1 Name friend_names = ['Shaun Spencer', 'Burton Guster', "Juliet O'Hara"] print(friend_names[0]) print(friend_names[1]) print(friend_names[2]) #3-2 Greetings for friend in friend_names: message = "What's Up " + friend + "?" print(message) #3-3 Your Own List transportation_comments = ["I would like t...
d14d7fe988e1fdbc1f9fba8b2c18790f8d561b15
nikmois/python
/python_university/morse_code_translator.py
5,573
3.546875
4
import tkinter from tkinter.font import Font from tkinter import * from tkinter import messagebox top = tkinter.Tk() top.title("Morse code translator") top.geometry('350x320') top.configure(bg="black") font_1 = Font(family='fixedsys', size=14, weight='normal') font_2 = Font(family='fixeds...
36230437e15791b24b3dc37fb819fa5bb77cdf07
zielman/Codeforces-solutions
/A/A 1504 Déjà Vu.py
749
3.734375
4
# https://codeforces.com/problemset/problem/1504/A def isPalindrome(x): if x == x[::-1]: return True else: return False def alla(string): for i in range(len(string)): if string[i] != 'a': return False return True def main(): t = int(input()...
a1bb7a69dba65928ed75a6460853766de942e48e
amidoge/Python-2
/ex072.py
460
3.953125
4
#I should get the original string and a reversed string. #Then I will compare the two. word = input("Word: ") o = [] r = [] for i in range(len(word)): o.append(word[i]) for i in range(len(word)): r.append(word[-i - 1]) #So that it would be -1, -2, and so on. same_count = 0 print(o) print(r) for i in range(len...
fdce8fd11b65830b7c265c903a4bcfa3bf3ac029
krskelton/Python-Projects
/DB/createdb.py
1,606
4
4
import sqlite3 #connect to a database conn = sqlite3.connect('example.db') #while the connection is open with conn: #the cursor is operating on the db cur = conn.cursor() #build the database cur.execute("CREATE TABLE IF NOT EXISTS tbl_files( \ ID INTEGER PRIMARY KEY AUTOINCREMENT, \ ...
cf3c8cc53e234ce02c99b0d835ae0ed40cdbf0c4
jayeshhinge98/demo
/python/Inheritance.py
469
4.0625
4
######Inheritance allows us to define calls in terms of another class. class Parent: value1="Jayesh" value2="Hinge" def sum(self,a,b): return a+b class Parent2(): value3="FIGmd" class Child (Parent,Parent2): pass # print("Value 1 is:",p.value1) # print("Value 2 is:",p1.value2) #will no...
007a92615dad9f7964ba2c5a639321c635c27a9f
Ochirgarid/algorithms
/basics/problem-4/code_py/pentagon_p_solution-garid.py
584
3.734375
4
#!/usr/bin/env python """ File: pentagon_p_solution-garid.py Find the perimeter of pentagon. """ __author__ = "Ochirgarid Chinzorig (Ochirgarid)" __version__ = "1.0" # Open file on read mode inp = open("../test/test1.txt", "r") # read input lines one by one # and convert them to integer a = int(inp.readline...
768f99a41f7f98f1d599beb2347c6c53867ef75b
tianyunzqs/LeetCodePractise
/leetcode_21_40/31_nextPermutation.py
1,572
3.71875
4
# -*- coding: utf-8 -*- # @Time : 2019/6/17 11:45 # @Author : tianyunzqs # @Description : def nextPermutation2(nums) -> None: """ Do not return anything, modify nums in-place instead. """ if sorted(nums, reverse=True) == nums: nums.sort() return if len(nums) < 3: ...
b45e2ab411a9d0054d0f993652159590409bae09
jmwest/Web-Database-Design
/proj2/pa2_rkrjjwkx1or/controllers/encryptPassword.py
677
3.609375
4
import hashlib import uuid #this function takes in a plaintext string, and returns the ciphertext with salt def encryptPassword(algorithm, plainPass, givenSalt = None): if givenSalt: salt = givenSalt else: salt = uuid.uuid4().hex # salt as a hex string for storage in db m = hashlib.new(algorithm) plainPass = ...
1abc1ef8eec422f017fe94ffa4d3601f33cff8f8
shortdistance/workdir
/Python_Learning/testConnectiondeque.py
418
3.765625
4
#-*-coding:utf-8-*- if __name__ == '__main__': from collections import deque d = deque('abcd') d.append('d') print d d.remove('d') print d d.pop() #ȳ print d d.popleft() #ȳ print d d1 = deque("hello world") d1.reverse() #ת print d1 d1.rotat...
d63d06aa5f4a559b18b0fc24d66d2e9d693ccee4
OliverGeisel/sudokusat-example
/my_solver/oliver/PuzzleInfo.py
2,844
3.5
4
import math import os class PuzzleInfo: def __init__(self, path_of_file: str, length: int = 9, text: str = ""): self.input_file_path, self.input_file_name = os.path.split(os.path.abspath(path_of_file)) self.length = length # values from 1 to length self.sqrt_of_length = int(math.sqrt(sel...
12a1acabeed0741d930ac6ec31b3c7da3d39c41c
NoahToomeyBC/Election_Analysis
/PyPoll_2.Py
957
3.84375
4
# Import the csv and os modules import os import csv # Open Election Results csv and assign variable for it file_to_load = 'Resources/election_results.csv' #Open and Read election results election_data = open(file_to_load, 'r') # Open the election results and read the file with open(file_to_load) as election_data: ...
672180057f4c5ad43423f9971f0eea474c43f810
matbrik/python-mix
/Python Mix/Python Mix/Bots/bot_part_obs.py
4,847
3.53125
4
#!/usr/bin/python3 import os def next_move(posx, posy, board): mem_board,lastMove=load_mem("test.txt") #print(mem_board) #update mem_board try: for i in range(5): for j in range(5): if board[i][j]!='o': mem_board[i][j]=board[i][j...
deefae2a4880f502e705500a2ce3ea3c707b896b
chaochaogege/leetcode_simple_01
/simplecode01.py
488
3.546875
4
#coding=utf8 class Solution(object): def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for i in range(len(nums)): j=i+1 for j in range(len(nums)): if (i!=j): ...
50836f22848f2e3b0bfeb91d7ebddb2026028c78
nandansn/pythonlab
/Learning/tutorials/workouts/area_of_triangle.py
153
3.921875
4
height = input('enter height of triangle:') base = input('enter base of triangle:') areaOfTriangle = (int(base) * int(height))/2 print(areaOfTriangle)
3461f39203aa36c5df687f19091bce9034770fbf
SlawekMaciejewski/Python_exercises
/oop/oop_dziedziczenie_employee.py
2,271
3.609375
4
import datetime class Employee: raise_amount = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay # self.email = f'{first}.{last}@aptor.com' # uzywajac @property mozemy zrezygnowac z tego atrybutu @property def email(self): ...
55a232999d194319035c72452f6cd835e63e035d
yanmarcossn97/Python-Basico
/Exercicios/exercicio018.py
322
3.9375
4
import math # math.sin(x) - retorna o seno de x # math.cos(x) - retorna o cosseno de x # math.tan(x) - retorna a tangente de x x = float(input('Insira um ângulo qualquer em radianos: ')) print('Seno: {}.'.format(math.sin(x))) print('Cosseno: {}.'.format(math.cos(x))) print('Tangente: {}.'.format(math.tan(x))) ...
55ddf39ac080a044495de1f86ccf4dd925c9c894
SakshayMahna/Robotics-Mechanics
/Part-3-TestingVisualization/visualize.py
1,462
3.796875
4
""" Visualize the transformations Matplotlib: quiver plot """ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import numpy as np # Function to plot a single transformation def plot_transformation(transformation): """ Plot Transformation matrix ... Parameters --- tran...
607a64ad8b5dfc8aabf7ee78ba793586f338c664
fructoast/Simulation-Eng
/simu1023/pi_monte.py
310
3.609375
4
#coding:utf-8 import math import random def return_area(a,b): return math.sqrt(a**2+b**2) pi = 0.0 times = 0 for i in range(1000000000000000000): if 1 > return_area(random.uniform(0,1),random.uniform(0,1)): pi += 1 times += 1 if times%10 == 1: print("pi:"+str((4*pi)/times))
c4d3d68b1082f98123c96aef1b52a898583d1417
ritamghoshritam/PythonApplications-SourceCode
/Story_Narrator.py
738
3.890625
4
import random import time def gen(): i = 0 while i < 5: i += 1 words1 = ["Surprize", "Tears", "Smile", "Sadness", "Rage", "love"] words2 = [" against the", "over the", "of the", "for the"] words3 = [" shadow", " light", " star", "sun", "moon"] words4 = ["for the money",...
8c1c5a88ab9d3b3e1b2d6b673c9d36454ea274ed
GodsloveIsuor123/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/100-print_tebahpla.py
100
3.875
4
#!/usr/bin/python3 for i in range(122, 96, -2): print("{}{}".format(chr(i), chr(i-33)), end='')
d9401145538efa4e493a200eaae54f9faa363913
malloryeastburn/Sudoku-Solver-PY
/game.py
4,306
3.84375
4
from tkinter import * import tkinter.font as tkFont from functools import partial root = Tk() root.title("Sudoku Solver") root.iconbitmap("C:\\Users\\mallo\\OneDrive\\Desktop\\images\\sudokuIcon.ico") fontStyle = tkFont.Font(family="Lucida Grande", size=30) #Default board board = [ [7,8,0,4,0,0,1,2,0], [6,0,0,0...
00b9d66218aa9645ed7364321537c8967f8df69c
pierre-crucifix/real-spanish
/word_adjacency_matrix_builder.py
2,732
3.609375
4
""" Script #4 1) Create the adjacency matrix of words in tweets. 2) Two words are considered adjacent iff they are present in the same tweet, which proxy the fact they are used in the same context In my situation, I chose not to work with a sparse matrix because my graph is quite dense, but it can be interest...
c9ddce318374df69bf276128eb92cd74e5012001
DDoeDDoe32/Python
/example/temp5.py
415
3.890625
4
''' num1 = 20 num2 = 30 if(num1 > num2) : #False print('{0} > {1}'.format(num1, num2)) else : print('{0} <= {1}'.format(num1, num2)) ''' ''' if(num1 == num2) : #False print('{0} == {1}'.format(nu1, num2)) ''' score = 70 if(score >= 90) : print('수') elif(score >= 80) : print('우') elif(score >...
5a6d8c3bc1e3004fec883de6d29f1ba4d00673b7
icesx/IPython
/python-base/src/learn/yields/yield.py
899
3.96875
4
# coding:utf-8 # Copyright (C) # Author: I # Contact: 12157724@qq.com # # # yield retrun value ,next continue def foo(num): print("starting...") num = 4 print("numxx") while num < 10: print("num:", num) num = num + 1 yield num num = num + 1 print("after yield", nu...
19a6fc07a3684d5022e17b54e5f51655a242bbd1
pvkc8888/python-testprograms
/Algos Hackerrank/Strings/sherlock_and_anagrams.py
1,025
4.15625
4
#!/bin/python3 # simple function to calculate factorial of n def factorial(n): if n == 1: return 1 else: return n * (n - 1) def sherlockAndAnagrams(s): anagrams = 0 Dict = {} for i in range(len(s)): for item in range(i, len(s)): # storing all the unique strin...
d38fe5ad10de9595a1bb813f1cbb5eb5717e4f6d
muhammed-ayman/CSCI-101-course-labs-solutions
/10/05.py
211
3.96875
4
dict1 = {'Ten': 10, 'Twenty': 20, 'Thirty': 30} dict2 = {'Thirty': 30, 'Fourty': 40, 'Fifty': 50} # Answer 1: for i in dict2.keys(): dict1[i] = dict2[i] # Answer 2: dict1.update(dict2.copy()) print(dict1)
01e3c96fefe13c360848f89f5c602689aabaac7b
chjdev/euler
/python/problem7.py
1,107
3.828125
4
# 10001st prime # Problem 7 # # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # What is the 10001st prime number? import itertools N = 10001 def is_divisible_by_one(x, factors): for factor in factors: if x % factor == 0: return True ...
bdbb8e5015da3fdbdb16163d489e31146274d49b
ranajaydas/AutomateBoringProject
/os_directorysize.py
345
3.578125
4
"""Prints the total size of all the files in a specified path.""" import os total_size = 0 directory_name = 'D:\\Installation Files' for filename in os.listdir(directory_name): total_size += os.path.getsize(os.path.join(directory_name, filename)) print('{} bytes'.format(total_size)) print('or {0:.2f} GB'.format...
bf09200ec1c86612901bd2e3f172be0522b6805c
jennLam/skills-assessment-2-dictionaries
/practice.py
5,278
4.46875
4
"""Dictionaries Practice **IMPORTANT:** These problems are meant to be solved using dictionaries and sets. """ def without_duplicates(words): """Given a list of words, return list with duplicates removed. For example:: >>> sorted(without_duplicates( ... ["rose", "is", "a", "rose", "is",...
8c196d966789f4081db21fd70bc0a799499e251e
adyadyat/pyprojects
/hw/day1/day1_hw1.py
363
3.953125
4
for i in range(1, 21): if i % 10 == 0: print(i, end='') print("#", end='') else: if i % 5 == 0: print("#", end='') print(i, end='') else: if i % 3 == 0: print(i, end='') print("*", end='') else: if i % 2 == 0: print(i, end='') print("+", end='') if i % 2 == 1: print(...
d263a7cb6f1d135b6ab0c387ff4a6c5e51bee1b1
nancyrs22/python-class
/clase3.py
676
3.953125
4
def main(): edad = int(input("que edad tiene: ")) #IF - ELSE if(edad > 18): print("mayor de edad") else: print("menor de edad") if(edad > 18): if(edad < 60): print("puede hacer servicio militar") else: print("es demasiado viejo para el servic...
86ca33bcf9b925d9fc44f3fab6d2792180242ac1
reisdima/redes_socket
/tcp/client.py
1,080
3.578125
4
import socket TCP_IP = '127.0.0.1' TCP_PORT = 3030 BUFFER_SIZE = 1024 print("==================================================") print('Propriedades do servidor:') print('Porta do servidor: {}'.format(TCP_PORT)) print('Ip do servidor: {}'.format(TCP_IP)) print('Tamanho do buffer (número de bytes): {}'.format(BUFFER...
da5459de9ac7c4756bb34e8b07da855a25cd798d
thakur-nishant/Coding-Challenges
/MatrixRoatation.py
379
3.6875
4
def matrixRotation(A): if not A: return A if not A[0]: return A row = len(A) col = len(A[0]) result = [[0 for i in range(row)] for j in range(col)] for i in range(col): for j in range(row): result[i][row -j -1] = A[j][i] return result A = [[1,2,3], [...
1c14edbb0b0c0f3f3e4678460916283b8b53334e
rossi2018/DataCamp_Exercises
/08Loops/exercise1.py
118
3.765625
4
#Can you tell how many printout the following while loop will do? x=1 while x<4: print(x) x=x+1 #Its 3 times
c105905de4cef0e9f52455e43e4aadd8f9462a71
MomusChao/Python
/75Set.issubset().py
435
3.96875
4
#75 Set.issubset() # if set is a subset of set2? Return Bool #set.issubset(set2) cities01 = {'Taipei', 'Tokyo','New York'} print(cities01,'\n',sep="") cities02 = {'Hanoi'} print(cities02,'\n',sep="") Ans01 = cities02.issubset(cities01) print(Ans01,'\n',sep="") print("====================") print(cities01,'\n',sep=...
9c1e5a0fecf163f22855ca414c303b813257f10c
Ardhra123/Python-Programming
/number of words.py
175
4.0625
4
fname = input("Enter the element: ") num_words = 0 for line in f: words = line.split() num_words += len(words) print("Number of words:") print(num_words)
c1edc883b1819a26c14309d8e2aa9cd58b346844
iszhangli/Learning
/FluentPython/14_可迭代的对象,迭代器和生成器/01_迭代.py
1,824
3.921875
4
# !/usr/bin/env python # -*- coding:utf-8 -*- # name: 01_迭代 # author: li zhang # date: 2019/11/25 # 迭代器模式: 按需一次获取一个数据项 # 加入了yield关键字,这个关键字用于构建生成器 # 迭代器用于从集合中取出元素,生成器生成不存在的数据 # 在python中,所有的集合都可以迭代 import re import reprlib RE_WORD = re.compile('\w+') # w匹配非特殊字符,+ 匹配一次或者多次 print(RE_WORD) class Sentence(object): ...
e9609f52bb57028e1f7d34677c5b7ff68f72afa5
1264799190/1803
/14day/4.计算机.py
265
3.78125
4
def jisuanji(i,w,q): if q == '+': print(i+w) elif q == '-': print(i-w) elif q == '*': print(i*w) elif q == '/': print(i/w) i = float(input('请输入一个数字')) w = float(input('请输入一个数字')) q = input('请输入+—×/') jisuanji(i,w,q)
fe4049b3418974eafa727557bd1880b921018d22
papibenjie/tuto-python-fr
/tp/recode-liste.py
662
3.90625
4
# Ces fonctions simples doivent etre recoder # fonctions sur les listes # Les fonction suivantes sont deja disponible dans python ! (max, min, sum) # Il faut recoder les fonctions def maxi(liste): # cette fonction retourne le nombre maximum de la liste return 0 def mini(liste): # cette fonction retourn...
1021573b29f9dd4ab93e2fe50432ad72f764e39d
pedr0diniz/cevpython
/PythonExercícios/ex065 - Maior e Menor valores.py
1,145
4.03125
4
# DESAFIO 065 - Crie um programa que leia VÁRIOS NÚMEROS inteiros pelo teclado. No final da execução, mostre a MÉDIA #ENTRE TODOS os valores e qual foi o MAIOR e o MENOR valores lidos. O programa deve perguntar ao usuário se ele quer #ou não CONTINUAR a digitar valores. from math import inf n = soma = cont = maior = 0...
e63ff59047f9d80cabe1a6375c2b8b5c436313b5
Craig-Sperlazza/pandas
/4_aggregate_stats.py
1,064
4.03125
4
import pandas as pd df = pd.read_csv('modified_pokemon.csv') # for index, value in df.iterrows(): # print(index, value) #print(df.head(10)) #print(df.tail(10)) # Example: Average of all the pokemon stats for a certain type, grouped by type print(df.groupby(['Type 1']).mean()) #Example 2: Do the same thing but...
b1b2a5652d5673d705a1fe1755fd67a2906c667b
momandine/Hidden-Markov-Models
/emission_probs.py
6,665
3.75
4
"""Class that stores the number of counts for each word, and for each unigram, bigram and trigram tag pattern. It also calculates and stores the emission probability of a word given a tag.""" from collections import defaultdict class EmissionProbEmitter(object): def __init__(self, source_file=None): #C...
38f922afabf52f5b5053f176c4fbe15eeb7a8e3a
cdamiansiesquen/Trabajo05Damian.Carrillo.
/Boleta 10.py
738
3.734375
4
# Boleta 10 #INPUT cliente=input("nombre del cliente") precio_de_piano=int(input("ingrese el precio de piano")) precio_de_saxofon=int(input("ingrese el precio de saxofon")) precio_de_bateria=int(input("ingrese el precio de bateria")) # Processing total=(precio_de_piano+precio_de_saxofon+precio_de_bateria) #OUPU...
b6bd2f31a247ae2ae89bc7929164046900b85903
NKcell/leetcode
/229. Majority Element II /_229.py
720
3.625
4
class Solution: def majorityElement(self, nums): if not nums: return nums nums.sort() res = list() i = 0 l = len(nums)//3 while i<=(2*l+1): if len(nums)<=i+l: break if nums[i] == nums[i+l]: res.append...
849f98c85d8daebd0ec853429a943603d386be9c
koneil612/Python-Exercises
/Python301Function.py
1,437
3.890625
4
###### Hello function # name=raw_input("what is your name? ") # # def hello(name): # return "Hello " + name # # hello(name) ##### y = x+1 function # import matplotlib.pyplot as plot # # def f(x): # return x + 1 # xs = range(-3, 4) # ys = [] # for x in xs: # ys.append(f(x)) # # plot.plot(xs,ys) # plot.show(...
75b8522d58823548591472884d8e6abde74c4892
henrikemx/PycharmProjects
/exercicios-cursoemvideo-python3-mundo1/Exercícios/Ex035_Guanabara.py
580
4.21875
4
# Enunciado: desenvolva um programa que leia o comprimento de 3 retas e diga ao usuário se elas podem, ou não, formar um triangulo # Solução apresentada pelo Guanabara.. print("-="*20) print("Analizador de Triangulos") print("-="*20) r1 = float(input('\nInforme o comprimento da reta 1: ')) r2 = float(input('Informe ...
c7c6daf981f34f095a11f72e27da3c94b179651d
jabbalaci/Bash-Utils
/add_new_desktop_icon.py
1,369
4.25
4
#!/usr/bin/env python3 """ A simple script that helps you create a desktop icon under Ubuntu. Usage: ------ * put it into the folder ~/Desktop , enter ~/Desktop and launch it * answer the questions and it'll create a launcher * a launcher icon will appear on the Desktop Author: Laszlo Szathmary (jabba.laci@gmail.co...
bceb1ab9f08a4738ef9934d3fd20a04f7feb2407
3nippo/system_of_equations_solving_methods
/tests/test_matrix.py
597
3.640625
4
import context from matrix import Matrix m1 = [ 4, 2, 3, 2, 0, 8, 7, 6, 13, 15, 11, 15] m2 = [8, 1, 1, 5, 3, 4, 7, 2, 7, 3, 4, 8] res = [ 69, 24, 49, 107, 62, 129, 301, 140, 270] A = Matrix(3, 4, elems=m1) B = Matrix(4, 3, elems=m2) Res = Matrix(3, elems=res) p...
16dd4eb3be11a7d5c81727f365169706778530f4
Prathmesh-Salunkhe/PracticeProgramming
/Dynamic_programming/dp_countsubsetdiff.py
551
3.515625
4
def countSubsetDifference(arr,total,diff,n,sum1 = 0): if diff == total - 2*sum1: return 1 if n <= 0 : return 0 count = 0 count += countSubsetDifference(arr,total,diff,n-1,sum1 + arr[n]) + countSubsetDifference(arr,total,diff,n-1,sum1) return count if __name__ == '__main...
e2a1c08ab8f04a9c3b646b96851af5a051c62e4d
nsimsofmordor/PythonProjects
/Projects/AutomateTheBoringStuff/Part_2/PatternMatching/isPhoneNumber.py
1,317
4.25
4
# isPhoneNumber.py # Say you want to find a phone number in a string # You know the pattern is: ###-###-#### def isPhoneNuber(text): if len(text) != 12: # is it 12 chars? return False for i in range(0, 3): # are the first 3 chars nums? if not text[i].isdecimal(): return False ...
bdcb699117259dd1e4e725dad03ba85c5fdb55e2
Tirklee/python3-demo
/T2_11 Python 交换变量 2.py
275
3.53125
4
# -*- coding: UTF-8 -*- # Filename : test.py # author by : www.runoob.com # 用户输入 x = input('输入 x 值: ') y = input('输入 y 值: ') # 不使用临时变量 x, y = y, x print('交换后 x 的值为: {}'.format(x)) print('交换后 y 的值为: {}'.format(y))
bd7e7ea2d52530fb032f7e4fac2991d15e5cbbba
willgoshen/CTCI-with-Python
/1-2-permutations.py
275
3.984375
4
def permutations(s1, s2): sorted_s1 = sorted(s1) sorted_s2 = sorted(s2) if sorted_s1 == sorted_s2: return "'{}' is a permutation of '{}'".format(s1, s2) return "'{}' is not a permutation of '{}'".format(s1, s2) print(permutations("this", "histy"))
31fb5eaa4d699d356110498cbdbec6aed0057da9
ballib/Forritun1
/assignment 6 (strings)/dæmi6.py
176
3.8125
4
a_str = input("Enter last name, first name: ") name = a_str.split(","+" ") fname = name[1] fletter = fname[0] lname = name[0] print(fletter.capitalize()+'.',lname.capitalize())
ede6cc2bfd094dbd682386abfff24e346515a878
UlvacMoscow/InitialTasks
/bubble_sort.py
477
3.984375
4
before_sort_list = [78, 45, 55, 11, -5, 9] def bubble_sort(my_list): last_item = len(my_list) - 1 for z in range(0, last_item): for x in range(0, last_item - z): print(my_list) if my_list[x] > my_list[x + 1]: my_list[x], my_list[x + 1] = my_list[x + 1], my_list[...
b195259246424078508425061224a3d2283a4ae5
OldTruckDriver/Chexer
/ChexerBattle/Chexers-master/random_player/utils.py
1,705
3.640625
4
# The minimum and maximum coordinates on the q and r axes MIN_COORDINATE = -3 MAX_COORDINATE = 3 # Delta values which give the corresponding cells by adding them to the current # cell MOVE_DELTA = [(0, 1), (1, 0), (-1, 1), (0, -1), (-1, 0), (1, -1)] JUMP_DELTA = [(delta_q * 2, delta_r * 2) for delta_q, delta_r ...
d62d8f3817abf2e777256f57d7ede66d8852056e
LeakyBucket/LPTHW
/ex11/ex11.3.py
238
3.5
4
color = raw_input('What is your color? ') home = raw_input('Where do you live? ') job = raw_input('What do you do? ') name = raw_input('What is your name? ') print "Hello %s, the %s from %s who really likes %s" % (name, job, home, color)
b03ee6a6e6e96cf91d0a0bea6638759db6cf9b57
Beelzenef/pyMemories
/tomarNum.py
516
3.984375
4
#!/usr/bin/env python def obtenerNumValido(minimo, maximo): valido = False; numero = 0; while not valido: try: numero = input("¡Dame un número! "); if int(numero) in range(minimo, maximo): valido = True; else: print("T...
50ee1b4779fe424424124767a0ba175064abaf68
blackbat13/matura_inf
/cwiczenia/rekurencja/fibbonaci.py
418
3.828125
4
def fib_rek(n): if n <= 2: return 1 if n > 2: return fib_rek(n - 1) + fib_rek(n - 2) def fib_iter(n): i = 3 tab = [0, 1, 1] while i <= n: tab.append(tab[i-1] + tab[i-2]) i += 1 return tab[n] number = int(input("Podaj liczbę: ")) result = fib_rek(number) pri...
9cfb4f453135d8b72b58cb1453c1fbb3191eb1cd
hippke/Projekt-Euler
/142.py
947
3.5625
4
from math import sqrt import math def isp(i): if i < 0: return False else: root = math.sqrt(i) if int(root + 0.5) ** 2 == i: return True else: return False # Create list of perfect squares squarelist = [] for i in range(1000): squarelist.appen...
d42a9515647bda4064fbfbebf004c3d43b211b5e
adichamoli/LeetCodeProblems
/005 - All Elements in Two Binary Search Trees/Solution2.py
993
3.8125
4
'''48 / 48 test cases passed. Status: Accepted Runtime: 308 ms Memory Usage: 17.6 MB''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # ...
0d9688f0f2e7d9dbf3e8015aac5a1bbda8a57f28
stroodle96/DSpython
/FunctionsS.py
6,605
4.5625
5
# -*- coding: utf-8 -*- """ Created on Wed Sep 5 17:19:33 2018 @author: John Stewart FUNCTIONS """ #%% # This program demonstrates a function. # First, we define a function named message. def message(): print('I am Arthur') print('King of the Britons') # Call the message function. message...
c5c6f6e623e5dba608bede8bc7707e3f98a62e60
AdamZhouSE/pythonHomework
/Code/CodeRecords/2585/60774/267473.py
524
3.84375
4
start = input() end = input() flag = True if(end == 'RXXLRrXXL'): print(False) elif(end == 'XRLXXRXLX'): print(False) elif(end == 'RXXLRXXXL'): print(False) else: i = 0 while(i < len(start)): if(start[i] != end[i]): if(i == len(start) - 1): flag = False ...
eab91e02e29b1db616bab055fc3cb9e87cb9bf69
DouglasOrr/Snippets
/pendulum/pendulum.py
2,728
3.921875
4
import math class Simulation: """Runs a simple inverted pendulum simulation.""" def __init__(self, noise): """Noise should be callable with the current time, return the torque.""" # constants self.mom_mass_1 = 0.1 self.mom_mass_2 = 1.0 self.damping = 0.01 self.dt...
cd681953ee8af063acdf5afd216b4e58e3b65735
Art83/python_bioinformatics
/subsrt_search.py
325
4
4
''' Looking for substring in a string with find ''' def substr_search(genome, substring): if genome.find(substring) is not -1: print("Yes") else: print("No") def main(): genome = input() substring = input() substr_search(genome, substring) if __name__ == "__main__": ma...
d11d0e5bf25a83fa63cdb1a8e2765495b559a7c5
UndeadHibari/Yunque_Spiders
/Python基础/List.py
820
4.1875
4
# 有序,0开始 # 列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。 # 列表的数据项不需要具有相同的类型 list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5 ] list3 = ["a", "b", "c", "d"] # 访问list元素 print("list1[2]:",list1[2]) print("list2[1:3]:",list2[1:3]) #含左不含右,便于计算长度:3-1=2,下标1开始的2个元素 # 更新列表 list3.append("e") list3.append("e") prin...
5f8060bb0f6d878aac8ee54d9bdd0e192822a702
csoriano1618/BuildingDestruction
/src/lib/parseparameters.py
1,106
3.71875
4
def parse_parameters(parameters, default_parameters): ''' Given a dictionary of default parameters, parse a custom dictionary of parameters, being a subgroup of all default parameters, add the faulting parameters with default values to the user custom dictionary of parameters. i.e. >>> par...
94031b93a8301eaa787421b80e529c2f748c1ede
alex-dsouza777/Python-Basics
/Chapter 2 - Variables & Data Types/07_pr_avg.py
152
4.03125
4
#Average of two numbers a = input("Enter first number:") b = input("Enter second number:") a = int(a) b = int(b) avg = (a+b)/b print("Avgerage is:",avg)
a1c5bbf7dba14fde0c5789ca03f8114e0ce52780
danny237/Python-Assignment
/Data types/smallest_num.py
336
4.28125
4
#program to find largest number from list def largest_number(list1): smallest_num = list1[0] for i in range(len(list1)-1): if smallest_num > list1[i+1]: smallest_num = list1[i+1] return smallest_num # list list1 = [1,2,3,4,10] # function call largest_num = largest_number(list1) pr...
3a480a24ad9fa9ea7c2584808165483c7d6e9834
LyaminVS/2021_Lyamin_infa
/turtle2/ex22.py
876
3.5
4
import turtle inp = list(input()) turtle.shape('turtle') turtle.speed(0) n = 0 f = open('/Users/vasilij/pylabs/pythonProject/nums') numbers = [line for line in f] f.close() turtle.penup() turtle.goto(-300, 0) turtle.pendown() for j in range(len(numbers)): numbers[j] = numbers[j].split(',') for k in range(len(...
92e32b68a9632e6eff186b98b6d65201030e98a2
pauloricardo-ggs/Python
/ClínicaME/Pessoa.py
868
3.59375
4
import Endereco as e class Pessoa(): def __init__(self): self.nome = "" self.rg = "" self.cpf = "" self.anoNasc = 0 self.mesNasc = 0 self.sexo = "" self.endereco = e.endereco() def cadastrar(self): self.nome = input("Entre com o nome: ...
1b97b98f9927b8794da2c932c6ebd4597ccbd943
Egorshve/Esercizi-informatica
/es27pag73.py
345
3.6875
4
giorno=1 veicoli=0 segnale=1 while True: print("Giorno: ",giorno) veicoli+=int(input("Inserire numero veicoli transitati: ")) segnale=int(input("Se vuoi continuare schiaccia 1,altrimenti 0: ")) giorno+=1 if segnale==0: giorno-=1 break print() print("In",giorno,"giorni ...
b2d8b7c1960e47005f151b6c916d9d4e4af80a43
Hewish8/TechnicalAssessment
/Dashboard.py
2,124
3.53125
4
import plotly as py from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot import plotly.graph_objs as go import mysql.connector from random import seed from random import random def plot_map(Year): #Connect to MySQL WHRdb = mysql.connector.connect( host = "localhost", user = "...
0daf3ab2b027a351f7f1d2dac089014b48d7583e
zhangwei725/PythonBase
/day02/流程控制if.py
1,095
3.828125
4
# name = input('请输入用户名') # if name == 'admin': # print('尊敬管理员用户您好!!! 欢迎来到 xxx上线了') # money = 10 # if money > 0: # print('有钱真好!!!') # print('您需要什么样的服务') # else: # print('滚!!!没钱还想来吃饭!!!') # print('程序结束') # 如果有苹果就买两斤苹果, # 没有苹果就买一个西瓜 # 如果都没有你就不要回来了 apple = 1 xigua = 0 if apple: print('xxx 买了两斤苹果,回家了!!!') ...
9dcda3befdfeb1b478687f75fd17783489316a5a
shivamvats/sandbox
/python/closure.py
280
3.703125
4
def makeClosure(a, b): d = 1 def closure(c): """The nested function must use the variables from the outer scope to \ be turned into a closure.""" print(a + b + c) return closure if __name__ == "__main__": fn = makeClosure(1, 2) fn(3)
e2c1552cb5ed88acd0b5612787f4a03adb3afe90
NobuyukiInoue/LeetCode
/Problems/0400_0499/0475_Heaters/Project_Python3/Heaters.py
2,366
3.671875
4
# coding: utf-8 import os import sys import time class Solution: def findRadius(self, houses, heaters): """ :type houses: List[int] :type heaters: List[int] :rtype: int """ houses.sort() heaters.sort() radius = 0 i = 0 for house in ho...
fe4d2b5077e45c9e8b045e5e89a06e04e337589c
Alex-GCX/multitask
/coroutine/iterator-base.py
1,828
3.90625
4
from collections.abc import Iterable import time class MyList(object): """自定义一个可迭代对象""" def __init__(self): self.content = list() def add(self, item): self.content.append(item) def __iter__(self): # 1.要使一个对象是可迭代对象,必须实现__iter__方法 # 2.要使一个对象迭代时能每次都返回一个值,必须让__iter__返回一个...
2fabb03f0f6b0b297245354782e650380509424b
klim1286/PythonBasics
/unit1-1.py
394
3.984375
4
y = 10 x = 'Тишь да гладь' print(f'Текст:{x}') print(f'Число:{y}') a1 = input('Введите первое число: ') a2 = input('Введите второе число: ') b1 = input('Введите первую строку: ') b2 = input('Введите вторую строку: ') print(f'Вы ввели числа: {a1}/{a2}') print(f'Вы ввели строки: {b1} / {b2}')
e7131752981f6c5ae0a4a7d86e2a57991f73a8f0
paxosglobal/dsert
/dsert/__init__.py
4,067
3.5
4
def assert_valid_dict(to_validate, known_contents={}, known_types={}, excluded_fields=[]): """ Take a dict to_validate and validate all known known + unknown fields, while skipping any excluded_fields Details of inputs: - known_contents is a dict with the exact key/value pairs expected in to_val...
eb89530dd50252f836d13ae02cc01be52046536b
frankymosutro/bedupython
/clase 03/lista-de-personas.py
1,234
4.0625
4
#/usr/bin/env python # -*- coding: utf-8 -*- #Definicion de objetos o clases class Persona(): """definicion dle objeto persona""" def __init__ (self, nombre, a_paterno, edad): """constructo de la clase persona""" self.nombre = nombre self.a_paterno = a_paterno self.edad = edad ...
6b53685e49c79904aa57b9a33560a817b862ef6a
pathakamaresh86/python_class_prgms
/module_packages/basics/build/lib/Dict/dict_menu_driven.py
2,082
4.125
4
#!/usr/bin/python def dict_append(x,key,value): temp=list() if key in x.keys(): if type(x[key]) == list: for val in x[key]: temp.append(val) else: temp.append(x[key]) temp.append(value) x[key]=temp else: x[key]=value def dict_delete(x,key,value): for key1 in x.keys(): if key...
2e5702c2d14e5a840ce585bfba073f3fbf7cdf07
Sourceless/algorithms
/algorithms/searching/kmp_search.py
1,143
3.9375
4
""" kmp_search.py This module implements kmp search on a sorted list. KMP Search Overview: ------------------------ Uses a prefix function to reduce the searching time. Pre: a sorted list[0,...n,] integers and the key to search for. Post: returns the index of where the first element that...
1d4e2f7ac819a5291ead321a004180b680ba4f7c
amarcolongo/PROGRAMMING-IN-PYTHON-C996
/MarcolongoProject.py
1,504
3.5
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import requests import pandas as pd import csv import numpy as np from bs4 import BeautifulSoup # In[2]: url = 'https://www.census.gov/programs-surveys/popest.html' # This is the url provided in the project description # In[3]: r = requests.get(url) # In[4]...
a94771be8d94ee2e7a94be6775c5d962d8b67e02
penghou620/Coding-Practice
/Python-Practice/Udacity-Programming-Languages/Lesson1/Boilerplate.py
664
3.828125
4
#!/usr/bin/python class Employee: employee_total = 0 def __init__(self,employee_name,employee_id): self.employee_name = employee_name self.employee_id = employee_id Employee.employee_total += 1 def total(self): print "Total employee %d" % Employee.employee_total def getName(self): print "Name: ", self.em...
8b2113a1723c2c0b34ea2b55f0528175067bb13b
vikramchdry/Python-coding-Practice
/subset.py
591
3.65625
4
'''def my_function(s): for ch in s: #print(ch) output = " " if ch.isalpha(): output = output+ch #print(output) x = ch print(x) else: d = int(ch) newchar = chr((ord(x)+d)) #print(newchar) #print(d) my_function('a4k3b2')''' '''def my_fun(s): for word in s: output = "" if word.isa...
e2a723e17be8e428d047a8f57ce7f180d377afc0
leapingllamas/p-value.info
/jokes_2013_01/generate_jokes.py
1,000
3.765625
4
def indefinite_article(w): if w.lower().startswith("a ") or w.lower().startswith("an "): return "" return "an " if w.lower()[0] in list('aeiou') else "a " def camel(s): return s[0].upper() + s[1:] def joke_type1(d1,d2,w1,w2): return "What do you call " + indefinite_article(d1) + d1 + " " + d2 + "? " +...
2de157112c44666679bda07b795779e5df6c6bd6
qwertie64982/Coding4Medicine-2017
/Ancestry/categorize.py
3,915
3.578125
4
# SUMMARY # This program segregates genomes by region. # Differences in genomes are larger between regions than between the people within them. # Thus, it is possible to determine categorize genomes by large vs. small differences. # # The purpose of this program is to demonstrate basically how # procedures li...
2bd90cb5a62d8c624c86be19dcd90b988a84e4eb
maro-create/pythonProject1
/Lekce 3/priklad015.py
802
3.78125
4
datum = input("Zadejte datum, pro které chcete vstupenky koupit ve formátu DD.MM.RRRR: ") from datetime import datetime pozadovaneDatum = datetime.strptime(datum, "%d.%m.%Y") print("pozadovaneDatum =", pozadovaneDatum) pocetOsob = int(input ("Zadejte počet osob: ")) zacatekSezonyA = datetime(2021,7,1) konecSezonyA = da...
ca6f82dcdd28e02fd420139dac15eaab0ac2a9af
AstinCHOI/algo_
/1_data_structure/2_linked_list/14_insert_at_sorted_doubly_lists.py
1,096
4.21875
4
""" Insert a node into a sorted doubly linked list head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None, prev_node = None): self.data = data self.next = next_node self.prev = prev_node return the head node of the...
ddb6cf3e8bd595be5ed56c37d701dff1d6494103
nbvc1003/python
/ch04_5/sub1.py
201
3.640625
4
x = 7 x += 2 print(x) x -= 2 print(x) x *= 2 print(x) x /= 2 print(x) x %= 2 # x = x % 2나머지의 나머지 print(x) x **= 2 # x = x ** 2제곰의 2제곰 print(x) x //= 2 # x = x // 2 print(x)