blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bd6513938f0b78cc4ab4c999ef8bae3a1fd37d8c
victoryfb/triangle_analysis
/shape_analysis.py
3,950
3.734375
4
# -*- coding:utf-8 -*- import cv2 as cv import numpy as np import matplotlib.pyplot as plt def triangle_filter(side1, side2, side3): """ Judge the approximate equilateral triangle """ error1 = np.abs(side1 - side2) error2 = np.abs(side1 - side3) error3 = np.abs(side2 - side3) if (error1 + error2...
ee627d8ea17043da565e6bc293e511c46e1e9b08
hector-han/leetcode
/dp/prob0122.py
1,402
3.671875
4
""" 122. 买卖股票的最佳时机 II easy 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 输入: [7,1,5,3,6,4] 输出: 7 解释: 在第 2 天(股票价格 = 1)的时候买入,在第 3 天(股票价格 = 5)的时候卖出, 这笔交易所能获得利润 = 5-1 = 4 。   随后,在第 4 天(股票价格 = 3)的时候买入,在第 5 天(股票价格 = 6)的时候卖出, 这笔交易所能获得利润 = 6-3 ...
e44e096d0f76e48af418cc6ec82d278f581efb4b
viralj/Python
/Encryption/Encryption.py
1,115
4.21875
4
""" Custom Encryption class /* * Author Name: Viral Joshi * * Join me on github : /viralj * facebook : /viral4ever * google+ : /+ViralJoshi * twitter : /viralhj * linkedin : /in/viralj * * */ required python version : Python 3.0+ """ class Encryption: def encryption(str): ...
d4083340831c8b396613147621b09bcb4f8f0bec
jacekkubacki/projectEulerInPython
/euler015.py
686
3.859375
4
#!/usr/bin/env python3 # Problem 15 # # Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. # # How many such routes are there through a 20x20 grid? # Solution: # Every route will contain 20 'downs' and 20 'rights'. #...
7dcf62607f0dc405c231eefb29189fd4fac69c21
yvette-luong/CodeS-Problem-Solving
/src/code_04.py
1,975
4.125
4
""" Given two strings that include only lowercase alpha characters, str_1 and str_2, write a function that returns a new sorted string that contains any character (only once) that appeared in str_1 or str_2. Examples: -------- csLongestPossible("aabbbcccdef", "xxyyzzz") -> "abcdefxyz" csLongestPossible("abc", "abc") -...
b53978dde1b303bfe119060a03d76a92f2a6a591
yasir-web/pythonprogs
/fact1.py
272
3.75
4
#WAP to find the factorial of given no. with format hints enter a number: 5 5!=5*4*3*2*!=120 #WAP to find the number of digits of given number #WAP to find the sum of digits of given number ENTER A NUMBER : 435 sUM: 12 #wap to find the palindrone number of given number
e52199b636e59f1163429627efc119490e5db883
xiajinchun/python-learning
/02_python_basics/05_dict_set.py
1,414
4.375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Python内置了字典:dict的支持,键-值(key-value)存储,具有极快的查找速度,dict的key必须是不可变对象 score = {'Michael': '95', 'Bob': 75, 'Tracy': 85} print score['Michael'] # 通过in判断key是否存在 print 'Michael' in score # dict提供的get方法,如果key不存在,可以返回None,或者自己指定的value print score.get('Bob') print score.get('Boba'...
131194acd119ba0b8dd9591b40609e0fad036217
vigneshragul/python_complete_tutorial-beginners
/Arg and kwargs/argsandkwargs.py
1,190
4.34375
4
# http://thepythonguru.com/python-args-and-kwargs/ EXAMPLE 1: def sum(*args): s=0 for i in args: s+=i print('sum is:',s) sum(1,22,3) --------------------------------------- def sum(a,b,c): print(a,b,c) c=[1,2,3] sum(*c) ---------------------------------------- def my_func(**kwargs): ...
de3c7f7224e0026f4b83843f07ae25b09071f4fb
simpanID/python
/Part 01/belajar-class/pewarisan/main.py
551
3.546875
4
from ability import Ability character1=Ability('Son Goku',55,'World',89,80) character2=Ability('Bezita',57,'Vegeta / Saiya',85,81) list=0 characters = [character1,character2] for character in characters: print('No : '+str(list)+'\n'+str(character.print())) list+=1 data = int(input('Please Input Character Num...
90be9f3ba182b2d0d605bb06b005ba54d6d70326
pikzel/PEGJudge
/solved/3nplus1.py
117
3.90625
4
n = int(input()) steps = 0 while n > 1: if n%2 != 0: # odd n = n * 3 + 1 else: n = n/2 steps += 1 print(steps)
a430c54738a9243a27573c0a50c447c6e2a1d6cc
MarkAvilin1/100_python_projects
/src/retirment_calculator/main.py
595
4.125
4
from datetime import datetime def retirement_calculator(): retirement_age = int(input("Please enter the retirement age: ")) client_age = int(input("Please enter Your age: ")) other_condition = int(input("Please enter Your age: ")) result = 0 if (client_age + other_condition) < retirement_age: ...
4fd1684100326ac99f88847cff22f36a0983862a
jaoist/pycc
/Dictionaries/6-4.py
1,114
3.90625
4
# Programming glossary with control loops. glossary = { 'variable':'A unique declared location that is used to store values.', 'dictionary':'A list of key/value pairs. Use a the key to access the value' ' which can be of any type.', 'loop':'A type of program flow control. Keeps executing as long as ' ...
720557ff8bab36732e5c21802daec9b2f41d4e99
cybersaksham/OpenCV-Tutorials
/T20_image_blending.py
2,182
3.875
4
""" STEPS FOR IMAGE BLENDING USING PYRAMIDS 1. Load 2 images 2. Find gaussian pyramids to suitable level i.e. 5 or 6 3. From gaussian pyramids construct laplacian pyramids 4. Join images in each level of laplacian pyramids 5. From the joint image pyramids, construct original image """ import cv2 im...
83ba63b169a71836932ea0ad50f9c98573bd4caa
Brandyzwz/practice
/练习/break&continue.py
183
3.59375
4
i = 0 while i<100: if i >=20: break elif i == 3: i +=1 continue else: print('这是第%d' % i) i+=1 print('这是第%d' % i) print('')
676430d20201e9bac960247685bc639b9827e3b6
ataicher/learn_to_code
/careeCup/q16.py
783
3.921875
4
#!/usr/bin/python -tt import sys def rotate_matrix(M,n): for i in range(n/2): for j in range(i,n-1-i): tmp = M[i][i+j] M[i][i+j] = M[-1-i-j][i] M[-1-i-j][i] = M[-1-i][-1-i-j] M[-1-i][-1-i-j] = M[i+j][-1-i] M[i+j][-1-i] = tmp def print_matrix(M,n): for i in range(n): print ...
6397732e1914799ceb9ece4929d53553d5a3c9f6
dirkdunn/GA_Lessons
/code_alongs/python_class/helloPython.py
273
3.828125
4
print 'Hello, Python' print "Hello, double quotes! Same thing." print 123 print True print False print "Hello, %s, any value: %r, and digits %d" % ('String interpolation', True, 888) print "s is for %s, r is for %r, and d is for digits: %d" % ('Strings','any value', 1111)
0606cceaff2aaeef52a35758d09c075c0528eb4b
edvinture/python
/untitled2.py
995
4.0625
4
x = random.randint(1, 3) y = input() #lose if x == 1 and y == "2": print("ножницы против камня! ты проиграл!") elif x == 2 and y == "3": print("бумага против ножниц! ты проиграл!") elif x == 3 and y == "1": print("камень против бумаги! ты проиграл!") #won elif x == 2 and y == "1": pri...
8bcdc4a26e2b3d8cb332737d41bdfb503f86ae8a
Sumedh3113/Python-Project
/GUI_Code_and_Note.py
6,783
4.375
4
''' July 5, 2018 @author: Sumedh Deshpande ''' #====================== # imports #====================== import tkinter as tk # as tk is alias so that we can use it in code from tkinter import ttk # for adding widget we use from tkinter import scrolledtext # for adding a scrollbar and text box ''' Self-Notes: Here ...
bc9f5ee5f5a756e651b8821d6d2f2925c7945a3d
cetoli/ada
/grace/main.py
1,085
3.65625
4
from random import randint from time import sleep itens = ('Pedra', 'Papel', 'Tesoura') comp = randint(0,2) jog = int(input('''\033[;32;mSuas opções: \033[;36;m[ 0 ] PEDRA [ 1 ] PAPEL [ 2 ] TESOURA \033[;32;mQual é a sua jogada? ''')) print('\033[;31;mJO') sleep(1) print('\033[;31;mKEN') sleep(1) print('\033[;31;mPO...
74a3b71804733da1a07c5ffd89d36f406e5fcd0d
Verbs2004/Python-Programming-In-Context
/ClassLabs/Lab15/Lab15.py
3,084
4.46875
4
# Lab15.py # 1A: Write a code segment using a while loop that generates the same output as # for count in range(5,20) # print(count) count = 5 while count < 20: print(count) count = count + 1 # 1B: # for i in range(15,-1,-1): # print(i) i = 15 while i > -1: print i i = i - 1 # 1C: A string ...
23255f69c76bc5e0841cc8494ad6b9a4e3cf57fc
ErlendAbrahamsen/INF3331
/Project3/complex.py
4,182
4.40625
4
#3.3/3.4 from math import sqrt class complex: """ Class representation of complex numbers with operations. Attributes: a: Real part of complex number. b: Imaginary part of complex number. """ def __init__(self, a, b): self.a, self.b = a, b def __str__(self): """ ...
34dfe279a16e4accc25313f85d41455095e04744
markshipsides/Python14DayChallenge
/PythonDay03.py
1,249
4.125
4
# MarkS - Python Challenge Day 03 - Flow control CALENDAR_MONTHS: tuple = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") BASIC_SUPERPOWERS: dict = {"Flight": 51, "Speed": 90} SUPERPOWER_UPPER_LIMIT = 80 SUPERPOWER_LOWER_LIMIT = 50 character_name: str = "Jimmy The Snowman" charac...
e487c06c2449e0a3fa95dceef022a319ebd834a7
stanislavshulgin/testtask
/main.py
1,418
3.953125
4
# импортим функции для работы с текстом from textHelper import * def main(): while True: fileName = '' # запрашиваем имя файла, пока оно не станет непустым while len(fileName) == 0: fileName = input('Введите имя файла, либо [Y] для выхода: ') if fileName.lower() == 'y': break try: file = open(file...
8b11c3338a0d4fe3f90b02667e1a632329c68427
qiongxiao/cs231n-lecture-notes
/assignment2/nn/cnn.py
1,095
3.5625
4
import numpy as np import tensorflow as tf def cnn(idx, X, filters, kernel_size, is_training, strides=(1, 1, 1, 1), padding='SAME', use_batchnorm=True, dropout=None): input_filter_size = X.shape[-1] Wconv = tf.get_variable(f'Wconv{idx}', shape=[*kernel_size, input_filter_size, filters]) bc...
04982230b66e427b2bae6c613ced04be19e6516c
Leon-Singleton/Forest-Fire-Simulation-Using-Cellular-Automata-Python
/release/ca_descriptions/templates/wind.py
3,270
3.59375
4
import numpy as np DIRECTIONS = {"NW", "N", "NE", "W", "E", "SW", "S", "SE"} def opposite(direction): #gets opposite direction e.g opposite of NE is SW list_directions = np.array(["N", "NE", "E", "SE", "S", "SW", "W", "NW"]) item_index = np.where(list_directions==direction)[0]+4 return list_directions[item_...
edb30a5f8447dea135ffecd6dfec25e84f9ec86d
nirakarmohanty/Python
/Panda/RowsAndColumnsOperation.py
679
3.546875
4
import pandas as pd import xlrd movie_df = pd.read_csv('E:\Python\Panda\movie.csv') print("Print Shape of the table :",movie_df.shape) rows,columns=movie_df.shape print("Print rows {} and columns {}".format(rows,columns)) print("Head values",movie_df.head()) print("Tail values",movie_df.tail()) print("Head values ...
36e3e3463dcd185cd8683995c7f00f5af84de367
jermstad/FastqStats
/jermstadsb_fastqstats.py
1,897
3.671875
4
import sys # Import sys to accept the file at the command line print("Steven Jermstad, BNFO301 fastqstats") try: # try to accept file fastqName = sys.argv[1] except: # Tell user if command line is empty print("Command line empty ") quit() fastqFile = open(fastqName, 'r') # Opens the file # Lis...
c22f15a5553e17fd837a062240caa569b790480d
CCreek96/UT-coursework
/CS303E/Benford.py
1,592
3.859375
4
# File: Benford.py # Description: This program reads a text file containing the population of each city, in each # state, and reports the frequency distribution of the the first digit of the # population numbers # Date Created: 27 November 2017 # Date Last Modified: 29 November 2017 def leadingDigit (num): ...
a6713e272515e65ce693a4d6f8b7093b0b338842
MohamadShafeah/python
/Day3/08Scopes/O01Scopes3.py
313
3.546875
4
# nested functions name = "Shiv" def college(): name = "Shankar" def room(): nonlocal name # refer the variable which is not local but available in parent name = "Param" print("room", name) room() print("College", name) college() print("Main", name)
02dce10d31ecdfe892fc21396ef03e1b28ac1e0c
dannybattle/2143-OOP-Chen
/Assignments/homework-01.md
4,477
3.984375
4
```python """ Name: Huiluo Chen Email: dannysirchen@gmail.com Assignment: Homework 1 - Lists and Dictionaries Due: 31 Jan @ 9:30 a.m. """ #A a = [1, 5, 4, 2, 3] print(a[0], a[-1]) # Prints: 1 3 a[4] = a[2] + a[-2] print(a) # Prints: [1, 5, 4, 2, 6] print(len(a)) # Prints: 5 print(4 in a) # Prints: True a[1] = [a[...
3f0be8816c8ffb726791697572594c3314b4fe5d
devmayke/python
/exercicio.py
591
4
4
# str1 = input("1 - ") # str2 = input("2 - ") # print("Conteúdo: ", str1, " ----- Comprimento: ", len(str1)) # print("Conteúdo: ", str2, " ----- Comprimento: ", len(str2)) # if str1 == str2: # print("As strings possuem o mesmo conteúdo") # else: # print("As strings não possuem o mesmo conteúdo") # if len(str1) == l...
ad0fc571d9a9c256c5dc5cbdb36eb0d662ae108e
JenZhen/LC
/lc_ladder/company/fb/Search_in_Rotated_Sorted_Array.py
1,025
3.765625
4
#! /usr/local/bin/python3 # https://leetcode.com/problems/search-in-rotated-sorted-array/ # Example """ Algo: Binary Seary D.S.: Solution: 注意2种情况 按以下方式罗列清楚情况 Time: O(logn) Space: O(1) Corner cases: """ class Solution: def search(self, nums: List[int], target: int) -> int: if nums is None or len(nums) =...
10b239c8a269e4fcebcad2631c14ab2765d75b41
williamsmichael/edX_MIT_cs_python
/removing_dups.py
622
4
4
# helpful comparison illustrating the need to clone or copy lists when traversing # -------------------------------------------------------- def removeDups(L1, L2): for e1 in L1: print("at index:{}, e1 = {}".format(index, e1)) if e1 in L2: L1.remove(e1) L1 = [1,2,3,4] L2 = [1,2,5,6] re...
dba86208540b5d0db854a86f69104d90908f84b4
flaviasalisboa/coursera-python-usp-parte1
/Semana-8/funcao-remove_repetidos.py
246
3.859375
4
# Semana 8 - Exercício 1 - Função remove_repetidos # de uma lista retira os valores repetidos def remove_repetidos(lista): templista = [] for i in lista: if i not in templista: templista.append(i) templista.sort() return templista
4c5a49a4955a1d526423be91d85e451f116cde23
shadowkael/some_single_py
/LintCode/3num_sum_closet.py
1,525
3.96875
4
__author__ = 'lenovo' class Solution: """ @param numbers: Give an array numbers of n integer @param target : An integer @return : return the sum of the three integers, the sum closest target. """ def threeSumClosest(self, numbers, target): # write your code here nu...
cb41ec4e93ad477904f202bb2a5f98a555402cd5
vikramforsk2019/FSDP_2019
/day01/forskfssdpday1solution/restart.py
736
3.8125
4
""" Code Challenge Name: Replacing of Characters Filename: restart.py Problem Statement: In a hardcoded string RESTART, replace all the R with $ except the first occurrence and print it. Input: RESTART Output: RESTA$T """ input_string = input("Enter your String :") replaced_char = inp...
fd4b0fb3b82e06050ebdfb7077b9abfad2415456
SushanKattel/LearnBasicPython
/Basic Tkinter GUI/creatingDirectoryToSave.py
5,493
3.53125
4
from tkinter import * import os, string def delete1(): screen.destroy() def newDirInfo(): diskInfo = disk.get().upper() mainFolderInfo = mainFolder.get() savingFolderInfo = savingFolder.get() disk_entry1.delete(0, END) mainFolder_entry1.delete(0, END) savingFolder_entry1.delete(0,...
5761a56747a5123cf7b035f628f890e6bc47b139
vvakrilov/python_basics
/02. Conditional Statements/02. Training/07. World Swimming Record.py
466
3.8125
4
world_record = float(input()) distance_in_meters = float(input()) time_in_seconds_per_meter = float(input()) slowdown = (distance_in_meters // 15) * 12.5 iv_dist_time = distance_in_meters * time_in_seconds_per_meter + slowdown difference = world_record - iv_dist_time if iv_dist_time < world_record: print(f" Yes, he...
52e4ea652ce29f3de08d42d69532ed59342f86c0
syedfarazhus/Beginner-programs
/55. patient condition.py
674
3.875
4
from typing import List from typing import Dict patients = { "Alice Liddel": {"bed": 1, "ward": "psych", "condition": "poor"}, "Bob Vance": {"bed": 2, "ward": "cancer", "condition": "good"}, "Charlie Andrews": {"bed": 3, "ward": "paediatrics", "condition": "good"} } def attend(patients: Dict[str, Dict], condition: st...
0d5f0a5828cda8130c2196294c440c1f058fc683
jxie0755/Learning_Python
/ProgrammingCourses/MIT6001X/week2/recursion_1.py
359
4.03125
4
# iteration method # a * b # break down to a + a + a... as a total b number of a. def mult_iter(a, b): result = 0 while b > 0: result += a b -= 1 return result print(mult_iter(3, 4)) # Recursion method def mult_iter2(a, b): if b == 1: return a else: return a + mult_...
d354c32f1692f9783a7c00293b1799dbe6408ef2
deepaksingh4520/python-code-
/f3.py
164
4.03125
4
def add(): n1=int(input("enter first number")) n2=int(input("enter second number")) sum=n1+n2 print("addition of two number is:",sum) add()
0ef573d82f2f77402b5175ef1d8d0b3e6935d8e3
kammitama5/Data_Science_001
/dcamp_001.py
909
4.25
4
# Create the areas list areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50] # Print out second element from areas print(areas[1]) # Print out last element from areas print(areas[-1]) # Print out the area of the living room print(areas[5]) # Create the are...
93c108645012d8f1ab2e9c51b56f6b6eeb33abeb
ikostan/ProjectEuler
/Problems_1_to_100/Problem_22/tests/test_problem_22.py
1,080
3.59375
4
#!/usr/bin/python import unittest import string import os from Problems_1_to_100.Problem_22.problem_22 import file_reader, \ alphabetical_value, \ total_of_all_name_scores class MyTestCase(unittest.TestCase): print("Running unit tests from: " + os.path.basename(__file__) + "\n") def test_file_read...
ed071eae8bee1b373cc713e1600bb02f36ff940f
cuimin07/LeetCode-test
/159.词典中最长的单词.py
1,154
4
4
''' 给出一个字符串数组words组成的一本英语词典。从中找出最长的一个单词,该单词是由words词典中其他单词逐步添加一个字母组成。 若其中有多个可行的答案,则返回答案中字典序最小的单词。 若无答案,则返回空字符串。 示例 1: 输入: words = ["w","wo","wor","worl", "world"] 输出: "world" 解释: 单词"world"可由"w", "wo", "wor", 和 "worl"添加一个字母组成。 示例 2: 输入: words = ["a", "banana", "app", "appl", "ap", "apply", "apple"] 输出: "apple" 解释: ...
0d1b14e6810d23de46b2265685b7b4b8f04ab13b
radif-ru/Python_Architecture_and_Design_patterns
/Вне проекта/Урок_8. Коды примеров/lava_flow.py
315
4
4
# Одна часть кода написана с учетом ошибки в другой части кода def cities(): result = ['gelendzik', 'piter', 'tula', 1, 'perm', 'samara'] return result def double(): city_list = cities() return [item * 2 for item in city_list] print(double())
e9c14500f033b70fedffd70b4db1a6861c01b3a9
benscruton/python_fundamentals
/coding_dojo_assignments/fundamentals/strings_and_lists.py
1,218
4.25
4
# In this string: words = "It's thanksgiving day. It's my birthday,too!" print the position of the first instance of the word "day". Then create a new string where the word "day" is replaced with the word "month". words = "it's thanksgiving day. it's my birthday, too!" print(words.find("day")) words = words.replace("...
3cc55417ba9a7030bec6c68d7970878d5988c731
CameronSima/pastiche
/formatting.py
1,142
3.9375
4
''' Sometimes, words show up with commas with no following space like,this. Add space if there is none. ''' def split_commas(line): by_commas = line.split(',') return ', '.join(by_commas) def remove_illegal_chars(word, illegals='{}[]_()/\\*$@#'): return word.translate(None, illegals) ''' Ensure that the l...
ee55e27adda2ef78afad151d5f0b0d09eabf082d
almehady/Bongo-Python-Code-Test
/test_code_2.py
2,479
3.65625
4
import unittest from code_2 import print_depth, Person class TestTask2(unittest.TestCase): def person_a(self): return Person("Paige", "Turner", None) def person_b(self, person_a): return Person("Walter", "Melon", person_a) def test_empty(self): data = {} print_depth(dat...
c658c0bbe2982a9e3131c7d83c999174ee323cf3
LiaoBoWen/MyProject
/Leaning/NLP_project/拼写纠错/练习/correct_relu.py
1,507
3.546875
4
from string import ascii_lowercase import re from collections import Counter def tokens(text): return re.findall(r'[a-z]+',text.lower()) with open('../data/big.txt','r') as f: WORDS = tokens(f.read()) WORDS_COUNTS = Counter(WORDS) def know(words): return {w for w in words if w in WORDS_COUN...
b59b7d547623c86c04cffb23bfa2424867c83a4a
Alexanderdude/PythonTaskManager
/task_manager.py
6,595
3.8125
4
bStop = True while bStop == True : # Starts a loop Username = input("\n" + "Please enter your username : ") # Asks for a username from the user U = open('user.txt','r+') # Opens file for line in U : # Checks each line of code sLogin = line iF...
8793d7e8df9e82acad6f6aa6b8e52d002ad7bfc5
Riddlerjoke/password
/password generator.py
1,379
3.5
4
import string from random import randint, choice from tkinter import * def generate_password(): password_min = 12 password_max = 24 all_chars = string.ascii_letters + string.punctuation + string.digits password = "".join(choice(all_chars) for x in range(randint(password_min, password_max))) passwor...
1e80235e090309b94d5e15d50875b97a47991de0
Shark-PT/Games.Python
/funcao_jogo.py
2,103
4.03125
4
import random from main import * from salas import * def monstro(monstro, local, prob1, prob2, prob3): print("***--- Estás numa luta contra um " + monstro) print(". Tu vais?: ---***") print("***--- A: Ver o inventario ") print("***--- B: Dar-lhe um soco? Sucesso: {xpto} %".format(xpto = prob1)) ...
34a4dba1540acc13fc8a08745c465e979ed16cf3
lchen-24/scripts
/PythonScripts/solution2.py
838
3.5625
4
# Note - this code must run in Python 2.x and you must download # http://www.pythonlearn.com/code/BeautifulSoup.py # Into the same folder as this program import urllib from BeautifulSoup import * url = raw_input('Enter URL: ') count = raw_input('Enter count: ') count = int(count) position = raw_input('Enter position:...
d4a02f1d3fd2bf30ce7ef5ad992aaa8c79bd9ad2
toshiNie/leetcode
/Search a 2D Matrix.py
917
3.734375
4
import bisect class Solution(object): def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ if not matrix: return False listA = [] listB = [] for i in matrix: ...
72aaff2fa279b20da1a226f9d7a43d30e8e6acf2
marinehero/Capital-construction-project
/Projects/BlogWebSite/框架/Wraps2.py
1,280
3.734375
4
# -*-coding=utf-8 -*- import functools, time # 这里实现一个完整的判断是否带参数的装饰器: def log(text): if callable(text): # 参数如果是函数,说明装饰器不带参传过来,text是一个函数 @functools.wraps(text) def wrapper(*args, **kwargs): start = time.clock() print ('这是不带参数的装饰器,开始执行') f = text(*args, **kwargs) #...
b80a9c8c29883b0536b5c627fd627f3f1fd6c7d6
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 1/Dictionary _ Tuple/Task1.py
523
3.546875
4
firstList = input().split(",") secondList = input().split(",") fisrtDict = dict() secondDict = dict() for i in firstList: temp = i.split(":") print(temp) fisrtDict[temp[0]] = int(temp[1]) for i in secondList: temp = i.split(":") secondDict[temp[0]]= int(temp[1]) Output = fisrtDict.copy() for el...
3f6e9b61218132cc5a2c8f0471487b299a1e5820
knowmefly/wanmen_learn
/test.py
691
3.671875
4
class Duck: def quack(self): print "Quaaaaack..." def feathers(self): print "The Duck has feathers." class Person: def quack(self): print "Person is not a duck" def feathers(self): print "The person takes a feather from the ground and shows it." class Car: def run(s...
685d487ce0b5dd6abe7fb9cb0ba151030c8f4f77
rokmokorel/Programiranje_1
/03_pisanje funkcij/03_podobnost.py
318
3.59375
4
def podobnost(niz1, niz2): tab = '' cnt = 0 for i, j in zip(niz1, niz2): if i == j: tab += '1' cnt += 1 else: tab += '0' if len(niz1) != len(niz2): tab += '0' * abs(len(niz2) - len(niz1)) return cnt, tab print(podobnost('sobota', 'robot'))
eae2aea7dbcdb7293f1abbfcbd5145f871b8d35c
frclasso/turma1_Python3_2018
/cap04/exercicio-4-6.py
426
3.984375
4
'''Exercício 4.6 Escreva um programa que pergunte a distância que um passageiro deseja percorrer em km. Calcule o preço da passagem , cobrando R$0.50 por km para viagem de até 200km, e R$ 0.45 para viagens mais longas. ''' distancia =float(input("Digite a distancia a percorrer: ")) if distancia <= 200: passagem = ...
9883ee72b61c61a967e9a11f6f5d268ca6c765a9
MinWooPark-dotcom/learn-python
/lambda/lambda02.py
493
3.796875
4
# 람다 : lambda 매개변수 : 리턴값 # def power(x): return x * x # def under_3(x): return x < 3 list_input_a = [1, 2, 3, 4, 5] # output_a = map(power, list_input_a) output_a = map(lambda x: x * x, list_input_a) print(output_a) # <map object at 0x104b8f730> print(list(output_a)) # [1, 4, 9, 16, 25] print() # output_b = filter...
1c21d2cc229b1375525f98ed312ab8b51a9ffaba
blite0/phyton6
/hw_5/hw_2.py
556
4.125
4
num1 = int(input("Enter 1st number: ")) num2 = int(input("Enter 2nd number: ")) num3 = int(input("Enter 3rd number: ")) num4 = int(input("Enter 4th number: ")) num5 = int(input("Enter 5th number: ")) numbers = [num1, num2, num3, num4, num5] def sq(x): if x >= 2: for y in range(2, x): if not (...
042c8374a2eb4e71b219a9df87e7c5c610a84f6c
CharFox1/Small-ideas
/bigMoney.py
1,942
3.515625
4
# Live counter to show how much someone has made during a semester # based on how much they will make total. In other words, the # ammount per second in this program is not the same as the # hourly wage divided by 3600. import time import datetime import pytz # number of days in the UMBC Spring 2019 academic cale...
817700c5236c8bd6f3116e5e72066c6febb6c9d8
juanfelipeortiz/Fundamentos_De_Programacion
/Ingreso_Notas.py
402
3.8125
4
contador=1 notaMaySiete=0 notaMenSiete=0 while contador<=10: nota=int(input('Ingrese la nota')) if nota>=7: notaMaySiete=notaMaySiete+1 else: notaMenSiete=notaMenSiete+1 contador=contador+1 print('La cantoidad de estudintes con nota mayores a 7 son: '+str(notaMaySiete)) print|('La...
5b37226a34a39fe48bcaa9efd96183d41968b4e4
DarioDistaso/ProgramacaoAplicativos
/SA3/sa3.py
1,184
3.90625
4
compra = float(input("\nValor Total da Compra: R$ ")) pagamento = float(input("\nValor recebido: R$ ")) while compra > pagamento: # caso o cliente pagar um valor menor da compra print("\033[1;31mValor errado!\033[m") pagamento = float(input("\nValor recebido: ")) else: # caso o cliente pagar um valor maior ou ...
68f48f0433c24a32903d2f84df5e9f21cfec1529
HiddenEvent/pythonAlgorithm
/exam01/003_bubbleSort.py
460
3.859375
4
# 버블정렬 # - 첫번째꺼랑 두번째꺼랑 비교해서 두번째꺼가 더 작으면 첫번째꺼랑 자리를 바꾼다. numbers = [7, 3, 2, 9] for i in range(0, len(numbers)-1): # n for index in range(i+1, len(numbers)): # n+1 if numbers[i] > numbers[index]: # 자리를 바꿔준다. temp = numbers[i] numbers[i] = numbers[index] number...
2c0bcd7d7f34ee15075fcbdac9b26e7aeeb40088
AVNISHPATEL102/WordGame
/WordGame.py
6,063
3.625
4
import random wordList = ['CODE', 'ERROR', 'EXECUTE', 'JAVA', 'FORTRAN','BLOOD','POTATOES','PANIC','STOMACH','CRAMP','PAIN'] letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] wordList.sort(key=len) def biggestWord(wL): max...
e1c06bc772ba0557a4b5c7e48c4ad4180e7513c1
craigfay/Python_Study
/Python 0035 - zero_matrix/zero_matrix.py
1,030
3.96875
4
# If an element in an NxM matrix is 0, its entire row and column are set to 0 # From pg 91 of Gayle Laakman McDowell's "Cracking the Coding Interview" # created 11.21.2017 by CB Fay # O(NM) def zero_matrix(matrix): zero_coordinates = [] for N in range(0, len(matrix), 1): for M in range(0, len(matr...
8ffc2c89c06ab2d86f48ad837a21287b4ea89402
YuPo13/py_phones
/contacts.py
1,538
3.890625
4
"""This script operates phonebook data operations""" import pickle def check_absence(func): """Check if contact requested exists""" def wrapper(self, name, *others): if name not in self.contacts: raise KeyError return func(self, name, *others) return wrapper class PhoneBook: ...
88bcc35b0256fabcd5f39b1bf5a656b4ed944609
nirajchaughule/Python_prac
/greatest of four.py
276
3.890625
4
print("Hello please enter 4 numbers:") a=input() b=input() c=input() d=input() if a>b: if a>c: if a>d: print(f"{d} is greatest") elif b>c: if b>a: if b>d: elif c>a: if c>b: if c>d: print(f"{c} is greatest") else: print(f"{d} is greatest")
9da128859821cefc24d47022c289eea890addbfd
royadityak94/Interview
/Gramma_Tech/moving_desired_element.py
1,045
4.25
4
# Python program to move all of the given desired element to either the back/front of the array without changing the relative ordering of the existing elements. # Logic: Maintaining the count of all other elements and keep swapping them def move_to_front(arr, ele): i = j = len(arr) - 1 while j >= 0: ...
619f665a6c9d2a1200d190a0cb53c5d5abdb6d00
cedricusureau/Rosalind
/Locating Restriction Sites.py
1,949
4.09375
4
#!/usr/bin/env python # coding: utf-8 # Problem # Figure 2. Palindromic recognition site # # A DNA string is a reverse palindrome if it is equal to its reverse complement. For instance, GCATGC is a reverse palindrome because its reverse complement is GCATGC. See Figure 2. # # Given: A DNA string of length at most 1 ...
584236e536589d6be04dd21912baa4f667730edc
RobinKarlsson/MuZero
/Player.py
361
3.546875
4
class Player(object): def __init__(self, player: int): self.player = player def __repr__(self) -> int: return self.player def __eq__(self, other): return self.player == other.player def _test(): p1 = Player(1) p2 = Player(2) assert p1 != p2 assert p1 == Player(1)...
45a141536259594456606957c3bd553fce88b469
CuiMingyu/DailyPlan
/00DeepLearning/Ch3/3.2/sigmoid.py
602
3.75
4
# 3.2.2 # only support float not numpy import numpy as np import matplotlib.pylab as plt def step_function(x): if x > 0: return 1 else: return 0 # 1. boolean judge elements in x and give it to y # 2. transform boolean into int def step_function_np(x): y = x > 0 return y.astype(np.int...
2bb8f6edd9a9d5d551a2e00033c2493291eab36f
forbearing/mypython
/Process/4.1_queue.py
2,154
4.25
4
=== 概述 1:元素进put(arg),元素出get(arg) 2:队列都是在内存中操作,进程退出,队列清空,队列也是一个阻塞的状态 === 队列分类 queue.Queue 先进先出队列 queue.LifoQueue 后进先出队列 queue.PriorityQueue 优先级队列 queue.deque 双线队列 === 队列方法 put 放数据,Queue.put() 默认有 block=True,和 timeout 两个参数。当 block=True 时, 写入是...
d5b80e1f7f2121f34f5aaaa25e16183a337099a5
SangeethaBheeman/lims
/lims/src/customer.py
1,285
3.59375
4
import config from database_connections import DBConnection class Customer: def __init__(self, first_name, last_name): self.first_name = first_name self.last_name = last_name def connect_to_db(self): db_connection = DBConnection() connection = db_connection.create_conn...
75a6c176d9662def79b6c3f8bc19234dbf60f8ed
xjqd/codes
/python/magic/compare.py
331
3.765625
4
#!/bin/python class Person: def __init__(self,name, age): self.name = name self.age = age def __cmp__(self, other): print "personal defination" if self.age < other.age: print "check < " return False if __name__ == "__main__": p1 = Person("liming", 30) p2 = Person("zhangsan", 40) if p1 > p2 : pri...
d4132b09007568f01380f888354f75b39b94ecb8
KarunaAthichan/BasicPythonProgramming
/FunctionPrintAsterisks.py
304
4.1875
4
# defining function def printAsterisks(n): # return how many astrisks want to be printed return "*"*n # main program starts here # get input from user n = int(input("Enter the numbers of asterisks: ")) # call the function with in print function print(n,"Asterisks printed", printAsterisks(n))
550a0bf8ad8b875244e35c35c1666fbc65120509
arcursino/FATEC
/Masanori/Lista1/Lista1_2.1.py
151
3.765625
4
metros = input("digite o valor em metros: ") metros = int(metros) milímetros = metros * 1000 milímetros = str(milímetros) + 'mm' print(milímetros)
17da7efae1957f9be7e40b3a925490360c8033bf
Reemomar/new-project
/day7.py
614
3.5
4
print("Hello") print('Hello') a = "Hello" print(a) a = """ealthDay specializes in producing evidence-based health content, which is licensed to media companies, hospitals, managed care organizations, publishers, non-profits and government agencies. Organizations automatically post our news and videos on thei...
f78f8b343f8265f92955ad3b360b4f9c2e5d6749
findlogan/afs-200
/week5/function/maxNumbers-step-1.py
405
4.34375
4
#Find the max of 3 numbers numbers = [] def findMaximum(numbers): return max(numbers) def findMinimum(numbers): return min(numbers) #print(findMaximum(5,3,16)) #Output: 16 for i in range(3): userInput = int(input("Enter number: ")) numbers.append(userInput) print("The MINIMUM number inputted is:", ...
95a27d32e23800fa4fd5b65f510c558242bdc532
razyesh/python-training
/Beeflux-test/q1.py
392
4.15625
4
""" Create a function to sum Input Numbers (parameters) which returns sum of inputed numbers. Also write Unittest for the function. my_sum(1,2) should return 3 e.g. my_sum(1,2,3) should return 6 my_sum(1,3,5,7,8) = 24 """ def my_sum(*args): #declare function name my_sum and return the total sum sum = 0 for...
b61a004f43635d4f523f1699839f85bff39b8870
ajstangl88/utils
/python_utils/misc_tools/sendEmail.py
1,637
3.71875
4
#!/usr/bin/env python #!/usr/bin/env python # -*- coding: utf-8 -*- import smtplib, sys def send_email(user, pwd, recipient, subject, body): """ Basic Email Set up for sending a notification :param user: The User Name for the account :param pwd: The password for the account :param reci...
acde20bedd5771650e9a4460bf9d0b8836f45733
min0201ji/Pyhthon_Programming_Basic
/Ch03/3_1_If.py
1,974
4.09375
4
""" 이름 : 박민지 날짜 : 2021/04/07 내용 : 파이썬 조건문 실습 교재 p.60 """ #if num1, num2 = 1, 2 if num1 > 0: #조건 print(('num1은 0보다 크다.')) # if문의 명령이 실행된다.,조건이 참이면 (if문 block)실행되고 거짓이면 안나옴. if num1 > num2: print('num1은 num2보다 크다') # if조건이 거짓이라서 실행 안됨/이 조건을 건너뛴다 #2개의 if문이 같은것 if num1 > 0: if num2 > 1: ...
bb451579c466fd7c28c3ec9bea293c054d7ad8bc
tetrapharmakon/PyEsercizi
/MetodoNewton.py
274
3.828125
4
#!/usr/bin/env python3 # ESERCIZIO: # ricerca di soluzioni approssimate della radice quadrata # attraverso il metodo di Newton def newton(x,a,epsilon): if x-a**2 > -epsilon and x-a**2 < epsilon: return a return newton(x,(a+x/a)/2,epsilon) #print(newton(2,1,10**-7))
434f2be3605de1a592b1a86909124a5657759c08
qtp1300/python
/py3_pycharm/ab.py
148
4.21875
4
#!python3 a = int(input('a:')) b = int(input('b:')) if a==b: print('a=b') else: if a>b: print('a>b') else: print('a<b')
151d0049d4f5a914c5fa9be5d8d76c5eb4219c4d
PdxCodeGuild/class_mudpuppy
/1 Python/hints/lab_04/opinion_gen.py
136
3.5
4
import random user_movie = input("What movie do you like? ") print(f"I thought that {user_movie} was {random.choice(['good', 'bad'])}")
4c228d037b639d811cfe9adcc62b3cec1fae5f2e
kajal1810/ideal-spoon
/pass.py
376
3.90625
4
#pass for i in [1,2,3,4,5]: if i==4: print "Element found" pass print "pass when val is ",i print i #When you do not want any code to execute, pass Statement is used. #It is same as the name refers to. It just makes the control to pass by without executing any code. #If ...
ac41442a2a4ccc93f283c6c4499f256f77677409
danieltshibangu/Mini-projects
/Opposites Function.py
929
4.25
4
# Daniel Tshibangu # program that determines if two integers input # by the user are of opposite signs (i.e. one is # positive and the other negative) # create main function # input variables prompt for a number def main(): num1 = int( input( "Enter first number: " ) ) num2 = int( input( "Enter second number:...
32471ddbd0a025de389d955a990ab2f6f3e858c3
ttungl/Coding-Interview-Challenge
/source-code/Map Sum Pairs 677.py
2,472
3.84375
4
# 677. Map Sum Pairs # ttungl@gmail.com # Implement a MapSum class with insert, and sum methods. # For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to ...
fcfe3043cdf850350ccb8c08684703d02c60f16a
vasunam/leetcode_solutions
/Easy/112.py
848
3.8125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isLeaf(self, root): if root.left==None and root.right==None: return True els...
df83ea9d8a5ba0f0a463c6e8927ab0156a7f095b
A01377515/Actividad_06
/Insectos.py
811
3.671875
4
#encoding: UTF-8 #Autor: Pablo Alejandro Sanchez Tadeo, A01377515 #Contador de insectos def main() : insectos = int( input("insectos recolectados hoy")) dia = 1 total = insectos print("Despues de ",dia," dia(s), has recolectado ",total," insectos") if total <= 30 : print("Te hace falta...
09d94913fe22bf2c29286969cedb9787fc67592b
mohit62/CTCI_Practice
/Arrays and String/OneAway.py
830
3.890625
4
import sys def isreplace(string1,string2): differ=0 for char1,char2 in zip(string1,string2): if char1!=char2: differ+=1 else: continue if differ==1: return True else: return False def isinsert_delete(s1,s2): index1=0 index2=0 while(index1<len(s1) and index2<len(s2)): if (s1[index1]!=s2[i...
d01f75c05f8761d77a1342b86c5cdac6afe8d23a
wfriedland/hack-oregon-trail
/game.py
13,035
3.828125
4
import time import pickle import random from random import seed,randint class OTGame(object): '''Oregon Trail text game. Developed by Python Foundations Class, Hack Oregon Summer 2016''' def __init__(self): # self.intro() # self.start_month = self.going() # self.role, self.bank = self.c...
6dce5338dd1976d8c0218f85e46ecf75b2e45942
gabriellaec/desoft-analise-exercicios
/backup/user_291/ch84_2019_06_06_19_40_18_478591.py
229
3.671875
4
def inverte_dicionario(dicionario): inversão = {} for n, v in dicionario.items(): if not v in inversão: inversão[v] = n else: inversão[v].append(n) return(inversão)
8798c0f13e1eca1cd05e6535789a43eaf02958d8
changyubiao/myalgorithm-demo
/classthree/6.py
2,842
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @Time : 2019/1/1 23:46 @File : 6.py @Author : frank.chang@shoufuyou.com 6 旋转正方形矩阵 【 题目】 给定一个整型正方形矩阵matrix, 请把该矩阵调整成 顺时针旋转90度的样子。 【 要求】 额外空间复杂度为O(1)。 要求 是矩形 才可以的哦. matrix: [[1 2 3] [4 5 6] [7 8 9]] ===> matrix: [[7 4 1] [8 5 2] [9 6 3]] matrix: [[ 1...
4355c40e4a1f0738253402e80eec85e9a74ee637
rahulkumaran/Hack-In-The-North
/outcome.py
3,216
3.53125
4
import pandas as pd import numpy as np # import matplotlib.pyplot as plt from sklearn.ensemble import RandomForestClassifier from sklearn.cross_validation import train_test_split pd.options.mode.chained_assignment = None import json from sklearn.externals import joblib # import statsmodels.formula.api as smf import skl...
8a9cf352960b37a309793834c430d91d91ed14b7
RutyRibeiro/CursoEmVideo-Python
/Exercícios/Desafio_61.py
316
4
4
#le primeiro termo e razao de pa, mostra os 10 primeiros termos usando laço while print('\033[36mCalculo de PA!\033[m') razao=int(input('Digite a Razão:')) pt=int(input('Digite o Primeiro Termo: ')) print('Os 10 primeiros termos da PA:') i=0 while i<10: print('{}° termo: {}'.format(i+1, pt+i*razao)) i+=1
086b7633c2b8e75f2b3d9cf8342da539e91f7204
hanoonaR/FSEAI_cv_assignments-1
/assignment_003/Test/assignment_003.py
783
4.15625
4
# assignment_003: Design a multilayer perceptron for solving XOR from scratch with # hard coded parameters with both numpy(task1) and pytorch(task2). # Task 1: Define function network_numpy() for computing XOR as multilayer perceptron with numpy import numpy as np # Your codes here.. # Define the data set XOR # X = a...
393550bff4f5ae3723997711df2611d1be0d8b35
jamesaud/pybind
/examples/meta_classes.py
902
3.828125
4
from MetaBind import BindableMeta # BindableMeta: Makes the class have bindable_class_methods and bindable_instance_methods # Plus, all inherited classes are also bindable. class Dog(metaclass=BindableMeta): def __init__(self, fname="", lname=""): self.name = fname + " " + lname def gr...
3ed5428b9ccaeb34a119fc7ae797fcb9c2f1e998
tojslee/BOJ_my_code
/1264.py
185
3.734375
4
a=input() while a!="#": print(a.count('a')+a.count('e')+a.count('i')+a.count('o')+a.count('u')+a.count('A')\ +a.count('E')+a.count('I')+a.count('O')+a.count('U')) a=input()