blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
19be9dc3f31bfa8844c2b2561555bf6435d8f28d
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/leetcode/LeetCode/1004 Max Consecutive Ones III.py
1,520
3.921875
4
#!/usr/bin/python3 """ Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s. Example 1: Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2 Output: 6 Explanation: [1,1,1,0,0,1,1,1,1,1,1] Bolded numbers were flipped from 0 to 1. ...
894237117c7d7f8d4c54549c16f01b9c53aba034
Bngzifei/PythonNotes
/学习路线/1.python基础/day05/06-形参的作用域.py
449
3.65625
4
print('作用域:') """作用域:""" """ 形参只能在定义它的那个函数内部使用,其他地方都无法使用 (开发中,尽量不要形参和变量同名) 形参和被外部的变量同名时,在函数内部优先使用形参,外部只能使用变量 两个在不同函数中,可以有同名参数,互不影响,各自只能在它们内部使用 """ b = 20 def func_sum(a): print(a) def func1(a): print(a) func_sum(1) func1(10)
a3f14d30e5f5861b5bc4eb4ae78739ed5053ff4c
bpeck/ProjectFuschiaFairy
/src/gamelib/Menu.py
5,700
3.53125
4
""" menu.py Setting up the different menu states which the player can use to operate the game by Adam Rickert, 2011 """ #! /usr/bin/env python import pygame, sys from pygame.locals import * import Variables as variables from Variables import * from Game import Game from Data import * def RunGame(screen): #de...
0894c068ad2bb8b66056c549df7637233f4e08eb
akarsh008/hackerrank
/algorithms/implementation/day-of-the-programmer.py
640
3.890625
4
#!/bin/python import sys def solve(year): # Days from January to September excluding February count = 215 feb = 28 if ((year >= 1700) and (year <= 1917) and (year % 4 == 0)): # 1700-1917: Julian calendar feb = 29 elif (year == 1918): # 1918: Transitionary calendar r...
f33b7d47295713c2e730bda388653d08de4be17d
gabriellaec/desoft-analise-exercicios
/backup/user_238/ch36_2019_03_30_18_24_51_393703.py
406
3.640625
4
def eh_primo(numero): i=0 impar=1 while i < numero and impar < numero: if numero == 2: resposta = 'True' elif numero % 2 ==0 or numero % impar == 0: resposta = 'False' else: resposta= 'True' i+=1 impar+=2 return resposta primo=1...
4e2c0b5e342eef01221904fbdb20535830381f3e
abdullahpsoft/Calculator
/index.py
1,007
4.25
4
def calculation(): operator = input("ChoseOperation \n + For Addition \n - For Subtraction \n * For Multiplication \n / For Division") number_1 = int(input("Enter first number:")) number_2 = int(input("Enter second number:")) if operator == "+": print("Addition: ", number_1 + number_2) eli...
dc27d5143454664b2737705342134669f740dab7
abiryusuf/pyhton_3
/algorithms/string.py
908
3.828125
4
def reverseString(str): res = "" str1 = str.replace(" ", "").lower() for reverse in str1: if reverse not in res: res = reverse + res return res print(reverseString("abir")) # def reverseSentence(str): # return " ".join(reversed(str.split())) # print(reverseSentence("I am abir")...
7a3cc92f49e410c1c405924b1fb6650da9f62b2b
bitwoman/python-basico-avancado-geek-university
/Variáveis e Tipos de Dados/exercicio_52.py
2,627
3.6875
4
#52. Três amigos jogaram na loteria. Caso eles ganhem, o prêmio deve ser repartido proporcionalmente ao valor que cada deu para a realização da aposta. #Faça um programa que leia quanto cada apostador investiu, o valor do prêmio, e imprima quanto cada um ganharia do prêmio com base no valor investido. aposta_a1 = int...
857dfc0623090fe15291c53dd4f99d44b229ceba
low101043/sortingAlgorithms
/python/insertion.py
774
4.5625
5
def insertion(data_array): """ This will sort the data numerically in ascending order data_array - This is the data to be sorted returns the data to be sorted """ for index in range(1, len(data_array)): #Will insert each data in the right position current_data = data_array[index] #Ge...
dd470a3f4791b21c778dadfadd6847aa06c0135f
MartinPSE/E.T.C
/sprata_coding/Sprata_/Week_3/Homework/Quiz#1_get_max_discounted_price.py
769
3.84375
4
# 쓱 최대로 할인 적용하기 / 문제를 잘 못 이해했어. # 내 쿠폰있는 만큼만 쓸 수 있는거야 shop_prices = [30000, 2000, 1500000] user_coupons = [20, 40] def get_max_discounted_price(prices, coupons): prices.sort(reverse=True) coupons.sort(reverse=True) prices_index = 0 coupons_index = 0 get_max_prices = 0 while prices_index < le...
16bab2334813b039f8799c1eb1daea8b3cff2275
luoshanya/crawl_project
/进程线程协程/多线程爬虫threading/05condition多线程生产消费.py
2,697
3.53125
4
import threading #导入随机数 random import random #创建全局变量 import time Money = 1000 gTimes = 0 #创建锁 这个condition是继承了Lock的 gCondition = threading.Condition() #封装成一个类 class Prodect(threading.Thread): def run(self): global Money global gTimes #设定死循环 while True: while True: mon...
e102a43937d3cf5b769fb155cdc3cb078a014205
namco1992/algorithms_in_python
/data_structures/linked_list.py
2,724
3.875
4
# coding: utf-8 """ 链表实际是无序列表的一种实现方式。 """ class Node(object): """Node 是单项链表中的一个基本单位。 主要有信息域与指针域。 在单项链表中,一个 node 只知道其下一个元素。 """ def __init__(self, info, p=None): self._info = info self._next = p @property def info(self): return self._info class LinkedList(object): ...
2c4c7eb51e437877377833d392eb26042f44838c
taanh99ams/taanh-fundamental-c4e15
/SS04/Homework_SS04/turtle1.py
239
4.125
4
from turtle import * shape("turtle") speed(0) listcolor = ["red","blue","purple","yellow","grey"] x = 3 for i in listcolor: color(i) for j in range(x): forward(100) left(360 / x) x += 1 mainloop()
03d1d3a94fa2fdb4980b923d576c8f7963370601
aubele/artbot
/Abgabe/Software/ArtBot/database_api.py
10,573
4.03125
4
import sqlite3 from sqlite3 import Error def open_db(db_file="./art.db"): """ Open, or create the database if it is not exsisting and returns the connection. Parameters: db_file(String): Path to the database file Returns: connection(sqlite3.Connection): The connection to the database """...
02b080b169c4bc14a2c5726e1a29c6b81d33a022
mliao21/python-a5-world-data
/world_data.py
3,870
3.859375
4
# world_data.py # AUTHOR NAME: Melissa Liao # # A terminal-based application for computing and printing statistics based on given input. # Detailed specifications are provided via the Assignment 5 git repository. # You must include the main listed below. You may add your own additional classes, functions, variable...
8acf03a6944bec5c0a94d1a23c2bec1ac2322b68
RH-Song/python-practice
/python_get_started/5_if_example.py
343
4.21875
4
x = 1 y = 2 z = 3 if x<y: print 'x is less than y' if x<y<z: print 'x is less than y and y is less than z' if y>x<z: print 'y is greater than x and x is less then z' i = 2 j = 3 if i > j: print 'i is greater than j' elif i == j: print 'i is equal to j' else : print 'i is less than j' if i ...
c72d0ec4aa310c76cc07ff16a2e61acf317a1fa6
rocampocastro604/panalysis
/code/NewtonDd.py
771
3.96875
4
def diferencias_divididas(x, lx, ly): """Metodo numerico de dfierencias dividadas Arguments: - `x`: Valor a interpolar - `lx`: Lista con los valores de x - `ly`: Lista con los valores de y (f(x)) """ y = 0 for i in range(len(lx)-1): if x >= lx[i] and x <= lx[i+1]: ...
0eccef35efe6fe92396f5870ec7abfd873f7d4b2
SilverFuNky/webapp
/web.py
2,039
3.703125
4
from flask import Flask , redirect , url_for , render_template , request import math def calc(a,b,c): if a or b or c != int: try: a = int(a) b = int(b) c = int(c) except ValueError: pass if a or b or c == int: try: ...
b0e23c9be6f19152f61061b880bbec5bb5bf866a
AlexEngelhardt-old/courses
/Data Structures and Algorithms/01 Algorithmic Toolbox/Week 4 - Divide-and-Conquer/assignment/2-majority_element/2-majority_element.py
1,339
3.78125
4
# Uses python3 import sys """You have to write an O(n log(n)) algorithm here. As per the video on the Master Theorem, you end up with O(n logn) iff you break your problems into *two* subproblems, each with runtime T(n/2) + O(n): T(n) = 2 * T(n/2) + O(n) """ def is_majority(candidate, array, left, right): return...
5f807c7a94e23c4483cf05e4a7d9f369c3521289
BANZZAAAIIII/Greedy
/Knapsack/filemanager.py
1,568
4.03125
4
from item import Item def read(filename): try: with open(f"Knapsack\data\{filename}.txt", 'r') as file: result = file.readlines() file.close() return list(map(int, result)) # Map string to int except FileNotFoundError: print("File was not found, this should never...
f1026b6f4a23eed733cf7c2200fb80c165972426
lemon-l/Python-beginner
/100例/打印星星.py
203
3.578125
4
n = 1 while n <= 7: m = int(input('请输入一个1~50的整数:')) if 1 <= m <= 50: print('*' * m) #表示有m个*被输出 n += 1 else: print('输入的数字有误,请重新输入!')
83fe47f9849e78f608ca4e37e11fb01cc965485a
YumanYIN/PythonTD
/TP9/CopieCorbone.py
315
3.515625
4
def cc(data): correct = 0 for i in range(2, len(data)): prix_1 = data[i - 2][1] prix_2 = data[i - 1][1] if ((prix_1 > prix_2) and (prix_2 > data[i][1])) or ((prix_1 < prix_2) and (prix_2 < data[i][1])): correct += 1 rate = correct / (len(data) - 2) print(rate)
360dd91ba20a0d0b908407541eff764f719ebc3b
ganglian/AutoapiTest
/LearnRequests/发送post请求.py
834
3.609375
4
''' 发送post请求 1.使用data传表单格式的参数 2.使用json传json格式的参数 3.post使用headers参数 ''' import requests # 发送post请求,带参数,可以使用data或json来传参,具体使用哪个看系统怎么实现 # 上一步注册成功的手机号,验证登录,登录使用post url = "http://jy001:8081/futureloan/mvc/api/member/login" canshu = {"mobilephone": "18220306410", "pwd": "123456", "regname": "小丑"} r = requests.p...
e658f1ec4bfcb043c06f6df5cb441434a0b3af15
Zhaeong/School
/CSC148/assignment 1/myqueue.py
871
3.984375
4
class EmptyQueueException(Exception): '''Exception raised when attempting to pop from an empty Stack object''' pass class Queue: '''A first-in, first-out queue of items''' def __init__(self): '''(Queue) -> None A new empty Queue.''' self._data = [] def enqueue(self, obj)...
32f71b276d72cbcb5163bf9f9ebd7e6d5e25fca4
inwnote154/Python
/Chapter6Test5.py
731
4.1875
4
def check_grade(score): grade="" if score>=80: grade="A" elif score>=75: grade="B+" elif score>=70: grade="B" elif score>=65: grade="C+" elif score>=60: grade="C" elif score>=55: grade="D+" elif score>=50: grade="D" ...
a3ad7195536b39a649802a4d7c62e57e7200171c
wirut2522/BasicPython
/whileloop.py
162
3.859375
4
""" i = 1 while i <= 10: if i == 10: print(i,end='') else: print(i,end=',') i=i+1 """ i = 1 while True: print(i) i = i + 1
248ce2fa88cf4f3d52fa05f60a94f9b1841f418e
ochimiru/self_taught
/neko_test.py
2,807
3.515625
4
import tkinter import random cursor_x = 0 cursor_y = 0 mouse_x = 0 mouse_y = 0 mouse_c = 0 # マウスを動かした時に実行する関数 def mouse_move(e): global mouse_x, mouse_y mouse_x = e.x mouse_y = e.y # マウスボタンをクリックした時に実行する関数 def mouse_press(e): global mouse_c mouse_c = 1 # マス目を管理する二次元リスト neko = [ [0,0,0,0,0...
50585cfcb0c9fc557adc08567a2006ff98966a64
affaau/myexamples
/pandas_example/pandas_way07.py
758
4.59375
5
''' https://www.learndatasci.com/tutorials/python-pandas-tutorial-complete-introduction-for-beginners/ ''' import pandas as pd import numpy as np movies_df = pd.read_csv("IMDB-Movie-Data.csv", index_col="Title") ''' Handle missing or null value Python - None Numpy - np.nan ''' movies_df.columns = [col.lower() ...
6f6a99b16f1b3532fd2408ba30c4960e6b9e2a09
Maciel-Dev/ExerciciosProg2
/Exercicio 1.py
371
3.640625
4
def fRetornaLista(numeros): #Retorna apenas numeros pares #Loop lista = [] for i in range(numeros + 1): if i%2 == 0: lista.insert(0, i) #oi #Retorno return lista def main(): inputUsuario = int(input()) listaRetorno = fRetornaLista(inputUsuario) print(lis...
5e8006d8b909e2772ed0edb54aa17e099d00dd32
Charles-Sabio-21/charlessabiorepository
/sal01p1.30.py
514
3.921875
4
""" Charles Jerome R. Sabio DATALOG Lab01 Feb 5, 2020 I have neither received nor provided any help on this (lab) activity, nor have I concealed any violation of the Honor Code. """ num = int(input("Type a number to see how many times you can divide it by 2 " #asks for the input to be processe...
aa415d65ba9145213d3a86474490abdaf35200fc
Klimatomas/Python_FI_MU
/Binary search.py
3,544
3.96875
4
__author__ = 'Tomas' # https://www.fi.muni.cz/IB111/sbirka/06-binarni_vyhledavani.html # from random import randint # # def guess_number_human(upper_bound): # the_number = randint(1, upper_bound) # round = 0 # while True: # round += 1 # print "----Round Number {}----".format(round) # number = input("Zadej ci...
d6dad4e1cb88f6b204e7c7ee009f66e506bcac91
NeilWangziyu/crawler
/random_way.py
350
3.875
4
import random from math import sqrt def random_cal_pi(): print("input n:") n = int(input()) count = 0 for i in range(n): x = random.random() y = random.random() if sqrt(x * x + y * y)<1: count += 1 mypi = 4 * count / n print("my pi is",mypi) if __name__ == '_...
6f6038cdf8c037db9e847e234b861654fce32a5a
Black0utss/Exercice-a-rendre
/Exercice 17.py
591
3.890625
4
#Palindrome # Saisie du mot first = input("Veuillez saisir un premier mot ") # Fonction Palindrome qui mesure la longueur de la chaine et test si le caractere i et sont inverse -1-i identique def palindrome(first) : for i in range(len(first)): if first[i] != first[-1-i]: # test de la chaine dans le se...
17af6557a876cb274e9c5b87ee4a07ceed87a7ab
doziej84/useful_script
/python/sliding_window.py
330
4.3125
4
''' This script showing you how to use a sliding window ''' from itertools import islice def sliding_window(a, n, step): ''' a - sequence n - width of the window step - window step ''' z = (islice(a, i, None, step) for i in range(n)) return zip(*z) ##Example sliding_window(range(10), 2...
4f152d26f0cb0b6ff32c899c7eddea1230213d9c
jdonzallaz/solarnet
/solarnet/data/dataset_utils.py
2,103
3.578125
4
from abc import ABC, abstractmethod from typing import Optional, Sequence, Tuple import torch from torch.utils.data import Dataset class BaseDataset(Dataset, ABC): @abstractmethod def y(self, indices: Optional[Sequence[int]] = None) -> list: pass def dataset_mean_std(dataset: Dataset) -> Tuple[floa...
a3eaab2e33abc55c9cef6f48fe77d2a748b1dc01
BercziSandor/pythonCourse_2020_09
/Num_py/numpy_10.py
4,860
3.640625
4
# Különleges numpy értékek # np.NaN (not a number): hiányzó érték # np.isnan() függvény # np.inf: végtelen nagy szám # https://www.geeksforgeeks.org/python-infinity/ # https://stackoverflow.com/questions/42315541/difference-between-np-inf-and-floatinf # https://stackoverflow.com/questions/17534106/what-is-the-differen...
dfab1e532bbad486675ce1583d5854e4abe1ece4
vikrantuk/Code-Signal
/Arcade/Intro/24_Minesweeper.py
1,535
4.03125
4
''' In the popular Minesweeper game you have a board with some mines and those cells that don't contain a mine have a number in it that indicates the total number of mines in the neighboring cells. Starting off with some arrangement of mines we want to create a Minesweeper game setup. Example For matrix = [[true, fa...
cb0384dd3a3416ff1c3e08df9b22d79e18b329c2
shrikantpadhy18/interview-techdev-guide
/Algorithms/Searching & Sorting/Insertion Sort/Insertionsort.py
727
4.3125
4
# Python program for implementation of Insertion Sort # Function to do insertion sort def insertionSort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] # Move elements of arr[0..i-1], that are # greater than key, to one position ahead # of their current position ...
3b1cd539984e72edc023ece92d79a7201e08629f
deki90to/Guessing_Number_Game-Python
/guessing_random_number_by_computer.py
552
4.125
4
import random my_number = int(input('My Number: ')) guesses = 0 while True: computer_guess = random.randrange(10) if computer_guess == my_number: print(f'Computer Has Guess My Secret Number {my_number}.') print(f'Left Guesses {3 - guesses}') break else: print(f'Computer Missed My Number {my_number}, His N...
52ed6d2af9d1ce107de9de7522dc468cf12b9148
ksy9926/Daily-Baekjoon
/문자열/상수/solution.py
248
3.625
4
a, b = input().split() a = list(a) b = list(b) a.reverse() b.reverse() a = int("".join(a)) b = int("".join(b)) print(a) if a>b else print(b) # 간단한 형태 a, b = input().split() a = int(a[::-1]) b = int(b[::-1]) print(a) if a>b else print(b)
b1eaededcc71c08459aaa19c1ee9899dfb8e73f4
qwerty-123456-ui/pythonlabtest
/Q4.py
427
3.984375
4
# Define a function generate_n_chars() that takes an integer n and a character c and returns a string, n characters long. For example, generate_n_chars(5,"x") should return the string "xxxxx“ using keyword only parameters. # def generate_n_chars(n,c): # return c*n # print(generate_n_chars(5,"x")) def generate_n_c...
29bd3d1101832539df6b3550a0f0b400b366ee17
alexanderajju/guess_game
/Guessing.py
394
3.90625
4
print("Guess any number between 0-50:\n") secret_number = 44 Guess_number = '' count = 0 limit = 3 out_of_moves = False while Guess_number != secret_number and not(out_of_moves): if count < limit: Guess_number = int(input("Enter guess: ")) count += 1 else: out_of_moves = True if out_of...
31695caf99f19af695b6fb5e5831a8a8f25200c1
98hyun/algorithm
/graph/dfs/dfs.py
427
3.53125
4
''' dfs 기본정의 ''' graph=[ [], [2,3,8], [1,7], [1,4,5], [3,5], [3,4], [7], [2,6,8], [1,7] ] visited=[False]*9 result=[] def dfs(graph,start_node,visited): visited[start_node]=True result.append(str(start_node)) for i in graph[start_node]: if not visited[i]: ...
e0174ab1105f098bece8374d39dbe43310a75bb9
paulaandrezza/URI-Solutions
/1234.py
406
3.6875
4
while True: try: e = list(input()) s = "" case = True for i in e: if i.isalpha(): if case: s += i.upper() case= False else: s += i.lower() case= True ...
188919c1d5c0cc54910d84d6d01223f4ce9230a2
WillSkywalker/The-Fifteen-Puzzle
/poc_fifteen_gui.py
4,566
3.625
4
""" GUI for the Fifteen puzzle """ from Tkinter import * # constants TILE_SIZE = 80 KEY_MAP = {'up':8320768, 'down':8255233, 'left':8124162, 'right':8189699, } class FifteenGUI: """ Main GUI class """ def __init__(self, puzzle): """ Create frame and ...
729093e7c23557d815db8e4f52149ae8d90aed4f
vmohana/UMN-HW
/Bayes_Learning.py
2,612
3.71875
4
# Python code for bayesian learning # Import libraries import numpy as np # Reading and extracting data training_data = np.loadtxt('training_data.txt') validation_data = np.loadtxt('validation_data.txt') #testing_data = np.loadtxt('testing_data.txt') def Bayes_learning(training_data, validation_data): ...
67dafd87e132064d3a492f3e8c9bdde80dae1110
Katy-Scha/programming_practice
/4 week/N6.py
459
3.96875
4
""" was a[i] before?""" a = input() a = a.split() before = set([]) for i in range(len(a)): if set([a[i]]) & before != set([]): print('yes') else: before.add(a[i]) print('no') """print (bool(a[0] == '1')) print(before & '1') a = [1, 2, 3, 1, 2, 3] before = set([]) for i in range(len(a...
5990ad4c61b3243c84e61d49278831e7eda2eb20
sanghavi06/dummyprj
/str.py
162
3.515625
4
def sravs(a): print(a) l= ['Nokia','samsung'] #i = int(input("enter name ") for i in l: a=input("enter name") print(l.index(i)) #sravs(name,addere) fun(a)
9222bcfaf37885cf629bac04089c70361d229b7d
sanket-qp/codepath-interviewbit
/week3/trees/is_balanced_binary_tree.py
1,390
4.125
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def insert(self, val): if val < self.val: if not self.left: self.left = TreeNode(val) else: self.left.insert(val) else: ...
39a217ffa48e11801adbd8064a10ae2f22126c33
buianhduc/C4T-B10
/session10/intialize2.py
316
3.53125
4
MyFavArtist = { 'name' : "OneRepublic", 'Esta_year' : '2007', 'Active' : True, } MyFavArtist["Head_Singer"] = "Ryan Tedder" MyFavArtist["Love"] = input("Do you love them?: ") print("{0} = {1} \n".format("Name: ",MyFavArtist['name'])) print("{0} = {1}".format("Head Singer: ",MyFavArtist['Head_Singer'])) ...
4c71d1aaa979efe2b8bc7c971b747835cca6fb9a
juanshishido/codewars
/kyu5/pig_it.py
264
3.875
4
from string import punctuation def pig_it(text): pig_latin = [] for word in text.split(): if word in punctuation: pig_latin.append(word) else: pig_latin.append(word[1:]+word[0]+'ay') return ' '.join(pig_latin)
7ac94f7d92c6261423a7a4cf71d44443f307cd46
vegart13/NLTK-Twitter-Sentimentality-Analysis
/TwitterAnalysis.py
3,284
3.75
4
import string from datetime import date import GetOldTweets3 as got from nltk.tokenize import word_tokenize from nltk.corpus import stopwords from nltk.sentiment.vader import SentimentIntensityAnalyzer def get_tweets(): # Using GetOldTweets we are able to retrieve tweets older than what the API allows on...
79e8c7d1b77b77ee5926aa1d5c6992e5efaf0203
javi-air/Project-Euler
/Solved/Problem2.py
286
3.734375
4
def fibonacci_sum(n): previous = 1 current = 2 total = 0 def next_fibo(p,c): return (c,p+c) while current < 4000000: total += (current if not current%2 else 0) (previous,current) = next_fibo(previous,current) print(total)
db92895491ef96da4c68aa48e852b90de161d49e
theoliao1998/Data-Manipulation-and-Analysis
/P1_Data_Gathering_&_Processing/theoliao-part-1/fatal_count_plot.py
1,036
3.59375
4
import matplotlib.pyplot as plt import numpy as np year = np.arange(2005,2016) data_f = [5543, 4942, 4838, 4443, 4443, 4172, 4111, 3842, 3427, 3557, 3616] data_uk = [3201, 3172, 2946, 2538, 2222, 1850, 1901, 1754, 1713, 1775, 1730] width = 0.35 fig, ax = plt.subplots() rects1 = ax.bar(year - width/2, data_f,...
ca14164ddf593c28b967828cefc78201f3675ae2
WeiyiGeek/Study-Promgram
/Python3/Day1/homework10.py
580
3.8125
4
#!/usr/bin/python #辗转相除法(欧几里德算法|计算大数效率高) # def gcd(x,y): # while 1: # temp = x % y # if temp == 0: # return y # x, y = y, temp # temp = input("输入除数与被除数利用,分割如( 319,377 ):") # temp = temp.split(',') # x = int(temp[0]) # y = int(temp[1]) # print("%d 与 %d 的最大公约数:" %(x,y),gcd(x,y))...
0079a71704e58839f3342bdcc0877970100fe6a3
upasek/python-learning
/tuple/try.py
119
3.890625
4
print("Enter a set of tuple (x, y) : ") a = [ tuple(map(int, input ("x : " ).split(","))) for x in range(5) ] print(a)
4feab4b79f88b9cd25d0ffd67b67135db52b2c05
eileenjang/algorithm-study
/src/soomin/programmers/42860.py
1,342
3.59375
4
# 조이스틱 https://programmers.co.kr/learn/courses/30/lessons/42860 ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def solution(name): answer = 0 count = change_alphabet(name) # 1. A 기준 자리 별 알파벳 움직여야할 숫자 횟수 계산! b > 1 c > 2 > # 2. 첫번째 위치 값 넣기 index = 0 answer += count[index] count[index] = 0 # ...
f82281d76a50cb1a1ddf8e66d28fdac84b8024cd
vanialadev/python3.zumbis
/Lista1.py
3,397
4.09375
4
# 1) Faça um programa que peça dois números inteiros e imprima a soma desses dois números a = int(input('Digite número 1:\n')) b = int(input('Digite número 2:\n')) print(a + b) # 2) Escreva um programa que leia um valor em metros e o exiba convertido em milímetros metros = int(input('Digite o valor em metros:\n')) mi...
ae84037475616cc8fd4cb9ec142cc716f25656db
rlui94/MNIST2
/main.py
7,375
3.90625
4
""" This program contains a perceptron learning algorithm trained on the MNIST database. Code for extracting MNIST images based on https://medium.com/@mannasiladittya/converting-mnist-data-in-idx-format-to-python-numpy-array-5cb9126f99f1 """ import data from mnist.loader import MNIST from random import random import n...
ddd19fc50b88a50968b78384ddac31c81896df5a
pakeke-constructor/UNIVERSITY
/COSC262/labs/a2_3.py
5,342
3.546875
4
def Lrecurrance(cache, a, b, i, j): ''' recurrance relation function for LCS ''' if a[i-1] == b[j-1]: cache[i][j] = cache[i-1][j-1] + 1 return cache[i][j] cache[i][j] = max(cache[i-1][j], cache[i][j-1]) return cache[i][j] def drecurrance(cache, a, b, i, j): """ recurr...
80b5e5d74c1d140a76c92a3ea939383e28a315a8
cfarrow/diffpy.srfit
/diffpy/srfit/equation/builder.py
22,905
3.796875
4
#!/usr/bin/env python ######################################################################## # # diffpy.srfit by DANSE Diffraction group # Simon J. L. Billinge # (c) 2008 Trustees of the Columbia University # in the City of New York. All rights reserved. # #...
82c32bec9e4429c7b313e8983fccca3966340086
nurlan5t/python-homeworks
/homework6.py
1,042
3.984375
4
class Account: def __init__(self, login, password): self._login = login self._password = password @property def login(self): return self._login @login.setter def login(self, value): print(value) print("Special Login can't be changed") @property def p...
016a0ec5403c3f14db01e5290593f18b9858f599
Suhaan-Bhandary/Sorting
/heap_sort/using_heapq.py
493
3.921875
4
import heapq # does not change the input. def heap_sort(taken_array): array = taken_array.copy() min_list = [] heapq.heapify(array) # O(n log n) for _ in range(len(array)): # O(n) min_list.append(heapq.heappop(array)) # O(log n) + O(1) return min_list array_one = [1, 2, 8, 4,...
0f4c0393edb932e459bdc3dad803f534f9124295
cgj333/46-Simple-Python-Exercises
/Somewhat Harder Exercises/42 - Sentence Splitter.py
2,133
4.09375
4
''' A sentence splitter is a program capable of splitting a text into sentences. The standard set of heuristics for sentence splitting includes (but isn't limited to) the following rules: Sentence boundaries occur at one of "." (periods), "?" or "!", except that Periods followed by whitespace followed by a lower case ...
8502f638864672b1ed7d46be90760576b85ef656
arkumar404/Python
/continue.py
136
4.09375
4
for num in range(10): if num % 2 == 0: print('Found an even number: ',num) continue print('An odd number', num)
ff3e1d3fed2d69921c670624cd8dfe6a6c8e668f
emma-metodieva/SoftUni_Python_Advanced_202106
/05. Functions Advanced/05-02-01. Even Numbers.py
231
4.03125
4
# 05-02. Functions Advanced - Exercise # 01. Even Numbers def even_numbers(x): if x % 2 == 0: return True else: return False numbers = map(int, input().split()) print(list(filter(even_numbers, numbers)))
61f6e55304211e91ca078feb1341f24cca63e8ed
anubhav-shukla/Learnpyhton
/the_in_keyword.py
210
3.734375
4
# in keyword # if with in # python the_in_keyword.py # here only see in if after see if other # statement and loops if 'a' in 'name': print('a is present') else: print('a is not present')
5f2f66c1f93c289eb14ec9eae35e3c2ee854ffb3
ChenKB91/physic-project
/project_physics.py
4,297
3.609375
4
# -*- coding: UTF-8 -*- ''' A_____A / = . =\ < Developed by CKB > / w \ current version: 1.3 update log: ver 1.0 - initial release ver 1.1 - fix weird acceleration ver 1.2 - fix "ball stuck in wall" problem ver 1.3 - add more balls, with collision ''' from visual import * ########impor...
60a3d705ff154c78b440195d4b6e343b5f777a1b
DevTyagi610/Open-Source-Enthusiast
/rotate_list_elements.py
448
4.1875
4
#rotating list elements anticlockwise def rotate(arr,n,k): k = k%n for i in range(0,n): if i < k: print(arr[n+i-k] , end=" ") else : print(arr[i-k], end = " ") lst = [] n = int(input("enter length of list: ")) for i in range(0,n): x = int(input("enter vals ...
a14dbdb2183ee59864b4997e42240ee90bedde48
datphamjp2903/phamthanhdat-fundamental-c4e14
/Fundamentals/session5/teencode.py
718
3.921875
4
teencode = { "cc": "con cu", "loz": "Do dang ghet", "Vl": "That la bat ngo", "gato": "Ghen an tuc o", "wtf": "Cai deo gi vay", "xl": "Xam loz, am chi 1 dieu nham nhi", "clgt": "Cai lon gi the?", "coin card": "Tuong duong voi cc", "cmnr": "Con me no roi! Nhan manh y muon noi" } while...
349f5490c1de656cb898144c117553e2c1d1c43e
goateater/SoloLearn-Notes
/SL-Python/Quiz/module6.py
372
3.6875
4
nums = {1, 2, 3, 4, 5, 6} nums = {0, 1, 2, 3} & nums nums = filter(lambda x: x > 1, nums) print(len(list(nums))) print() def power(x,y): if y == 0: return 1 else: return x * power(x, y - 1) print(power(2, 3)) print() a = (lambda x:x * (x + 1)) (6) print(a) print() nums = [1,2,8,3,7] res ...
c870d686d31c3a1c51443346854e1d348f8ae977
PythonHead/Python-3.4
/PythonWork/using for loops.py
1,079
3.609375
4
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. >...
43eddd2b09bc708afbeeda71ccb94bda5eca0bc4
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4254/codes/1674_1105.py
1,033
3.640625
4
# Teste seu código aos poucos. Não teste tudo no final, pois fica mais difícil de identificar erros. # Ao testar sua solução, não se limite ao caso de exemplo. Teste as diversas possibilidades de saída b = input("Digite o nome do brasao: ").lower() if(b != "lobo" and b != "leao" and b != "veado" and b != "dragao" and ...
7a5c5e08c1311700db4aa967377f4693ba00e7f3
peekachoo/dangthuhuyen-fundamental-c4e25
/Session4/exercise.py
259
3.59375
4
number = [34, 90, 76, 3, 1, 9, 13, 21, 26, 33, 49, 80] # print(number.index(min(number)), min(number), sep=". ") minn = 34 for i in range(len(number)): if minn > number[i]: minn = number[i] min_index = i print(min_index, minn, sep=". ")
d4f60132ed6debb965d0982655dd20d679f7cf16
KubaGwozdz/MatrixLangCompiler
/AST.py
4,717
3.671875
4
class Node(object): def __init__(self,parent=None): self.parent = parent def __str__(self): return self.printTree() def accept(self, visitor, table=None): return visitor.visit(self) def setParent(self, parent): self.parent = parent class Program(Node): def __init...
2e245c2a2f827092ef7c823bf499e954a4325ca7
madboy/ex47
/ex47/lexicon.py
948
3.953125
4
direction = ['north', 'south', 'east', 'west'] verb = ['go', 'kill', 'eat', 'smack', 'open'] stop = ['the', 'in', 'of', 'and'] noun = ['bear', 'princess', 'nose', 'door'] def to_number(word): try: number = int(word) return number except ValueError: raise ValueError('Word is not a number...
ea1acfa19a36a0b5499e68e600ffd28d2a43e8fd
arrenfaroreuchiha/vectores
/vector2.py
272
4.15625
4
# -*- coding: utf-8 -*- # lista = [] # for i in range(0,5): # numero = raw_input("numero: ") # lista.append(numero) # print lista lista = [] for i in range(0,5): numero = raw_input("numero: ") lista.insert(i, numero) print lista maximo = max(lista) print maximo
a6f7bf66ab33cba099c515b0b41be4c8077a55dc
AP-MI-2021/seminar-2-ioana637
/pb1.py
1,785
4.15625
4
def is_prime(n): ''' Verifica n nr prim :param n: nr intreg :return: True daca n este prim si False, altfel ''' if (n<2): return False if (n>2 and n%2 == 0): return False for d in range(3, n//2 + 1, 2): if n % d == 0: return False return True def ...
73b6ad6f2e26eb9cb6fe7f6dc5ac6f6ed4f542dc
Marcelo510/cursos-python
/Introduccion/Humei2.py
14,586
3.578125
4
### Pequeño Repaso for i in range(1, 10): if i % 2 == 0: print(f"El número {i} es par") ## Control de flujo base = { 1: {"nombre":"Fernanda", "apellido":"Fernandez", "dni":333333331}, 2: {"nombre":"Gonzalo", "apellido":"Gonzalez", "dni":333333332}, 3: {"nombre...
6969ce4f68f3f6face823d877d593cc00428caf7
jia2zhang/web-requests-exercise
/get_data.py
1,399
3.703125
4
# get_data.py import json, requests, pandas, html, os, urllib.request print("REQUESTING SOME DATA FROM THE INTERNET...") print("---------------------------------------------") ## TODO: Requesting a Product request_url = "https://raw.githubusercontent.com/prof-rossetti/nyu-info-2335-201905/master/data/products/2.json"...
56c0867191c876e67d255528fd7dd86731caa54b
tab1tha/Beginning
/comparison.py
546
4.34375
4
#this program finds the largest value among values from the user x=int(input("enter the value of x:")) y=int(input("enter the value of y:")) z=int(input("enter the value of z:"))#input values of various variables if (x>y and x>=z): print('{} is the largest number'.format(x) ) elif(y>x and y>z): print('{...
d16ad955d808bdb5578e479957ec6a50d79f0bf8
humayun-ahmad/py
/pandas/initial.py
792
3.53125
4
import pandas as pd # df = pd.read_csv('data.csv', engine='python-fwf') # please use engine='python-fwf' # print(df.to_string()) myDataset = { 'cars' : ["BMW", "volvo", 'Ford'], 'passings' : [3, 7, 2], 'extra' : ['','2',''] } myvar = pd.DataFrame(myDataset) # print(myvar) a = [1,2,3]...
7ee47ae463a853b30ca452ac16e4677ccf2b491b
chefmohima/DS_Algo
/max_sum_of_contiguous subarr.py
579
3.78125
4
# Given an array of integers that can be both +ve and -ve, # find the contiguous subarraywith the largest sum.e.g, [1,2,-1,2,-3,2,-5] -> the first 4 elements have the largest sum # The main assumption is the max sum at any index i of array A must include the cumulative sum at index i-1, say B[i-1] # only if it is no...
30ccb82e5c1b6c77f384aa978d3bfac0dbb274dd
mkosmala/shiny-octo-bear
/Image_uploading/convert_file.py
378
3.734375
4
#!/usr/bin/python import sys import codecs if len(sys.argv) < 3 : print ("format: convert_file <input_file> <output_file>") exit(1) infilename = sys.argv[1] outfilename = sys.argv[2] with codecs.open(infilename,'r',encoding='cp1252') as infile, codecs.open(outfilename,'w',encoding='utf-8') as outfile: ...
eb85658eae1af8b53fcfadb14173942c69baec55
24gaurangi/Python-practice-scripts
/FirsrLongestWord.py
426
4.3125
4
''' This function returns the first longest word from the input string ''' def LongestWord(sen): max=0 st="" for c in sen: if c.isalnum(): st=st+c else: st=st+" " words=st.split(" ") for word in words: if len(word) > max: max=len(word) ...
b97d9e8c1469670576d77dc5f3f6a0b8dc665332
Johnny-kiv/Python
/Блокнот.py
844
3.609375
4
#Это тренировка] from tkinter import* from tkinter.filedialog import* import fileinput def n(): fra1 = Frame(root, width=1000, height=100, bg="darkred") fr = Text(root, width=100, height=10, wrap=WORD, bg="white") fra1.pack() fr.pack() root.mainloop() def o(): op=askopenfilename() print(op) ...
defd1a01f358d91ad123bb4eb73b99771163fecb
ShaikNaquibuddin/Python
/SortingAlgorithms/selectionsort.py
423
3.9375
4
def selectionsort(A): for i in range(0, len(A)-1): minindex = i for j in range(i+1, len(A)): if A[j] < A[minindex]: minindex = j if i != minindex: A[i], A[minindex] = A[minindex], A[i] A = [] for _ in range(int(input())): A.append(int(i...
21795c14715d138255f79ea55916afb043c1f972
FernandaHinojosa/Reto-18
/test_gun.py
1,268
3.734375
4
from unittest import TestCase from main import Gun import sys sys.tracebacklimit = 0 class TestGun(TestCase): def setUp(self): print(self._testMethodDoc) def test_lock(self): """--Test Lock""" msg = "The posicion of the lock is wrong" gun =Gun(5) gun.lock() sel...
8494e48fa4d7ff78477c7d66a16e31de2d5d5bdc
jeffvswanson/CodingPractice
/Python/Zelle/Chapter6_DefiningFunctions/ProgrammingExercises/5_PizzaCost/pizzaCost2.py
954
4.34375
4
# pizzacostpersquareinch2.py # A program that calculates the cost per square inch of pizza. """Redo Programming Exercise 2 from Chapter 3. Use two functions-one to compute the area of a pizza, and one to compute the cost per square inch.""" import math def pizzaArea(radius): area = math.pi * radius ** 2 retur...
0ad0272dcf484b9a1f78e9263fa00d4c28828711
Dairo01001/python_URI
/URI_1051.py
492
3.8125
4
def solve(salary: float): if salary > 4500.00: dif = salary - 4500.00 return (dif * 0.28) + 270.0 + 80.0 if salary > 3000.00: dif = salary - 3000.00 return (dif * 0.18) + 80.0 if salary > 2000.00: dif = salary - 2000.00 return dif * 0.08 def main(): s...
366f3c7fcec2c8489917520ae4776890983f99f5
ddz-mark/LeetCode
/回溯/401. 二进制手表.py
581
3.53125
4
# -*- coding: utf-8 -*- # @Time : 2020/5/26 10:30 下午 # @Author : ddz class Solution(object): def readBinaryWatch(self, num): """ :type num: int :rtype: List[str] """ if num < 0: return [] # 思路一:暴力枚举 res = [] for h in range(12): ...
5c0606023d6791049e71956afa913fde28fb0107
gaolaotou2458/python2021
/day08-1/购物车作业.py
2,890
3.65625
4
# author:xuxk # contact: 徐小康 # datetime:2021/2/26 8:31 # software: PyCharm """ 文件说明: """ ''' #1.用户先给自已的账户充钱:比如先充3000元。#2.页面显示序号±商品名称+商品价格,如: 1电脑1999 2鼠标10… n购物车结算 I 3.用户输入选择的商品序号,然后打印商品名称及商品价格,并将此商品,添加到购物车,用户还可 4.如果用户输入的商品序号有误,则提示输入有误,并重新输入。 5.用户输入n为购物车结算,依次显示用户购物车里面的商品,数量及单价,若充值的钱数不足,则 6.用户输入Q或者q退出程序。 7.退出程序之后,依次显示用户...
ae96b2c92e511c9114669c258126176cc17d4725
ThaiTOm/Dev
/Algorithm-Python/codeWars/TicToeChecker.py
211
3.859375
4
def is_solved(board): for x in board: if x.count(1) == 3: return 1 elif x.count(2) == 3: return 2 is_solved([[0, 0, 1], [0, 1, 2], [2, 1, 0]])
3ca2b082fd09cea2c4aa6426a1125b88a2389a1e
anupjungkarki/IWAcademy-Assignment
/Assignment 1/DataTypes/answer22.py
275
4.40625
4
# Write a Python program to remove duplicates from a list list_data = [5, 6, 7, 5, 8, 4, 9, 7] print('Before:', list_data) empty_list = [] for item in list_data: if item not in empty_list: empty_list.append(item) list_data = empty_list print('After:', list_data)
912382a53ecbdf760a14c7b372c14df45d558f42
ly989264/Python_COMP9021
/Week2/lab_1_1_Temperature_conversion_tables.py
418
4.28125
4
''' Prints out a conversion table of temperatures from Celsius to Fahrenheit degrees, the former ranging from 0 to 100 in steps of 10. ''' # Insert your code here start_celsius=0 end_celsius=100 step=10 print('Celsius\tFahrenheit') for item in range(start_celsius,end_celsius+step,step): celsius=item fahrenheit=int(...
a661ddd4fa9fd5c254e049649a5e4f267b21f54d
manhcuongpbc/tranmanhcuong-fundamental-c4e18
/Session05/homework5/ex5.py
427
3.765625
4
prices = { 'banana' : 4, 'apple' : 2, 'orange' : 1.5, 'pear' : 3 } stock = { 'banana' : 6, 'apple' : 0, 'orange' : 32, 'pear' : 15 } for key in prices.keys(): print(key) print("price: ", prices[key]) print("stock: ", stock[key]) print() total = 0 for key in prices: ...
fb808d491b7a2867cf1b9f8ebedcf73e52b4988c
deb991/TopGear__Projects_n_Assignments
/Python L1 Assignments/data/str__matcher.py
341
4.0625
4
#!/usr/bin/env python import os import sys import string data = input('Enter the string to test it: ') words = data.split() for word in words: for chars in word: print([chars]) print(data.find('e')) print(word.find('e')) print(data[3]) ## Buffer ## Need to optimised & m...
1a84c8e1a51777f3c12b44705d408c726539fa2a
MrBrightside7991/python
/Python Scripts/excepciones_8.py
236
3.796875
4
# -*- coding: utf-8 -*- """ Created on Fri Mar 6 19:25:49 2020 @author: CEC """ string='x' try: while True: string=string+string print(len(string)) except MemoryError: print('Esto no es gracioso')
a4545a244105d69f50c6b7af34021d37efecf957
tannyboi/induction
/practise_03Aug/factorial.py
283
4.28125
4
# -*- coding: utf-8 -*- """ Created on Mon Aug 3 17:41:32 2020 @author: TANMAY MATHUR """ def factorial(num_for_factorial): if(num_for_factorial<=1): return 1 return num_for_factorial*factorial(num_for_factorial-1) print(factorial(5)) print(factorial(-3))
f956a8de035cdb79e770ba30e857f18a32425409
shreyaspj20/EDA-ON-STUDENT-S-DATASET
/ML-MINOR-MAY.py
7,215
3.953125
4
#!/usr/bin/env python # coding: utf-8 # ### THIS IS THE EXPLORATORY DATA ANALYSIS PROJECT ON THE STUDENT'S PERFORMANCE DATASET. # # #### 1.IMPORTING THE NECESSARY LIBRARIES OR PACKAGES # In[1]: import pandas as pd import numpy as np import matplotlib.pyplot as mat import seaborn as sns # #### 2.STORING THE DATA...