blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fa00a4d857f0b64381be27ee8db06783c56194d3
tonper19/PythonDemos
/beyond_the_basics/07.iterables_and_iteration/iterables_and_iterators.py
8,595
4.15625
4
import itertools from functools import reduce import operator import datetime import time class Trace: # Trace class taken from lesson 3 def __init__(self): self.enabled = True def __call__(self, function): def wrap(*args, **kwargs): if self.enabled: print(f"** ...
6cccc0e570b51376f6eda3c90f1ec13b860f410f
lilei7542/step-to-python
/daily_project/1/4.py
372
3.84375
4
# no.1 L = ['Google', "Runoob", "中国","Taobao"] print (L) # no.2 print (L.__len__()) # no.3 print ("当前字母 :") # no.4 for letter in 'Python': # 第一个实例 print ("当前字母 :",letter) fruits = ['banana', 'apple', 'mango'] for fruit in fruits: # 第二个实例 print ('当前水果 :', fruit) print ("Good by...
94f5069d8e83014512418d972ee8f6cfaa22afb8
yuquan1006/Python_Spaces
/PythonSyntax/class_objects/base_class.py
2,434
4.09375
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ # # @Version : 1.0 # @Time : 2018/4/17 # @Author : YUQUAN # 学习重点 :类 # 1.方法(功能) # class person: # 定义一个类 person # def __init__(self, name): # __init__ 方法会在类的对象被实例化时立即运行。这一方法可以对任何你想进行操作的目标对象进行初始化操作 # self.name = name # # def say(self): ...
cfa36baeb78cd0882baee9aa813f75a0d2c4686f
stuart-gill/flask-sqlalchemy-tutorial
/section5/code/create_table.py
472
3.765625
4
import sqlite3 connection = sqlite3.connect("data.db") cursor = connection.cursor() create_user_table = "CREATE TABLE IF NOT EXISTS users (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE, password TEXT)" cursor.execute(create_user_table) create_item_table = "CREATE TABLE IF NOT EXISTS items (id...
6a968820d01a6fa87830f66d3fbc023b30434c28
sjshtura/stepstone-examples
/morse.py
225
3.546875
4
def txt2morse(s): morse_alphabet = {'a': '.-', 'b': '-...',\ 'c': '-.-.', 'd': '-..', 'e':'.'} morse_string = '' for char in s: morse_code = morse_alphabet[char] morse_string += morse_code + ' ' return morse_string
c28077b156f115dd3afa4db268608123a99443bc
Pamellavsl/Uri
/1180.py
199
3.6875
4
quantidade = int(input()) lista = [] lista = [int(i) for i in input().split()] menorValor = min(lista) posicao = lista.index(menorValor) print("Menor valor:", menorValor) print("Posicao:", posicao)
677daa4fdf4c6e798ccc7d9806f693a351b29edc
pdx-cs-ai/shut-the-box
/stb.py
3,566
3.90625
4
#!/usr/bin/python3 # Shut The Box analysis # https://en.wikipedia.org/wiki/Shut_the_Box # Bart Massey # Monte Carlo and search-based analysis of Shut The Box. # Uses digital scoring on the 1..9 board. import random import argparse from math import floor, log10 from choices import * from solve import solution # Play...
626d5127a2426fce065743d6383fc00027463463
ytxfate/fastapi_template
/project/utils/operate_numeric.py
1,190
3.515625
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- ''' @File : operate_numeric.py @Desc : 精确数值操作 ''' # Standard library imports import decimal # Third party imports # Local application imports def round_up_x(val, x=2): """数值取有效小数位(使用 round 函数) [解决部分小数遇 5 不进的情况] @params: val : 需要取精确值的数据 x :...
c5b735e4cd8bdcff382239373acb5aa51e318957
marlonrenzo/A01054879_1510_labs
/Lab06/sparsevector.py
1,658
3.875
4
import doctest """ We cannot implement code to determine vector length because of the fact that zeroes are not shown in the sparse vectors. We could determine all the zeroes in between and before known values (e.g. {2:5, 6:3} would have a total of 5 zeroes). However, we could have many trailing zeroes, so first we mus...
b418c984cef38f0028a687ea563999b1bcc89348
sengaigibon/pythonhomework
/ex21.py
1,469
3.671875
4
# Take the code from the How To Decode A Website exercise and instead of printing the results to a screen, write the results to a txt file. # In your code, just make up a name for the file you are saving to. # Extras: # Ask the user to specify the name of the output file that will be saved. import requests from bs4...
7408dd1fa499ab0650b2d62f65f7260424434692
NigrumAquila/py_checkio
/scientific_expedition/letter_queue.py
158
3.515625
4
def letter_queue(commands): result = '' for i in commands: if 'PUSH' in i: result += i[-1] else: result = result[1:] return result
0c47db28fafab912d394ce27409821747de73041
mihyr/Artificial-Intelligence
/n_queens_problem/main.py
5,683
3.578125
4
import student_code class bcolors: RED = "\x1b[31m" GREEN = "\x1b[32m" NORMAL = "\x1b[0m" def init_board(): return [[0 for x in range(0,10)] for x in range(0,10)] def set_board(board, data): for y in range(0,10): for x in range(0,10): board[y][x]=int(data[y*10+x]) def check_result(m...
83609f22541ed5add8844b4a302774ebf543a759
Abhinav-Bala/Pathfinding_Visualizer
/cell.py
3,178
4.3125
4
# Abhinav Balasubramanian # April 20, 2021 # ICS3UO-C # This file has the cell class which will be called in the main program # It also contains a function which will draw the cell on the pygame screen import pygame # this class will allow each cell to have its own properties that can be modified class Cell: ...
2ae969a7d0cec46f835e79ce06d6df9c34563d5c
algoasylum/PythonForDataScience-Aug2019
/utils.py
730
3.8125
4
def printProps(props, name, var): """ Print the properties of var Args: props: a tuple of functions to call on var name : string to be printed (name of var) var : variable of interest. This can be any type, but currently restricted to function objects without arguments Returns: ...
bea86f8aa42f03818c16dd402f4109a589a4675e
rayguang/AlgorithmSolutions
/hackerrank/tribonacci.py
513
3.625
4
``` Write a function to compute and return the number of ways in which to climb a flight of n steps, taking 1, 2 or 3 steps at a time. https://stackoverflow.com/questions/22562023/n-steps-with-1-2-or-3-steps-taken-how-many-ways-to-get-to-the-top/40920969#40920969 ``` # Recursive O(n), memorization import functools @...
75196ad161c50eedf2cad9be356ae1db6be713cd
jdrover/Screan_Scrapped
/sceenScrap.py
669
3.828125
4
# import libraries from urllib.request import urlopen from bs4 import BeautifulSoup raw_html = open('scrape.html').read() html = BeautifulSoup(raw_html, 'html.parser') for p in html.select('p'): print(p.text) # specify the url #quote_page = open('scrape.html').read() # query the website and return the html to t...
87a00b0bd7c8c6f64b683aca63479b68165e4976
lilacman888/pythonExam
/src/2020_06_01/if07.py
625
3.84375
4
# 조건문 : if ~ elif ~ else문 # if 조건식1 : # 실행문장 # elif : # 실행문장 # else : # 위의 조건식을 만족하지 않을 경우에 실행될 문장 # 키보드로 점수(0~100점)를 입력했을때, 입력한 점수가 어느 학점인지 판별하는 프로그램 작성 # 90 >= A # 80 >= B # 70 >= C # 60 >= D # 60 < F n = int(input('점수를 입력하세요')) if n>=90: print('A학점입니다.') elif n>=80: print('B학점...
9996bf648dca5ee77e83e3158ca5c95fac21104e
Madoka09/Worker15
/utils/functions.py
296
3.78125
4
''' Functions of general purpose ''' def fortnight_number(date): ''' Calculate fortnight number based on a date ''' month = date.month day = date.day year = date.year fn = month * 2 if day >= 1 and day <= 15: fn = fn - 1 return '{}{:02}'.format(year, fn)
6eb97c067ebe21ae7037af74dd6502b6a4f5107a
UWPCE-PythonCert-ClassRepos/Python210_Fall2019
/students/kclark75/assignment07/html_render.py
2,522
3.828125
4
#!/usr/bin/env python3 """ A class-based system for rendering html. """ # This is the framework for the base class class TextWrapper: """ A simple wrapper that creates a class with a render method for just text This allows the Element classes to render either Element objects or plain text ""...
c42fad1faacb03bf312cb6984a38ce3687659503
loganintech/cs420-assignments
/three_walk.py
807
3.609375
4
should_be_true_graph = { "s": ["w"], "w": ["t", "y"], "y": ["z", "x"], "x": ["s"], "z": ["t"], "t": [], # dest } should_be_false = { "a": ["b"], "b": ["c"], "c": ["a"], } countmap = {} path = [] def three_walk(src, dst, length, g): if src == dst: return length % 3 =...
4a0f5db2f0143bfd37d4384a37abd9ebd82ca182
Teddykavooh/Reboot-Book-API
/app/models.py
1,392
3.5
4
class Books: books = {1: {"Title": "Paths Of Glory", "Author": "Jeffrey Archer", "Genre": "Adventure", "Items": 5}, 2: {"Title": "Not A Penny More Not A Penny Less", "Author": "Jeffrey Archer", "Genre": "Crime", "Items": 7} } def get_all_books(self): return self.books def...
16ef160c78b51cc77d69a22c21d1815deca7cab5
dervlascully/GirlScriptPython
/Week2/Loops.py
1,827
4.46875
4
# WHILE LOOP # With the while loop we can execute a set of statements as long as a condition is true. # basic while loop i = 1 while i < 6: print(i) i += 1 # while loop with break i = 1 while i < 6: print(i) if i == 3: break i += 1 #while loop with continue i = 0 while i < 6: i += 1 if i == 3: ...
ef44ac81498e815bb66ea1242b3f662513bb1855
NMVRollo/PythonStepik
/7_9/2.py
138
3.921875
4
numbers = [] height = int(input()) for i in range(1, height+1): numbers.append(str(i)) print(''.join(numbers + numbers[-2::-1]))
c2ed231714aac3f474bbf29ab0c8e8f5623beb9c
WOWOStudio/Python_test
/Xin/LeetCode/data_structure/chapterII/sectionII.py
1,271
3.5
4
''' 剑指 Offer 10- II. 青蛙跳台阶问题 一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶。求该青蛙跳上一个 n级的台阶总共有多少种跳法。 答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返回 1。 示例 1: 输入:n = 2 输出:2 示例 2: 输入:n = 7 输出:21 示例 3: 输入:n = 0 输出:1 提示: 0 <= n <= 100 作者:Krahets 链接:https://leetcode-cn.com/leetbook/read/illustration-of-algorithm/57h...
5cb5ad194023bcafe2c4abc910d0113ced157d00
jluocc/jluo2018
/python/python/老师笔记/python/day06/day06/exercise/list1.py
584
3.75
4
# 练习: # 已知有列表: # L = [3, 5] # 用索引的切片等操作,将原列表的改变为: # L = [1, 2, 3, 4, 5, 6] # 将列表反转(先后顺序颠倒),删除最后一个元素后,打印此列表: # print(L) # [6, 5, 4, 3, 2] L = [3, 5] # print(id(L)) L[1:1] = [4] L[0:0] = [1, 2] L[len(L):len(L)] = [6] print(L) # L = [1, 2, 3, 4, 5, 6] # 将列表反转(先后顺序颠倒),删除最后一个元素后,打印此列表: L[::]...
5ae3689c95d3cfa7fb2057f00e299c21985f6ab4
AdamZhouSE/pythonHomework
/Code/CodeRecords/2309/60627/275273.py
125
3.625
4
n,m = input().split() n = int(n) l = [] for i in range(n): l.append(input()) print(n,m) if n ==2 and m == 3: print(2)
a72652c498bbd66d4dcf9b6b500756e9cddc5f12
tcrowell4/adventofcode
/2015/day15.py
2,809
3.75
4
#!/usr/local/bin/python from itertools import combinations_with_replacement, permutations from collections import defaultdict def find_sum_in_list(numbers, target, num_properties): # results = [] results = [ combo for combo in combinations_with_replacement(numbers, num_properties) if...
b468b3fce3d71a536cb07fe511ee2711ae6d1383
acemodou/Working-Copy
/DataStructures/v1/Arrays/multidimension/squareMatrices/matrix.py
998
4.3125
4
__about__ = ''' Brief: Diagonal matrix: Is a matrix that M[i, j] = 0 if i != j Usage: It gives us important information on independent componenet in a system Author(s): Modou ''' from typing import List class Diagonal: def __init__(self, A: List[int]): self.diagonal...
9f7095e3ca453522484e2ba4a6cfeb662bc4b010
anandabhishek01555/100Daysofcode
/DAY-64/Common Uncommon.py
425
3.625
4
s1=input() s2=input() for i in range(len(s1)): if (s1[i] not in s2): print(s1[i],end="") print() for i in range(len(s2)): if (s2[i] not in s1): print(s2[i],end="") print() x="" l1=len(s1) l2=len(s2) if l1>l2: for i in range(l1): if s1[i] in s2: x+=s1[i] e...
7d780a2e0ccf8c1014a5b00dd4be8a997856f62e
Aiyane/aiyane-LeetCode
/1-50/两数之和.py
900
3.640625
4
# -*- coding: utf-8 -*- #!/usr/bin/python3 # File Name: 两数之和.py # Created Time: Sun 29 Apr 2018 10:38:08 PM CST """ 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。 你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] """ """ 思路: 通过字典来进行速度上的提升 """ class Solution: ...
840ab02101e2a81d079d01e9f3691a2f3cfb4fee
taltech-coding/python-slides
/exception/exception_str.py
307
4.1875
4
import math def calculate_square_root(value): if value < 0: print("Must not be a negative number") return -1 # return something to understand something went wrong return math.sqrt(value) # ... ask for user input # user enters -1 user_input = 'a' calculate_square_root(user_input)
299a8c71a1d3e9df655ed196c182b49d50e9a6b6
blodyx/tkpy
/tkpy/map.py
11,883
3.625
4
from math import sqrt def cell_id(x, y): """ :func:`cell_id` will convert :class:`int` x and :class:`int` y into cell id that understand for TK. :param x: - :class:`int` x cell's coordinate. :param y: - :class:`int` y cell's coordinate. return: :class:`int` """ return (536887296 + x) + (...
8c9283fe037f1b46ec2c7b575a92aa3ca0645eea
ArthiVivek/Ciphers
/a2-cipher_functions.py
10,527
4.1875
4
# Functions for running an encryption or decryption algorithm ENCRYPT = 'e' DECRYPT = 'd' # Write your functions after this comment. Do not change the statements above # this comment. Do not use import, open, input or print statements in the # code that you submit. Do not use break or continue statements. ...
41d67970d38965b8e1f43fe6de2f8dc1b9fd5924
mjumbewu/fun-a-day-2019
/fade_light.py
2,326
3.921875
4
""" A "simple" (who am I kidding; I don't know how simple it might be) fading LED. """ from RPi import GPIO import math import time # I'm working through this with a couple of different sources. The first is an # article on how pulse width modulation works with LEDs[1]. It's neat that, by # it's explanation, the dimm...
6ed9f7fe3d9b57a644a92313530233a4fe4fa1da
TheodoreMatthew/Excercise-Week-2_2440061253_Theodore-
/question5.py
814
4.71875
5
#Question 5 """ Write a program that calculates the wavelength of a wave traveling at a constant velocity given the speed and the frequency. Use the formula lambda = v/f, where lambda is wavelength in meters, v is velocity in meters per second, and f is frequency in Hertz (cycles per second). Print the velocity, ...
a8832c4ee1846de7f15933bce03e8d9e25984896
maksiplus19/crypto
/source/part2.py
1,997
3.515625
4
from itertools import count from typing import Iterable, List, Optional def prime_gen(): numbers = count(2) while True: p = next(numbers) yield p numbers = filter(p.__rmod__, numbers) # gen = prime() # i = 1 # while (i := next(gen)) < 1000: # print(i) def gcd_ext(first: int, sec...
2b6cf4d2d0e9e2f365f94407f0266916c6a6bb1d
alexabate/GalSim
/galsim/random.py
24,441
3.65625
4
""" @file random.py Addition of docstrings to the Random deviate classes at the Python layer. """ from . import _galsim def permute(rng, *args): """Randomly permute one or more lists. If more than one list is given, then all lists will have the same random permutation applied to it. @param rng T...
4155502ac5157c216643f95e2dfffcae7c315947
lohanidamodar/udemy-python-gui-and-gaming
/basic/8-checkbuttons.py
417
3.578125
4
#!/usr/bin/env python __author__ = 'dlohani' from tkinter import * root = Tk() label1 = Label(root, text = "Name: ") label1.grid(row=0,column = 0) entryName = Entry(root) entryName.grid(row = 0, column = 1) button1 = Button(root, text = "Save") button1.grid(row=0, column = 2) checkButton = Checkbutton(root, te...
fd2d65fdb402c16deb36d9ba3bad9bb46b094c5c
cafeciaojoe/pyTuts
/Beginner_Tutorials/is_not_none.py
469
4.40625
4
A = None B = None if A: print('A is not a thing it is None') A = 1 if A: print('A is now a thing, it is 1') print('A is not None... {}. Because A is None '.format(A is not None)) print('A is not None... {}. Because B is None '.format(B is not None)) """ the line below is like saying: A = (B is not None) ""...
802d5c80ebb01bf0f60152ef73028ecb563eb6c6
supvigi/python-first-project
/Tasks/2020_12_12/For/For2.py
220
3.84375
4
a = int(input("Put in the A: ")) b = int(input("Put in the B: ")) c = int(input("Put in the C: ")) lst = [a, b, c] ggl = 0 for x in lst: if ggl < x: ggl = x print("The biggest number in the list is", ggl)
f60f25d12e3eb2ae665f151824567b7f06012701
sudhirshahu51/projects
/Algorithms/Graph/Bellman_Ford_Algorith.py
4,261
4
4
# To implement Bellman Ford Algorithm using queue to find the shortest path including negative weights class Vertex: # Class of vertex def __init__(self, key): self.id = key self.connected = {} # dictionary of all the connected vertices with tht vertices self.s...
278d9eb16ebad5e515b87573022d396e05cce2f7
taepd/study
/Machine Learning/수업 자료/1주차_파이썬 프로그래밍/제04일차/myArrSum.py
344
4.15625
4
# 리스트의 모든 요소들의 합을 구해주는 함수 arrsum def arrsum(data): total = 0 for item in data: total += item return total mylist = [10, 20, 30] result = arrsum(mylist) print(result) mydata = (1, 2, 3) result = arrsum(mydata) print(result) myset = set((11, 22, 33)) result = arrsum(myset) print(result)
899fe933711d3e072b8fe8ba9be253fc5dad3751
seggiepants/Exercism
/python/pig-latin/pig_latin.py
2,673
4.09375
4
from functools import reduce consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z'] vowels = ['a', 'e', 'i', 'o', 'u', 'y'] # **Rule 4**: If a word contains a "y" after a consonant cluster or as the second letter in a two letter word it makes a vowel sound (e...
d0ac24f085ee9cf5a5ef6bd2bcb571dedf7f81f4
mzshieh/snp2016
/lec09/exercise/task1.py
672
4.21875
4
# read a float a = input() a = float(a) # Idea # step 1: test if a is negative # Negative: int(a) >= a # Positive: int(a) <= a if (a < 0): # a is negative if (a-int(a) == -0.5): # 5 to even if (int(a) % 2 == 0): print(int(a)) # even is up else: print(int(a)-1) # even down ...
c2a981feba7cdf5a25b09c38afe992b13edc6932
RainFZY/LeetCode-Practice
/501.二叉搜索树中的众数.py
932
3.671875
4
# # @lc app=leetcode.cn id=501 lang=python3 # # [501] 二叉搜索树中的众数 # # @lc code=start # 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 # Binary Search Tree, in-order traversal(任何...
5ca0bfe09c2c87cddeaebc1357c81f8748bed125
simyy/leetcode
/PowerofFour.py
711
4.125
4
""" Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without loops/recursion? Analysis: 1. power of 2: 2 - 10, 4 - 100, 8 - 1000, then it must be n&(n - 1)==0 2. power of 4 must be...
6e734c1bde1608d4e9a341a47960a39b4e2a6e97
marcegeek/frro-soporte-2018-06
/practico_01/ejercicio_01.py
141
3.8125
4
def max(a, b): if a > b: return a else: return b assert max(8, 5) == 8 assert max(5, 8) == 8 assert max(5, 5) == 5
1141628c7c92f84ea0ffcd07661929f2c935c350
MudOnTire/python3-learning
/6. string formatting.py
633
4.25
4
num1 = 3.1415926 num2 = 10.2324235978 # PREVIOUS print('num 1 is', num1, 'and num 2 is', num2) # FORMAT METHOD print('num 1 is {} and num 2 is {}'.format(num1, num2)) print('num 1 is {0} and num 2 is {1}'.format(num1, num2)) print('num 1 is {1} and num 2 is {0}'.format(num1, num2)) # FORMAT OPTIONS print('num 1 is {...
0b247b139a1af20ee83fac3d0fd2fe22e45cf05b
kwebam/c-162
/c-160.py
2,128
3.796875
4
from tkinter import * from tkinter import filedialog from PIL import ImageTk, Image import os root = Tk() root.minsize(650,650) root.maxsize(650,650) open_img = ImageTk.PhotoImage(Image.open("open.png")) save_img = ImageTk.PhotoImage(Image.open("save.png")) exit_img = ImageTk.PhotoImage(Image.open("exit.jp...
ce4857ffcf1d865f5c943156b12e04273c1c6906
Ritapeace/holbertonschool-higher_level_programming
/0x11-python-network_1/103-search_twitter.py
1,720
3.5
4
#!/usr/bin/python3 """ getting info from twitter API """ if __name__ == "__main__": import sys import requests import base64 API = "https://api.twitter.com/" # get the costumer key and secret key cos_key = sys.argv[1] sec_key = sys.argv[2] # string to search string = sys.argv[3] ...
4a84baf59ca678ee3a27987f6d857101fc009831
huanhuan18/test04
/learn_python/列表的遍历.py
800
3.8125
4
# my_list = [10, 20, 30, 40] # 列表是序列式容器,支持索引、切片 # print(my_list[0],my_list[2]) # print(my_list[:2]) # 1.列表的遍历(遍历:每个元素不重复的访问一遍) # index = 0 # while index < len(my_list): # print(my_list[index]) # index += 1 # 2.for循环一般都用于容器中元素的遍历 # for val in my_list: # print(val) # break continue 用在循环中,也可以...
844aa2c15cf9e146364f8c6dda363527a7c99c0e
nimishjain1000/LeetCode-Solutions
/string/splitString.py
408
3.515625
4
class Solution(object): def balancedStringSplit(self, s): """ :type s: str :rtype: int """ balanced = 0 count = 0; for i in s: if i == 'L': balanced += 1 else: balanced-= 1 ...
45c4e7e74c2a9b013244a28eb2ac5e3e14da3fe2
roshangardi/Leetcode
/207.Course Schedule.py
1,024
3.5625
4
from collections import defaultdict class Solution: def canFinish(self, numCourses, prerequisites): coursemap = defaultdict(list) indegreelist = [0] * numCourses for course in prerequisites: indegreelist[course[0]] += 1 coursemap[course[1]].append(course[0]) ...
bbb959685d9d1e673c34cfd11a294a9ac9160ce9
sayalijo/my_prog_solution
/hacker_rank/Algorithms/Strings/two_strings/two_strings.py
316
3.875
4
#!/bin/python3 import sys def twoStrings(s1, s2): flag = 'NO' for char in s1: if char in s2: flag = "YES" break return flag q = int(input().strip()) for a0 in range(q): s1 = input().strip() s2 = input().strip() result = twoStrings(s1, s2) print(result)
8eb354e468b3194ba861895ad9e76849c688547b
Archana-SK/python_tutorials
/Functions/_functions.py
4,302
4.25
4
import datetime import time # Simple Function with no arguments def greet(): # Doc String """greet function prints hello world to the console""" print('Hello world') # If the first statement of a Module, class or function defnition is a string, # that string becomes a documentation string associated obje...
4fc081f8ef31b064ad52bde3cbcc5bfe63c35af5
magedu-pythons/python-19
/6-kwei/week14/homework.py
2,178
3.828125
4
# 1、实现一个可迭代的类 class IterClass: def __init__(self, *args): self.body = args def __iter__(self): return iter(self.body) def p(self): for item in self.body: print(item) # test i = IterClass([1, 2, 3], [4, 5, 6], [7, 8], [9]) for it in i: print(it) # 2、给出一个无序的整型列表,找...
8687a523d2151aa5902020d5a695a588cbf2b227
lilaspourpre/newsexplorer
/pyqt/Splitter.py
1,538
3.578125
4
# -*- coding: utf-8 -*- import re def get_first_letter(word): for c in word: if c.isalnum(): return c def split_into_sentences(text): words = text.split() punc = {'.', '!', '?'} initial_punc = {'.', '"', "'", '«'} exceptions = {'т.н.', 'т.е.', 'т.к.', 'Т.н.', 'Т.е.', 'Т.к.'} ...
9831940bae48e263b7e48ac6a1259235ece59620
zonghui0228/rosalind-solutions
/code/rosalind_ins.py
809
3.984375
4
# coding: utf-8 """ Insertion Sort url: http://rosalind.info/problems/ins/ Given: A positive integer n≤103 and an array A[1..n] of integers. Return: The number of swaps performed by insertion sort algorithm on A[1..n]. """ # 插入排序 # 每次找最小值 # 最坏的情况下复杂度为list长度的平方 def ins(array): swap = 0 for i in range(len(arra...
32c73b9a1a959dedb39b805b63d9e6adb5857ed8
AndreyAD1/mipt_course
/lesson_22_shortest_paths_of_weighted_graph/ex_2_Dijkstra_algorithm.py
2,633
4.21875
4
from collections import deque from typing import Dict, List def get_adjacency_list(edges: List[str]) -> Dict[str, Dict[str, int]] or None: """ Return an adjacency list representing a graph. Convert the list of strings like 'edge_start, edge_finish, edge_weight' into the adjacency list representing a ...
8c7508dfb748e21b98b101e9a9010df3463dd38d
lucaslyon96/Estudo_python
/impares.py
94
3.953125
4
n=int(input("Digite o valor de n: ")) i=0 num=0 while i<n : num = i*2 +1 print (num) i=i+1
6f694e0857799ce24f90a51fbe99614e483fd4fa
NobleWolf42/Python101
/Examples for Landon Python/bmi.py
841
4.5
4
#This section prompts the user for the input of their weight and height pounds = float(input("Please enter your weight in pounds: ")) print("Enter your height, separately, in feet and inches...") feet = float(input("Enter feet: ")) inches = float(input("Enter inches: ")) #This section preforms conversions from standar...
3f6396e9727c2a741ae9381e784326aab3bbd5a0
MaximOlifer/DM_colloquium_2019
/console/N.py
5,490
3.5625
4
from modules.classes import * from modules.N import * def input_Natural(message=''): n = Natural() n.pop() string = input(message) for c in string: n.append(int(c)) n.n += 1 n.reverse() n.n -= 1 return n def print_Natural(n, end='\n'): num = n.copy() num...
a11fbdb1875c0ef67c329a184e58606e84a70d21
feliperx/learningPython
/fundamentos-projetos/area_circuferencia_v8.py
305
3.71875
4
import math def circuferencia(raio): print('Area: {}' .format(math.pi * float(raio) ** 2)) if __name__ == '__main__': # se estiver no MÓDULO PRINCIPAL execute # identação, todos dentro da identação estão dentro do comando if raio = input("Informe o raio: ") circuferencia(raio)
d7456f213a81c15b716aa0c52c9dfa8a309f5be0
AngeloK/hackerrank-source-code
/Algorithms/Graph/bfs.py
2,450
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ################################################################################ # Breadth First Search: Shortest Reach # URL: https://www.hackerrank.com/challenges/bfsshortreach # Result: Test Case #2 & Test Case # 4 timeout ###############################################...
a1cd906bcc267073fd1b0e2e0494c998aa4636c3
spring-2019-csc-226/a03-master
/a03_heremesa.py
2,251
3.5625
4
###################################################################### # Author: Anna Heremes # Username: heremesa # # Google Doc link - https://docs.google.com/document/d/1yCQfE_FiUNe92sQm6q4uFHCBj1JHMS-zqJ3MtALIzuc/edit?usp=sharing # Assignment: A03: A Pair of fully Functional Gitty Psychedelic Robotic Turtles ######...
96ac80201ff74578c63cd3b4eb0f47781e23acb4
gcspanda/Python-Crash-Course
/ch07/7-06.py
468
3.9375
4
active = True while active: age = input("Please input one age: ") age = int(age) if age >= 3 & age <= 12: print("Price: $10") elif age > 12: print("Price: $15") else: active = False while 1: age = input("Please input one age: ") if age == 'quit': break e...
98c7f3d0fca4b7021135c1adc5f02020bbf2925c
LeeAhYeong/Python_300_For_Beginner
/04_List/057_print_min_max.py
323
4.09375
4
nums = [1, 2, 3, 4, 5, 6, 7] min_num = min(nums) max_num = max(nums) print('max:',max_num) print('min:',min_num) def max_cus(data_list): max_value = data_list[0] for data in data_list: if data > max_value: max_value = data return max_value nums = [-1,-2,-3,-4,-5,-6] print(max_cus(num...
b463dae52bff152bbadb3dcf6e718b8097f3501e
RumorsHackerSchool/PythonChallengesSolutions
/Guy/hackerrank.com/Write a function.py
504
4.3125
4
''' Task You are given the year, and you have to write a function to check if the year is leap or not. Note that you have to complete the function and remaining code is given as template. ''' def is_leap(year): leap = True not_leap = False # Write your logic here if year % 4 == 0: if year % 10...
c99413ec8f1c1fa585840877c32611930b0f55de
ntt99992003/Python-Course
/handson02182015.py
8,740
4.21875
4
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> #if else statement we use for decisions >>> if 1: print('True') True >>> # if something is true, do this >>> if not 1: print("true") >>> else: Syn...
d6db84c77641748ef8b47e9f7b9af9d6d04d0d47
myers404/algorithms-and-data-structures
/Dynamic_Programming/edit_distance.py
1,074
3.71875
4
#!/usr/bin/python def print_matrix(matrix): for i, row in enumerate(matrix): print row print '' def edit_distance(s1, s2): cols = len(s1) + 1 rows = len(s2) + 1 memo = [[0 for _ in range(cols)] for _ in range(rows)] for i in range(1, rows): memo[i][0] = memo[i-1][0] + 1 for i in range(1, cols): mem...
874b7e48ba112d12a4f286454516290a282213d8
Taoge123/OptimizedLeetcode
/LeetcodeNew/DynamicProgramming/LC_750_Number_Of_Corner_Rectangles.py
8,241
3.921875
4
""" http://www.cnblogs.com/grandyang/p/8433813.html Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectangle is 4 distinct 1s on the grid that form an axis-aligned rectangle. Note that only the corners need to have the value 1. Also, all four 1s used must be distinct. ...
b791fb282867ce42ca1236d2f087bd2e02cb325c
shivam712/data-structure-practice
/task/circular_ll.py
675
4.0625
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def isCircularList(head): if(head == None): return True node=head.next while (node != None) and (node != head): node = node...
b51881398757f5373925bdeffe5cf8d1d170eb7d
harshitmody72/hacktoberfest
/code + Probems/4.py
511
4.09375
4
def swap_case(s): i =0 tr = len(s) rt = '' while i< tr : if s[i].isupper() == True: rt += s[i].lower() elif s[i].islower() == True: rt += s[i].upper() elif s[i] == " ": rt += " " else : rt += s[i] i +=...
3d8ffdedac9361bc24dbb40a112a45c9a628202c
luokaidream/python_YiJinJing
/day02/conditaonal01.py
1,976
3.765625
4
# -*- coding:UTF-8 -*- # Author: LuoKai # date = 2021/1/6 """ python 中也使用if else, While 等处理条件控制和循环控制 """ """ # if 条件控制 """""" a = int(input("请输入数字:")) if a == 10: print("输入正确!!") else: print("输入错误!!") # 多条件控制 if elif else age = int(input("请输入年龄: ")) if age < 18: print("我还是少年!") elif 18 < age < 40: pri...
20a372f80224479dab2aecc2b422b67589dc58b2
mverini94/PythonProjects
/incomeTaxCalculator.py
491
4
4
''' Author....: Matt Verini Assignment: Homework 02 Date......: 2/05/2020 Program...: This program is designed to calculate income tax ''' stanDeduction = 10000.0 depenDeduction = 3000.0 taxRate = .20 grossIncome = float(input("Please enter your gross income: ")) numOfDependents = int(input("Please enter your number ...
5921f3895a23a388a5c650766537a63c171d6e17
RyanPersson/physics-python
/rangetheta.py
466
3.828125
4
import matplotlib from matplotlib import pyplot as plt import numpy as np theta = 3.14/3 vi = 30 phi = np.arange(0,3.14/2 - theta,.01) R = (2/9.8)*np.power(vi,2)*(np.sin(theta)*np.cos(theta + phi))/np.power(np.cos(phi),2) plt.plot(phi,R, label='R(Φ) = (2/g)vi^2sinθcos(θ+Φ)/cos^2(Φ)') plt.xlabel('Slope angle Φ, 0 <= Φ ...
ebfdb2900029b02ecb6d4a2d70659995c4c8b6a3
kmranrg/DataStructures
/01_ClimbingStairs/solution.py
220
4
4
n = int(input('Enter no of steps: ')) def countWays(n): one, two = 1, 1 for i in range(n-1): temp = one one = one + two two = temp return one print('Total no of ways =',countWays(n))
93950d542a7a914cbe800b8987bad54f72211e2a
mwijaya3/Training
/CSTraining/CodingSchool/Bootcamp - Intuition/doublelinklist.py
3,898
4.34375
4
class Node(object): """ Definition of a node (element) in a linked list """ _value = None # value stored in the node _next = None # forward link _prev = None # backward link def __init__(self, value): self._value = value class DoubleLinkList(object): head = None # head (begin) of the list tail = None...
1da485b4ae2eeae8e354a0868c4bf1eaf1cb6419
yuhal/ppt-convert
/convert_pdf.py
1,349
3.765625
4
# -*- coding: utf-8 -*- # !python3 """ PPT convert PDF """ import os import filetype import win32com from win32com.client import Dispatch def ppt2pdf(filename,dst_filename): """A folder with the same name as the PPT file will be created in the same directory.This folder contains all PDF images generated b...
0b01073a24a3e132fb1e74a5fbf3086e8a5773fb
FitAdam/Classic-Number-Guessing-Game
/controler.py
471
3.625
4
class Controler: def __init__(self): pass def welcome(self): y = int(float(input("I'm thinking of a number! Try to guess the number I'm thinking of: "))) return y def get_input(self): y = int(input('Guess again: ')) return y def play_again(self): game ...
e37a20bb0f76a57b6fe5946ac5a0e6b661376dff
sangeethadetne/python
/GuessingGame.py
338
4.09375
4
secret_word = "giraffe" guess = "" guess_count = 0 guess_limit = 3 out_of_guess = False while guess != secret_word and not(out_of_guess): if guess_count < guess_limit: guess = input("enter the guess word : ") guess_count += 1 else: out_of_guess = True if out_of_guess: print("you are out of guesses") else: pr...
8d936f419633eb81a2a253523369316894ff10a2
zinni/funcoes
/funcoes.py
3,719
3.578125
4
class Funcoes(object): def __init__(self, conjunto = ''): self.upper = 'ABCDEFGHIJKLMNOPQRSTUVXYWZ' self.lower = 'abcdefghijklmnopqrstuvxywz' self.conjunto = conjunto def tamanho(self): contador = 0 for x in self.conjunto: contador += 1 return conta...
ed4ab6e801d4519a17805f0e5f5d57f8ec2d7a0e
firdausis/codility
/tape_equilibrum.py
292
3.53125
4
def solution(A): total = sum(A) above_part = 0 below_part = total min_diff = float('inf') for a in A[:-1]: above_part += a below_part -= a diff = abs(above_part - below_part) if min_diff > diff: min_diff = diff return min_diff print(solution([1, 2, 3, 4, 2]))
4679df943de72425e4a30ba0ecf080e388f9d992
cross-sky/sicp
/c2_2_2.py
553
3.953125
4
def tree(root, branches = []): for branch in branches: assert is_tree(branch), 'branches must be a tree' return [root] + list(branches) def is_tree(tree): if type(tree) != list or len(tree) < 1: return False for branch in branches(tree): if not is_tree(branch): return False return True def branches(tree...
33a8cb0301f118f5908e619306ab488b8102ff8c
Bencee16/Image_classification
/convnet_pytorch.py
2,805
3.78125
4
""" This module implements a Convolutional Neural Network in PyTorch. You should fill in code into indicated sections. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import torch import torch.nn as nn import torch.nn.functional as F class ConvNet(nn.Mod...
c6f71d17d9e28d9a769236324290fcbb1acfeee0
MFry/pyAlgoDataStructures
/pramp/h_tree.py
1,243
3.96875
4
from math import sqrt """ |----| |-----| | | |-----------| | | |----| |-----| """ def drawLine(x1, x2, y1, y2): pass def h_tree_vertical(x, y, starting_length, depth): bottom_y = y - (starting_length / 2) top_y = y + (starting_length / 2) drawLine(x, x, bottom_y,...
fd1f70a60f8004e76e0054c9846d0608d040ff8a
pathway27/old-proj
/trains/graph/graph.py
4,878
4
4
import operator class Graph(object): def __init__(self): """ Graph class, made up of nodes (keys) and its neighbours (values) represented in a dictionary (self.graph) """ self.graph = {} def add_node(self, node): if node not in self.graph: self.graph[...
9c36392bf49a902d975071f85136109867ea606d
zainllw0w/skillbox
/lessons 21/Рукурсия/task2.py
300
4.15625
4
def power(a, n): if n == 1: return n * a return a * power(a, n - 1) float_num = float(input('Введите вещественное число: ')) int_num = int(input('Введите степень числа: ')) print(float_num, '**', int_num, '=', power(float_num, int_num))
377a2487c733e760e8d3c1649bbc0717343834de
yevgenybulochnik/data-analysis
/pythonFAB/guessingGame.py
837
3.921875
4
import random print("Pick a number 1-100 and I will guess it.\n") start = 1 end = 100 usr_response = "" valid_response = ["Lower", "Higher", "Correct!"] tries = 0 while usr_response != "Correct!": print("Im guessing your number") comp_guess = random.randint(start, end) tries += 1 print("Is your numb...
824c892496b9af66da9646903e05018d93b673f1
fejesgergorichard/LeetCode
/040-to-lower-case/Solution.py
768
4.125
4
# Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. # Example 1: # Input: "Hello" # Output: "hello" # Example 2: # Input: "here" # Output: "here" # Example 3: # Input: "LOVELY" # Output: "lovely" # # # # # # # # # # # # # # # # # # # # # # # # # # # ...
2e1d4ec2de37c27b8119b044434bb788feed54e6
JoseMacevo/First_Python_Course
/lanzamiento_excepciones.py
412
4
4
import math def calcula_raiz_cuadrada(numero): if numero < 0: raise ValueError("El valor no puede ser negativo") else: return math.sqrt(numero) Nusuario = (int(input("Introduzca un valor: "))) try: print(calcula_raiz_cuadrada(Nusuario)) except ValueError: ...
9874b38b56719b54f09bc545f7a7193dd5cf5026
edwrx02/TheVirusGame
/game/bullet2.py
418
3.515625
4
''' Created on Jun 7, 2015 @author: Edwin ''' import pygame class Bullet2(pygame.sprite.Sprite): """ This class represents the bullet for the bad guy. """ def __init__(self): super().__init__() self.image = pygame.image.load("Gunfire_rockets_2.png") self.rect = self.image.get_rect() ...
b45636584b68c784e3ea0b8204594f5a8a9664be
indervirbanipal/deep-learning-using-tensorflow
/cnn.py
1,737
3.828125
4
import tensorflow as tf tf.__version__ from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) print(mnist) sess = tf.InteractiveSession() x = tf.placeholder(tf.float32, shape=[None, 784]) y_ = tf.placeholder(tf.float32, shape=[None, 10]) # Weight t...
36b80e9660925b79d88eee2976b5dedab1843cce
bivolul/pynet_testz
/LESSON1/8/parser.py
649
3.8125
4
#!/usr/bin/env python ''' 8. Write a Python program using ciscoconfparse that parses this config file. Note, this config file is not fully valid (i.e. parts of the configuration are missing). The script should find all of the crypto map entries in the file (lines that begin with 'crypto map CRYPTO') and for each crypto...
0814619376fdce5e8a5b06141b1da3d30518d68b
pierg/strix
/parser.py
3,177
3.546875
4
from typing import Tuple from logic import * ASSUMPTIONS_HEADER = 'ASSUMPTIONS' GUARANTEES_HEADER = 'GUARANTEES' INS_HEADER = 'INPUTS' OUTS_HEADER = 'OUTPUTS' END_HEADER = 'END' COMMENT_CHAR = '#' FILE_HEADER_INDENT = 0 DATA_INDENT = 1 TAB_WIDTH = 2 def parse(file_path: str) -> Tuple[str, str, str, str]: """Ret...
a44b4ca450586b630bba3c2d9ad17912fbedbc63
lkloh/kalman_filter_phil_kim
/recursive_filter/1st_order_low_pass_filter/low_pass_filter.py
1,918
3.671875
4
#!/usr/bin/env python3 """ Chapter 3.2: 1st order low-pass filter \bar{x}_k = \alpha\bar_{x}_{k-1} + (1-\alpha)x_k where 0 < \alpha < 1 More recent measurements are more highly-weighed than less recent ones. This enables noise-filtering and also tracking variation in the measurements simultaneously with minimal tim...
e0145fe7d400e6a864dc4e702a84917694012ad3
Caustin122/Cryptology
/Challenges/think-you're-smart-enough?/rijndael.py
1,143
3.734375
4
# Rijndael # by: The Epidemics from sys import stdin from hashlib import sha256, md5 from Crypto import Random from Crypto.Cipher import AES import base64 import re # the AES block size to use BLOCK_SIZE = 16 # the padding character to use to make the plaintext a multiple of BLOCK_SIZE in length PAD_WITH = "#" # the ...
83b66ac72cc020695163847eea0a1e743cddd8fc
SociallyAwkwardTurtle/Python
/ThonnyTunnitöö.py
1,025
4.125
4
#programm kysib su nime, siis annab arvutustehte ja ytleb, kas sa vastasid õigesti, kysib kas tahad ka uut tehet ja kui ytled ei, lõpetab ära print("What is your name?") myName = input() print("Hello, " + myName) from random import * a = (randint(1, 10)) b = (randint(1, 10)) c = input("How much is " + str(a) + "*" + st...
e7031632efba2a536a183436e6c254db31c1a144
QiLinXue/ICS4U
/Classes Program/piece.py
2,573
4.21875
4
from __init__ import * from functions import * # Chess Piece class Piece: ''' A piece object that describes each individual piece Attributes ---------- color: str Contains the color (white / black) name: str Determines the symbol (pawn / rook / knight / bishop / queen / king) x : int Determ...
a605a4173243e525af7fd68b4e215e5b2a9d887d
Ruizdev7/pyEjercicios
/herenciaSuper.py
843
3.78125
4
class Persona(): def __init__(self, nombre, edad, lugarResidencia): self.nombre=nombre self.edad=edad self.lugarResidencia=lugarResidencia def descripcion(self): print("Nombre: ", self.nombre, "\nEdad: ", self.edad, "\nResidencia: ", self.lugarResidencia) class Empleado(Persona...