blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
a7f8138fe5c089abddd4312a9cbd48f2f1622ccb
Sandeep-2511/Python-Practise
/prog8.py
148
3.703125
4
l = "This is umbrella" count = 0 for i in l: if i == 'e': count = count + 1 print("the occurence of e and is are:",count, l.count('is'))
b752fdc52354cfc9fd1892a48258f8fb8647cdcd
reshmanair4567/100daycodingchallenge
/Python/Fibonnaci.py
529
4.0625
4
#Iterative## def Fibonnaci(n): a=0 b=1 if n<0: print("please enter valid input") if n==0: return a if n==1: return b else: for i in range(2,n+1): c=a+b a=b b=c return b ''' #Recursion def Fibonnaci(n): if n<0: p...
0ec5ed951d292eb62f32e310777f72f26fb78896
davidhawkes11/PythonStdioGames
/src/gamesbyexample/chomp.py
3,112
4.125
4
"""Chomp, by Al Sweigart al@inventwithpython.com A dangerously delicious logic game. Inspired by a Frederik Schuh and David Gale puzzle, published by Martin Gardner in Scientific American (January 1973) More info at: https://en.wikipedia.org/wiki/Chomp""" __version__ = 1 import random, sys print('''CHOMP By Al Sweig...
155984b2aa54cbea2aacaf60b57bf8fa4c6b7696
NIDHISH99444/CodingNinjas
/recursionBacktracking/uniqueNumberCombination.py
758
3.828125
4
def printArray(p, n): for i in range(0, n): print(p[i], end=" ") print() def printAllUniqueParts(n): p = [0] * n # An array to store a partition k = 0 # Index of last element in a partition p[k] = n # Initialize first partition # as number itself while True: printArra...
a9ba82a0c7dc5f6a859f17ac00e3d1e786349eaf
mishraabhi083/standard-algorithms
/smallest_09_num.py
399
3.734375
4
def solve(num, base=[]): if base == []: base = ['9' + '0' * (len(str(num)) - 1)] while base != []: # print(base[0]) if int(base[0]) % num == 0: return int(base.pop(0)) else: last = base.pop(0) base = (base + [last + '0'] + [last + '9']) if __name__ == "_...
f4e1b664751849880849d57b522313e4ce1a92b5
macraiu/software_training
/leetcode/py/414_Third_Maximum_Number.py
1,103
4.125
4
""" Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). """ def thirdMax(nums): a = sorted(set(nums)) if len(a) < 3: return max(a) else: return a[-3] import time import ran...
eb06cb81e4c205e40e18f0723110c0f2374d2382
Saifullahshaikh/Assignment-5-Practice-problem-4.4-4.5
/P.P 4.5.py
336
3.78125
4
print('Saifullah, 18B-092-CS, A') print('Assignment# 5, practice problem 4.5') first = 'Saifullah' last = 'Shaikh' street = 'PIB Street ' number = 46 city = 'Karachi' state = 'Pakistan' zip_code = '12564' mailing_label = ('{} {}\n{} {}\n{}, {} {}') print(mailing_label.format(first,last,number,street,city,st...
2b4e2fba18266e04218a9c47dba601f2c09a4f17
Oleksandr015/Algorytmy
/data_structures/deque.py
803
3.65625
4
from collections import deque if __name__ == '__main__': # --------------------------- # ---------- STACK ---------- # --------------------------- stack_deque = deque() stack_deque.append(1) stack_deque.append(2) stack_deque.append(3) assert stack_deque.pop() == 3 a...
ad7d3128ff138ec687d26fb518a1668f9f84761d
kunweiTAN/techgym_ai
/Nk3Q.py
1,031
3.953125
4
#AI-TECHGYM-3-3-Q-1 #回帰問題と分類問題 #インポート import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model #データを作成 #0〜1までの乱数を100個つくる #値の範囲を-2~2に調整 x1 = x1 * 4 - 2 x2 = x2 * 4 - 2 #yの値をつくる #標準正規分布(平均0,標準偏差1)の乱数を加える y += np.random.randn(100, 1) #モデル #[[x1_1, x2_1], [x1_2, x2_2], ...
05bb2ce9c36217ebbeeff655129e74edcda7b432
ggorla/PathtoFAANG1
/Leetcode/56Mergeinterval.py
439
3.71875
4
def insert1(intervals, newinterval): result=[] for interval in intervals: if not result or result[-1][1]<interval[0]: result.append(interval) else: result[-1][1] = max(result[-1][1],interval[1]) return result if __name__ == "__main__": intervals = [[1,...
bf322c0d44f5f29d23512dd1541762d932636484
Lukazovic/Learning-Python
/CursoEmVideo/exercicio072 - numeros por extenso.py
472
4.0625
4
numeroExtenso = ('Zero', 'Um', 'Dois', 'Três', 'Quatro', 'Cinco', 'Seis', 'Sete', 'Oito', 'Nove', 'Dez', 'Onze', 'Doze', 'Treze', 'Quatorze', 'Quinze', 'Dezesseis', 'Dezessete', 'Dezoito', 'Dezenove', 'Vinte') numeroEscolhido = int(input('\nDigite um número entre 0 e 20: ')) while numeroEscolhido<0 and numeroEscolhido...
b0f85cf0b0e6bf55ad25c32314d95cbfc98fa054
JGuymont/ift2015
/5_dictionnary/5.3 arbres binaires de recherche/5.3.1 abr/Tree.py
3,282
3.890625
4
#!/usr/local/bin/python3 from ListQueue import ListQueue class Tree: """ADT Tree""" class Position: """inner class Position""" def element(self): """Return the element stored at this Position.""" raise NotImplementedError('must be implemented by subclass') def...
ee198bc3403a53a3e1bca9ee1d6fdf894c3b36bd
sginne/solidabis
/graph.py
3,110
4.1875
4
""" Class implementing graph """ class Graph(object): def __init__(self, graph_dict=None): """ Initializing graph """ if graph_dict == None: graph_dict = {} self.__graph_dict = graph_dict def vertices(self): """ vertices of the graph """ retu...
dcd7000d110e865b1fa9815d5cd985e5f5b7278e
PRaNenS/python
/ErrorOccur.py
2,318
3.625
4
# 임의 에러 발생 class BigNumberError(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg # 예외 처리 try: print("한자리 숫자 나누기") num1 = int(input("숫자1 >")) num2 = int(input("숫자2 >")) if num1 >= 10 or num2 >= 10: raise BigNumberError("입력값: {0}, {1}...
142d796c660b86ec3050fe942837286424a529d0
kenan666/caseStudy
/pandas_exercise/SimpleITK_py/sitk_transform.py
23,154
3.5625
4
# SimpleITK transform from __future__ import print_function import SimpleITK as sitk import numpy as np %matplotlib inline import matplotlib.pyplot as plt from ipywidgets import interact, fixed OUTPUT_DIR = "Output" print(sitk.Version()) ''' Points in SimpleITK Utility functions A number of functions th...
3fe8ff6ea8a307276a311b01f494c3e92175868d
corridda/Studies
/Articles/Python/pythonetc/year_2018/september/operator_and_slices.py
2,069
4.5
4
"""Оператор [] и срезы""" """В Python можно переопределить оператор [], определив магический метод __getitem__. Так, например, можно создать объект, который виртуально содержит бесконечное количество повторяющихся элементов:""" class Cycle: def __init__(self, lst): self._lst = lst def __getitem__(se...
02061e20918ea8b66aca91ee764917dcb2103c31
blueprint515/ForPy04
/ex3.py
945
4.21875
4
# print "I will now count my chickens:" print "I will now count my chickens:" # print "Hens", count "25 + 30 / 6" print "Hens", 25 + 30 / 6 # print "Hens",count"100-25*3%4" print "Roosters",100-25*3%4 # print "Now I will count the eggs." print "Now I will count the eggs." # count"3+2+1-5+4%2-1/4+6" print 3+2+1-5+4%2...
cd55b8cfe9bb5bce3e8c7e443f93e8044bccecd8
gkelty/Sorry
/gameLoop.py
10,796
3.5625
4
# this is starting the game import mainTest from Button import Button from TextInputBox import TextInputBox from dbConnection import dbConnection from Board import Board from boardButton import BoardButton import mainMenu import PossibleMoves import pygame import pygame.locals as pl import sys import os.path pygame.i...
5e79f7addb7828d3d855994bd2af26d28f107b63
Naman-Kansal/python
/interviewbit/maxNonNegativeArray.py
410
3.578125
4
def max_non_negative_arr(A): t = [] s = [] for i in range(len(A)): if A[i] < 0: if t is not []: s.append(t) t = [] else: t.append(A[i]) val = [] for i in range(len(s)): val.append(sum(s[i])) i = val.inde...
9d2f8ab2aaa881d94740b0960200d51dd2ff7a96
awan1/cs91_final_project
/project/webpage/static/graph-test.py
715
3.515625
4
""" @author: Adrian Wan graph-test.py: a test for generating a graph visualization """ import networkx as nx from networkx.readwrite import json_graph import json from itertools import permutations def main(): G = nx.Graph() # List of nodes. Nodes are tuples of (node_name, attribute_dict) node_list = [(i, {'rt'...
9cb373c9b7f48a3aedf124d678960083c867c4a2
aglia-iu/LocationNavigation
/ApplicTests.py
5,172
3.75
4
# This is the test file that tests both the LocationNode class and the Program class # It contains two vlasses: A NodeTest Class and a ProgramTest class. import sys import LocationNode from LocationNavigation import LocationNavigation from LocationNode import LocationNode from PySide2 import QtCore, QtWidgets...
c0f74771800d5e1f2418aff8c0a00ea33c2ada4c
cho0op/python_databases
/movi_list_app/database.py
2,035
3.6875
4
import sqlite3, datetime connection = sqlite3.connect('data.db') def create_tables(): with connection: connection.execute( "CREATE TABLE IF NOT EXISTS movies (" "id INTEGER PRIMARY KEY," " title TEXT," " release_timestamp REAL)") connection.execute(...
00ebff5e2473d63861d0cc16f78ce8e8b450509c
declau/python-beginner-projects
/madlibs/madlibs.py
651
4.125
4
# # String concatenation - (Como coocar strings juntas) # # Vamos supor que você quira criar uma String que diga "Subscribe to ______" youtuber = "Denis Claudiano" # Alguma variável string # # Alguns modos de se fazer isso! # print("Subscribe to " + youtuber) # print("Subscribe to {}".format(youtuber)) # print(f"Subs...
707869713e87750ec6c1356f4defc3e68f9ea242
karadisairam/Loops
/45.py
259
4.21875
4
for x in range(5): print(x) #To display numbers 0 to 10: for x in range(11): print(x) #Odd numbers in 0 to 20 : for x in range(21): if x%2!=0: print(x) #Even numbers : for i in range(10): if i%2==0: print(i)
dbb6f5a0d9624b3f4e4e8b9f1e2e588bd33b2669
OlhaHolysheva/Python_Cor_HW
/Are You Playing Banjo.py
269
3.796875
4
def areYouPlayingBanjo(name): # Implement me! #for i in name: #name = str(name) if name[0] == 'R' or name[0] == 'r': return name + "plays banjo" else: return name + " does not play banjo" print(areYouPlayingBanjo('olga'))
d8ef635900411b6d943de59efa7ab0b038dd08eb
love-adela/algorithm-ps
/codeit/fibonacci.py
160
3.84375
4
# Time Complexity : O(2 ** n) def fibo(n): if n == 1 or n == 2: return 1 return fibo(n-1) + fibo(n-2) for i in range(1, 11): print(fibo(i))
eb64ab2304d1c83b2b0c6471d6b578c525830102
Ken2399/326-Group-Project
/final.py
2,177
4.25
4
class Account: """Create an account that will either be used to be a customer or an online retailer. """ def __init__(self, account_type, username, birthday, address, email, password): def change_login_credentials(): """ Purpose: to edit login credentials (update email, chang username, etc....
769faf22bd9361a9ead99cddb22e211785112994
vishal-asrani/tutorials
/python/itertools/chain.py
332
3.609375
4
from itertools import * a = [0,1,2,3,4,5] b = ['zero', 'one', 'two', 'three', 'four', 'five'] c = ['a', 'b', 'c', 'd', 'e', 'f'] print(list(chain(a,b,c))) # [0, 1, 2, 3, 4, 5, 'zero', 'one', 'two', 'three', 'four', 'five', 'a', 'b', 'c', 'd', 'e', 'f'] print(list(chain(a[0:],b[:1],c[0:2]))) # [0, 1, 2, 3, 4, 5, 'zero...
5ba454ac6522ceb80956f78d5ae0cbeef708c46e
Vineet2000-dotcom/Competitive-Programming
/CODECHEF/June Starters/TOTCRT.py
456
3.625
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 28 10:17:16 2021 @author: Vineet """ t=int(input()) for i in range(t): n=int(input()) d1={} list1=[] for i in range(n*3): x,y=map(str,input().split()) if x not in d1: d1[x]=int(y) ...
384e0d96bfd3d7b0a43d0fcbd8d5a96ce7f9058c
Priyansh-Kedia/MLMastery
/24_feature_importance.py
6,831
4.46875
4
# Feature importance refers to a class of techniques for assigning scores # to input features to a predictive model that indicates the relative # importance of each feature when making a prediction. # We will create test dataset with 5 important and 5 unimportant features # Dataset would be created both for classif...
0c9537118e144859a65068d1923ded156e4f0cae
alexandraback/datacollection
/solutions_5738606668808192_0/Python/pilagod/3.py
1,150
3.5625
4
class Solution(object): def getJamcoins(self, n, j): maxJamcoins = (1 << n) - 1 curJamcoins = (1 << (n - 1)) + 1 result = "" count = 0 while count < j and curJamcoins < (maxJamcoins - 1): curJamcoins += 2 binaryJamcoins = "{0:b}".format(curJamcoins) ...
9bff0918f45312c8657a2fd45baf034daa32995d
maksik228/info11
/Урок 2/задание 6 стр 18.py
99
3.71875
4
n=int(input()) if n%2==0 or n%3==0: print("истина") else: print("ложь")
f86b8c3612bd32446def10008bec3a6d76e34fc8
Tabish596/Data-Structure-Algo
/stack.py
977
4.0625
4
class node: def __init__(self,value): self.value = value self.next = None class stack: def __init__(self): self.top = None self.bottom = None self.length = 0 def peek(self): if self.top is not None: print(self.top) return def push(s...
8030283a380430ff1fd340385caac318be4b5ece
joymajumder1998/Coding-By-Joy-Majumder
/dummy python code templates/linkedlist.py
871
3.671875
4
class Node: def __init__(self,value): self.value=value self.link=None class List: def __init__(self): self.header=None def insert(self,value): new=Node(value) if(self.header==None): self.header=new return ptr=self.head...
384b416b41f73235fa6531980575dd43a509da68
seetwobyte/news
/aiden-4advance.py
236
3.953125
4
import turtle fred = turtle.Pen() fred.speed(0) fred.color("purple") fred.width(5) for i in range(100): fred.forward(i * 2) fred.circle(i * 2, 90) fred.right(20) # then hit the enter key and watch the magic # purple spiral
5e30c802ff80c9718cb7f11de62e97195567adad
zarev/interview-bootcamp
/arrays.py
3,017
3.5625
4
def rev_slice(string): if(type(string) == str): print(string[::-1]) def rev_for(string): for char in range(len(string), 0, -1): print(string[char-1]) def mergeSorted(arr1, arr2): # check input if(len(arr1) == 0): return arr2 if(len(arr2) == 0): return arr1 merged = [] i, j = 0, 0 ...
0c9274cb5d5edfc9edda48f2061f1e4d0b27d501
Piersoncode11/Python-Project-PM
/Area of Circle Challenge PM.py
435
4.09375
4
print("What is the radius of the circle?") radius = float(raw_input()) area = radius * radius * 3.14 print(area) print("What is the radius of the sphere") radius = float(raw_input()) volume = 4.71 * int(radius) ** 3 print(volume) print("What is the value for x?") x = float(raw_input()) x = int(x) print(...
67707d50f2c85e05ece4153e1d7d085c8e4a83c3
lanestevens/aoc2017
/day03/d3-2.py
1,661
3.65625
4
# -*- coding: utf-8 -*- import sys def next_coordinate(xy): #special case for origin if xy == (0, 0): return (1, 0) #Bottom right - move out to the right if xy[0] > 0 and xy[0] == -xy[1]: return (xy[0] + 1, xy[1]) #Top right - move to the left if xy[0] > 0 and xy[0] == xy[1]: ...
ab4bf0a513379c8f7494182f4c12dab293ea7c21
hzwangchaochen/red-bull
/leetcode/python/reverse_linked_list.py
613
4.125
4
class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next class Solution: def reverse_linked_list(self,root): dummy_node=None while root: next = root.next root.next = dummy_node dummy_node = root r...
8d4dcb6368819ce68d842ac0ab223ac0bc91e5cb
Journalisme-UQAM/devoir-1-NoemieLaurendeau
/devoir1JHR.py
251
3.546875
4
#coding: utf-8 for annee in range(1930,2018) : for numero in range (0,1000) : print(str(annee)[2:] + format(numero,"03d")); # Excellent! Ça fonctionne super bien! # Tes deux scripts sont identiques, alors je ne commente que celui-ci :)
fadb0e01793da124749b6a705a2dbb1c85e10ce4
guogenjuan/python
/pythonScipt/mutiPlus.py
239
3.734375
4
def mutiPlus(): s='' for j in range(9): for i in range(9): if j>=i: s = (i+1)*(j+1) print(str(i+1)+'*'+str(j+1)+'='+str(s)+' ',end='') print() mutiPlus()
b5eb4a320f463ff2b911cc78b2a2b274cb1a40f6
yurijvolkov/mmb
/algo.py
4,526
4.03125
4
import time import math import numpy as np def straightway(A, B): """ Simplest way to multiply matrices. (By rowXcolumns rule) Time complexity: O(N^3) :param A: np.ndarray :param B: np.ndarray :return: np.ndarray """ if A.shape[1] != B.shape[0]: r...
0ff661aeac659a56163cd8c0f3aa1aa68fae6246
romariick/python_learning
/controlflow/controlflow.py
121
3.75
4
x = int(raw_input("Please entrer un number")) if x > 0 : print "Superieur zero " else: print "Inferieur zero"
f7e6f8981704180874b965a671be4bfe5c75630f
junwon-0313/PythonBasic
/python/Input,Output/2.py
294
3.71875
4
in_str = input("2자리 숫자의 암호를 대시오! \n") #print(type(in_str)) #change data type , match is neccessary real_junwon = '11' real_lee = "22" if real_junwon == in_str: print("Hello Junwon") elif real_lee == in_str: print("Hello lee") else: print("로그인 실패!")
44f97e7ecbaeb7464604e020cd665ae6db72796d
cmurphy/netsec
/lab2/p3_tcp_server.py
460
3.53125
4
# Problem 3: Follow the example code at python.org to write a TCP server. Listen on TCP port 2003 for a message containing the flag. import socket TCP_IP = '192.168.14.149' TCP_PORT = 2003 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind((TCP_IP, TCP_PORT)) sock.listen(1) conn, addr = sock.a...
50f40f5809746916dad0992e7f2a0f4bca7cb77b
formigaVie/SNWD_Works_201711
/Class08/example.py
548
4.03125
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- # define variable name creator = "FormigaVIE" # print welcome to user print "=" *80 print "Welcome to {} example" .format(creator) print "=" *80 # Put Make string lower case to a personal greeting user=raw_input("\nPlease enter your name: ") print "\n Hello {}, pleasure t...
9e7d83dfb56184f30cb8fcd4adb48f43c6166a35
caiosuzuki/exercicios-python
/ex036.py
373
3.9375
4
casa = float(input('Digite o valor da casa: R$')) salario = float(input('Informe seu salário: R$')) anos = int(input('Em quantos anos quer pagar? ')) prestacao = casa / (anos * 12) if prestacao > salario * 0.3: print('Empréstimo negado! O valor da prestação (R${:.2f}) excede 30% do seu salário'.format(prestacao)) e...
4f0b3ad0db4a5d1514059e6acd37edfb0f7060d9
Stefan1502/Practice-Python
/exercise 29.py
1,020
4.34375
4
# This exercise is Part 1 of 3 of the Hangman exercise series. The other exercises are: Part 2 and Part 3. # In this exercise, the task is to write a function that picks a random word from a list of words from the SOWPODS dictionary. Download this file and save it in the same directory as your Python code. This file i...
e4a56364774f93b0418e4f01a70c6aba86ec328a
SaifullahKatpar/pyusgs
/test.py
732
3.6875
4
# using the requests library to access internet data #import the requests library import requests def main(): # Use requests to issue a standard HTTP GET request url = "https://waterservices.usgs.gov/nwis/site/?format=rdb&stateCd=ri" result = requests.get(url) printResults(result) def printResults(re...
2166230a514bb1845fb3b1e070008964163cde37
sivagopi204/python
/day7-2.py
1,468
3.828125
4
def getCofactor(mat, temp, p, q, n): i = 0 j = 0 # Looping for each element # of the matrix for row in range(n): for col in range(n): # Copying into temporary matrix # only those element which are # not in given row and column if (row != p and col != q) : te...
2b8b6001e170c41c895569e44e4d3d871dd29a40
krother/Python3_Package_Examples
/json/example_json.py
232
3.921875
4
import json # Convert a dictionary to a JSON-formatted string: data = {'first': 1, 'second': 'two', 'third': [3,4,5]} jj = json.dumps(data) print(jj) # Convert JSON string back to a Python dictionary: d = json.loads(jj) print(d)
f0b24e787e4fd3f49a662eca77dfd95821041256
gsrini27/Books-BK-PythonCookbook3rd
/Chapter1-Data_Structures _and_Algorithms/p1.8.py
386
3.875
4
# Calculating with Dictionaries prices = { 'ACME': 45.23, 'AAPL': 612.78, 'IBM': 205.55, 'HPQ': 37.20, 'FB': 10.75 } print(prices.keys(), prices.values()) # zip() creates an items that can only be consumed once s min_price = min(zip(prices.values(), prices.keys())) print(min_price) prices_sorted ...
38f19472dfa2d351e68d03a443f8686f28d16349
ManishShah120/Python_Basics
/Day6/Dictionaries.py
463
3.734375
4
''' Dictionaries in Python is similar to STRUCTURE in C Dictionaries contains Dictionary = {"KEY":"Values",} ''' Customer = { "Name":"Manish", "Age":21, "Gender":"Male", "Is_Verified": True } #print(Customer.get("name"))#None is an object with no value Customer["Name"] = "Kumar" print(Custo...
dfa481fbc92f0870556d21482296f476acc53230
SubhoBasak/MachineLearning
/GradientDescent/gradient_descent.py
1,107
3.53125
4
import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression x = [1, 3, 2, 5, 3, 4, 6, 2] y = [2, 2, 1, 4, 3, 5, 6, 3] m = b =0 lrn = 0.1 line = lambda X: m*X+b #line = lambda X: model.coef_*X+model.intercept_ def graph(func, x_range): x_points = np.array(x_range).reshape(-...
8125f287d64e90d807a8ee7016e3709ee68ea41e
wsgan001/PyFPattern
/Data Set/bug-fixing-4/4b8aebca6a302429a90e5713afc635b1bc35edb1-<jaccard_distance>-fix.py
569
3.65625
4
def jaccard_distance(set1, set2): 'Calculate Jaccard distance between two sets\n\n Parameters\n ----------\n set1 : set\n Input set.\n set2 : set\n Input set.\n\n Returns\n -------\n float\n Jaccard distance between `set1` and `set2`.\n Value in range [0, 1], where 0...
785f696325670ebe70bebdb6f1115bde6e78e89a
matthewrmettler/project-euler
/Problems 1 through 50/problem48_self_powers.py
279
3.59375
4
''' Author: Matthew Mettler Project Euler, Problem 1 The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. Status: Correct ''' print(str(sum([int(str(value**value)[-10:]) for value in range(1, 1001)]))[-10:])
662d44fffc457d8140d5783f9b9021243b563b21
Agusef22/Python
/CursoBasicoDePython/Listas.py
2,601
4.65625
5
"""**append()**Este método agrega un elemento al final de una lista. **count()**Este método recibe un elemento como argumento, y cuenta la cantidad de veces que aparece en la lista. **extend()**Este método extiende una lista agregando un iterable al final. **index()**Este método recibe un elemento como argumento, y ...
0c291bf1d72c58c6430691a65c42eaef8072c79d
choiking/LeetCode
/linkedlist/sortList.py
2,389
3.921875
4
# Author: Yu Zhou # 148. Sort List # Sort a linked list in O(n log n) time using constant space complexity. # 思路 # 用链表的方式切分,然后递归Split,之后Merge # 这道题要注意是切分的时候,要写个Prev的函数用来储存Slow的原点 # Time: O(nlogn) # Space: O(1) # **************** # Final Solution * # **************** class Solution(object): def sortList(self, he...
e68f9a57756f4f48be846ec673ae2dae8d23c6ed
Satish980/JNTUK_Python_Workshop
/Day_3/tuple_demo.py
1,006
4.625
5
#!/usr/bin/python # tuples in python atup = ('physics','chemistry',2010,2014) btup = (80,82,73,64,85) # to print complete tuple print("atup :", atup) print("btup :", btup) # to print first element of the tuple print("atup[0]:", atup[0]) # to print elements starting from 2nd till 3rd print("btup[1:3] : ", btup[1:3]...
ffd9249c31c64b1a539b121fb7356195f1088916
spsree4u/MySolvings
/strings/longest_prefix_string.py
733
4.0625
4
""" Input: ["flower","flow","flight"] Output: "fl" Input: ["dog","racecar","car"] Output: "" """ def find_longest_prefix(strs): if not strs: return "" # Time complexity is m*n where m = len(strs[0]) and n = len(strs) # Space complexity is O(1) for i in range(len(strs[0])): for j in r...
73c0a9d98ec5cb2eb8d9b1ff02a97a0ddce29ff7
mubeen070/PythonLearning1
/test.py
235
4.125
4
#msg="hello world" #msg2="sony" #print(msg2+": "+msg) #val1="3" #val2="4" #print(val1+val2) #fruits = ["apple", "banana", "cherry"] #for x in fruits: # print(x) val1=8 val2=13 if 13 > 8 : print( "13 is greater than 8" )
b0200c7317916b3352459cf65a62a24bab5227c6
renjieliu/leetcode
/0001_0599/21.py
1,692
4.1875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeTwoLists(self, list1: 'Optional[ListNode]', list2: 'Optional[ListNode]') -> 'Optional[ListNode]': start = ListNode() #dummy start no...
49a349d93ece3c264ccca1edd8c9ebde0003266e
dlstzd/FamilyTree
/Family.py
5,236
3.546875
4
from PersonID import * import pickle import tkinter as tk #future issue each person needs a unique id #or we list duplicate and allow the person to select the correct person -- peopleList = [] def update_file(): with open("list.pkl", "wb") as f: f.write(pickle.dumps(peopleList)) def get_person(peopleLis...
c9a6580bc8f648ade956a75359f07487782b1a60
Irisviel-0/a1
/find_my_neighbourhood.py
489
3.671875
4
def find_my_neighbourhood(x, y): NameStr = 'ABCDEFGHIJ' a = NameStr[int(y)]+str(int(x)+1) return a def find_all_restaurants_in_neighbourhood(x, y): Neib = find_my_neighbourhood(x, y) list1 = [str(Neib)+'CR', str(Neib)+'MR'] return list1 if __name__ == "__main__": for i...
2e8934c4d547826bde1d029a3d76d3abe8ad01d2
ShreyanshNanda/CyberSecurity
/Assignment 03/almost_there.py
222
3.890625
4
print("True if n is within 10 of either 100 or 200") def almost_there(n): if(abs(100-n) <=10 or abs(200-n) <=10): return True else: return False n=int(input("Enter the number : ")) almost_there(n)
161f6016f1b6f7c7bbe11706184d3972b009643c
AdamMcCarthyCompSci/Programming-1-Practicals
/Practical 7/p13p2.py
531
4.28125
4
""" Define max function with two variables If first is greater than second then return first else then return second prompt for first float prompt for second float print result """ def max(a,b): """Function that returns the largest of its two arguments""" if a>b: ret...
dcb48b749fa4c408be2cfe1a7ad3f3de912ae2c8
RahatIbnRafiq/leetcodeProblems
/Tree/437. Path Sum III.py
579
3.609375
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def helper(self,root,origin,targets): if root is None:return 0 hit = 0 for t in targets: ...
5a76f80621d9496f12a46b5ae466bf6ebb5dc796
evercsing/flatiron
/Chung Soo Lee_API Project.py
2,421
3.890625
4
# Python program to find current # weather details of any city # using openweathermap api # import required modules import requests, json import matplotlib.pyplot as plt # Enter your API key here api_key = "c4440a0676f79455da1890baf316cde9" # base_url variable to store url base_url = "http:...
363d2410efc59f9dc5536bbd714290d87a1ad1fe
DouglasKosvoski/URI
/1001 - 1020/1008.py
162
3.75
4
NUMBER = int(input()) HOURS = int(input()) VALUE = float(input()) SALARY = HOURS * VALUE print('NUMBER = %d'%(NUMBER)) print('SALARY = U$ %.2f'%(SALARY))
638f3cd1e20db07152aa793bd3775df6228666b4
heden1/1nledande-programer1ng
/selfPractice/l5worIndex.py
558
3.703125
4
def word_index(text): dict ={} if len(text)==0: return dict text=text.split(' ') for i in range(len(text)): list1=[i] if text[i] in dict: list1=dict.get(text[i]) list1.append(i) dict[text[i]]= dict.get(text[i],list1) ...
2737f7110d5b74283d1b76dc699ea1a1a966f01a
GeorgeVince/HackerRank
/Data Structures/Stack/balanced_brackets.py
490
3.84375
4
# -*- coding: utf-8 -*- """ Created on Mon Jun 5 16:13:21 2017 @author: George """ def is_matched(expression): stack = [] pairs = {'(':')', '[':']','{':'}'} for x in expression: if pairs.get(x): stack.append(pairs[x]) else: if len(stack) == 0 or x != stack[len...
c798478cfb2a114b702284ae7607a9120e0f6b8f
shayansaha85/pypoint_QA
/set 5/20.py
279
4.15625
4
n = int(input("How many elements do you want? : ")) numbers = [] squares = [] for i in range(n): el = int(input(f"Enter the element #{i+1}: ")) numbers.append(el) for x in numbers: squares.append(x**2) print("Entered list :",numbers) print("Square list :",squares)
3152fc7a9d94bfb326066f962046b3ca38112082
drewwestphal/aoc2016
/3.py
713
3.5625
4
#!/usr/bin/python import itertools def checkTriangle(s1,s2,s3): for perm in itertools.permutations([s1,s2,s3]): if not perm[0]+perm[1]>perm[2]: return False return True #valid = filter(checkTriangle, open('./3input.txt')) trianglerows = [[int(x) for x in line.split()] for line in open('./3input.txt')] validr...
bb2d3ee1668b3248d74f489d975fd60e7afa1958
SurinJeon/python_study
/chap04/dict/final_question.py
870
3.71875
4
# 3번 numbers = [1, 2, 3, 4, 7, 5, 8, 4, 2, 8, 5, 8, 4, 1, 8, 5, 6, 9, 3] counter = {} for number in numbers: key = number if key in counter: counter[number] += 1 else: counter[number] = 1 print(counter) # 4번 character = { "name":"기사", "level":12, "items":{ "sword":"불꽃의...
70547951ef91e624d5c6e2daff4f04aff3cd7f67
kleinstadtkueken/adventOfCode2018
/src/2018/day_13/exercice1.py
4,970
3.5
4
#!/usr/bin/python3 from enum import Enum, auto class Turn(Enum): LEFT = auto() RIGHT = auto() STRAIGT = auto() # def next(self): # if self.LEFT: # return self.STRAIGT # elif self.STRAIGT: # return self.RIGHT # elif self.RIGHT: # return self...
28431b71e1179b8297bbee03b2d629c2fc381d23
zazolla14/basic-python
/break_while.py
139
3.875
4
#CONTOH menggunakn while dengan memanfaatkan BREAK while True: data=input("Data : ") if data == "x": break print(data)
8a2a34c0a8970a8344ea1495c4ca22dd9c833962
mattwelson/Archive
/COMP150/Lab06/div3.py
180
4.25
4
def is_divisible_by_3(n): if n % 3 == 0: print n, "is divisible by 3!" else: print n, "is not divisible by 3 :(" is_divisible_by_3(6) is_divisible_by_3(7)
906c8ca96ab5fdeae29be5c60f0e8eaa3f1bdce3
kasy1tu/Financial-Records-Election-Analysis-
/PyBank/main.py
1,702
3.828125
4
#Open csv as read file import os import csv file_to_load = os.path.join("Resources", "budget_data.csv") #Defined all variables total_months = 0 total_net = 0 change_values = [] total_net_change = 0 greatest_increase = [" ", " "] greatest_decrease = [" ", " "] greatest_increase_month = [] greatest_decrease_month = ...
c7a67c23b2aae88e039c045f3dae89fe6b372e5e
samarla/LearningPython
/factorial using function.py
289
4.25
4
number = int(input('enter any number: ')) def factorial(n): if n == 1: # The termination condition return 1 # The base case else: res = n * factorial(n-1) # The recursive call return res print('the factorial of given number is: ',factorial(number))
4f894f14232c1f4c87e772b7a8dc6e9ac11be3c1
Crown0815/ESB-simulations
/polygon.py
216
3.71875
4
from math import * small_radius = 1.3 side_length = 2 * small_radius number_of_sides = 4 radius = side_length / (2*(sin(pi / number_of_sides))) print(radius+small_radius) print((radius+small_radius)/small_radius)
9048a804a00728b642a9f35790f5dad62d142740
jackh08/Python-General
/python_week4 clus and reg.py
4,634
3.5625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Exercise – Week IV Data Programming With Python – Fall / 2017 Regression, Clustering """ import pandas as pd import numpy as np import numpy.polynomial.polynomial as nppp import scipy.cluster.vq as spcv import scipy.stats as sps from pylab import plot, title, show, l...
1ab59fe086485d9f4ef1966e7c18e0d8609c72b0
ViktoriaCsink/AnnotatePdf
/segment_docx.py
1,380
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This function will access URLs that point to word documents and get the text. Word documents are converted into pdfs in order to break them down into pages. The text will be broken down into pages to do analysis on each page later on. Input: 'response' (the result of...
13fd0849e73a9208c1f0eae7b379ada53188565d
lucas-mascena/Numerical_Methods
/Interpol_1.py
829
3.890625
4
''' Linear Interpolation Method ''' ''' time = [0,20,40,60,80,100] temp = [26.0,48.6,61.6,71.2,74.8,75.2] #y = lambda xp, x1, x2, y1, y2: y1+((y2-y1)/(x2-x1))*(xp-x1) #y(50,40,60,61.6,71.2) def y(xp, x, y): for i, xi in enumerate(x): if xp < xi: return y[i-1]+((y[i]-y[i-1])/(x[i]-x[i-...
d03ca4a8f9f758821d3af8d7d5b382706e3f64f4
iTrauco/list_exercises
/11_11_2019/string_exercises.py
2,502
4.03125
4
#uppercase a string # string = 'strang' # string2 = string.upper() # string2 = 'yeet'.upper() # print(string2) #capitalize a string # string = 'strang gang' # string2 = list(string) # cap = string2[0] # string2.remove(cap) # string2.insert(0, cap.upper()) # final = ''.join(string2) # print(final) #...
7c1f942760ae059db2b48de811baf973a8cd8be4
Brunocfelix/Exercicios_Guanabara_Python
/Desafio 003.py
280
4.09375
4
#Crie um programa que leia dois números e mostra a soma entre eles, utilizando os tipos primitivos n1 = int(input('Digite um primeiro número: ')) n2 = int(input('Digite um segundo número: ')) s = n1 + n2 print('A soma entre {} e {} será {}'.format(n1, n2, s)) print(type(n1))
100680433b32392bf9c071e839a14eaa2cb3adbe
JeffVa1/MonteCarlo-AreaCalculator
/MonteCarlo_AreaCalculator.py
2,056
3.6875
4
import numpy as np import math import matplotlib.pyplot as plt import random #print("Monte Carlo integration method to compute the area of 2D donut") #print("============INFORMATION============") r_outer = 1 r_inner = 0.5 actual_area = (math.pi * r_outer * r_outer) - (math.pi * r_inner * r_inner) ''' print("Outer Ci...
5fad73d783659f89d48a5ed3282e4368c33e67f1
kantawat1156-github/allelab-procon
/Lab08PB_01.py
508
4.5
4
import math r = float(input("Enter a radius: ")) def circle(r): circle = math.pi * (r**2) return circle def circumference(r): circumference = 2 * math.pi * r return circumference def sphere(r): sphere = 4 / 3 * math.pi * (r ** 3) return sphere print("Area of a circle with radius %.2f ...
cb21a0306d30e2006f17975acd02bdc0c4a05c48
ultimate010/codes_and_notes
/133_longest-words/longest-words.py
577
3.671875
4
# coding:utf-8 ''' @Copyright:LintCode @Author: ultimate010 @Problem: http://www.lintcode.com/problem/longest-words @Language: Python @Datetime: 16-06-18 10:28 ''' class Solution: # @param dictionary: a list of strings # @return: a list of strings def longestWords(self, dictionary): # write ...
3176153befc5fc18cbc5215e36992b6e64e24bb7
zonghui0228/rosalind-solutions
/code/rosalind_inod.py
457
3.78125
4
# ^_^ utf-8: ^_^ """ Counting Phylogenetic Ancestors url: http://rosalind.info/problems/inod/ Given: A positive integer n (3≤n≤10000). Return: The number of internal nodes of any unrooted binary tree having n leaves. """ with open("../data/rosalind_inod.txt") as f: n = int(f.readline().strip()) # n = 4 print("th...
fb3318f64f23dc64daebdb37d4e1d56ff46148c7
Silocean/Codewars
/7ku_fizz_buzz.py
704
4.09375
4
''' Description: Return an array containing the numbers from 1 to N, where N is the parametered value. N will never be less than 1. Replace certain values however if any of the following conditions are met: If the value is a multiple of 3: use the value 'Fizz' instead If the value is a multiple of 5: use the value '...
197f71001b7130deecd20ee7f96116cbfdc5930b
emildi/QNLP
/modules/py/pkgs/QNLP/encoding/encoder_base.py
322
3.546875
4
from abc import ABC, abstractmethod #Abstract base class class EncoderBase(ABC): """Base class for binary encoding bitstring data""" def __init__(self): super().__init__() @abstractmethod def encode(self, bin_val): pass @abstractmethod def decode(self, bin_val): pa...
1a705d414c859de168285260a9122b6fecf939bb
caaare-ctrl/google-auto-dino
/main.py
1,028
3.921875
4
# https://elgoog.im/t-rex/ # You goal today is to write a Python script to automate the playing of this game. # Your program will look at the pixels on the screen to determine when it needs # to hit the space bar and play the game automatically. # You can see what it looks like when the game is automated with a bot: # ...
1662dc0d3e6a78f2d4ee16bd5760c9e7e332d883
Lokeshbalu/AttendanceMonitoringSystem
/mailserver/sendmail.py
1,157
3.625
4
import smtplib import sqlite3 from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText def sendmail(contacts): tolist=[] for data in contacts: conn=sqlite3.connect("database/attendance") c=conn.cursor() c.execute("select email from contacts where id="+str(data)) k=c.fetchall() l=k...
a9e0a458f957bb5ef5c8d0116d824db152f0401e
ShanDeneen/lesson2
/Adventure Game (Formative).py
3,571
4.25
4
vName=input("Please enter your name: ") print("Hello",vName) def tentacle(): print("You have been trapped inside a giant octopus's stomach.You can try and exit through any of the octopus's 8 tentacles.") choice= input("Choose a number between 1 & 8: ") if choice != "1" or "2" or "3" or "4" or "5" or "6" or ...
bdd39c7b6668d21b1208af82da40c9acc2e94186
ovchingus/optimization-methods
/linear-extremum-search-methods/1py/util.py
472
3.515625
4
from math import sqrt def sign(x): """ Return 1 if arg larger then 0, -1 is smaller then 0 """ return int(x > 0) gr = (1 + sqrt(5)) / 2 def naive_fib(n): if 0 <= n <= 1: return n else: return naive_fib(n - 1) + naive_fib(n - 2) def better_fib(n): if 0 <= n <= 1: ...
504dc6bfcaab29b603394fef88fb6746b3766eab
paweldabrowa1/automat_biletowy_mpk
/automat_biletowy_mpk/coins/coins_holder.py
2,434
3.8125
4
from automat_biletowy_mpk.coins import * class WrongAppendAmountException(Exception): """Throw when user gives negative number at CoinsHolder.append""" pass class WrongRemoveAmountException(Exception): """Throw when user gives positive number at CoinsHolder.remove""" pass class CoinsHolder: ""...
19cc319eb936384cf4fb5bc90be19d8aa3110488
Aasthaengg/IBMdataset
/Python_codes/p02699/s255579636.py
132
3.515625
4
val = input().split() sheep = int(val[0]) wolf = int(val[1]) if (wolf - sheep) >= 0: print("unsafe") else: print("safe")
725bad04a3d28723d4c8a1bb8ae69a213c65d899
dti-t-s/pythonScraping
/save_csv_join.py
376
3.78125
4
print('rank,city,population') # 2行目以降を書き出す join()メソッドの引数に渡すlistの要素はstrでなければならないことに注意 print(','.join(['1', '上海', '123'])) print(','.join(['2', 'カラチ', '123'])) print(','.join(['3', '北京', '123'])) print(','.join(['4', '天津', '123'])) print(','.join(['5', 'イスタンブル', '123']))
0b5a0c79639242c229cdf5c222db42ef9815e95b
FrankGuo22/Codeforces
/A295.py
348
3.5
4
# A295.py a = raw_input() string = raw_input() judge = 0 chk = {'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0,} for ch in string: if chk[ch.lower()] == 0: chk[ch.lower()] = 1 judge += 1 if judge == 26: p...
5e711633fdf4e7f11140244fffb097ffd8754054
rangerjo/python.casa
/examples/kap09-func/fibonacci.py
933
3.734375
4
#!/usr/bin/env python3 # herkömmliche Funktion, liefert die ersten n # Fibonacci-Zahlen def fiblst(n): a, b = 0, 1 result = [] for _ in range(n): result += [a] a, b = b, a+b return result print(fiblst(10)) # Ausgabe [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] # Generator-Funktion def fibgen...