blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
bcd71b974626cf9a62445a587cd21afb2085d9f8
Sydcn-tek/Python-By-Sydcn
/day02.py
8,413
3.78125
4
# username=input('请输入用户名:') # password=input('请输入密码:') # if username =='admin' and password =='123456789': # print('身份验证成功!') # else: # print('身份验证失败!') # s=input('请输入成绩:') # if '60'<=s<'70' : # print('成绩为C!') # elif '70'<=s<'80' : # print('成绩为B!') # else : # print('成绩为A!') # us...
9725fd88bf4149217c5cf924c2a9adc57ee036ba
srisaipog/ICS4U-Classwork
/Learning/Classes/encapsulating/oct 24.py
841
3.796875
4
class Person: def __init__(self, name: str, age: int): self.set_name(name) self._age = age def get_age(self): return self._age def set_age(self, to_be_age): if type(to_be_age) == int: self._age = to_be_age def get_name(self): ...
caf7ebd6e43de85002b5607ae2cd6da15796ce22
tolkamps1/sevens7
/hands.py
4,455
3.5625
4
import db import players import board def create_hand(hand, player_id): clubs = [] diamonds = [] spades = [] hearts = [] for [num, suite] in hand: print("HAND!!! num{} suite {}".format(num, suite)) if(suite == "clubs"): clubs.append(str(num)) if(suite == "spades"...
1495d71aad82337c3002d566f5d7548ed1387e81
xaviBlue/curso_python
/tuples.py
191
3.765625
4
x = (1,2,3,4,5) print(type(x)) y=tuple((1,2,3)) print(y) print(x[0]) #usamos del para eliminer la tupla locations={ (34.56,6431.4):"tokyo", (34.6,641.4):"orlando" } print(locations)
46b1efb1cb015d099bd0ae7db12bf2d3d90a688e
sanjaykumardbdev/pythonProject_1
/19_ifelif_2.py
190
3.953125
4
x = 21 if x == 1: print("One") elif x == 2: print("Two") elif x == 3: print("Three") elif x == 4: print("Four") elif x == 5: print("Five") else: print("Wrong Input")
3970600d8d6b34e49334b5d718fd1d1f9c5faa97
SimonCWatts/CS50x
/dna.py
2,924
4.25
4
import sys import csv def main(): ''' The main function opens the csv & txt files, extracts the list of STRs to search for, and prints the name of the person whos dna profile matches the sample provided in the txt file. ''' # If your program is executed with the incorrect number of command-li...
e4350b17d767face5cf41d076617b98fc1843822
azznggu/PythonGettingStart
/PythonGettingStart/list/list5comprehension.py
521
3.890625
4
# list안 for, if문 사용 가능. a = [i for i in range(10)] print(a) b = list(i for i in range(10)) print(b) #요소를 다른값과 연산 가능. c = list(i*2 for i in range(10)) print(c) #반복문 뒤 조건문 지정. #range에의해 생성된 숫자 요소 조건문(짝수)인 경우에만 i로 지정, i를 리스트 요소로 리스트 생성. d = list(i for i in range(10) if i%2== 0) print(d) #for,if 복수 사용 가능. e = list(i*...
c2f3dbd2cd86dc77bccf8a8fb6bf15e7b2daae53
anthonyfong100/ntu-bookings
/src/utils.py
250
3.5
4
def is_valid_court_num(court_number: int) -> bool: # valid court numbers are 1...6 return 1 <= court_number <= 6 def is_valid_time(start_time: int) -> bool: # valid start time are 8...21 , 24 hour clock return 8 <= start_time <= 21
97d5725d73346838e030c6e513f8e5b8da0316fd
Aimee-yjc/python_learning
/08/02/checktnt.py
717
3.859375
4
import re # 导入Python的re模块 pattern = r'(黑客)|(抓包)|(监听)|(Trojan)' # 模式字符串 about = '我是一名程序员,我喜欢看黑客方面的图书,想研究一下Trojan。' match = re.search(pattern,about) # 进行模式匹配 if match == None: # 判断是否为None,为真表示匹配失败 print(about,'@ 安全!') else: print(about,'@ 出现了危险词汇!') about = '我是一名程序员,我喜欢看计算机网络方面的图书,喜欢开发网站。' match = re.m...
32b6c4aaf0a633608b996bd7a5fcda0f7db2ea07
esantos92/aulas-praticas
/ProgramasPython/secao08/exercicio03.py
150
4.15625
4
vetor=[] for i in range(0,10): num=int(input("Digite um número: ")) vetor.append(num) vetor.reverse() for i in vetor: print(i)
1fdd55ecdf66c1f7d6108198217e2e4b3a273fcf
abhimaprasad/Python
/Python/ObjectOrientedProgramming/DemoPrograms/student.py
924
3.65625
4
class student: def __init__(self,roll,name,course,total): self.roll=roll self.name=name self.course=course self.total=total def printstudent(self): # print(self.roll) print(self.name) print(self.course) print(self.total) def __str__(self): ...
613fe48f962def97c979c959121a1850a18eb739
Levintsky/topcoder
/python/leetcode/tree/429_N-ary_level.py
1,207
4.03125
4
""" 429. N-ary Tree Level Order Traversal (Easy) Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3-ary tree: We should return its level order traversal: [ [1], [3,2,4], [5,6] ] Note: The depth of the tree i...
07c961c55308d04381bdd780ce617c8057eb3205
spruce808/learning
/PythonApplication1/PythonApplication1/PythonPuzzle1.py
1,133
3.90625
4
class Puzzle1Solver(object): """A program that prints all sequences of binary digits, such that each digit in the sequence is a 0 or 1, and no sequence has two 1's adjacent in the output. """ @classmethod def main(cls): num_bits = 32 max = (1 << num_bits) - 1 val...
25a9d101935927eee207623fc563c7efd9ea3464
Yaachaka/pyPractice1
/bhch08/bhch08exrc11.py
879
4.34375
4
""" bhch08exrc11.py: Section 8.3 described how to use the shuffle method to create a random anagram of a string. Use the choice method to create a random anagram of a string. """ print('*'*80) from random import choice word = input('Enter a word: ') letter_list = list(word) l = '' l = [choice(letter_lis...
379e45342717968aa1b37b163b0603401a298f92
guyavrah1986/learnPython
/learnPython/classes_and_objects_9/accessSpecifiersInPython.py
580
3.5625
4
class TestObj: def __init__(self): func_name = "TestObj::__init__ - " print(func_name) def __test_obj_private_function(self): func_name = "TestObj::__test_obj_private_function - " print("TestObj::__test_obj_private_function - ") def example_func(): func_name = "example_f...
f031d4e53b5b11b0b57a591769709e35f563c3c8
BielMaxBR/Aulas-de-python
/AulasdePython/exercícios/ex004.py
362
3.890625
4
txt = input('digite algo:') print('isso é um número?', txt.isnumeric()) print('isso é uma alfabético?', txt.isalpha()) print('isso é alfanumérico?', txt.isalnum()) print('isso é um espaço?', txt.isspace()) print('isso é apenas maiúsculo?', txt.isupper()) print('isso é apenas minúsculo?', txt.islower()) print('isso é ca...
7815c0e169e6a29334e192d3ec3989deb5b403dc
AssiaHristova/SoftUni-Software-Engineering
/Programming Basics/nested_loops/car_number.py
990
3.609375
4
start_num = int(input()) end_num = int(input()) flag_1 = True flag_2 = True flag_3 = True flag_4 = True for num_1 in range(start_num, end_num + 1): for num_2 in range(start_num, end_num + 1): for num_3 in range(start_num, end_num + 1): for num_4 in range(start_num, end_num + 1): ...
2ae0773cc4befe11e6d5163a41daa35c7bb6ccb1
zzj0403/markdowm-summary
/python/面向对象总结/02定义与产生.py
988
3.9375
4
class Student: # 学校 school = '清华大学' # 数据(属性) name = '类中的name' # 让对象在产生的时候 有自己的属性 def __init__(self,name,age,gender): # 形参中放 你想让对象有的而独立的属性 name,age,gender self.name = name # self指代的就是每一次类实例化(加括号调用)产生的对象 self.age = age # 该句式 类似于往对象的空字典中 新增键值对 self.gender = gender # 选课 ...
e6f987005d0c62775df81f4e25b71f50e715eb39
Lakshanna/emiscel_training
/Thavamani/python1/default_arg.py
63
3.609375
4
def add(num,n=3): return num+n print add(5,2) print add(5)
aabc42b54fa3bdd3beaf8efecdcdbb41e4a26e07
jtchuaco/Python-Crash-Course
/scripts/Chapter 7/cities.py
693
4.28125
4
# Using break to Exit a Loop # use break statement to exit a while loop immediately without running any remaining code in the loop # it directs the flow of your program # use it to control which lines of codes are executed and which aren't prompt = "\nPlease enter the name of a city you have visited:" prompt += "\n(En...
734c435bf5b44483124ff9fa289ea80d86841078
QuentinDuval/PythonExperiments
/graphs/NumberOfFlipsToZeroMatrix_hard.py
1,917
3.65625
4
""" https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/ Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbours of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighboors if they share ...
434765ecdf86b0325683e59b729e2ca82d964d12
sqlunet/builder
/semantikos/_schema.py
1,049
3.546875
4
#!/usr/bin/python3 import sqlite3 import sys sql_tables_schema= """SELECT name, type FROM sqlite_schema WHERE type='table';""" sql_indexes_schema="""SELECT name, type FROM sqlite_schema WHERE type='index';""" sql_columns="""PRAGMA table_info('%s')""" def collectNames(rows): return [name for name,type in rows] def...
f99b6131b967bea9c79a093c5aaa626c74911f2d
arpit04/Python-Exercism
/pig-latin/pig_latin.py
498
4.0625
4
vowel = ['a','e','i','o','u'] def translate(text): if text[0:2] == 'xr' or text[0:2] == 'yt': return text+"ay" elif text[0] in vowel: return text+"ay" else: for i in range(len(text)): if text[i] == 'y' and i!=0: return text[i:]+""+text[0:i]+"ay" x ...
11e0734856e43dea1087fed4541816be31e19422
younguk95/kmove_python
/basic/while_test.py
760
3.640625
4
listdata=[] while True: print(''' ==========리스트 데이터 관리====== 1.리스트에추가 2. 리스트 데이터 수정 3. 리스트 데이터 삭제 4. 종료 ''') menu = int(input("메뉴를 선택하세요")) if menu == 4: break elif menu == 1: data=input("추가할 데이터를 입력하세요") listdata.append(data) print(listdata) elif menu =...
93049807f501effa6ac0b0e2fa1fc600a3fdf800
wangpeibao/leetcode-python
/easy/easy1608.py
1,828
3.9375
4
""" 1608. 特殊数组的特征值 给你一个非负整数数组 nums 。如果存在一个数 x ,使得 nums 中恰好有 x 个元素 大于或者等于 x , 那么就称 nums 是一个 特殊数组 ,而 x 是该数组的 特征值 。 注意: x 不必 是 nums 的中的元素。 如果数组 nums 是一个 特殊数组 ,请返回它的特征值 x 。否则,返回 -1 。可以证明的是,如果 nums 是特殊数组,那么其特征值 x 是 唯一的 。 示例 1: 输入:nums = [3,5] 输出:2 解释:有 2 个元素(3 和 5)大于或等于 2 。 示例 2: 输入:nums = [0,0] 输出:-1 解释:没有满足题目要求的特殊数组,故而也不存...
79f720fa9e11f78a998b817cca43241c64dc29ab
ANkurNagila/My-Code
/Code48.py
391
3.75
4
t=input() try: t=int(t) print("Invalid Input") except: res="" i=True for x in t: if x=="G": res+="C" elif x=="C": res+="G" elif x=="T": res+="A" elif x=="A": res+="U" else: print("Invalid Input") ...
e08d7c16dda94331b6062b48fb6e0fb50a7dbac3
jdacode/Blockchain-Electronic-Voting-System
/network.py
398
3.609375
4
from ipaddress import ip_address class Network: def __init__(self, ip): self.ip = ip @staticmethod def is_a_valid_ip(ip): try: ip_add, port = ip.split(":") if int(port) < 0 or ' ' in port: return False if ip_add == 'localhost' or ip_address(...
7ad3596c8ab78cb6c8966b7a2d56b3d0852521fc
santosclaudinei/Python_Geek_University
/sec05_ex10.py
280
3.546875
4
sexo = input("Digite seu sexo: ") altura = input("Digite sua altura: ") if (sexo in "MmFF"): if (sexo in "fF"): print(f"O seu IMC é {62.1 * float(altura) - 47}") else: print(f"O seu IMC é {72.7 * float(altura) - 58}") else: print("Dados invalidos.")
fd602eea2b7cbd8e5e053a8fa78805e23c6eb5a6
nithen-ac/Algorithm_Templates
/data_structure/trie_tree.py
1,474
3.875
4
# The trie is a tree of nodes which supports Find and Insert operations. It is also called prefix tree. # trie tree is built to help match the whole words list in one batch. # Scenario: autocomplete, spell checker, IP routing, T9 predictive text, solving word games. # just basic version, improvement like: double-array ...
01cd0d465b67cbd296cff787a672eb7a7dfc5b84
moreirafelipe/univesp-alg-progamacao
/S1/V2 - Arquivos/texto 2/hello.py
736
3.65625
4
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> line1 = 'Olá, desenvolvedor Python...' >>> line2 = 'Bem vindo ao mundo python!' >>> print(line1) Olá, desenvolvedor Python... >>> print(line1) Olá, ...
f47b2453c587a09f5370cdf11c801d9eebaf07aa
Sewoong-Lee/python-TIL
/p210329_01_print.py
467
3.96875
4
#주석 : 프로그램의 설명을 적는다. (앞에 # 적으면 주석됨)(주석 할거 위 아래에""",''' 쓰면 전체주석) #print함수 ''' print(10+30) print(15+1) print(13-4) print(8/9) print(45*7) ''' """ #문자는 "" 로 적음 #이스케이프문자 : \n 줄바꿈 #매개변수, 인자, 인수 print("헬로", end=",") print('ㅋ') print('"ㅋㅋㅋ"ㅋㅋ"ㅋㅋㅋㅋ"') print('z','z',11) print('zz'+'zz') print('zz + 123') print('z\nz\n' *3) ...
9e42b6803ef8ea0fdb880066c62743de5908e36e
alikhalilli/Algorithms
/.z/Arrays/Rotation/MultipleRotationsV2.py
498
4.25
4
""" @github: github.com/alikhalilli Time Complexity: O(n) Space Complexity: O(1) arr = [1, 2, 3, 4, 5, 6] k1 = 1, [2, 3, 4, 5, 6, 1] k2 = 3, [4, 5, 6, 1, 2, 3] k3 = 4, [5, 6, 1, 2, 3, 4] """ def leftRotate(arr, k): n = len(arr) start = k % n for i in range(start, start+n): print(arr[i % n], end=...
b86eb96ffba8d5fd6a0deb0528ba50ab2551f2a7
neilsambhu/CAP6415-project
/PatternTheory_WACV_Original/PatternTheory_WACV_Original/SupportBond.py
2,840
3.6875
4
import math as math class SupportBond: 'Defines characteristics for bond type - Support - for a generator' #Constructor for initializing an instance of a Support bond def __init__(self, bondID, bondName, bondDir, currGenID): self.type = "Support" #Bond Type self.compatible = {} #Dictionary of compatible generat...
1e2a78fe1e37555e935d79597d8f2e92e5b29d1b
seObando19/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
1,907
3.75
4
#!/usr/bin/python3 """ Define Square class. """ from models.rectangle import Rectangle class Square(Rectangle): """ """ def __init__(self, size, x=0, y=0, id=None): """ Initialize square class Arguments: size (int): value to square side. x (...
d4e23f1fa4ca386f15145daad32e68a9f4085ed2
liyi-1989/neu_ml
/code/data/sample_helix.py
2,453
3.84375
4
import pdb import numpy as np def sample_helix(n_points, z_range, var=0.0, frequency=1.0, x_amplitude=1.0, y_amplitude=1.0, x_phase=0.0, y_phase=0.0, z_locs=None): """Randomly generate samples from a helix function. This function is used to generate random noisy samples from a helix. The...
06fc9b2e4eacb04fc706a0e2c7acb55a7d42c731
leexingmunjolene/python2013lab4
/compress.py
931
3.625
4
# compress.py # Devise an effective and efficient lossless compression algorithm # for compressing large textual documents. # @, # , &, * try: infile = open('flintstones.txt','r') outfile = open('cflintstones.txt','w') char = 0 consec = 1 for line in infile: while char+1 != len(line): ...
4392106f06cf535b95be3f391b0b2dc30c501b6e
AdamRhoades95/Python-SQL
/Programming/Python/Test_Ex/Read_Write_File/write.py
770
4.25
4
# this will just write a file for the first time # this will get path and file name # this will get text from user # this will continue until text = !1- # ask user for path and file print("type \"default\"\nor type out a path followed by the file") file_Path = raw_input("file path: ") if file_Path.lower() == "default...
0fcf50bc574c6c25c2c84ccfd1dfd39ac56f5c03
FRANKLIU90/Python
/18 April/3-24-18_python class toolkit.py
817
3.953125
4
import math class Circle: print('class circle') def __init__(self, radius): self.radius = radius print('init circle') def perimeter(self): return 4 * self.radius def area(self): a = self.__perimeter() s = (a / 4)**2 return s __perimeter = perimete...
0206eb5f6b2b5a6af2e116f2a03b2c9ca86769df
OddExtension5/ProgrammingBitcoin_from_scratch
/NumberTheory/lcm.py
1,353
4
4
#lcm(a,b) of integers a & b ( both different from zero) is the smallest positive integer that is divisible by both a&b # we know lcm(a,b) * gcd(a,b) = a*b def lowest_common_multiple(a, b): """ >>> lowest_common_multiple(3,2) 6 >>> lowest_common_multiple(12, 80) 240 Note: The Least Common Mu...
997f086977310ad033bc1358ee3b529384cfb36b
TodimuJ/Python
/starGenerator.py
196
4.125
4
number = int(input("What is n: ")) for i in range(number): for j in range(number): if i == j or j == (number-i-1): print("*") else: print(" ")
4766de6b99247d61f8be5f477a94db9708b46d4a
KARTHICKMUTHUSAMY/beginer
/pro19.py
159
3.609375
4
n1=int(input()) arr1=list() for x in range(n1): arr2=list(map(int,input().split())) arr1=arr1+arr2 arr1=sorted(arr1) for s in arr1: print(s,end=" ")
d35b0b7f8a3f1617f3f80d3af5ebafa6b44216c8
daringli/PERFECT_utils
/new_plot/sort_species_list.py
1,060
4.15625
4
def sort_species_list(species_list,first=["D","He"],last=["e"]): #sorts list so that the first element in "first" that is in species_list will be first, then the second that exists, etc. #elements between first and last have no prefered order output_list=[] if any([f in last for f in first]): pr...
c1a75896b59838f26755a0681a4851bc566091d1
huboa/xuexi
/oldboy-python18/day02-列表-字典/00-day02/day2/dd.py
238
3.765625
4
#coding:utf-8 x=u'你瞅啥' #python2的字符串就是bytes # # print type(x) is bytes print(x) # unicode--------->encode('utf-8')----->bytes #bytes----------decode('gbk')------------>unicode # x=u'你瞅啥' # print x # print type(x)
94053e49679a026aaaca81ca52e70248159bb024
aksbaih/portfolio
/Python/Neocis Coding Challenge/part2opt.py
2,215
3.5
4
''' This is an optimized approach to the problem described in part2.py. It uses scipy's minimization function to minimize a loss function with variables x, y, r: the x and y coordinates of the center of the circle and its radius respectively. The loss is the sum of the distance squared of each toggled point from the c...
1ad96d1660218814c5a52b522d161f211d75d113
ids0/ATBSWP
/Chapter_06/tablePrinter.py
1,328
4.125
4
tableData =[['apples','oranges','cherries','banana'], ['Alice','Bob','Carol','David'], ['dogs','cats','moose','goose']] def printTable(table): rows = len(table[0]) # Number of rows to print col = len(table) # Number of columns to print colWith = [0] ...
1f58fae86be0e38796d7befa44dee320e8b105e5
vineetkumarsharma17/MyPythonCodes
/String/Check_substring.py
190
4.21875
4
str=input("Enter a string:") sub=input("Enter sub string:") if sub not in str: print("not") else:print("yes") #using find method if(str.find(sub)==-1): print("not") else:print("yes")
6426eb703f777100c005013a67c7c36d1248d8c8
callmezzzhy/python-creeper
/算法和数据结构/去重.py
171
3.84375
4
l=[2,2,3,1,2,74,5,6,6,7,8,9,9] l1=list(set(l)) l1.sort(key=l.index) print(l1) l2={}.fromkeys(l).keys() print(l2) l3=[] [l3.append(x) for x in l if x not in l3] print(l3)
179fb80953e5f9aa806abc59f532742aee9cb92f
rohit20001221/leetcode
/stacks_que/bfs_tree.py
787
3.890625
4
from collections import deque as dque class Node: def __init__(self, value): self.value = value self.right = None self.left = None def BFSTree(root): ans = [] if root is None: return ans queue = dque([root]) while queue: n = len(queue) temp = ...
1bdfbc535b84f020c071ce98c6c96ee347b89a0c
rootid23/fft-py
/dp-top20/edit-distance-dp-5.py
1,109
3.828125
4
# LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of length 3. # LCS for input Sequences “AGGTAB” and “GXTXAYB” is “GTAB” of length 4. # Input: str1 = "geek", str2 = "gesek" # Output: 1 # We can convert str1 into str2 by inserting a 's'. # Input: str1 = "cat", str2 = "cut" # Output: 1 # We can convert ...
b04593a85d772d10a96470e714a2799e41db60b4
andrei-kozel/100daysOfCode
/python/day002/exercise1.py
312
3.90625
4
# 🚨 Don't change the code below 👇 two_digit_number = input("Type a two digit number: ") # 🚨 Don't change the code above 👆 #################################### #Write your code below this line 👇 num_one = int(two_digit_number[0]) num_two = int(two_digit_number[1]) print(num_one + num_two)
2925e3f7c1711de434805d2976331fa02ac61248
vidh2000/Aurora-Borealis-Simulation
/vector.py
5,677
3.875
4
import random import math import numpy as np # Get pi PI = 3.141592653589793 class Vector: # If two arguaments are given, set z = 0 def __init__(self, *args): if len(args) > 3 or len(args) < 2: raise ValueError("Must pass 2 or 3 arguments but {len(args)} were given") self.x = args...
740ddc3126b371eea60d78f47de6aa126e05ff32
ffismine/leetcode_github
/普通分类/tag分类_贪心算法/55_跳跃游戏.py
1,731
3.84375
4
# -*- coding:utf-8 -*- # Author : Zhang Xie # Date : 2020/3/18 0:11 """ 给定一个非负整数数组,你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 判断你是否能够到达最后一个位置。 示例 1: 输入: [2,3,1,1,4] 输出: true 解释: 我们可以先跳 1 步,从位置 0 到达 位置 1, 然后再从位置 1 跳 3 步到达最后一个位置。 示例 2: 输入: [3,2,1,0,4] 输出: false 解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳跃长度是 0 , 所以你永远不可能到达最后一个位置。 ...
bd08145d8486b886360f3df5a2614ea5cd67265f
BohdanVey/Tic_tac_toe_game
/game.py
1,286
3.984375
4
""" The main module to play game """ from board import Board from btree import BinaryTree def make_move(board): """ Make move :return: None """ board.print_board() if board.move == Board.player: while True: pos_x, pos_y = [int(x) for x in input("Enter move coordinate separ...
c02288ed11075c655ff68070ddeec2cebccd2b3d
norbertbago/codecademy
/learn_python_3/functional_programming.py
636
3.5625
4
from six.moves import reduce list_1 = range(9) list_2 = ["Hi", "Hello", "Cao", "Ahoj", "Cau", "Hola", "Halo"] #map function print(list(map(len, list_2))) print(list(map(lambda x: (x, -x), list_1))) print(list(map(lambda two: two+"hi", list_2))) print(list(map(lambda square: square**2, list_1))) #filter funciton ...
14537db9558216bc013dd422d9a6d9bf4db6a904
chadonet-65/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,008
3.609375
4
#!/usr/bin/python3 def matrix_divided(matrix, div): errorMessage = "matrix must be a matrix (list of lists) of integers/floats" if not matrix: raise TypeError(errorMessage) if not isinstance(matrix, list): raise TypeError(errorMessage) for lists in matrix: if not isinstance(lists...
13915cad41fa1d4d26ff12f9d2f087b46d1ac96f
sysnad/LearnPythonTheHardWay
/ex6.py
1,192
4.46875
4
#this line explains how many types of of people there are by using python format d which #is meant to denote decimal integers x = "There are %d types of people." % 10 #binary is a string representing the word binary so we're allow to charcterise through #%s format binary = "binary" #since we are not able to...
9251f7e1e974babc0f4f5dd002de343c89bff81f
karthikaDR/AlgorithmsPrep2
/Matrix/WordSearch.py
1,296
3.984375
4
def checkword(board, row,column, string): if len(string) == 0: word = 'Found' return word #Increment/Decrement the row and column dfs = [(0,1), (0,-1), (1,0),(-1,0)] if (row >= len(board) or row < 0 or column >= len(board[0]) or col...
a7a5318c462dafc3c53f674a3db2d3335bd71551
avi527/Data-Structure-Algorithms
/Array/find_maxm_distance_between_two_number.py
533
4.1875
4
# Python3 code to Find the minimum # distance between two numbers def minDist(arr, n, x, y): min_dist = 99999999 for i in range(n): for j in range(i + 1, n): if (x == arr[i] and y == arr[j] or y == arr[i] and x == arr[j]) and min_dist > abs(i-j): min_dist = abs(i-j) return min_dist #...
2e9dfff42105dfcebf8c8ec1a3d943274a864e4e
bhaskar7310/Multiple-Reaction-OCM
/reaction.py~
24,555
3.515625
4
''' This module will read the rate equation provided by the user in the [reaction_system]_rates.txt file and then convert it to a mathematical form, which will be called for different values of Temperature and mole fractions to calculate the actual rate. Now one important point to note is that this calculatio...
ccd01ce30c1a553c5cb3018871dfc54eae0b5691
vijgan/HackerRank
/Search/find_maximum_index_product.py
3,079
4.5
4
''' This function, 1. Takes the original array and 2 generated arrays (left_array and right_array) 2. left_array and right_array are the exact length as the original array 3. It calls 2 functions get_left_index and get_right_index. 4. Each of these functions will calculate the left and right value (greater than current...
682a500dc5822d2aa950d79c099cd3e50ef36a65
batukochan/VSCode-Python-Egitim
/04_liste_string_metodlar/listeler_islemler.py
1,979
3.890625
4
#region iki listeyi birleştirmek """ sayilar = [1,2,3,4,5,6,7,8] harfler = ['a',"b","c","d"] ''' summation''' listelerinBirlesimi = sayilar + harfler print(listelerinBirlesimi) listelerinBirlesimi = harfler +sayilar print(listelerinBirlesimi) print(type(listelerinBirlesimi)) #list listelerinBirlesimi.append("python")...
e92e484b8d6b3ad718abd8cc09f9e905b5ce21e2
bjflamm/python
/python_practice/gcd.py
580
3.84375
4
# //calculate gcd of two numbers def gcd(num1,num2): divisor = 1 gcd = 1 while(divisor <= num1 and divisor <= num2): if(num1 % divisor == 0) and (num2 % divisor == 0): gcd = divisor divisor += 1 return gcd def gcd2(num1,num2): gcd = 1 if(num1 < num2): for i ...
ca7f65e50aa637dd87b450dd52fe323b5d7e38fb
calfdog/Robs_automation_tools
/misc_utils/covert_string_to_dict.py
777
3.96875
4
""" Developed by: Rob Marchetti July 2021 Lazy man's script that lets you take a string that you want as a dict and converts it to a dictionary Example: INPUT: s = "Lang1 Python Lang2 Ruby Lang3 Java Lang4 Perl" OUTPUT: {'Lang1': 'Python', 'Lang2': 'Ruby', 'Lang3': 'Java', 'Lang4': 'Perl'} ...
e64b975130d584713de066d60a70b46e5e55c883
danoliveiradev/PythonExercicios
/ex104.py
455
4.03125
4
def leiaInt(msg): """ -> Função que só aceita a leitura de números :param msg: recebe texto pedindo um número :return: retorna o resultado na análise """ num = input(msg) while num.isnumeric() is False: print('\033[31mERRO! Digite um número inteiro válido.\033[m') num = input...
b1bb38fdcc138be9623a825c3249aa4d2ab0a936
makubex01/python_lesson
/ch5/kwargs.py
243
3.53125
4
def show_keywords(**args): for key, value in args.items(): #argsのキーとvalueに代入 print(key + "=" + str(value)) #1つずつkeyとvalueを出力 print("---") show_keywords(a=55,b=87) show_keywords(c=55,d=87,e=62)
e107ea669cde1d90afef49fea00f20cbdfcc0209
deepakag5/Data-Structure-Algorithm-Analysis
/leetcode/puzzle_generate_parenthesis.py
660
3.515625
4
# Time : O(4^n/ sqrt(n)) # Space : O(4^n/ sqrt(n)) def generate_parenthesis(n): if n == 0: return [] result = [] def backtrack(s='', left=0, right=0): # we need to have a closing bracket for each opening bracket # so a pair hence 2*n if len(s) == 2 * n: result...
fdd914f82bab8a9c0ef614df8d964509f4597c0f
beczkowb/algorithms
/binarysearch.py
1,614
3.828125
4
import unittest def search(A, p, r, x): if len(A) == 0: return None elif r < 0 or p > len(A): return None elif p == r: if A[p] == x: return p else: return None else: q = (r-p) // 2 if A[q] == x: return q elif x...
9e649402ca52f83c02723632c7253f477bc2652c
codinggosu/algorithm-study
/src/dongjoo/week4/minaddparan.py
853
3.515625
4
# 921. Minimum Add to Make Parentheses Valid class Solution: def minAddToMakeValid(self, S: str) -> int: # decrease counter for ')' and increase for '(' count = 0 idx = 0 answer = 0 while idx < len(S): if S[idx] == ")": count -= 1 elif ...
e6b4b59a45456e827d53e0c624d553bd2c81505c
JonesPaul98/guvi
/perimeter of a rectangle
145
3.953125
4
l=int(input("enter the length of a rectangle:")) b=int(input("enter the breadth of a rectangle:")) p=2*(l+b) print("perimeter of a rectangle",p)
6e53d955acd35f5f1da0fcdde636fa234e57bfcb
snail15/CodingDojo
/Python/week3/Dictionary/dictionary.py
227
4.375
4
dict = { "name": "Sungin", "country of birth": "Korea", "age": 30, "favorite language": "Korean" } def printdict(dict): for key in dict: print("My {0} is {1}".format(key, dict[key])) printdict(dict)
d6af1267c2a31667e03870df1398a4f3bb7afc50
juniortheory/python-programming
/unit-2/problem4.py
1,278
4.15625
4
''' #problem 4 a = str(input('What caculation would you like to do? Add, Subtract, Multiply or Divide: ')) if 'Add' == a: print('Add!') b = int(input('What number would you like to Add?: ')) c = int(input('What other number would you like to Add?: ')) print('Your total is:', (b + c)) elif 'Subtract' == ...
af37be8e2663b3101ec34d4203382446e1462f80
Minions1128/helloworld
/basic/parameters_of_function.py
1,382
4.25
4
# -*- coding: UTF-8 -*- """ 介绍了函数参数的传递过程: 1,list参数传递 2,参数的打包 3,开包 4,函数作为参数 """ # 参数传递 a = 1 def plus(a): a += 1 return a print plus(a) print a """ 输出结果:2,1 """ b = [1, 2, 3] def pluss(b): b[0] += 1 return b print pluss(b) print b """ 输出结果: [2, 2, 3] [2, 2, 3] """ # 参数的默认值 def...
efabd0778655c682f8bb5dd951d1439d99ec6e9b
A01376718-Silvia/Mision-04
/Software.py
955
3.921875
4
# Autor: Silvia Ferman Muñoz # Programa que lee el número de paquetes comprados e imprime la cantidad descontada (si la hay) y el total. # Tecnica Top-Down # CONSTANTE del costo costo = 1500 # Calcular el descuento, depende de las unidades def calcularDescuento(paquetes): if paquetes < 10: return 0 ...
355d7487fca677d69c659436fad7e5b197f3ca97
JineshKamdar98/Codchef-Problem-Solutions
/Codechef Problem solutions/byte to bit.py
409
3.5625
4
for t in range(int(input())): n=int(input()) n=n-1 bit,nibble,byte=0,0,0 r=n%26 k=n//26 if(r>=0 and r<2): bit+=pow(2,k) print(bit,nibble,byte) elif(r>=2 and r<10): nibble+=pow(2,k) print(bit,nibble,byte) elif(r>=10 and r<26): byte+=pow...
6efe9ab64465563e4517ea469eed3a917584b16b
choukin/learnPython
/day1/str.py
414
3.75
4
# -*- coding: utf-8 -*- print('%2d-%02d' % (3, 1)) print('%.2f' % 3.1415926) print('Hello, {0}, 成绩提升了 {1:.1f}%'.format('小明', 17.125)) s1 = 72 s2 = 85 r = '{0} 成绩提升了 {1:.1f} %' s3 = (s2-s1)%s1 print(r.format('小明',s3)) print('%s 成绩提升了 %.1f %%'%('小明', s3)) ch = '中文' chencode = ch.encode('utf-8') print(chencode) chd...
796c7f5f7d63fffbadcf38588d5ba43db3a42b3b
Kdcc-ai/python
/面向对象高级编程/6.使用枚举类.py
2,828
3.8125
4
# 当我们需要定义常亮时 一个办法使用大写变量用过整数来定义。。 # 比如定义12个月 显得麻烦 # 所以有个好方法 是为这样的枚举类型定义一个class类型 # 每个常量都是class的唯一实例 from enum import Enum Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')) # 这样 我们就获得了Month 类型 的 枚举类 可以直接用 Month.Jan来引用一个常亮 # 或者枚举他的所有成员: print(Month.Jan) print(Mont...
3b76e2302ce7a135efe0a170974f4f5a0f592ca1
salee1023/TIL
/3.Algorithm/07. Tree/중위순회.py
764
3.59375
4
def f(n): # n번 노드 방문, 방문 후 유효한 노드인지 검사 if tree[n][0]: # 유효한 노드면 f(tree[n][1]) # 왼쪽 자식으로 이동 print(tree[n][0], end='') # n번 노드에서 할일 (왼쪽자식에서 리턴 후, 중위순회 in-order) f(tree[n][2]) # 오른쪽 자식으로 이동 # ------------------------------------- for tc in range(1, 11): N = int(input()) tree = [[0]*3 for...
93be0f3ac9172a34f68970d07f8b0d771b0b110b
frankcj6/Data_Structure_Review
/binary search.py
3,883
3.890625
4
# linear search def linear_search(data, target): for i in range(len(data)): if data[i] == target: return True return False # binary search def binary_search_iterative(data, target): low = 0 high = len(data) - 1 while low <= high: mid = (low + high) // 2 if ta...
a8d77aa92095f20ee41157e21c21ce81e59ca2b5
sunnyyeti/Leetcode-solutions
/493 Reverse Pairs_MergeSort_BIT.py
1,186
3.578125
4
# Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. # You need to return the number of important reverse pairs in the given array. # Example1: # Input: [1,3,2,3,1] # Output: 2 # Example2: # Input: [2,4,3,5,1] # Output: 3 # Note: # The length of the given array will not ...
dbe56dfff93c189916655272ba1e7cf9807c8214
824zzy/Leetcode
/A_Basic/String/L0_1805_Number_of_Different_Integers_in_a_String.py
312
3.703125
4
""" https://leetcode.com/problems/number-of-different-integers-in-a-string/ check if character is digit by `if c.isdigit():` """ class Solution: def numDifferentIntegers(self, word: str) -> int: word = ''.join([c if c.isdigit() else ' ' for c in word]) return len(set(map(int, word.split())))
0c520ffed9ddd6b62d29d1a4356a44e4cda99f4e
GitFiras/CodingNomads-Python
/03_more_datatypes/1_strings/03_01_replace.py
446
4.40625
4
''' Write a script that takes a string of words and a symbol from the user. Replace all occurrences of the first letter with the symbol. For example: String input: more python programming please Symbol input: # Result: #ore python progra##ing please ''' words = input("Please write a number of words, separated by com...
0ec1a804791046dfe0bc7b6e9544518bc34b18a7
vkd8756/Python
/array/encrypt.py
747
3.515625
4
class Crypto: def __init__(self,str1,encrypt=[]): self.str1=str1 self.encrypt=[0]*26 j=4 for i in range(26): if j+97>122: j=0 self.encrypt[i]=chr(j+97) j+=1 #print(self.encrypt) def encryption(self): ...
1c6a3b08bccd7d8f88ce82276d24c2c20bc98fce
nafSadh/py
/arith/phrase_num.py
1,137
3.90625
4
import sys words = [ "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" ] tens = ["", "", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"] ...
597c70f4beebbbc7a5c31d3bcbbac0f9786523ce
warleyzee/python
/lista/zip_zipLongest.py
845
3.5625
4
""" ZIP - Unindo Interáveis ZIP_LONGEST - Itertools """ from itertools import zip_longest, count #Criar um indice automatico indice = count() """ Código """ cidade = ['São Paulo', 'Belo Horizonte', 'Salvador', 'Monte Belo', 'Outra'] """ Mais Código """ estado = ['SP', 'MG', 'BA'] """ Mais Código """ sigla...
1e9f49d4a1fa38e5f883e28dc83bda1ec6cf0035
cesslab/mazegame
/experiment/maze_game.py
3,414
3.5
4
import random from typing import List class Maze: def __init__(self, name: str, start_x: int, start_y: int, end_x: int, end_y: int): self.name = name self.start_x = start_x self.start_y = start_y self.end_x = end_x self.end_y = end_y class MazeCollection: def __init__...
05422d10f392834e00dd24ecf98a5ff6ce2b6d2f
Arnoldj2/Python-Projects
/File_Transfer_Project/File_Transfer_3.py
2,641
3.515625
4
from tkinter import * import tkinter as tk from tkinter import filedialog import os from datetime import * import os.path, time import shutil class ParentWindow(Frame): # Tkinter frame class def __init__(self, master, *args, **kwargs): Frame.__init__(self, master, *args, **kwargs) # def...
669bba65e007052c8782432798a59803a4942341
cybelewang/leetcode-python
/code990SatisfiabilityOfEqualityEquations.py
2,288
4.1875
4
""" 990 Satisfiability of Equality Equations Given an array equations of strings that represent relationships between variables, each string equations[i] has length 4 and takes one of two different forms: "a==b" or "a!=b". Here, a and b are lowercase letters (not necessarily different) that represent one-letter va...
817418f96e93c9d9fc239b0560c19fc82d6bf611
Aasthaengg/IBMdataset
/Python_codes/p02419/s376849379.py
163
3.53125
4
w = input() t = [] while True: temp = input() if temp == 'END_OF_TEXT': break else: t += [s.strip(',.') for s in temp.lower().split(' ')] print(t.count(w))
95cbb5c8705d31f801db363a9df3e307bc215d3b
EdisonZhu33/Algorithm
/备战2020/052-二叉树的最大最小深度.py
2,251
4.125
4
""" @file : 052-二叉树的最大最小深度.py @author : xiaolu @time : 2020-02-25 """ from typing import List class TreeNode(object): """ Definition of a binary tree node.""" def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def buildTree(self, inorde...
23aedb0f4162872f656c7f1ba65a4b760d5f6c87
Flutflut/Dictionary_Examples
/printdict.py
492
3.890625
4
import json #Open the dictionary file dictfile = open('dictionary.json',) #load the dictionary file into a database database = json.load(dictfile) #Close the file now that I am done with it dictfile.close() # for each entry in the dictionary for entry in database: print("========================\n...
9c98fceb8962a15c428845244820b48eee2d001b
kasamdh/python
/swap.py
605
4
4
''' Implement function swapFL() that takes a list as input and swaps the first and last elements of the list. You may assume the list will be nonempty. The function should not return anything. >>> ingredients = ['flour', 'sugar', 'butter', 'apples'] >>> swapFL(ingredients) >>> ingredients ['apples', 'sugar', 'butter', ...
caaa87f7045a7552926a4a704050679f375b69f4
rai-roshan/beautifulsoup_web_scarping
/csv_r_W/read_csv.py
620
3.921875
4
import csv with open('names.csv','r') as f: #filehandling open file as f csv_f=csv.reader(f) #convert file f in csv file object #next(csv_f) #skip the first list ['.....','......','.........'] #for line in csv_f: # print(line) # print(line[0],line[1],line[2]) #we have to use in...
cc9ee4ee85f49cb743c47c4f353f4a92ae4a4973
pm0824/June-Leetcoding-Challenge-2020
/Find_The_Duplicate_Number.py
1,173
4.03125
4
''' Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. Example 1: Input: [1,3,4,2,2] Output: 2 Example 2: Input: [3,1,3,4,2] Output: 3 Note: You m...
dc1857b9442e55fec5fab0f6de8238874a768b33
jagnoor/python-challenge
/PyBank/Resources/PyBank.py
2,964
4.09375
4
# Python Homework - Py Me Up, Charlie - PyBank # Import Modules/Dependencies import os import csv # Variables month = 0 amount = 0 change = [] month_count = [] increase = 0 increase_month = 0 decrease = 0 decrease_month = 0 # Set Path For File PyBankPath = os.path.join('.', 'PyBank', 'Resources', 'budget_data.csv...
027d7adb29a53a376a109fa1a4dc70e83a329eea
avalliere/swap-meet
/swap_meet/vendor.py
1,840
3.5
4
class Vendor: def __init__(self, inventory=[]): self.inventory = inventory def add(self, item): self.inventory.append(item) return item def remove(self, item): if item not in self.inventory: return False self.inventory = [ thing for thing in...
cd3185fb5029b4d1f8bdaa9231ae59a5a0efd3db
AnaTrzeciak/Curso_Python
/3-Looping/tabuleiro.py
274
4
4
#ecoding:utf-8 #Loop dentro de loop #Tabuleiro NxN print("Vamos criar um tabuleiro de tamanho NxN.") n= int(input("Digite N (tamanho do tabuleiro):")) for linha in range(n): for coluna in range(n): print("x ",end= '') print() #quebra de linha
bc89d28e19ca5761c98e7e6887837a2ea8a90ad7
gagande90/Data-Structures-Python
/Sets/sets1.py
1,670
4.1875
4
number_set = {1, 2, 3, 4} # sets use curly braces for creation letter_set = {'a', 'b', 'c', 'd'} mixed_set = {1, 'a', 2, (1, 2, 3)} # types must be "hashable", i.e. immutable empty_set = set() # have to use the set() function, cannot use = {} ...
3e51500a4051bef24af3a074352a7485a3bde501
hotheat/LeetCode
/098. Validate Binary Search Tree/recur.py
568
3.5
4
from collections import deque class Solution: def isValidBST(self, root: TreeNode) -> bool: if root is None: return True else: return self.helper(None, root, None) def helper(self, minv, root, maxv): if root is None: return True if (minv i...
9cd42b86cae256361425411a230ef5f21836fbd6
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/ncbden001/question4.py
657
4.1875
4
import math lower = eval(input("Enter the starting point N: \n")) upper = eval(input("Enter the ending point M: \n")) print("The palindromic primes are:") def prime(n): if n < 2: return False if n == 2: return True if not n & 1: return False for x in range(3, int...
4d06b383051957bc4ff42b9a10378675e70610ee
jonowadsworth/Crash-Dictionaries
/Dict_test.py
1,205
4.3125
4
# Nesting a dictionary within a list. # Syntax seems to be: # dict # dict # dict #list[dict1, dict2,dict3] etc alien_0 = {'Colour': 'Green', 'Points': 10} alien_1 = {'Colour': 'Yellow', 'Points': 5} alien_2 = {'Colour': 'Red', 'Points': 15} aliens = [alien_0,alien_1,alien_2] for alien in aliens: ...