blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
dca00d13b5dcc3d426fe42ffa8c864bbf24d40d4
chiragnayak/python
/PyTraining/tech_rnd/Day_1_22March2021/comprehension.py
1,401
3.640625
4
print('-' * 75) # Without using comprehension sqr = [] for n in range(1, 11): if n % 5 == 0 or n % 3 == 0: sqr.append(n ** 2) print('sqr -', sqr) # List Comprehension # [expr iteration <condition>] sqr_lc = [n ** 2 for n in range(1, 11) if n % 5 == 0 or n % 3 == 0] print('sqr_lc -', sqr_lc) print('-' * 7...
bb34fbc6f2baf6bfbd99ffa0865c2331d164af74
JPauly-tec/Tarea1PaulyJimenez
/CharFunction.py
1,258
3.84375
4
def char_check(x): # revisa dato ENTRADA: carácter a revisar SALIDA: 0 o 1 global ER # crea variable global de error if isinstance(x, str): # revisa que la entrada sea un string if x.isalpha() is True: # revisa que la entrada sea del alfabeto if len(x) == 1: # revisa que la ...
e4f681424d3296907ab7773d320e238725942a85
hrithiksagar/Competetive-Programming
/Python/Chapter 5 Dictionary and Set/problem 6.py
955
3.828125
4
""" Create an empty dict. allow 4 friends to enter thier fav lang as values and use keys as their names assume that the names are unique IF names of 2 friends are same; what will happen? If languages if two friends are smae what will happen? """ # favLang = {} # a = input("enter ur fav lang Shubham: \n") # b = input(...
92974d20628f8bb20c01ea8a7eac9811ce743e18
Almenon/AREPL-vscode
/test/manualAreplTests/multipleTypes.py
1,036
3.78125
4
########################################### # Code ########################################### import math # doesn't show up (good, we dont want modules to show) a = 1 b = 1.1 c = float('nan') d = float('infinity') e = float('-infinity') accent = 'é' g = {} h = [] i = [[[]]] j = lambda x: x+1 # doesnt ...
f4258360799c484e20942b855aac1f887b6d956d
Degamey/Memorizing-game
/main.py
3,893
3.5
4
import turtle import time import random as r from langue import * from tifunc import timer from string import ascii_uppercase,ascii_lowercase from testrandom import randchoes let=ascii_uppercase+ascii_lowercase letnum=let+"0123456789" print(let) t=turtle.Turtle() t.hideturtle() t.screen.setup(900, 600) ...
3f4d8f9a394ae861f5be27f68d110b0fbd0e72dd
popadrianc/learning_python
/Exercises/ex3.py
557
4.15625
4
#This should be a counting program print("I will start counting cakes") print("Banana cake", 25 + 30 / 6) print("Apple cake", 100 - 25 * 3 % 4) print("Now I will count the syrup:") print( 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) print("Is it true that 3 +2 < 5 - 7?") print(3 + 2 < 5 - 7) print("What is 3 ...
5a287b325f31a4c536474f03c85bbdea4213cbe3
Anaivbvo/CSE
/notes/Anai S.L. Lopez - Challanges.py
1,455
4.34375
4
""" Easy: 1. Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them. """ print("Anai", "Lopez") namelist = ["Anai", "Lopez"] namelist. reverse( ) print(namelist) """ 2. Write a Python program to find whether a given number (accept from the user) i...
f5d23f05333c4921107d563423501046ff875e06
hebaflemban/datastructure-
/queue.py
1,484
3.796875
4
from random import randint class Node: def __init__(self, data, next=None): self.data = data self.next = next class Queue: def __init__(self, limit=None, front=None, back=None): self.front = front self.back = back self.limit = limit self.length = 0 def i...
7e7d25ce8c8f6f176a4587022aed9bb4e9b27724
Mugambiii/python-1
/lesson 7 -functions.py
1,540
4.03125
4
def addition(): num1 = float(input("Enter first number")) num2 = float(input("Enter second number")) result = num1 + num2 print("{} + {} ={}".format(num1, num2, result)) #addition # def addition2(num1,num2,num3): # result = num1 + num2 + num3 # print("{} + {} ={}".format(num1, num2,num3, result...
489b0d1a7f6ecd7be001d001cf323db2f86f2c1c
AdamZhouSE/pythonHomework
/Code/CodeRecords/2126/60899/275099.py
363
3.71875
4
def largestDivisibleSubset(nums): s = {-1: set()} for n in sorted(nums): s[n] = max((s[d] for d in s if n % d == 0), key=len) | {n} return list(max(s.values(), key=len)) def main(): list0 = list(map(int,input().split(","))) list1 = largestDivisibleSubset(list0) list1.sort() print(li...
8118ce64a2b70ee1871287574a5007e9d36d02b2
Falconssko/skola
/uloha 6.py
503
3.796875
4
a=input("zadaj meno 1. cloveka:") am=float(input("zadaj vahu 1. cloveka:")) b=input("zadaj meno 2. cloveka:") bm=float(input("zadaj vahu 2. cloveka:")) c=input("zadaj meno 3. cloveka:") cm=float(input("zadaj vahu 3. cloveka:")) P = (am+bm+cm)/3 print('priemerna vaha je:', P) if am > P: print("a nadprie...
f109aac3d2da36f385d0ece865e370490eda837b
error707-persona/Hacktoberfest-21
/CryptoGraphy.py
1,862
4.0625
4
#CRYPTOGRAGHY USING RAIL FENCE CIPHER METHOD ''' Input Text : Sentence that needs to be encrypted, Key : Any integer (encrypting the text) ''' def main(): clearText =input("Enter text :") clearText = clearText.replace(" ","") clearText = clearText.upper() key = int(input("enter Key:")) ...
379a52c89378c8772d3e5b69ad18c097ed5ca7f1
mtj6/class_project
/album.py
455
3.921875
4
def make_album(artist_name, album_title, tracks_number=' '): """Return information about an album.""" album = {'name' : artist_name, 'title' : album_title} if tracks_number: album['tracks_number'] = tracks_number return album record = make_album('beyonce', 'lemonade') print(record) record ...
d8afaf00398a7259cca4be7eea1a8983a6fe1b96
zoro16/tf_tutorials
/high_level_api/numpy_arrays.py
1,700
3.515625
4
import numpy as np import tensorflow as tf # Load the training data into two NumPy arrays, for example using `np.load()`. with np.load("/var/data/training_data.npy") as data: features = data["features"] labels = data["labels"] # Assume that each row of `features` corresponds to the same row as `labels`. assert f...
86e34ae6075047e37b7dc0739e3789d0d610279a
Neeraj-kaushik/Coding_Ninjas_Python
/ConditionalsAndLoops/PalindromeNumber.py
163
3.796875
4
num=int(input()) rev=0 digit=num while digit!=0: rev=rev*10 rev=rev+digit%10 digit=digit//10 if rev==num : print("true") else: print("false")
0eeee7705ee7710ecbd77a31fb9f64a1afc5ff7e
alvinwang922/Data-Structures-and-Algorithms
/Tries/Add-Search-Word.py
1,675
3.953125
4
""" Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter. """ class WordDictionary: def __init__(self): ""...
8b376abd8af5b6453563d51c08783db557131ec7
Tom-Szendrey/Highschool-basic-notes
/Notes/Banking Examples Programs/school.py
814
3.96875
4
#mr t #jan 1 2000 # this program proves that I know what I am doing class Person(object): #the class methods variables and code goes here. def __init__(self, initial): self.name= initial self.birthdate="" self.height=0 def set_dob(self,date): self.birthdate=da...
3a2f98d1c97fe2e70e14dda9c1bdfa224a8f6ed6
hanrick2000/leetCode-5
/PythonForLeetCode/728_SelfDividingNumbers.py
629
3.515625
4
class Solution: def selfDividingNumbers(self, left, right): """ :type left: int :type right: int :rtype: List[int] """ result = [] for i in range(left, right + 1): temp = i divide = True while temp > 0: mode ...
6d82cb65b98b404608ac85d11d3c570a4a58cc87
harsilspatel/HackerRank
/Mathematics/Geometry/Points On a Line.py
193
3.640625
4
x = [] y = [] for i in range(int(input())): a, b = map(int, input().split()) x.append(a) y.append(b) x.sort() y.sort() if (x[-1] == x[0] or y[-1] == y[0]): print ("YES") else: print ("NO")
6675c87e0b827a62b53192168ac50e857b22ac0d
AlexandrSech/Z49-TMS
/students/Volodzko/Task_2/task_2_3.py
223
3.828125
4
""" Создать строку равную первым пяти символам введенной строки """ my_strinng = input("Введите строку: ") string_result = my_strinng[:5] print(string_result)
1d54e4197fa4926dff7c1c8ecfe7e70bc5b7ce74
deepsjuneja/Task1
/prime.py
237
3.96875
4
def num(): n = int(input("Enter a number")) c = 0 for i in range(2, n): if n%i == 0: c = c+1 if c == 0: print("Prime Number") else: print("Not a prime number") num()
36476a1e2fe20f04e4ad0a5c2d00e731b6345fb2
Reid00/KnowledgeGraph
/DataStructure/letcode05.py
799
3.53125
4
# -*- encoding: utf-8 -*- ''' @File :letcode05.py @Time :2020/07/10 16:38:10 @Author :Reid @Version :1.0 @Desc :请实现一个函数,把字符串 s 中的每个空格替换成"%20"。 ''' # 示例: # 输入:s = "We are happy." # 输出:"We%20are%20happy." # 限制: # 0 <= s 的长度 <= 10000 def resolution(): """ 内置replace 方法 """ ...
423e730dd654924ded852fefb1801788a81ef167
astorcam/scripts_Seguridad
/analFrec.py
449
3.8125
4
import operator text= input("Mete el texto cifrado: ") letras=["e","a","o","l","s","n","d","r","u","i","t","c","p","m","y","q","b","h","g","f","v","j","ñ","z","x","k","w"] caracteres={} for char in text: if char.isalpha() or char=="ñ": if char in caracteres: caracteres[char]+=1 else: caracteres [char]=1 ap...
71ee5e3080435b48daf880ca08517318b892905a
pytorch/tutorials
/advanced_source/dynamic_quantization_tutorial.py
10,140
3.5
4
""" (beta) Dynamic Quantization on an LSTM Word Language Model ================================================================== **Author**: `James Reed <https://github.com/jamesr66a>`_ **Edited by**: `Seth Weidman <https://github.com/SethHWeidman/>`_ Introduction ------------ Quantization involves converting the ...
c78f15642c1c6a5f47637fa44d1ed4b79575a8ac
aniruddhafrnd/python_proj
/pgm1_divison_q1.py
393
3.765625
4
''' Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line. ''' mylst = [] myno = range(2000,3200) for x in myno: if x%7 == 0 and x%5 != 0: ...
f0af3341d0db22d926e56a932e4abbf8c7bc6a53
maxrmjf8/IACodigos
/CodeClass.py
1,679
4.25
4
#Code in Class #Ejercicio 1.- Programa en python que dado como dato el sueldo de un trabajador, le aplique un aumento del 15% si su sueldo es inferior a $1000.00 y del 12% en caso contrario. def main(): st= float(input("Introduce tu sueldo: ")) if(st<1000): sf = st*.15 + st elif(st >= 1000):...
aab5c091441863757056c2fcb055402d66d6f700
chingxwen/FYP
/News/Classes/Plotting News Graph - function.py
2,162
3.515625
4
import matplotlib.pyplot as plt import pandas as pd from datetime import datetime df = pd.read_csv("Formatted_Data_Sentiment.csv") senti = df["Sentiment"] df["Date"] = pd.to_datetime(df["Date"], format = "%Y/%m/%d") date = df['Date'] #Line Graph def senti_linegraph(date, senti): start_date = input("Please i...
624c8bcf049a6af39333583a6cd0b9ad82027331
farmkate/asciichan
/crypto/LC101rot13.py
470
3.921875
4
#LC101rot13.py def rot13(mess): # Your code here rotate = 13 cipher = '' alphabet = 'abcdefghijklmnopqrstuvwxyz' for char in mess: if char.isalpha(): index = alphabet.index(char) cipher = cipher + alphabet[(index + rotate) % 26] else: cipher = cip...
f17dacabee9825e9cc3d0806ecf4daf7a9c7c0c1
kennethyu2017/cs231n_assignments
/assignment3/cs231n/image_utils.py
3,017
3.625
4
import urllib2, os, tempfile import numpy as np from scipy.misc import imread from cs231n.fast_layers import conv_forward_fast """ Utility functions used for viewing and processing images. """ def blur_image(X): """ A very gentle image blurring operation, to be used as a regularizer for image generation. ...
9b1d4324e57abc09372304022a26f1f66e468aad
BaoziSwifter/MyPythonLeetCode
/pythonLeetcode/448.找到所有数组中消失的数字.py
2,809
3.859375
4
# # @lc app=leetcode.cn id=448 lang=python3 # # [448] 找到所有数组中消失的数字 # # https://leetcode-cn.com/problems/find-all-numbers-disappeared-in-an-array/description/ # # algorithms # Easy (54.02%) # Likes: 226 # Dislikes: 0 # Total Accepted: 17.8K # Total Submissions: 32.9K # Testcase Example: '[4,3,2,7,8,2,3,1]' # # 给定...
de4e48a7ecbb312cf5c162f7893346dbe17a708c
pumbaacave/atcoder
/Leetcode/kthSmallestBST.py
918
3.734375
4
# Definition for a binary tree node. from typing import List class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def kthSmallest(self, root: TreeNode, k: int) -> int: # inorder travel cnt = ...
0aeb9869c502f0d730499f86429c3be86710b7e1
dishant-helpshift/Git_Intro
/code01.py
334
3.59375
4
def getFizzBuzzUptoN( n ): fizzbuzzSeq = [] for i in range( 1, n+1): tmpstr = "" if i%3==0: tmpstr += "Fizz" if i%5==0: tmpstr += "Buzz" if tmpstr == "": tmpstr = tmpstr + str(i) fizzbuzzSeq.append( tmpstr ) return fizzbuzzSeq if __name__ == "__main__": fizzbuzzSeq = getFizzBuzzUptoN( 10 ) prin...
cced8ec5079198dc899ae32536b47b4b25e288b0
kadarakos/dag-cppn
/network.py
7,309
3.875
4
import random import math random.seed(2777) class Node(object): """A neuron in a network. Takes inputs, adds them up and applies and activation function to the sum. Parameters ---------- idx : str Name of the node. func : function Activation function. Attr...
8015a79c1bc20fdfd8b90719ce4e5efc5cf096d5
Allard-Timothy/algorithm-design-and-analysis
/algorithm-design-and-analysis/Week3/min_cut.py
1,887
3.796875
4
"""Your task is to code up and run the randomized contraction algorithm for the min cut problem and use it on the above graph to compute the min cut (i.e., the minimum-possible number of crossing edges). """ from random import choice from copy import deepcopy def contract(v1, v2, G): """Contracts two vertices fro...
df7f0c9091e1b9d37ef406f044cce34e81941050
EnzDev/GiveMeSomeArtBaby
/utils.py
557
3.984375
4
def average(c1, c2, w=0.5): '''Compute the weighted average of two colors. With w = 0.5 we get the average.''' (r1, g1, b1) = c1 (r2, g2, b2) = c2 r3 = w * r1 + (1 - w) * r2 g3 = w * g1 + (1 - w) * g2 b3 = w * b1 + (1 - w) * b2 return (r3, g3, b3) def rgb(r, g, b): '''Convert a color r...
1958de37e9376c874b0b19feec831728fc4e6679
Daniel-Benzion/codingbat_python
/logic-2/make_chocolate.py
161
3.671875
4
def make_chocolate(small, big, goal): if goal > (big * 5): result = goal - (big * 5) else: result = goal % 5 if small >= result: return result return -1
56a4d56f8c9efc19cf201ba0fb688a2a46c55691
Neriitox/Portfolio
/Missing Multipliers.py
180
3.859375
4
num = int(input("Times table: ")) step = int(input("Step: ")) for a in range(1, 13, step): answer = a * num print(f"{num} x [] = {answer}") #Shows your time tables
e812c365bde987674d46da2389b14c210021096f
sctu/sctu-ds-2019
/1806101074赵贤雯/day20190423/test02.py
239
3.625
4
class Node: def __init__(self,data,next): self.data = data self.next = None # 有三个结点 n1 = Node(1) n2 = Node(2) n3 = Node(3) # n1的下一个结点是n2 n1.next = n2 # n2的下一个结点是n3 n2.next = n3
455205c166f7eff829242ca90bca39cd88a62735
meenakshisl/Cryptography
/Cryptography/AES/AES_ECB/padding.py
1,029
4.0625
4
#----------functions to pad , unpad and check_padding--------- def unpad(cipher_text,block_size) : #---------unpads parameter string after checking for padding--------- assert check_pad(cipher_text,block_size)=="Ok",check_pad(cipher_text,block_size) ch=ord(cipher_text[-1]) plain_text=cipher_text[:-c...
dbbf9e3b24b633a821fcf75acb3098d86c846dbc
oujieying/airlines_prices_ongoing
/airlines-sinkUtils/Jsonutils.py
822
3.609375
4
import json class MyClass(object): def __init__(self): self.a = 2 self.b = 'bb' if __name__ == '__main__': # 创建MyClass对象 myClass = MyClass() # 添加数据c myClass.c = 123 myClass.a = 3 # 对象转化为字典 myClassDict = myClass.__dict__ # 打印字典 print(myClassDict) # 字典转化为json ...
e1c5f070876f5079b14020ad2d568acf6d919151
guiw07/leetCode
/448_FindAllNumbersDisappearedInAnArray.py
931
3.953125
4
""" 448. Find All Numbers Disappeared in an Array Given an array of integers where 1 <= a[i] <= n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space and in O(n) runtime? You may assume...
0813ecb0aa139633ad96ceb734e6fcf9bfc0e771
DamianNery/Tecnicas-De-Programacion
/5Mayo/18/CalculadoraFechas.py
1,179
4.0625
4
#!/usr/bin/env python3 #Intentá hacer una calculadora para fechas. Podrías empezar con una que sume y #reste fechas (año-mes-día) Se puede ir agregando otras funciones: (ej. sumar #o restar teniendo en cuenta horario, etc.) import datetime def CalculadoraFechas(): dia1=int(input("dia1: ")) mes1=int(input("me...
15f2f09ec701d96cef8bf30a9df794fff4cb7ded
KKhushhalR2405/AlgoNOOB
/product-sum.py
221
3.59375
4
def productsum(arr,l,s): for i in arr: if type(i) is list: s+=productsum(i,l+1,0) else: s+=i return s*l arr=[5,2,[7,-1],3,[6,[-13,8],4]] print(productsum(arr,1,0))
e3825da8ba45dc086452544e7de29f2e3b98d4c7
ming-log/MetaClass
/03 自定义元类.py
1,616
3.765625
4
# __author__:"Ming Luo" # date:2020/9/28 # 原始类 class fun(object): age = 18 gender = "男" # 假想一个很傻的例子,你决定在你的模块里所有的类的属性都应该是大写形式。 # 如何通过元类来实现 def upper_all_attr(class_name, class_parent, class_attr): for k, v in class_attr.items(): if not k.startswith("__"): del class_attr[k] ...
9b25e755d3c30974d81a9581534ddfcd24d125a8
Aasthaengg/IBMdataset
/Python_codes/p03698/s351814909.py
142
3.53125
4
S = input() tmp = [] ans = "yes" for i in range(len(S)): if (S[i] in tmp): ans = "no" break else: tmp.append(S[i]) print(ans)
7f7f6cc5e3489c7f84137f8e5c2a2b564c1c9744
Flor246/PythonFlor
/Modulo1/scripts/ingreso_datos.py
483
3.90625
4
# control + n - > abro un nuevo file # control + s -> guardar cambios # Terminal: cls -> limpiar terminal # ejecutar python : python nombre_archivo.py # 1. Solicitando numero x = int(input('Por favor ingrese un dato numerico: ')) # 2. elevando numero al cubo potencia = x ** 3 # 3. Mostrando resultado # print('El n...
3de62f716e23bfed25dcc134efdd8ddade184667
UJurkevica/python-course
/homework/week1/exercise3.py
414
4.40625
4
#3a floating_var = 8.98 integer_var = 4 string_var = 'Jam' #3b print(f'This item is an integer: {floating_var.is_integer()}') #test if variable is integer print(f'Ratio of this integer is: {integer_var.as_integer_ratio()}') #it provides ratio for the variable (in this case for the integer) print(f'Given variable begin...
8954621d65258d4dac39d9aced7771b069c143d8
87chevytruck/All_Labs
/Python and Network Labs/Performance Labs/Lab5A_Packaged/Calculator_Functions/Lab5A_definitions.py
2,138
3.875
4
""" Ricky Smith, Lab5A: Modules & Packages, 12 Sep 2018 Lab5A Definitions """ # def multi function def multi(x, y): return x * y # def divide function def divide(x, y): return x / y # def power function def power(x, y): return x ** y # def fibonacci function (itterative version for fast result...
a4ace0e0e1d63b53b1612bc70d725f6e03e8fa34
DanielSoaresFranco/Aulas.py
/exercícios/ex094.py
1,161
3.734375
4
mulheres = [] pessoas = [] pessoa = {} s = m = 0 while True: pessoa.clear() pessoa['nome'] = str(input('Nome: ')).capitalize() pessoa['idade'] = int(input('Idade: ')) pessoa['sexo'] = str(input('Sexo: ')).strip().lower()[0] while pessoa['sexo'] not in 'mf': print('Erro! Digite M ou F.') ...
d06067d919884f5cd2246ab09159f126f929b1b5
MardanovTimur/propeller
/main.py
574
3.609375
4
import platform, os from spell_checker import search from trie import Trie WORDS_PATH = "/usr/share/dict/words" if platform.system().lower() in 'linux': WORDS = os.path.abspath(WORDS_PATH) else: raise SystemError("linux devices only") def create_tree(words: str=WORDS_PATH): tree = Trie() file = open...
33a83a7f4d3654dd19264056ca5de211d5b7c0cf
ChanningC12/PythonLearning
/Python_Codecademy/List and Function.py
1,070
4.03125
4
#battleship board=[] for i in range(0,5): board.append(["0"]*5) def print_board(board): for row in board: print (" ".join(row)) #Hide from random import randint board=[] for i in range(0,5): board.append(["0"]*5) def print_board(board): for row in board: print (" ".join(row)) def rando...
23ffb66fdd98943463fc3ec60611aae6ceeaec31
ZhengyangXu/LintCode-1
/Python/Implement Queue by Two Stacks.py
986
4.25
4
""" As the title described, you should only use two stacks to implement a queue's actions. The queue should support push(element), pop() and top() where pop is pop the first(a.k.a front) element in the queue. Both pop and top methods should return the value of first element. """ class Queue: def __init__(self):...
751bf0dd19d4c77093ddee2e9d80226cb1ee499b
dengdaiyemanren/python
/yield.py
704
3.59375
4
# -*- coding: utf8 -*- def fab(max): n,a,b = 0,0,1 while n < max: print b a,b = b,a+b n = n +1 #fab(5) def fabx0(max): n,a,b = 0,0,1 L = [] while n < max: L.append(b) a,b = b , a+b n = n + 1 return L def fab01(max): n,a,b = 0,0,1 ...
3b05fa83a9c2fba61761fa7208a9e17076dc8b97
a-morev/Python_Algos
/Урок 1. Практическое задание/task_4.py
1,844
3.71875
4
""" Задание 4. Написать программу, которая генерирует в указанных пользователем границах: случайное целое число; случайное вещественное число; случайный символ. Для каждого из трех случаев пользователь задает свои границы диапазона. Например, если надо получить случайный символ от 'a' до 'f', то вводятся эт...
b8dbdb5071bccdb9473b4730461d831684b291cc
01090841589/ATM
/그외/08 4주/타일 붙이기.py
398
3.578125
4
import sys sys.stdin = open("타일붙이기.txt") def inf_sec(N, num): global total if N == 0: total += num return if N >= 1: inf_sec(N-1, num) if N >= 2: inf_sec(N-2, num*2) if N >= 3: inf_sec(N-3, num) T = int(input()) for tc in range(1, T+1): N = int(input()) ...
f961155622dd24fcc38cd3e5d9046a876098caa4
nguyenbac5299/LearnPython
/condition/while.py
907
3.8125
4
i = 0 while i < 10: print(i) i += 1 else: print('end') i = 0 while i < 10: print(i) i += 1 break else: print('end') # not execute because has break # while True: # response = input('Say something: ') # if response == 'bye': # break for i in [1, 2, 3]: if i == 2: ...
d04806c75e39147c5f663d28a5e2a578607daa35
taufanmw/repo01
/tipedatalist.py
844
3.640625
4
#tipe data list #tipe data sederhana anak1 = 'Eko' anak2 = 'Dwi' anak3 = 'Tri' anak4 = 'Catur' print(anak1) print(anak2) print(anak3) print(anak4) #tipe data array print('\ntipe data array') anak = ['Eko', 'Dwi', 'Tri', 'Catur'] print(anak) #kalau menambahkan variabel baru print('\ntambah var baru') anak.append('Lim...
dbb025e2c3efe62028c5d5bdf2e8df50154cf3bb
arpitbbhayani/recursion
/03-sum-of-digits.py
384
4.21875
4
# # Perform sum of digits using recursion # sum_digits(123) = 1 + 2 + 3 = 6 # def _sod(number: int) -> int: if number == 0: return 0 units_digit = number % 10 remaining_number = number // 10 return units_digit + _sod(remaining_number) def sum_digits(number: int) -> int: return _sod(nu...
0b7cc39e8150b2c13b86fc1f211569702bf7d50c
shifty049/LeetCode_Practice
/Medium/652. Find Duplicate Subtrees.py
1,187
3.890625
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 findDuplicateSubtrees(self, root: Optional[TreeNode]) -> List[Optional[TreeNode]]: self...
e5bbfbc97e8b4359a7b74da2af777cf269722939
saiwho/learn-python-the-hardway
/ex34.py
345
3.875
4
animals = ['bear', 'python3.6', 'peacock', 'kangaroo', 'whale', 'platypus'] print("\nAll the list members:") print(animals) print("\nLast item of the list:") print(animals[-1]) print("\nFirst two items of the list:") print(animals[0:3]) print("\nItems from 2 to last but one:") print(animals[1:-1]) print("\nLast two it...
ca81ebaf74aeaf0b8f764ad4542a9d7d1b1ae1a2
127-vitor/python_fundamentals
/Aulas/estrutura_repetição.py
1,192
3.828125
4
# -*- coding: UTF-8 -*- # from __future__ import print_function # x = 1 # while x < 10: # print(x) # x += 1 # print('fim do while') # x = 1 # while True: # print(x) # x +=1 # usuários = dict(renato='ninja12', vitor='ninjutsu34', lucas='kinjutsu87', lia='doujutsu09', erik='taijutsu123') # for us...
43e1b48dc194eadba3cd700770169ba41236c11d
RamyaRamasubramaniyan/PythonProjects
/HackerRankSolutions/ShopperDelight.py
3,627
4.09375
4
# HackerRank - Shopper's Delight # A Shopaholic wants to buy a pair of jeans, a pair of shoes, a skirt, and a top but has a limited budget in dollars. Given different pricing options for each product, determine how many options our customer has to buy 1 of each product. You cannot spend more money than the budgeted amo...
222815a5462a828a7e712c35693d713e2f7a885a
BC-csc226-masters/a03-fall-2021-master
/a03_emilbekuuluy.py
4,223
3.640625
4
###################################################################### # Author: Yryskeldi Emilbek uulu # Username: emilbekuuluy # # Assignment: A03: Fully Functional Gitty Psychedelic Robotc Turtles # Purpose: To continue practicing creating and using functions, more practice on using the turtle library, # learn about...
eef42a182ff592e498fc36c4b9e869dfa6548e5e
vcatafesta/chili
/python/sena.py
447
3.890625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import random num1 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] num2 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] # random.shuffle(num2) sorteados = "Dezenas sorteadas: " i = 0 while i < 5: dezena = "00" while dezena == "00": random.shuffle(n...
b668affd63049e4d1f8c6688ef5bf60ce042f432
Aasthaengg/IBMdataset
/Python_codes/p03289/s196878305.py
98
3.96875
4
from re import match if match("^A[a-z]+C[a-z]+$", input()): print('AC') else: print('WA')
f3778a4abfdeed4145bc6104d1f6ecfb5b2be18d
tglanz/codes
/python/tests/test_heap.py
999
3.546875
4
from structures.heap import Heap def test_default_constructor(): heap = Heap() assert heap is not None, "shouldn't be None" def test_min_heap_builder(): heap = Heap.create_min_heap() assert heap is not None, "shouldn't be None" def test_max_heap_builder(): heap = Heap.create_min_heap() assert...
e2e0781f43f432f0bdcabc27b7af9b3349b20f2b
devendraingale2/PythonPrograms
/pattern26.py
192
3.515625
4
''' + = + = + = + + = + ''' a="+" b="=" for i in range(4,0,-1): for j in range(i): if j%2!=0: print(a,end=" ") else: print(b,end=" ") print()
0917b77f509c8c2841c64933a38613cf091be7e3
mwinn53/Euler
/Problem 4 - Largest Palindrome Product/Problem4.py
1,944
4.28125
4
# coding=utf-8 """ PROBLEM 4: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. APPROACH: (1) Iterate through two ranges, each from 100-999. Compute ...
772c39c84eb4a4265db3fd9940ef5ae2f05813a3
Youngwook-Jeon/python-ds-algos
/ds/QueueWithCapacity.py
2,046
4.1875
4
class Queue: def __init__(self, max_size): self.items = max_size * [None] self.max_size = max_size self.start = -1 self.top = -1 def __str__(self): values = [str(x) for x in self.items] return ' '.join(values) def is_full(self): if self.top +...
d2e2351c7f006ebdf83a5719b8205d0bcdae9989
mchlstckl/blog
/PrimusNaivus/PrimusNaivusPy.py
426
3.71875
4
import time def is_prime(x, primes): return not any(x % p == 0 for p in primes) def find_primes(index): primes = [] candidate = 2 while len(primes) < index: if is_prime(candidate, primes): primes.append(candidate) candidate += 1 return primes # warm-up find_primes(500) tic = time.clock() primes = find_p...
38521c500ab6a95fad685ae48af6fe10e021c707
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_199/2694.py
685
3.515625
4
tests = int(raw_input()) for test in range(1, tests+1): count = 0 arr, k = raw_input().split(" ") arr = list(arr) k = int(k) index = 0 while index+k-1 < len(arr): if arr[index] == '-': count += 1 for i in range(index, index+k): if arr[i] == '+': ...
87520c6b5544b678bfe817b48435658c72a15b5d
Htrams/Leetcode
/two_sum.py
649
3.65625
4
# My Rating = 6 # https://leetcode.com/problems/two-sum/ # Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. # You may assume that each input would have exactly one solution, and you may not use the same element twice. # You can return the answer i...
808f7e1ab95187468e9904ea83525b673ffe16db
enio-infotera/VernamCipher
/py/encrypt.py
441
3.640625
4
# # # Use: encrypt("hello", "XMCKL") # => "eqnvz" # # def encrypt(st, key): if len(st) != len(key): return "Text and Key have to be the same length." alphabet = list("abcdefghijklmnopqrstuvwxyz") nText = [] kText = [] for i in range(len(st)): nText.append(alphabet.index(st[i].lower())) kText.append(alphabet....
39558bfb792f6e0627e0237fe7051e0f1979b305
JavierCamposCuesta/repoJavierCampos
/1ºDaw/ProgramacionPython/Python/NumerosPrimos/Primos.py
862
3.75
4
''' Created on 11 Nov 2020 @author: estudiante ''' '''Esta funcion devueove True si el valor introducido como argumento es un numero primo y False en caso contrario''' '''Crea un programa que pida al usuario un entero mayor que 0 y muestre por la saida estanr todos los numeros primos comprendidos entre el numero 1 y ...
cabf4b5032463878f9dcce1cbb9ab5a891011ca6
Zlstg/py
/廖雪峰基础知识/1.变量.py
570
3.609375
4
#一个变量存储一个值 message = "bixu,hello word!" print(message) #一个变量存储一个值,可以任何时候改变这个值 message = "chouxifu" print(message) message = "xifujiudezou" print(message) ''' 变量名只能包含字母,数字和下划线。且只能以字母或下划线开头。 空格不允许出现在变量名中。 不能用Python关键字作为变量名。 变量名应当是有意义的。不能过短或过长。 小心使用小写的l和大小的O,容易与1和0混淆。 ''' print("xifushi") zl = "pangzi" print("xifushi:"...
965cc00c38e894736ad19e0fb3cfa44b2f104e5b
PFurtak/PythonExerciseSetOne
/madlib.py
948
3.546875
4
# prompt user for inputs to place inside of a madlib adjective_one = input("Please provide an adjective. ") place_one = input("Please provide a city name. ") fluid_one = input("Please name a type of fluid. ") martial_arts_movie = input("Please provide your favorite martial arts movie. ") print("It was a " + adjective...
0c18a5a1c0f6a1c709cea2d08a244b0d4afc2acc
pdruck/Name-Generator
/NameGenerator.py
5,280
4.15625
4
# opens a file that contains a list of either male or female names def openFile(gender): names_in_file = [] if(gender == 'M' or gender == 'MALE'): # opens a list of boys names contained in the cwd file = open('namesBoys.txt', 'r') elif(gender == 'F' or gender == 'FEMALE'): # opens a list of girls names contain...
601a1d881d4e6dcc75070d807af01aaf3e99391a
heartbeat180/LeetCode_practice
/leetcode/editor/cn/[283]Move Zeroes.py
1,694
3.515625
4
#给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 # # 示例: # # 输入: [0,1,0,3,12] #输出: [1,3,12,0,0] # # 说明: # # # 必须在原数组上操作,不能拷贝额外的数组。 # 尽量减少操作次数。 # # Related Topics 数组 双指针 from typing import List #leetcode submit region begin(Prohibit modification and deletion) class Solution: def moveZeroes(self, nums: List...
bff3e5308603964d4cac565320447a4e2af2d577
alankrit03/Problem_Solving
/Balanced_Brackets_1.py
666
4
4
"""''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Following Code contains only a single type of brackets ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''""" def show_brackets(st, left, right): if left + right == 2 * n: print(st) ...
cce3f013f7bf5243b7aa669774d9071b154cfd02
lermon2000/PythonBasics_HSEU
/week_1/maximum.py
657
3.703125
4
# Напишите программу, которая считывает два целых числа A и B # и выводит наибольшее значение из них. Числа — целые от 1 до 1000. a, b = [int(input()) for i in range(2)] # підносимо різницю в ступінь, щоб позбутися мінусу: diff_positive = (a - b) ** 2 diff_sqrt = diff_positive ** .5 # додаємо до меншого числа його рі...
73b792722fac09f643fc4bff62c952b7f4714af9
PapaGede/globalCode
/loops.py
1,327
4
4
# A code for loops # # x=2 # for x in range(2,20): # if x%2==0: # print(x) # def even(x,y): # for x in range(x+1,y): # if x%2==0: # print (x) # x=int(input("Please enter the first number \n")) # y=int(input("Please enter the second number \n")) # even(x,y) # def even(x,y): # f...
d9ee96d3067d912518e286eb5d87c506e177f269
XUEMANoba/python-jichu
/18-day/3连用.py
418
3.53125
4
list = [13,6,10,21,30,50,4,89,2] for i in range(len(list)): for j in range(i+1,len(list)): if list[i] > list[j]: list[i],list[j] = list[j],list[i] print(list) num = 4 center = int(len(list)/2) if num in list: while True: if list[center] > num: center = center-1 elif list[center] < num: center = cente...
af3a747efb78c658a79d18de351ee1ea11c1551f
LiveAlone/pythonDemo
/3.7/advance/Functionable.py
4,595
3.71875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- """ description: 函数式编程, 支持高阶函数方式 """ # 高阶函数执行方式 # def add(x, y, f): # return f(x) + f(y) # # print(add(-100, -200, abs)) # map reduce filter sorted 过滤执行方式 # # def f(x): # return x*x # # map 的结果 是一个 Iterator 需要遍历执行方式 # print(list(map(f, [1, 2, 3, 4, 5]))) # redu...
86c961bcdb36d9398d450652e4b80df7a06f8cb7
joaabjb/curso_em_video_python_3
/desafio003_somando_dois_numeros.py
148
3.875
4
n1=int(input('Digite o primeiro número: ')) n2=int(input('Digite o segundo número: ')) print('A soma entre {} e {} é {}'.format(n1, n2, n1 + n2))
e3233fa9aef57f4edeade9f4917e85ad3dcea0a7
kylecombes/ComputationalArt
/recursive_art.py
7,983
3.703125
4
""" Generates "random" artwork using sine, cosine, sigmoid, products, averaging, squaring, and cubing functions. """ import random import math from PIL import Image functions = ['prod', 'sigmoid', 'squared', 'cubed', 'avg', 'cos_pi', 'sin_pi'] function_count = len(functions) def build_random_function(min_depth, max...
0bff7e4b751143beec14faebcf248d5ab375aab9
khurram-saeed-malik/ARDrone
/com/group/1/ConceptTesting/pyimagesearch/shapedetector.py
518
3.5
4
# import the necessary packages import cv2 class ShapeDetector: def __init__(self): pass def detect(self, c): # initialize the shape name and approximate the contour shape = "unidentified" peri = cv2.arcLength(c, True) approx = cv2.approxPolyDP(c, 0.04 * peri, True) # if the shape is a triangle, it wil...
fab70a5ac29623a84d14ed15762f7d2ecde6a394
WilliamslifeWayne/python_practice
/practice_4_3.py
1,107
3.75
4
#coding = utf-8 #1⃣️。使用一个for循环打印数字1-20 for num in range(1, 21): print(num) #创建一个数字列表,其中包含数字1-1000000使用 max min # numbers = [] # for numb in range(1, 1000000): # numbers.append(numb) # print("numbers的最大值是:", max(numbers)) # print("numbers的最小值是:", min(numbers)) # print("numbers的总和是:", sum(numbers)) #4-6通过给函数...
6e3346b01402aff11ebc8f12cff6e1fdc9374025
chu-he/rosalind
/015_locating_restriction_sites/recom.py
737
3.625
4
reverse = {} reverse['A'] = 'T' reverse['T'] = 'A' reverse['C'] = 'G' reverse['G'] = 'C' def ReverseComplement(string): revcom = '' for ch in reversed(string): revcom += reverse[ch] return revcom # Read the dataset file = open('dataset.txt', 'r') data = file.read() file.close() result = ...
114a5b6f2e2575ad6bf5076f5d09183fee0f5376
HeberCooke/Python-Programming
/Chapter2/exercise10.py
644
4.15625
4
""" Heber Cooke 10/3/2019 Chapter 2 exercise 10 This program calculates the total pay for time and overtime the program takes an input of the hourly wage an input of the regular pay hours an input of the overtime pay hours the program calculates the overtime pay by multiplying wage by 1.5 the reg pay and the overtim...
d6ab2493bcbf0a2dd60cff72fb84dc28583db59b
SafwanSa/monkey-writing-Shakespeares-phrases
/Main.py
503
3.984375
4
from Population import Population target = "Abduelah Hajjar" population_num = 1000 mutation_rate = 0.01 population = Population(target, mutation_rate, population_num) while(not population.finished): # Will stop the loop if it found the target population.evaluate() # Will calculate the fitness for each D...
4b216eeba1f418e3855382feda00181d2b0a6911
Dolantinlist/DolantinLeetcode
/51-100/78_subsets.py
356
3.578125
4
class Solution(object): def subsets(self, nums): nums.sort() res, tmp = [], [] self.dfs(nums, 0, tmp, res) return res def dfs(self, nums, index, tmp, res): res.append(tmp) for i in range(index, len(nums)): self.dfs(nums, i + 1, tmp + [nums[i]], res) ...
c4dcec91fd66194bce0cee3c5e3b2a5a1f5d870d
temirlanr/tkinter
/tkinter basic.py
3,729
4.09375
4
from tkinter import * root = Tk() root.title("CalculatOR!!!!") entry = Entry(root, width=40, borderwidth=3) entry.grid(row=0, column=0, columnspan=4, padx=10, pady=10) def button_click(number): current = entry.get() entry.delete(0, END) entry.insert(0, str(current)+str(number)) def clearButton(): en...
00ca9147f64c557db62a4593107dae820e6a3af3
JeffHoogland/weathertrek
/gmaps/geocoding.py
2,466
3.734375
4
# -*- coding: utf-8 -*- from gmaps.client import Client class Geocoding(Client): GEOCODE_URL = "geocode/" def geocode(self, address=None, components=None, region=None, language=None, bounds=None, sensor=None): """Geocode given address. Geocoder can queried using address and/or ...
fa7669a799a7cad62b49403f09199291d3684533
arnav1993k/Denoising
/patter/models/activation.py
1,131
3.625
4
import torch from torch.nn import Module, functional as F class Swish(Module): """Implementation of Swish: a Self-Gated Activation Function Swish activation is simply f(x)=x⋅sigmoid(x) Paper: https://arxiv.org/abs/1710.05941 Shape: - Input: :math:`(N, *)` where `*` means, any number of...
78ef998fd40ffa4bb03caac5e2f1f9f0ab5a32a8
zhjr2019/PythonWork
/01_Python_Basis/Python_Karon/03_循环/jr_07_continue.py
347
4.09375
4
i = 0 while i < 10: # comtinue 某一条件满足时,不执行后续重复的代码 if i == 3: # 注意:在循环中,如果使用 continue 这个关键字 # 在使用关键字之前,需要确定循环的计数是否修改,否则可能会导致死循环 i += 1 continue print(i) i += 1
ed4233b9cdef94ea4a353d9872a0aa948c7a43e6
rishabh0509/python_first
/list_example.py
204
3.8125
4
fruits = ['apple', 'pear'] #can store diff. datatypes in a list print (fruits) fruits.append('strawberry') print(fruits) fruits[1]='blueberry' print(fruits) color=(255,255,255) print(type(color))
6d95bb477b57e200423b2fc897f5ef4cca5482f3
JulesNunez/python-jumpstart-course-demos
/apps/02-guess-number-app/you_try/program.py
1,378
4.25
4
import random import os print('-----------------------------------') print(' GET IT RIGHT, OR YOU DIE! ') print('-----------------------------------') print() def say_it(text): s = 'say "{}"'.format(text) os.system(s) the_number = random.randint(0, 100) guess = -1 tell_name = 'WELCOME TO THE FABUL...
054dcd1e28c12427a9673e9b4789c66a6bb643a6
Fernandoramos24/ejercicios-parcial-1-fundamentos
/ejercicio tiendas don pepe.py
279
3.671875
4
descuento=0 precio = float(input("digite precio: ")) dia = input("ingrese dia de la semana") if dia=="martes" or dia=="jueves": descuento = precio * 0.15 preciofinal = precio - descuento print("el precio final a pagar es de $0, preciofinal,""con un descuento de",descuento)
3648aa9ef6146046f7f095bcd08b092948063df8
fatawesome/StructProgramming
/Practice2.2/task6.py
222
3.8125
4
import math print('Give me X') x = float(input()) print('Give me Y') y = float(input()) c = math.sqrt(math.pow(x,2) + math.pow(y,2)) if ((x <= 1) and (y <= 1)) and (c >= 1): print("Good!") else: print("Bad :(")
6da808e231903be6b5b5f3889b0772417428fec8
NitishShandilya/CodeSamples
/maximumSumSubArray.py
672
3.8125
4
""" Given a 1D array, find the maximum sum obtained from a sub-array with sequential elements. The program utilizies Kadane's algorithm. Time complexity is O(n), where n is the size of the array. """ class MaximumSumSubarray(object): def __init__(self, arr): self.arr = arr self.length = len(self.arr...