blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9f275ad1e1a0cca2033c5f29afd65fb8b12b1eeb
Santhoshkumard11/Day_2_Day_Python
/series_generator.py
366
3.734375
4
#question 2 #generate the series #3 8 14 22 34 53 83 129 197 294 print("Enter the lenght of the series:") seriesLength =int(input()) s1,s2,s3 = 1,5,3 gen_series = [] for itr in range(1,seriesLength): gen_series.append(s3) s3 += s2 s2 += s1 s1 += itr result = (str(gen_series).replace(',','...
ad0244a649cfb87c503df242ec9a641edd94c480
Lipin-Pius/python-exercises
/calc/calc.py
811
3.8125
4
#! /bin/python import click @click.command() @click.option('--add', nargs=2, type=float) @click.option('--sub', nargs=2, type=float) @click.option('--mul', nargs=2, type=float) @click.option('--div', nargs=2, type=float) def calc(add,sub,mul,div): if add and not sub and not mul and not div: # if the option is only --...
7b68517d94c4d3e99b42c664d8bc680140cdf015
shubham1697/ML
/python problems/quadraticEquation.py
317
3.765625
4
a = int(input()) b = int(input()) c = int(input()) def quadraticEq(a, b, c): D = b**2 - 4*a*c if D < 0: print("Imaginary") else: r = int((-b - D**0.5)/2*a) s = int((-b + D**0.5)/2*a) if r == s: print("Real and Equal") else: print("Real and Distinct") print(r,s, sep = ' ') quadraticEq(a, b, c)
0126f50156f241aeeb1a07a4d84ea38504e918e4
AwesomeZaidi/Problem-Solving
/Python-Problems/easy/listRemoveDuplicates.py
428
4.0625
4
# Exercise 13: # Write a function that takes a list and returns a new list that contains # all the elements of the first list minus duplicates. def dedupe(x): y = [] for i in x: print("i in x = " + str(i)) if i not in y: y.append(i) print(y) return y #this one uses sets def dedu...
fbeca65cb7d3ad4a71262b3d28b210aeb0a24b89
aleksandromelo/Exercicios
/ex096.py
229
3.53125
4
def area(l, c): a = l * c print(f'A área de um terreno {l}x{c} é de {a}m².') print('Controle de Terrenos') print('-'*40) larg = float(input('LARGURA (m): ')) comp = float(input('COMPRIMENTO (m): ')) area(larg, comp)
7ac8729cc1d02136fda65aa686c6e4cde61a99ec
littleliona/leetcode
/easy/101.symmetric_tree.py
2,127
3.84375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x, left=None, right = None): self.val = x self.left = left self.right = right class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool ""...
7ac1337d7f4a66ea081d1ddcd06e24b45d4a611c
Linuxea/hello_python
/src/basic/ninenine.py
161
3.609375
4
for x in range(1, 10): for y in range(1, 10): if x + 1 == y: break print("%d * %d = %d\t" % (y, x, x * y), end="") print("")
ce1752c019b083e93987428fb06d2ed7772640ac
franciscomunoz/pyAlgoBook
/chap1/R-1.14.py
217
3.96875
4
#!/usr/bin/python def pairProductOdd(data): for i in data: for j in data: if i * j & 1 != 0: print("The product {0} and {1} are odd".format(i,j)) data = [2,3,4,4,5,3,3,5,8,9,10] pairProductOdd(data)
7138b8a6049c1522a97f023ebde6b2b9ad6bbfd6
piyushabharambe/undochanges
/pantaloon.py
291
4.125
4
#total cost of shopping print("Each quantity costs 1000rs!") quantity=int(input("Enter the number of the quantity you want=")) total=quantity*1000 if(total>10000): print("Your total including 10% discount=",total-(0.1*total)) else: print("your total excluding discount",total)
ee460485b7bf745bd78bfb84c49491fdb1aea263
UWPCE-PythonCert-ClassRepos/Self_Paced-Online
/students/tfbanks/Lesson02/gridprinter.py
931
3.9375
4
# This is the result of manual processes moved into function form. # I cleaned up during the process and deleted the old methods so the end result is just the function def grid(x,y): #Defines a function to print grid to specified dimensions - #x being the size of the squares, #y bein...
be5401ea9c7f07c17582a6ae79f333794459b167
DigitalCrafts/gists
/Data_Analytics/python training/installing packages/class ecercises/conditional-file-load.py
726
3.90625
4
import pandas as pd # create function to conditionally load a file def load_file(file_to_load): # conditional logic to load file based on user input if file_to_load == "items": loaded_df = pd.read_csv("items_sample.csv") return loaded_df.head() elif file_to_load == "inventory_activity": ...
cb6bebbcd85c9caabdf02252062fd84d08eebb6f
tsunny92/udemy_python
/pylintdemo.py
494
3.796875
4
''' <<<<<<< HEAD This is very simple script ''' def myfunc(): ''' This is very simple function ''' first = 10 second = 20 print('First number is {}'.format(first)) print('Second number is {}'.format(second)) ======= A very simple script ''' def myfunc(): ''' A very simple function ...
c762ee9649cca79d79ff7970f00fb51d2d7bdf14
jiangjiane/Python
/pythonpy/class1.py
756
3.65625
4
#! /usr/bin/python3 # -*- coding: utf8 -*- #例1 class MixedNames: data='spam' def __init__(self,value): self.data=value def display(self): print(self.data,MixedNames.data) print('-----例1-----') x=MixedNames(1) y=MixedNames(2) x.display() y.display() #例2 class NextClass: def printer(se...
925423e29d5c577562647fc9cbb6f2aa9f267c3b
Rohan-J-S/school
/elif_1.py
139
3.890625
4
a = int(input()) b = int(input()) c = int(input()) if a>b and b>c: print ("a") elif b>a and b>c: print ("b") else: print ("c")
a23bdea7f2664983c183c6ea376e30a16c619dec
CrazyCoder4Carrot/leetcode
/python/351-400/364. Nested List Weight Sum II.py
529
3.59375
4
class Solution(object): def depthSumInverse(self, nestedList): """ :type nestedList: List[NestedInteger] :rtype: int """ unweight = weight = 0 while nestedList: nextlevel = [] for temp in nestedList: if temp.isInteger(): ...
06d69da198b312c6dd10403fe83f9faa5dfd3be2
kinsei/Learn-Python-The-Hard-Way
/ex41.py
3,754
4.3125
4
# This is exercise 41 in Learn Python The Hard Way # This was writen for Python 2.6 # Word Drills # * Class - tell python to make a new kind of thing # * Object - two meanings: 1) the most basic kind of thing. 2)an instance of something # * Instance - what you get when you tell python to create a class # * def - How ...
eb636daf64d32fc109624cf232671101c5c0a515
asengupta74/GW_RNN
/sinegaussian.py
783
3.609375
4
import numpy as np import matplotlib.pyplot as plt def sinegauss(A, fc, sigma, n, l_lt=-1, r_lt=1): ''' Input parameters: A (float): represents the amplitude of the corresponding sine wave fc (float): represents the frequency of the corresponding sine wave sigma (float): standard deviation of the correspondin...
7c00e35f9f0e50a817bcb6aa8e911d8b6884fca1
anusha362/python_basics
/Avodha/regular_expression.py
468
3.953125
4
import re # pattern=r"avodha" # # if re.match(pattern,"hi avodha,how r u?"): # # if re.search(pattern,"hi avodha,how r u?"): # # print("matched") # # else: # # print("not matched") # print(re.findall(pattern,"hi avodha,avodhaghtrg avodhatyytyghj")) # str="hi avodha, how r u?" # pattern=r"avodha" # new1=re.sub(p...
1ce171c031cd9fd02162ae98df3818e607744388
sacheenanand/Python
/not.py
243
3.5625
4
__author__ = 'sanand' x = 100 if not x > 100: print("not is valid") else: print("not is not valid") a_List = [5, 10 , 15, 20, 25, 30, 35, 40, 45] for c in a_List: if not c in (10, 25): print("not is working: ", c)
2bf4a3d1c0ea33258f3a06287c7307cefe6a9927
sadarshannaiynar/ai_lab_programs
/exp-05-tic-tac-toe-two-player.py
1,859
3.859375
4
import random def print_board(board): for i in range(9): print(board[i] + '|', end='') if (i + 1) % 3 == 0: print('\b ') def check_win(board, symbol): win_conditions = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]] for i in win_conditio...
9464295e2618942cc767d38bc5710d7bd391e88c
gfobiyatechnical/2k19-With-Python-
/Getting started With Python 3._/Lab/que9.py
360
4.21875
4
#Aim : Program to find the hypotenuse of a right angled triangle, when the base and height are entered by the user. #Developer: Rakesh yadav h = float (input("Enter height of triangle : ")) b = float (input("Enter base of triangle : ")) # calculation hypotenuse = ((h**2) + (b**2))**0.5 print("Hypotenuse of a rig...
8d4869a292aab48a8476559c8258bb565d137deb
ChuixinZeng/PythonStudyCode
/PythonCode-OldBoy/Day3/随堂练习/函数_参数组_6.py
2,045
3.703125
4
# -*- coding:utf-8 -*- # Author:Chuixin Zeng # 参数组就是指非固定函数 # 前面的定义的函数有个问题,就是调用的参数超过了定义的形参,就会报错 # 用于实参数目不固定的情况下,如何去定义形参 # *后面跟的是变量名,不一定写args,但是规范就是args,统一写args比较好 # *args:接受N个位置参数,不是关键字参数,转换成元组的形式 # *kwargs,接收N个关键字参数,转换成元组的形式 def test(*args): print(args) # 打印的结果是一个元组,多个实参被放到了一个元组里面 test(1,2,3,4,5) # 还可以按照下面的进行传递,...
ed548d17b7ef31c6d88737342b92357a76d7d5d0
christineurban/codewars
/python/sum-of-odd-numbers.py
278
3.96875
4
# https://www.codewars.com/kata/sum-of-odd-numbers def row_sum_odd_numbers(n): row_start = 1 for i in range(n): row_start += i*2 print row_start row_total = row_start for i in range(n-1): row_total += row_start + (i+1)*2 return row_total
0fc2040cc905f08d02d6740ed33a7d2097431ce9
imthiazh/PySim
/simMatrix.py
3,377
3.671875
4
def simMatrix(fnarg,fnarg2,fn1,fn2,f1,f2): flag = 0 count = 1 print("----- Class/Module Analysis of "+f1+" & "+f2+" -----") print() print("Classes/Modules identified in "+f1) print(str(count)+". "+f1) print() print("Classes/Modules identified in " + f2) print(str(count)+". "...
56745c67167686d679469d80773b76b2e7b9324c
csw279/new
/practice code/12whilefor.py
583
3.59375
4
# # x={'a':1,'b':2} # # for i in x: # # print("{} {}".format(i,x[i]),end='@@\n') # # x=[1,2,3,45,6] ## 打印的时候本来就是换行打印 # # for i in x: # # print(i,end=' ') # x=[1,2,3,4,5,6,7,8,9] # for i in x: # while i >5: # print('{}该数字大于5'.format(i)) # break # ##请0-100之间的奇数之和 sum=0 for i in range(10)...
5992fb92d5658e45396cfc0807118dc4ea937c9a
valeriejuneloka/Zeros_Matter
/player.py
856
3.8125
4
from const import WHITE, BLACK def switch_color(color) -> Int: """ Assigns opposite color. """ if color == BLACK: return WHITE else: return BLACK class Player: """ Human player """ def __init__(self, gui, color="black"): self.color = color self.gui = gui ...
1ccdf0be3bec402b9f1e74fd5e251df3ed0ed0c7
mira0907/python
/圓周.py
187
3.59375
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 19 21:11:10 2021 @author: dkjua """ print('半徑值?') x= float(input()) y = x * 3.14159265 *2.0 print("圓周長 = "+ str(y) )
7854df5e8979951c4fcb389369435deb2a63037c
Jce1231/Dfes3work
/dice_roller.py
616
4.125
4
import dice #roll some dice roll_times = int(input("Please enter how many times you want to roll the dice: ")) roll_Type = int(input("Please enter what type of dice to roll: ")) rolledNum = dice.roll(roll_times,roll_Type) for i in range (roll_times): print("The result from dice roll",i+1,"is",rolledNum[i]) rollA...
43e821e48529733761d237977fcb5c631f0522ea
PashaWNN/education
/архив/Программирование 1, 2 семестр/task6_60g.py
1,060
4.3125
4
""" Шишмарев Павел. Вариант №14. Задание 6. Задача 60г. Даны действительные числа x, y, | x^2 - 1 , если (x,y) принадлежит D U=| | sqrt(|x - 1|) в противном случае D определена графиком(см. задачник) """ from math import sqrt def D(x, y): r = sqrt(x**2 + y**2) #Вычисляем расстояние точки от начала координ...
087b41ec05205fab6408fecb17606d1ff82ceb8f
encgoo/hackerrank
/Graph/jeanies_route.py
3,300
3.9375
4
#!/bin/python3 import os import sys from collections import deque def jeanisRoute(k, roads, cities, n): # Step 1: Build a minimu sub-tree # A sub-tree with minimum number of roads that # are needed to connect all the cities jeanis needs to deliver letter to # 1.1 translate roads to roads_ for easier/...
26b9dc3bcca39132395b1deab0a7d4a0ed4afdcd
OrlovaNV/learn-homework-2
/string_challenges.py
712
3.953125
4
word = 'Архангельск' print(f'Последняя буква в слове: {word[-1]}') c = 0 for i in word.lower(): if i == "а": c += 1 print(f'Количество букв "а" в слове: {c}') Vowel = 0 x = ('а', 'е', 'и', 'о', 'у', 'ё', 'ю', 'я') for i in word.lower(): if i in x: Vowel += len(i) print(f'Количество гласный бук...
45c2a77d08912487750c8c104241da6081e660dd
simonRos/PasswordTesting
/Setup.py
1,794
3.609375
4
#Sets up testing parameters #For use by test administrator #Simon Rosner #5/25/2017 with open('settings.txt','w+') as file: file.write("minLength: " + input("What is the minimum password length? ") + "\n") file.write("maxLength: " + input("What is the maxi...
508c9f21f39dcdb7d8cb41190c2386042fb13de3
csmith23/NEAT
/NEAT.py
4,487
3.609375
4
__author__ = 'Coleman' import random class Population: def __init__(self, size): self.species = [Species()] self.species[0].representative = Organism() self.species[0].organisms = self.organisms self.innovation = 0 self.innovationGenes = {} # (source, destination):...
ddacfdc5683b59a2973ad64b5965f18796731f1a
cccccccccccccc/Myleetcode
/344/reversestring.py
419
3.84375
4
"""" timecomplexity = O(n) spacecomplexity = O(1) """ class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ if len(s) <=1: return l,r = 0,len(s)-1 while l <= r: s[l] ,s[r] = ...
e2a621750733ff1dcafb7402a6637fdc2cdd3587
sheikh-zeeshan/AllInOne
/Python/basic/fileinbasic.py
983
3.640625
4
# r -> read file for opening default # w -> for wroting # x -> file create if not exists # a -> append at end # t -> text mode (text file) default # b -> binary mode # + -> read and write f= open("harry.txt", "rt") val=1 if val==1: content = f.read() print(content) elif val==2: content = f.read()...
6d80a10c0149fda0b1fea3828782d1ac2411cf44
Michael-Odhiambo/Data-Structures-And-Algorithms-using-Python
/Arrays/VectorADT/tests.py
119
3.578125
4
list1 = [ 1, 2, 3, 4] list2 = [] n = len( list1 ) - 1 index = 1 while n >= index : print( list1[n] ) n -= 1
76fafbbee794f4e30fd8b54490cd16bc2fa94a79
drhlchen/LeetCode-Challenge
/Climbing Stairs.py
807
4.03125
4
''' 70. Climbing Stairs You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 ste...
72f316375c537da178f2651340f3af7887c8749d
vcelis/hackerrank-python
/strings/find-a-string.py
589
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Title : Find a string Subdomain : Strings Author : Vincent Celis Created : 19 July 2018 https://www.hackerrank.com/challenges/find-a-string/problem """ def count_substring(string, sub_string): result = 0 for i in range(len(string) -...
02d421c2f4ed53d3383bdfbe08ba8c4811cc8825
msrockada/week-2-day-1
/K.py
277
3.578125
4
part1 = input().split() n = int(part1[0]) h = int(part1[1]) * 3 for i in range(0, n): trainings = input().split() sum = 0 for training in trainings: sum = sum + int(training) if sum >= h: print("YES") else: print("NO")
0bcb430318a3947ff1a75431731c269ce0ebe164
tweakimp/littleprojects
/sudoku/sudoku.py
6,221
3.78125
4
import test zeromatrix = [[0 for j in range(1, 10)] for i in range(1, 10)] startcandidates = [[[x for x in range(1, 10)] for j in range(1, 10)] for i in range(1, 10)] def printmatrix(matrix, start=zeromatrix): for i in range(9): for j in range(9): if (j == 2 or ...
6a90ece9999d6af212078756e4d70278812dfdb9
ClarkResearchGroup/qosy
/qosy/lattice.py
14,824
3.671875
4
#!/usr/bin/env python """ This module defines Unit Cell and Lattice classes that conveniently handle the indexing of orbitals in a crystalline lattice of atoms. """ import copy import itertools as it import numpy as np import numpy.linalg as nla from .tools import argsort, remove_duplicates class UnitCell: """A...
af690307267dd08eaee1fdf919ae76c5324e6973
JGallione/Yelp-Restaurant-Scrape
/Restaurants_Search.py
5,243
3.578125
4
import sys import time import csv import urllib.request from bs4 import BeautifulSoup from County_Muni_Lists import * from Clean_csv import clean_csv import inquirer #--------------------------------------# State_Abbreviation = input("Please Enter the State Abbreviation: ") countylists = [] for item in raw_Countylists...
8e50edf77e25b5535849189ac4621ccbc2f04d35
vasketo/EOI
/Python/Día 2/calcularimpuestos.py
941
4.1875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- # Preguntar por pantalla el salario anual y si el salario es superior a 30.000€ calcular el # porcentaje de impuestos a pagar siendo este de un 30%. Si el salario es superior a # 20.000€ pero inferior a 30.000€ calcular el porcentaje de impuestos a pagar siendo # este d...
b370ef810737381d977ecc0201b05d529e5953b2
MacMacky/Python-Exercises
/codingbat/string1.py
966
3.625
4
def hello_name(name=""): return "Hello " + name + "1" def make_abba(a="", b=""): return a + b + b + a def make_tags(tag="", word=""): return '<' + tag + '>' + word + '</' + tag + '>' def make_out_word(out, word): lenOut = len(out) return out[0:lenOut-2] + word + out[lenOut-2:lenOut] def ext...
c6a59725e529af6ba0a29df17be6e23066885a2d
BeahMarques/Workspace-Python
/Sesão 4/exercicio28/exercicio 30/app.py
97
4.0625
4
n = 0 usuario = int(input("Digite um numero; ")) while n <= usuario: print(n) n = n + 1
9a19345614237e576a7c6380f72fdd979bf15e56
sillas-rosario/Data_Science
/Udacity_Lessons/Quiz_Investigating_TheData.py
3,368
3.5
4
# -*- coding: utf-8 -*- """ Created on Thu May 31 10:44:21 2018 @author: Sillas """ #Quiz Questions about Student Data: # 1 Ho long to submit projects # 2 how do students who pass # 3 their projets differs from thow who dont ? # # THE OTHER QUESTION # How much time students spend taking...
febee8412eb37f3b8f178da2a3a2eb5b9585eb3f
f1amingo/leetcode-python
/数组 Array/二维数组中的查找.py
1,363
3.6875
4
# -*- coding:utf-8 -*- # 运行时间:371ms # 占用内存:5732k # class Solution: # # array 二维列表 # def Find(self, target, array): # # write code here # for clist in array: # for i in clist: # if i == target: # return True # return False class Solution:...
0c393731e90f63c71531da893e6ddd4a0ca208e0
wuyeguo/advance_python
/py/2_function_coding.py
6,372
3.90625
4
# coding: utf-8 ## 求和问题 命令式 函数式 对象式 # 命令式 # x=1 y = 2 求 x和y的和 # 求 x和y的平方的和 # 求 x的m次方与n次方的和 # In[1]: # 命令式 def sum1(x, y): return x + y def sum2(x, y): return x ** 2 + y ** 2 def sum3(x, y, m, n): return x ** m + y ** n # In[2]: print sum1(1, 2) print sum2(1, 2) print sum3(1, 2, 3, 4) # In[3]: #...
11707876476d767b0893ff096201debf487a51a7
TranXuanHoang/Python
/00-basic/exercise4.py
775
4.1875
4
""" 1) Write a normal function that accepts another function as an argument. Output that other function in your "normal" function. 2) Call your "normal" function by passing a lambda function – which performs any operation of your choice – as an argument. 3) Tweak your normal function by allowing an infin...
98a37e8387d08d4987bfded90f2bec68bc7bb100
syurskyi/Algorithms_and_Data_Structure
/_algorithms_challenges/codewar/_Codewars-Solu-Python-master/src/kyu6_Title_Case.py
768
3.671875
4
class Solution(): def __init__(self): self.title_case = self.title_case_01 def title_case_01(self, title, minor_words=''): words = title.capitalize().split() minor_words = minor_words.lower().split() ret = [] for w in words: if w in minor_words: ...
c04ad8af54029a58c269c4e8ccc61ebda6e25640
w5802021/leet_niuke
/Tree/257. Binary Tree Paths.py
674
3.796875
4
from Tree import operate_tree class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def binaryTreePaths(root): #思路同112的路径之和2 def dfs(root, tmp, res): if not root: return [] tmp += str(root.val) + '->' if...
fc06fe17095bac61f141d6af046615053ef27997
praisino/Zuri-Projects-Tasks
/mockATMproject.py
1,541
3.8125
4
# imports from datetime import datetime #To show current Date now = datetime.now() # Database name = input("What is your name? \n") allowedUsers = ['Seyi','Mike','Love'] allowedPassword = ['passwordSeyi','passwordMike','passwordLove'] # Login phase if(name in allowedUsers): password = input("Your Paass...
79ed4910ecf694a12b1cee78fd782958e2a2ead9
Kinggoid/ML
/perceptronen.py
1,057
3.8125
4
from typing import List class Perceptron: def __init__(self, weights: List[float], bias: float, name: str): self.weights = weights self.threshold = 0 self.name = name self.bias = bias def calculate_output(self, inputs: List[int]): """In deze definitie kijken w...
75eff17ca987638d99b159e06c54c54a43c5c445
NikitaFir/Leetcode
/Count Primes.py
393
3.578125
4
class Solution(object): def countPrimes(self, n): result = 0 temp = [1]*n for i in range(2, n): if temp[i] == 1: result += 1 k = 2 c = i while c * k < n: temp[c * k] = 0 ...
c25183dd68456de3341da0483b007c98ccc565aa
VadimZakablutski/proovV
/proovV/proovV.py
398
3.84375
4
from random import* m=0 print("Хочешь поиграть?") while a.isalpha()!=True: a=int(input("Камень - 1, ножницы - 2, бумага - 3?")) try: TypeError b=randrange(1,3) if b==1: print("Камень") elif b==2: print("Ножницы") elif b==3: print("Бумага") if a>b: print("dsf") elif a==b: print("ничья") elif ...
47eaf3e33d88ae82e3032e8d64755cf315e6b3fd
srirachanaachyuthuni/Basic-Programs-Python
/mergeSingularLinkedLists.py
1,015
4.15625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: cursor1 = l1 cursor2 = l2 result = ListNode(0) cursor3 = result ...
6b07ca2fee609fe8435348bf4dec38b86bd71209
raviteja1117/sumanth_ketharaju
/array5.py
145
3.671875
4
from numpy import * arr1 = array([2, 5, 3, 9, 7]) arr2 = array([4, 5, 8, 7, 9]) # arr3 = arr1+arr2 print(concatenate([arr1, arr2])) # print(arr3)
864fa0c11e5d0773b7771114c6ae3586e422ffb4
Ostins-source/GlitteringAdvancedLead
/uzdevumi.py
844
3.765625
4
#1. uzdevums x = input("Ievadi jebkādu tekstu: ") print(len(x)) #2. uzdevums c = input("Ieavadi vārdu: ") print(c[0]) #3. uzdevums z = "Sveika, Pasaule!" print(z[10:15]) #4. uzdevums v = input("Ievadi jebkādu teikumu ar mazajiem burtiem: ") print(v.upper()) #5. uzdevums b = input("Ievadi jebkādu teikumu ar lielaji...
2a24c7a215c827b51efa53135f9e4363da61ccb1
noorulameenkm/DataStructuresAlgorithms
/LeetCode/30-day-challenge/September_2021/September 22nd - September 28th/shortestPathInGridWIthObstacles.py
1,291
4.09375
4
from queue import Queue from typing import List """ Problem Link:- https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination """ class Solution: def shortestPath(self, grid: List[List[int]], k: int) -> int: m, n = len(grid), len(grid[0]) queue = Queue() queue.put((...
b035b995f004068f191a831a264ccc38649e4733
caionakai/analysis_algorithm
/calculadora.py
285
3.6875
4
import math x = 3400 empirico = x + (0.3*x) * ( (0.7*x) + (0.7*x * math.log2(x)) + (0.7*x) + (0.7*x)) print("Custo empirico: ", empirico) assintotico = x**2 * math.log2(x) print("Custo assintotico: ", assintotico) proporcao = empirico/assintotico print("Proporcao: ", proporcao)
bdcd481c6e2bc66aa3286c23db31b6567383effe
urishabh12/practice
/slinkedlist.py
1,183
3.703125
4
class ListNode: def __init__(self, data): self.data = data self.next = None return def has_value(self, value): if self.data == value: return True else: return False class SingleLinkedList: def __init__(self): self.head = Non...
d988aa95ee6d693df37fb7e4cf4877a026dceace
oleoalonso/atvPython-24-09
/exerPython-24-09-10.py
641
3.84375
4
# Leonardo L. Alonso Carriço # leonardo@carrico.com.br # Exercício Prático Python [24/09] 10 ################################################################### # 10) Faça um programa que imprima a soma de todos os números pares entre dois números da sua escolha. num1 = int(input('\nDigite o primeiro número : ')) nu...
10fb6d40cf3007939522753e9f3d1cdc3d3496de
lcdlima/python_projects
/even_odd_positive_negative.py
629
4.0625
4
# Read 5 Integer values. Then show how many entered values were even, how many entered values were odd, how many entered values were positive and how many entered values were negative. i = 1 PAR = 0 IMPAR = 0 POSITIVO = 0 NEGATIVO = 0 while i <= 5: N = int(input()) i += 1 if N%2 == 0: PAR += 1 ...
9967a9739d2200ca672c71b509dad4792fd9cd32
shrinkdo/leetcode
/1_twoSum.py
465
3.546875
4
def twoSum(nums, target): diff_cache = {} for i in range(len(nums)): x = nums[i] if x in diff_cache: return sorted([diff_cache[x], i]) else: diff_cache[target - x] = i assert 0, "no solution" if __name__ == "__main__": nums = [2, 7, 11, 15] target = 9 sol = twoSum(...
f8de740a6c0d63044f37ee78a2029f42594d6da4
DiogoCaetanoGarcia/Sistemas_Embarcados
/2_Programação_sistemas_operacionais/2.1_File_stdio/Python/Ex6.py
349
3.65625
4
def abre_arq(arquivo, modo): try: p = open(arquivo, modo) except OSError: print("Erro! Impossivel abrir o arquivo!") exit(-1) return p fp = abre_arq("arquivo.txt", "w") string = "0" while(len(string) > 0): print("Digite uma nova string. Para terminar, digite <enter>: ") string = input() fp.wri...
13d92159962d118f84e9d0cf821164278db5443d
eseabro/my-repository
/2019-2020 School Projects/ESC180 Assignments/lab3.py
5,318
3.65625
4
import utilities def rotate_90_degrees(image_array, direction): #1 for clock_wise. -1 for anticlockwise m = len(image_array) n = len(image_array[0]) output_array = [] if direction == 1: #clockwise for j in range(n): row = [] #clears row every time so that it doesn't duplic...
6ef76e1c7f0cbeb9e850115cf12418d2f7efa7dc
stephanieeechang/PythonGameProg
/PyCharmProj/List0_10.py
864
3.84375
4
''' Create list from 0 to 10 ''' a = 0 myList = [] while a <= 10: myList.append(a) a+=1 print myList ''' Concise way to create a list ''' list2 = [x**2 for x in range(11)] print list2 ''' Combines the elements of two lists if != ''' A = [1,2,3] B = [4,5,6] C = [] for a in A: for b in B: if a !...
fe28b5e79d2b2e68fd0b80d55c7346b3478be0a8
ratthaphong02/Learn_Python_Summer2021
/KR_Python_Day12_Sum & Average Function.py
895
4.09375
4
# ฟังก์ชั่นหาผลรวมและค่าเฉลี่ยตัวเลข # Method 1 # sum1 = 0 # while True: # n = int(input("Input your number : ")) # if n < 0: # break # sum1+=n # avg = sum1/n # print(sum1,avg) # Method 2 # def summation(sum1,i): # n = int(input("Input your number : ")) # if n < 0: # ...
1bf7965e345ad0d399d4fdaf46490cb898615ee4
Adithyabinu/AdithyaPROGRAMMINGlab2
/CO1programe7.py
840
3.671875
4
list=[1,2,3,4,5] list1=[5,7,8,9,78] c=int(0) a=int(0) for i in list and list1: if len(list)==len(list1): print("list are of same length") break else: print("list have different length") break for i in range(0,len(list) and len(list1)): c=c+list[i] a=a...
773e16ced64a1d835415aa4f099ede7face42883
eyoxiao/githubtest
/python/com/terry/generator.py
873
3.578125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 08 15:31:42 2016 @author: eyoxiao """ def getFirstNFibonacci(number): n,a,b = 0,0,1 fArray = list() while n<number: fArray.append(b) a,b=b,a+b n=n+1 return fArray def getFibByGen(number): n,a,b=0,0,1 while n<number: ...
8b0196b9cd8643a516730276f084afc249ce8b8e
dfm066/Programming
/ProjectEuler/Python/latticepath.py
369
4.15625
4
def lattice_path(n): list = [] list.append(1) for i in range(1,n+1): for j in range(1,i): list[j] += list[j-1] list.append(list[-1]*2) return list[-1] def main(): size = int(input("Enter Grid Size : ")) path_count = lattice_path(size) print("Total Poss...
18ca527d5ff7b58d1db9cd424fdf222fe5314f80
brickgao/leetcode
/src/algorithms/python/Valid_Sudoku.py
1,289
3.765625
4
# -*- coding: utf-8 -*- class Solution: def isValidMat(self, mat): rec_set = set() for l in mat: for num in l: if num == '.': continue if num in rec_set: return False else: rec_s...
c033d0cc1f6277160e2322c86a9701fa4a7aae91
Akzhan12/pp2
/Lecture 6/14.py
346
4.09375
4
def isPangram(s): t = '' for i in range(len(s)): if s[i].isalnum(): t += s[i] l = set() for i in range(len(t)): l.add(t[i]) if len(l) >= 26: return 'The input string is pangram' else: return 'The input string is not pangram' s = input().lo...
0cdf2f8d1e24c1923313a8818094e2c5b083dfd8
zhang4881820/python-fundamental-study
/StringAndText/study-08.py
884
3.59375
4
# 多行模式编写正则表达式 import re comment = re.compile(r'/\*(.*?)\*/') text1 = '/* this is a comment */' text2 = '/* this is a \n ' \ 'multiline comment */' print(text2) print(comment.findall(text1)) # .就是不匹配换行 ,所以匹配不到 print(comment.findall(text2)) # 修复方法 ?:不捕获组。意思就是定义一个以匹配为目的的组。但是不对这个组进行分离捕获 # 也就是括号内的内容将被捕获 comment = re.comp...
0a6ec7dfe8695bc87eeb442bf3bab2bc094a7a7c
jungleQi/leetcode-sections
/classification/algorithm/6-search/bfs/tree-bfs/107. Binary Tree Level Order Traversal II.py
970
4.15625
4
''' Given a binary 3-tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). ''' import collections def levelOrderBottom(root): levels = [] if not root : return levels def _helper(node, level): if not node: return ...
6003dcccd44916d9c7ebdc25d199afe14c768749
gabriel376/exercism
/python/pythagorean-triplet/pythagorean_triplet.py
289
3.765625
4
def triplets_with_sum(total): triplets = [] for a in range(1, total): b = int((pow(total - a, 2) - pow(a, 2)) / (2 * (total - a))) c = total - a - b if a < b and pow(a, 2) + pow(b, 2) == pow(c, 2): triplets.append([a, b, c]) return triplets
6dcb7e1b4f7a5cd9e34e4e9434472846c47dc3a9
eodenyire/holbertonschool-interview-4
/0x00-lockboxes/0-lockboxes.py
565
3.796875
4
#!/usr/bin/python3 """ Check if cratess can be opened. """ def canUnlockAll(boxes): """ Checks if box can be opened """ unlock = [False] * len(boxes) unlock[0] = True keys = [] for key in boxes[0]: keys.append(key) for key in keys: if ((key < len(boxes)) and...
b62ebab0f6109a82853ed0203350752669300088
mateusziwaniak/Small-projects-exercises
/Distance between cities.py
718
3.828125
4
from geopy.geocoders import Nominatim from geopy.distance import geodesic geolocator = Nominatim(user_agent="Distance between cities") def get_location_one(place): location = geolocator.geocode(place) return location place_one = input("Please enter first City: ") location_one = get_location_one...
aeeefb99065413701f4fd2307b83a185c03155d1
maniyar2jaimin/particle_swarm_optimization
/swarm.py
7,407
4.09375
4
#!/usr/bin/env python """ Source: http://www.swarmintelligence.org/tutorials.php (http://www.cs.tufts.edu/comp/150GA/homeworks/hw3/_reading6%201995%20particle%20swarming.pdf) ... PSO simulates the behaviors of bird flocking. Suppose the following scenario: a group of birds are randomly searching food in an area. Ther...
e06567bd789c871fdaf4e6a717c764aa0c20d600
joezhoujinjing/Sentiment-Classifier
/sentiment_classifier.py
8,216
3.609375
4
import random import collections import math import sys from collections import Counter from util import * ############################################################ # Feature extraction def extractWordFeatures(x): """ Extract word features for a string x. Words are delimited by whitespace characters onl...
545aa500d8163345c46d80ab7bb01208676504a7
dylanbuchi/Python_Practice
/decorators/performace.py
461
3.578125
4
import time def performance(func): def temp(*args, **kwargs): start = time.time() result = func(*args, **kwargs) end = time.time() seconds = round((end - start), 2) print(f"This function took {seconds} seconds to run") return result return temp @performance...
650bc9782b749221c44eaf30e2b3d468c5610747
urstkj/Python
/python/project_euler/problem_36/sol1.py
719
3.5625
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- from __future__ import print_function ''' Double-base palindromes Problem 36 The decimal number, 585 = 10010010012 (binary), is palindromic in both bases. Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. (Please note that ...
64856f52540d3b445232b03820e0f02e7ac29eae
00wendi00/Python-initiation
/algorithm/search_fibonacci.py
1,704
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @File : search_fibonacci.py # @Author: Wade Cheung # @Date : 2018/7/3 # @Desc : 斐波拉契查找 from algorithm.Fibonacci import fibonacci_create def fibonacci_search(lis, key): """斐波拉契查找, 平均性能,要优于二分查找。但是在最坏情况下,比如这里如果key为1,则始终处于左侧半区查找,此时其效率要低于二分查找 :param lis: :pa...
f1737281cc9aeeb11d0ed55e72dbd85d7a49d44e
spohlson/Py_Basic_Exercises
/ex11.py
376
4.125
4
# Input code print "How old are you?", age = raw_input() print "How tall are you?", height = raw_input() print "How much do you weigh?", weight = raw_input() # The comma after the end of each above print statement # allows the print to not end the line with a newline char # and go to the next line print "So, you're ...
f0172ce268dd5be4c51c45c8d401f8430c267b1c
davidadeola/My_Hackerrank_Solutions
/python/text_wrap.py
783
3.953125
4
# Init solution # def wrap(string, max_width): # div_count = int(len(string)/max_width) # div_count = None # if(len(string)%max_width != 0): # div_count = int(len(string)/max_width) # else: # div_count = int(len(string)/max_width) + 1 # start = 0 # stop = max_width # arr = [] # for i in r...
ad7cd8ee66f8aff68c69383c9567a69cc615e22c
W-Thurston/Advent-of-Code
/2019/Day 1 The Tyranny of the Rocket Equation_1.py
703
3.9375
4
import math with open('Day 1 The Tyranny of the Rocket Equation_1.txt','r') as file: input_text = file.read() input_text = input_text.split('\n') ## SOLUTION 1 # final_fuel_count = 0 # for i in input_text[:-1]: # final_fuel_count += (math.floor(int(i)/3))-2 #print(final_fuel_count) ## SOLUTION 2 def find_fuel...
294f705ac8196a44329f3a8003a8dae6453667fa
anu-coder/Basics-of-Python
/scripts/L2Q6.basic_math.py
742
4.0625
4
''' Level 2 Question: Write a program that calculates and prints the value according to the given formula: Q = Square root of [(2 * C * D)/H] Following are the fixed values of C and H: C is 50. H is 30. D is the variable whose values should be input to your program in a comma-separated sequence. Example Let us assu...
551234268d5e832a7225b9ffa0b6aafcd4c2e837
Jdbermeo/TareasComputacional
/tarea_5/espectro.py
830
3.5
4
def espectro_potencias(fft_x,fft_freq): """ Esta funcion calcula el espectro de potencias de cada senal y devuelve los 10 valores mas grandes de amplitud con su respectiva frecuencia. Input: - fft_freq: arreglo numpy de tamano [400,24]. Frecuencias de cada senal. - fft_x: arreglo numpy ...
0403d7f142eaa37697fef02e6a5e6e7cf5e4fc01
wangfeihu1992/GY-1908A
/day01/wwweee/__init__.py
281
3.703125
4
# 大于 print(1 > 0) # 小于 print(1 < 0) # 等于 print(1 == 0) # 不等于 print(1 != 0) # 大于等于 print(1 >= 0) # 小于等于 print(1 <= 0) a = 1 b = 6 print(a < b) print(a > b) print(a <= b) print(a >= b) print(a != b) print(a == b) a = 2 print()
70a841768784896235ac91692aa560994680aa37
eclipse-ib/Software-University-Fundamentals_Module
/02-Data_Types_and_Variables/Exercises/7-Water_Overflow.py
607
3.84375
4
# TANK_CAPACITY = 255 # # n = int(input()) # # water_in_tank = 0 # # for i in range(1, n+1): # water = int(input()) # water_in_tank += water # if water_in_tank > TANK_CAPACITY: # water_in_tank -= water # print(f"Insufficient capacity!") # continue # print(f"{water_in_tank}") # По-к...
f8981c26228b1576b3b7920f3d1b3ff9e0f3965c
carlygrizzaffi/Girls-Who-Code-2019
/dictionaryattack.py
941
4.46875
4
#Opens a file. You can now look at each line in the file individually with a statement like "for line in f: f = open("dictionary.txt","r") print("Can your password survive a dictionary attack?") #Take input from the keyboard, storing in the variable test_password #NOTE - You will have to use .strip() to strip w...
b56e8fa260b5765d7a551783b5dc674d35c8569b
lilaboc/leetcode
/66.py
604
3.59375
4
# https://leetcode.com/problems/plus-one/ from typing import List class Solution: def plusOne(self, digits: List[int]) -> List[int]: one = False for i in range(len(digits) - 1, -1, -1): if i == len(digits) - 1 or one: digits[i] += 1 if digits[i] == 10: ...
688286b1c2a258b7a3045eb78b307055df8b5cb5
k-washi/image-processing-test
/modern-python/s1.py
1,819
3.859375
4
from typing import Set, List import random """ My First Script: Calculate an important value. """ print(355/113) class Dice: RNG = random.Random() def __init__(self, n: int, sides: int = 6) -> None: self.n_dice = n self.sides = sides self.faces: List[int] self.roll_number = 0...
c1e4619c026736a37867353a910072ba2edb5d24
SeanLuTW/codingwonderland
/lc/lc599.py
1,105
3.515625
4
""" 599. Minimum Index Sum of Two Lists """ """ Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need to help them find out their common interest with the least list index sum. If there is a choice tie between answers, outpu...
ef68912d31d9948a70dbe7a5d710d3b1693acf3d
LuoyingLi2991/Technical-Tools
/Daily.py
3,824
3.59375
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 30 10:40:20 2017 Class that calcs the time series of daily price high and low, given any intra-day frequency data. There are also TWO OPTIONS too retrieve data: OPTION 1: Retrieves Yesterday's HiLo OPTION 2: Retieives the last 24hr M...
e22f92fd5dfbc4330a55d8c0d9e937973b4d5d68
jonghoonok/Algorithm_Study
/Graph/332. Reconstruct Itinerary.py
512
3.703125
4
from collections import defaultdict def findItinerary(tickets): result = [] travel = defaultdict(list) for node in sorted(tickets, reverse=True): travel[node[0]].append(node[1]) def dfs(node): while travel[node]: dfs(travel[node].pop()) ...
1cbe3601a5a164cd90f3e4a9640e07a5e8342a99
RSprogramer/hello-world
/p1.py
585
3.78125
4
class Bank: balance = 0; def deposite(self): deposited = input("Enter amount to deposite :$"); print("Amount deposited : $" + str(deposited)) balance = deposited; return print("Deposite of amount $" + str(deposited) + " done succesful"); def withdraw(self): ...
919ee666c33997546bf3ec0d2450817275f72e68
tutunamayanlar2021/Python
/dictionary_example.py
1,355
4
4
""" ogrenciler = { '120': { 'ad': 'Ali', 'soyad': 'Yılmaz', 'telefon': '532 000 00 01' }, '125': { 'ad': 'Can', 'soyad': 'Korkmaz', 'telefon': '532 000 00 02' }, '128': { 'ad': 'Volkan', ...
16c84e8aa14e340b847ce4103577062a622cb9df
arpitran/HackerRank_solutions
/Python/Set .intersection() Operations/solution.py
538
3.75
4
n =int(input("No. of students subscrbed to English newspapers")) # No. of students subscribed to English newspapers N = set(map(int,input("# Space separated roll numbers of students in 'n'").split())) # Space separated roll numbers of students in 'n' b = int(input("# Number of students described to French newspapers"))...
8593cc27d83d4c0f70f276a64f024517e0faaa53
jacobkutcka/Python-Class
/Week04/prime_numbers.py
1,028
4.3125
4
################################################################################ # Date: 03/04/2021 # Author: Jacob Kutcka # This program takes a number # and checks if it is a prime number ################################################################################ def main(): # Call for user input num = ...