blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ef0230eb8ce67b50a5d15c71f8422c9aed7bd6af
dingjiongfeng/data-structure-for-python
/task7/algarithm.py
4,862
3.890625
4
def climb_stair(n): if n==1: return 1 if n==2: return 2 return climb_stair(n-1)+climb_stair(n-2) climb_stair(4) def queen(queen_list, current_column=0): for row in range(len(queen_list)): # 如果已至最后一列,则打印结果,跳出递归 if current_column == len(queen_list): f...
1b863afb2574a20cb03ee0ba6b3afe5a10f7c1ff
Mario97popov/Python-Advanced
/Tuples and Sets excercise/Periodic_Table.py
673
3.65625
4
def input_to_list(count): lines = [] for _ in range(count): lines.append(input()) return lines def Convert(string): li = list(string.split(" ")) li.pop(0) return li def print_result(elements): for el in elements: print(el) n = int(input()) elements ...
c7346278f38e08249b02cc125e717b74bdab6d2f
aerospaceresearch/orbitdeterminator
/orbitdeterminator/util/input_transf.py
1,992
3.8125
4
''' Converts cartesian co-ordinates to spherical co-ordinates and vice versa ''' import sys import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) from util import read_data from math import * def cart_to_spher(data): ''' Takes as an input a data set containing poi...
96a808e8d3bf916436100d17778fb966107c1256
shuttle2021/Pandemic-Data-Analysis-LPU
/Contacts .py
3,647
4.15625
4
database = {"shuttle":9080590855,"barath":638383877,"hannah":6987237898} print("\nGreeting\'s from Vigneshwaram") print("Welcome to phoneBook\n") while True: print("Type EDIT to edit the contact number\n CREATE to create a new contact\n SEARCH to search a specific contact\n DELETE to Delete the con...
a67933fe9eba50d6a107eae8368a7852336c273d
ArcticZeroo/Semester-2-Projects
/JavaScript/NodeJS/Bots/Discord/channelbot/classes-2-small.py
955
4.0625
4
import math class Shape(object): def __init__(self, shape, perimeter, area): self.type = shape self.area = area self.perimeter = perimeter userShape = input("Please input the shape (circle/rectangle/square/triangle): ") shape = None if userShape == "rectangle": width = input("Please in...
f828226e7bdae1d5dd62bed262da8a35b7ca9ba5
JetSimon/Advent-of-Code-2017
/Day 12/day12.py
2,052
3.625
4
def connect(a, b): if(a not in b.connected): b.connected.append(a) if(b not in a.connected): a.connected.append(b) #print(a.id, " connected with ", b.id) def processData(): out = {} f = open('input.txt', 'r') for line in f: id = line.split("<->")[0].strip() out[...
8037babfa860e7aae93b8bb84578d503d72e9282
kungleakhana/bootcamp
/kung.leakhana19/week01/c19_str_mix.py
197
3.609375
4
a=input("Enter a word: ") if len(a)==0: print("0000") elif len(a)==1: print(a*4) elif len(a)==2: print(a*2) else: string1=a[1::-1] string2=a[-1:-3:-1] print(string1+string2)
8aa3be5ae81b918c318fc766418e573002e94570
Kings-Ggs-Arthers/CP3-Gun-siri
/assignments/Exercise11_Gun_S.py
207
3.9375
4
floorPyramid = int(input("Floor :")) for x in range(floorPyramid): print(" "*(floorPyramid - x),"*"*((x*2)+1)) for y in range(floorPyramid): print(" "*(y+1), "*"*((floorPyramid*2) - ((y*2)+1)))
13aaf6558deb9f4cdeef027306648eb0c5636d9d
KillianSan/Calculadora
/Calculadora V2.1.py
2,285
4.21875
4
def calculate(): operation = input(''' Calculadora do Matilha San: Por favor, escolha uma das operações e digite o simbolo dela, ou o nome e depois aperte ENTER: + adição - subtração * multiplicação / divisão Para reiniciar o programa, digite denov...
c8cd46b44ed7b910c322fc1f61dd70a79d46b445
UIHackyHour/AutomateTheBoringSweigart
/11-debugging/factorialLog.py
736
3.671875
4
# Find the bug. # Hint: Look at the output. import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') # logging.disable(logging.CRITICAL) ## The above line is commented to allow debugging print statements. ## Uncommenting that line will remove debug excess output fo...
1d6a660977a141c794ceca44fc77aa36b31c74ab
nicguindon/CSC462-distributed-image-processing
/yolo-object-detection/image_combiner.py
1,669
3.515625
4
# ----------------------------------------------------------------------------------------------------- # Images (Frames) to Video # Using this code we can generate video from Images (Frames). We have to add pathIn (path of the folder # which contains all the images). I set framerate with 0.5 so it will take 2 image...
76e993a39d6ff140986aca97a8ff990945e6c3ac
turkarshreyash/Cryptography
/lab2/python7.py
693
3.828125
4
def additiveCipher(input_string, key): input_string = input_string.lower() output_string = "" for i in input_string: if i == ' ': output_string += ' ' else: output_string += chr(((ord(i)+key-97)%26)+97) return output_string if __name__ == "__main__": input_s...
da4ea4edb32c878406429a4e7244c4cefe5cbf81
prateekiiest/Competitive-Programming-Algo-DS
/Interviewbit/binary_search/square_root.py
947
3.890625
4
# Problem Statement : https://www.interviewbit.com/courses/1/topics/4/problems/square-root-of-integer class Solution: # @param A : integer # @return an integer def sqrt(self, x): # Base cases if (x == 0 or x == 1) : return x # Do Binary Search for floor(sqrt(x)) ...
58b3d6a7b81b3ccbeb9f10180c9aced2a58938b0
Ngocdungnb/hoangngocdung-fundamentals-c4e23
/session3/password.py
333
4.09375
4
n = input(" password: ") while (len(n)<=8) or n.isalpha() or (n.isupper() or n.islower()) or n.isdigit(): print ("not ok") n = input(" password: ") if (len(n)<=8): print ("ngan qua") if n.ialpha(): print(" can so'") if (n.isupper() or n.islower()) or n.isdigit(): print ...
b39dabac1f05336177d48566071d509079d3a781
AdamZhouSE/pythonHomework
/Code/CodeRecords/2352/60605/299761.py
250
3.828125
4
x = input() if x == "2 2 4": print("0\n0\n0\n0") elif x == "1 1 1": print("0") elif x == "3 4 4": print("3\n2\n2\n2") elif x == "5 5 6": print("3\n2\n1\n1\n3\n2") elif x == "2 5 3": print("1\n2\n2") elif x == "1 10 3": print("1\n1\n1") else: print(x)
37f819f93585f85f03a8a3d8bf3c57d20ebcd59d
cjrzs/MyLeetCode
/查找常用字符.py
508
3.5
4
""" coding:utf8 @Time : : 2020/10/14 18:07 @Author : CJR @File : 查找常用字符.py 题目链接:https://leetcode-cn.com/problems/find-common-characters/ """ from collections import Counter from typing import List class Solution: def commonChars(self, A: List[str]) -> List[str]: # 使用python的内置库Counter,两两比较得出共有的元素 r...
0620545654440e0f27af5a22d469756d594ff308
kroebuck/sudoku
/sudoku.py
12,422
4.03125
4
import math from square import Square class Sudoku: """Takes in a sudoku puzzle to be solved.""" def __init__(self, init_data, box_size): self.valid = True self.length = len(init_data) self.box_size = box_size self.grid = [[Square(init_data[j][i], self.box_size) for i in range(...
87a71571ab03337682772b3beb240458c0aa71fa
anuradhaschougale18/PythonFiles
/28th day RegEx, Patterns, and Intro to Databases.py
685
4.25
4
''' Task Consider a database table, Emails, which has the attributes First Name and Email ID. Given N rows of data simulating the Emails table, print an alphabetically-ordered list of people whose email address ends in @gmail.com. ''' import math import os import random import re import sys if __name...
d56cd7daacf0bc377eeaae9e9ce16280a2ed6ee9
AldoFusterTurpin/coding-challenges
/insertANodeAtASpecificPositionInALinkedList.py
774
4.03125
4
# ALDO FUSTER TURPIN # For your reference: # # SinglyLinkedListNode: # int data # SinglyLinkedListNode next # Input: # 3 n # 16 a number of the linked list # 13 a number of the linked list # 7 a number of the linked list # 1 new number to insert # 2 position where to insert the new nu...
83fb4fef4f43026ad9140898eb423fe263ce4d94
Tubes-Daspro/Fungsi
/.github/workflows/F06.py
2,666
3.625
4
# F06 Menghapus Item dari Database def hapusitem(gadget,consumable): # Menghapus item dari repository. # Output: deletion of array of [integer,string,string,integer,string,integer] # KAMUS LOKAL # VARIABEL # ID : string (Input berupa id dari barang yang akan di delete.) # ver : stri...
b14de546f2da8e44a4de7ed59819f88c08e55b58
evidawei/Hacktoberfest2021-2
/Python/Designing Non-Deterministic Finite Automata.py
1,058
3.828125
4
def stateX(n): #if length of n become 0 #then print not accepted if(len(n)==0): print("string not accepted") else: #if at zero index #'a' found call #stateY function if (n[0]=='a'): stateY(n[1:]) #if at zero index #'b' then print #not accepted elif (n[0]=='b'): print("string not accep...
c2eb336754fc36ce7161adb13bad36deb6670829
spiderten/Python
/ex036.py
540
3.859375
4
print('\033[34mVamos analizar sua situação para emprestimo...') valorcasa = float(input('Digite o valor do imovel que você deseja comprar: ')) salario = float(input('Digite o seu salario: ')) anos = int(input('Digite em quantos anos você vai pagar essa casa: \033[m')) mensal = valorcasa / (anos*12) if mensal...
9eb5aa80f493aef3a003b6414e2c9603ab532c2f
sbburton/madlibs_atbs
/main.py
928
4.28125
4
#! python3 # Makes a silly madlibs from pathlib import Path print('What text file would you like to madlib?') inFile = open(input()) fileString = inFile.read() inFile.close() # Split String into list for analysis wordList = fileString.split() # Find words to replace in list, replace them with user input for i in ran...
5c221d1cb797d42cc8d1fface084c8f0b63ea3ea
makhmudislamov/cti_ips_2020
/mod2_math/excel.py
1,470
4.15625
4
""" Prompt Given a column title as appears in an Excel sheet, return its corresponding column number. Examples: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 UMPIRE walkthrough Understand: First, note down all key information. What is the key action? What is the input? What...
7cb9b6b2c0f3d4cef9cd39256fd362982bf08e6d
Jason0LiYaoCN/University-Assignments
/DataStructure_implementation/Linked List/recursion.py
1,214
3.921875
4
import turtle # my_turtle = turtle.Turtle() # my_win = turtle.Screen() # def draw_spiral(my_turtle, line_len): # if line_len > 0 : # my_turtle.forward(line_len) # my_turtle.right(90) # draw_spiral(my_turtle, line_len - 5) # draw_spiral(my_turtle, 14) # my_win.exitonclick() ...
9f26aa4302cbe6e4f39792bf476b16fd8663b6fe
kosmosmo/Osm2Maya
/convertor.py
834
3.71875
4
from math import sin, cos, sqrt, atan2, radians import math class Convert(object): def __init__(self,p1,p2): self.p1 = p1 self.p2 = p2 def latDis(self): R = 6373.0 lat1 = radians(self.p1[0]) lon1 = radians(self.p1[1]) lat2 = radians(self.p2[0]) lon2 = rad...
dbe0d3ce7a038390f59c1657a382f0174a46fa24
merecmoneyh/IA-Programa3
/Unicelular.py
3,303
3.625
4
"""Versión de Python utilizada 3.7.0 (Recomendado utilizar la consola de Linux o cmd en Windows) Integrantes: - Aco Guerrero Iván Rogelio - Ricardo Hernández Gómez - Hernández Arrieta Carlos Alberto - Hernández García Luis Angel Éste es un programa que simula el comportamiento de un autómata celular unidimensio...
39dd1f0e5c9ce40df1f81c39fd4db89c5347dac2
borisnimcevic/advent-2020
/day1/day1.py
506
3.640625
4
numbers = [] with open("input.txt", "r") as file: for line in file.readlines(): numbers.append(int(line)) def day1(): for i in range(len(numbers)): for j in range(i+1, len(numbers)): result = numbers[i] + numbers[j] if result == 2020: solution = numbers[i...
1da2ece6ce4c4d0c2c6a5f18be829ab84314645f
LuisMatheus/MachineLearning_Perceptron
/perceptron.py
1,421
3.5625
4
import numpy as np class Perceptron: def __init__(self, input_values , output_values , learning_rate , activation_function): oneColumns = np.ones((len(input_values), 1 )) * -1 self.input_values = np.append(oneColumns,input_values,axis=1) self.output_values = output_values sel...
1b26b9635f639f91cf7d6020bc9b9d1cecc3eb92
GISIS-UFF/RTM_python-fortran
/src/plot_binary.py
2,380
3.953125
4
#!/usr/bin/python # Plot 2D binary file. # This script import a 2D binary file # and plot as image # # INPUT: # filename = path with the 2D binary file. # dim1 = Number of elements in first dimension # dim2 = Number of elements in second dimension # # OUTPUT: # file ...
f2d878f3116492a6a72a22e82290423515b5d54d
swat199538/LeranPython
/list.py
1,828
4.3125
4
# __________________list的学习__________________ # 创建一个list classmate = ['he', 'mean', 'tef'] # 计算list的长度 a = len(classmate) print(a) # 获取list某个索引的值 print(classmate[0]) # list追加元素到末尾 classmate.append('zh') print(classmate) # list把元素插入到指定位置 classmate.insert(1, 'Jack') print(classmate) # list删除末尾元素 classmate.pop() pri...
ae42b4c852ab022a6eb723fbf1ff808febafca9c
Nikola123-coder/Python_kurs
/Zad_1.py
1,309
3.671875
4
''' Napisz program obsługujący bazę danych pracowników. W bazie danych przechowuj imię, nazwisko, email, rok urodzenia, pensję. Skorzystaj z modułu `json`. Przykład użycia:$ python employees.py Co chcesz zrobić? [d - dodaj, w - wypisz] d Imie: Jan Nazwisko: Nowak Rok urodzenia: 1980 Pensja: 5000.0 $ python ...
543c5d2d7492478e923f3cb8720dbf92a57a9be0
RKartik9/code-hack
/Python/calcy.py
1,047
4.15625
4
# Calculator using Python. # Adding two numbers def add(x, y): return x + y # Subtracting two numbers def subtract(x, y): return x - y # Multiplying two numbers def multiply(x, y): return x * y # Dividing two numbers def divide(x, y): return x / y print("Select operation.") print("1.Addition") pri...
f3bad4ce6904e1fac9a0962c64b56b0d7426b0e4
Marsters/skool
/Property Testing 26022021.py
663
3.75
4
class Dog(): def __init__(self, name, breed, size, length): self._name = name self._breed = breed self._size = size self._length = length def getSize(self): return self._size def setName(self, string): self._name = string def getName(self...
cebd5348b77308e2ffd47946ee52f91d0fd55735
Kingcitaldo125/Python-Files
/src/magnitude_and_dot.py
533
3.921875
4
def dot(x,y): """Returns the dot product of vector""" addedindex1 = 0 addedindex2 = 0 for i in x: addedindex1 += i for i in y: addedindex2 += i return addedindex1/addedindex2 vector1 = [5,4,7] vector2 = [1,7,6] index = 0 indexlist = [] for i in vector1: i**=2 index += ...
238b74a4e4624bc1f87cc9f18920fad5b886944c
nm1999/python-shape
/shape.py
128
3.609375
4
import turtle tur = turtle.Turtle() tur.color("red") tur.speed(1) for i in range(21): tur.forward(90) tur.left(10)
2c4cad36b484bb284eb660a1761402e93dd5347a
aecobb53/weatherman
/weatherman/sql_butler.py
8,275
3.53125
4
import sqlite3 import datetime import yaml class SQLButler: """ SQLButler handles data addition and extraction from the database. There is a csv database version that is designed to be completely compatable and interchangable but SQL is likely to be faster in the long run. """ def __init__(se...
edf7a8455e4a71a87be9143fd8904080a9a3aea5
gokhangg/pyPCE
/Test/ExampleFunctions.py
1,007
3.9375
4
TEST_MULTIVARFUNCTION_NUM = 2 def TestFunction0(input): return input[:, 0]**2 + 3 * input[:, 0] + 6 * input[:, 1] \ + input[:, 1]**3 + 7 * input[:, 2] + 1.5 * input[:, 2]**3 def TestFunction1(input): return input[:, 0]**2 + input[:, 1]**2 + input[:, 2]**2 + 7 * input[:, 1] \ + 6 ...
d5a9ff6ad3ab7ce85968d28beb6405a006705927
fivism/mibot
/hello_me.py
445
3.578125
4
## Hello World import sys import markovify lines = int(sys.argv[1]) # Get raw text with open("fixedlines.txt") as f: text = f.read() # Build model text_model = markovify.NewlineText(text) # # Print five randomly-generated sentences # for i in range(5): # print(text_model.make_sentence()) # Print three rando...
3ea92e06eea822d16ece96c1c7215e6206a51464
cjjhust/python_datastucture
/2-8-1.py
1,800
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 10 12:39:46 2018 @author: CJJ """ from collections import deque class LRU: def __init__(self,cacheSize): self.cacheSize=cacheSize self.queue=deque() self.hashSet=set() # 判断缓存队列是否已满 def isQueueFull(self): return len(self...
714395e2b84ddece11a45ec78b179672ad31516b
Nandini457/Guessing-game-
/nandini.py
517
4.125
4
print('this is guessing game') import random random_number = random.randrange(1,10) guess = int(input("what could be the number")) correct = False print(random_number) while not correct: if guess==random_number: print("congrats you gotr it") correct = True elif guess>random_number: ...
481182e149704b7fe92d2f7b2247a9a10a7f8005
jkbockstael/leetcode
/2020-08-month-long-challenge/day02.py
1,622
3.984375
4
#!/usr/bin/env python3 # Day 2: Design HashSet # # Design a HashSet without using any built-in hash table libraries. # # To be specific, your design should include these functions: # - add(value): Insert a value into the HashSet. # - contains(value) : Return whether the value exists in the HashSet or not. # - remove(...
19f204dd4bd4cb0fa7339cd5389d7a6321fb3879
magicalsoup/Python
/Graphics/Introduction To Python Graphics/Functions With Parameters/FunctionOfSeveralParameters.py
167
4.09375
4
import turtle def draw_Shape(sides,length): for i in range (sides): turtle.forward(length) turtle.left(360 / sides) draw_Shape(3, 100)
da4f3d9d763fecfb2b4f3fc692ed8b1a7ba9629a
zying16/CSNote
/geektime/数据结构与算法之美/_08_ListStack.py
674
3.59375
4
class ListStack: def __init__(self, n: int): self.items = [] self._capacity = n self.count = 0 def push(self, item): if self.count >= self._capacity: return self.items.append(item) self.count += 1 def pop(self): if self.count == 0: ...
1b5dd264887c1860a67ea46b2158301b1352b12a
chunisama/leetcode
/EoP - Python/W3D1/find_longest_nondecreasing_subseq.py
1,244
4.25
4
# The problem of finding the longest nondecreasing subsequence in a sequence of integers has implications to many # disciplines, including string matching and analyzing card games. As a concrete instance, the length of a longest # nondecreasing subsequence for the array in Figure 16.15 is 4. There are multiple longes...
dea81517cfb9ec5d4f0df637a258303a8ef31bf1
vikasvaish21/Data-structures-and-algorithms-Nanodegree
/P02/Problem_4.py
1,189
4.0625
4
def sort_012(input_list): """ Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal. Args: input_list(list): List to be sorted """ front_index = 0 last_index = len(input_list)-1 mid_index = 0 while mid_index <= last_index: if input_list...
2671d0c3f61d538137ea0d672cf35d3ac75de9ed
pranithmacha/PythonExamples
/prime copy.py
559
4.46875
4
# method to check if a number is prime def check_prime(number): if number % 2 == 0 or number % 3 == 0: print 'not a prime' else: print 'prime' # method to check if a string is palindrome or not def check_palindrome(string): status = True if len(string) == 1 or len(string) == 0: status = True els...
d14bcc0bf41c93eed8c373ee4b3f520211b35133
paige0701/studyAlone
/python/python-as-calculator/lists.py
657
4.375
4
# List are comma separated values enclosed in square brackets squares = [1, 4, 5, 6, 9, 15] print(squares) # Just like strings, arrays can be indexed using numbers print('Find third item in list using number 2 => {0}'.format(squares[2])) # 5 print('Find last item in list using index -1 => {0}'.format(squares[-1])) #...
11a74c737ac08e3ad86fb95bfb26b04f34d705dd
lidiadx/python-mitx-6001x
/lowestPayment.py
595
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Sep 22 13:34:36 2017 @author: iya """ balance = 3926 annualInterestRate = 0.2 monthlyInterestRate = annualInterestRate/12 monthlyPayment = 10 testBalance = balance while True: for month in range(1, 13): unpaidBalance = balance - monthlyP...
2a948dd7cf61dcc754f52194841b11236e0f4686
KevinKnott/Coding-Review
/Month 01/Week 02/Day 06/a.py
2,650
3.90625
4
# Decode Ways: https://leetcode.com/problems/decode-ways/ # A message containing letters from A-Z can be encoded into numbers using the following mapping: # 'A' -> "1" # 'B' -> "2" # ... # 'Z' -> "26" # To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the...
9afe7ab64ebbca9e506e41ad5058c551124c1780
olafurs17/Python-files
/assignment4_6.py
748
4
4
''' Write a Python program using for loops that, given an integer n, prints all the perfect numbers from 1 to n. A perfect number is an integer whose sum of integer divisiors (excluding the number itself) add up to the number. For example, 6 is a perfect number because the sum of its integer divisors (1+2+3) is equal...
64b238886fdec10f1ef2d9f47e43942c228486c1
avm99963/programmingclub
/restaurante_advanced.py
686
3.875
4
import readline foodAlreadyRequested = [] foodAvailable = ["banana", "cookies", "pizza", "macarrones"] def requestFood(food): if food in foodAlreadyRequested: print("I think you've already ordered "+food+".") elif food in foodAvailable: print("You ordered "+food+".") foodAlreadyRequest...
984add77a9c4c18dd88cb45ee0be73377228c692
yodeng/sw-algorithms
/python/linked_list/delete_node_single_linked_list.py
1,086
4.09375
4
#!/usr/bin/env python # encoding: utf-8 """ @author: swensun @github:https://github.com/yunshuipiao @software: python @file: delete_node_single_linked_list.py @time: 2018/1/16 15:11 @desc: 删除单向链表的节点(不可以是尾节点),参数只有节点这个元素, O(1) @hint: 在插入和删除节点,都是需要找到需要插入和删除元素的前一个节点进行操作。因此可以把要删除的节点变为前一个节点。 """ from singly_linked_...
8edaf29b4577bbd0f818c10a95211a1d43bc8c89
nemmiz/aoc2019
/python/03.py
1,862
3.734375
4
#!/usr/bin/python3 def wire_points(wire_def): x, y, dx, dy = 0, 0, 0, 0 points = [] steps = wire_def.split(',') for step in steps: direction = step[0] amount = int(step[1:]) if direction == 'U': dx, dy = 0, -1 elif direction == 'D': dx, dy = 0, 1...
d83ec49eb31a3a04bc1566c8bc10e7a6e1ed129e
bkdbansal/CS_basics
/leetcode_python/Recursion/second-minimum-node-in-a-binary-tree.py
2,615
3.703125
4
# V0 : DEV # V1 # http://bookshadow.com/weblog/2017/09/03/leetcode-second-minimum-node-in-a-binary-tree/ # 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 findSecond...
e539ea09c5cb2911ef65250f5b36513100e7d9c5
limeiyang/python-study
/2.字符串.py
830
4.09375
4
# 长字符 (双引号和单引号一样) str01 = "my name is limeiyang my name is limeiyang my name is limeiyang my name is limeiyang " str02 = "my name is limeiyang " \ "my name is limeiyang my name is limeiyang my name is limeiyang " # 直接换行,自动加 \ str03 = """ 原格式输出 原格式 哦! """ print("str01为", str01) ...
d4664ce03941112fada1f091dfa7897ffe6d0ce5
JDaisy/LeetCode
/simple_141.py
855
3.984375
4
#coding=utf-8 ''' 题目:给定一个链表,判断链表中是否有环 解题思路1:依次遍历每个节点,并将该节点放入set中,每次遍历节点时看set中是否已存在该节点,若存在则有环,若不存在则无环 解题思路2: 定义两个指针,一快一慢,快的每次走两步,慢的每次走一步,如果有环,则两指针必定会相遇 ''' class Node(): def __init__(self, data=None, next=None): self.data = data self.next = next def solution(self, head): fast = head...
5d88b6f61865cb0d37da905a573fbae4f57721ed
lnandi1/Subroutines_23SEP2018
/Password_program.py
6,476
4.3125
4
############################################### ################ ### This Program Assigns a Score and Strength# ### to a Password ############################ ############################################### ## Importing APIs' import random import re ### Display Menu def Display_Menu(): print...
af26c36f603f85d1adfc70bb3b6b57669ae760e8
jeevano/py-astar
/main.py
6,995
3.640625
4
import pygame # constants BLACK = (0, 0, 0) WHITE = (255, 255, 255) LIGHT_GREY = (100, 100, 100) DARK_GREY = (200, 200, 200) RED = (255, 0, 0) BLUE = (0, 0, 255) PURPLE = (200, 0, 255) WINDOW_WIDTH = 400 # width of window WIDTH = 20 # num of cells in grid WINDOW = pygame.display.set_mode((WINDOW_WIDTH, WIN...
eb83c7690a08c70cee48fe6ce30f80d17f12447e
reurc/StockAppPy
/PycharmProjects/StockApp/main.py
597
3.5
4
from urllib.request import urlopen; import json symbol = input('Please enter symbol name: '); shares = float(input('Please enter number of shares: ')); url = urlopen('https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=' + symbol +'&outputsize=compact&apikey=KIH6VFJ03Z89T5DI'); str_response = url.read...
347224bbe3267c12975a50a94a8ad07c293d4ef0
ZainChen/algorithm
/LeetCode/1480. Running Sum of 1d Array/python3-1.py
397
3.71875
4
class Solution(object): def runningSum(self, nums): """ :type nums: List[int] :rtype: List[int] """ k = 0 result = [] for i in nums: k += i result.append(k) return result if __name__ == '__main__': nums = [1, 2, 3, 4] s...
e0f2b03c0f2cf7172547b369d4adbc69e73d1258
cce2955/Dump
/numbersort.py
1,153
3.859375
4
#Poet and the Pendelum solution #Inspired by a codewars problem #This program will take a set of inputs from a user and sort them from lowest to highest #After that it will place the lowest number in the center of the list, the second highest next to it, the next highest to the right of that, etc. #Example is a set of ...
1635c1553623992a4963fea5c496e3ef0c09343f
zepler2011/leetcode_solution
/zshen/dp-longest-max/longest-increasing-subsequence-lc76-dp.py
1,073
3.6875
4
class Solution: """ @param nums: An integer array @return: The length of LIS (longest increasing subsequence) """ def longestIncreasingSubsequence(self, A): # write your code here if not A: return 0 n = len(A) f = [1] * n t = [-1] * n ...
f708a3e159682563a5569c314f003b5b3fbc19e1
Aditya20kul/Python-Fun-Scripts
/github-stats.py
3,151
3.5
4
#Script that displays the useful information about the required user ######################### Created By - Aditya Kulkarni ##################### # # # LinkedIn Profile Link - https://www.linkedin.com/in/adityakulkarni20/ # # # # ###########################...
6aa0bd6929f1bacbcbe1d2b6cbd3a6cd134727fe
IsaVV/Python
/2.py
636
4.15625
4
#2. Faça um programa que calcule a raiz quadrada de um número, caso o número informado #for negativo, a exceção deve ser tratada, caso a entrada não for um número, #a exceção também deverá ser tratada. #O programa só irá finalizar após o usuário digitar uma entrada válida. #O valor da raiz quadrada deve ser exibido...
1f24e176bd5ae5eb5747ab780068044656c118aa
jonathankamau/my-dsa-snippets
/assessment_feedback_implementation/graph.py
2,836
4.0625
4
"""Graph initialization.""" class Node(object): """Create a new node object.""" def __init__(self, value): self.value = value self.edges = [] self.visited = False self.total_cost = 0 self.distance_from_start = 0 self.heuristic = 0 class Edge(object): """C...
2dc9e1ee1e570399a9427c723cb3d7c3a403239b
AmikDon/Library-Management-System
/burrow.py
7,589
4.4375
4
#this module does the burrowing process. A function is defined which asks the user his/her name and the Book ID he/she wants to burrow. #If the user inputs invalid ID, then the program asks the user to input a valid ID. #If the required book is not available, the program tells that the required book is not available....
e061834e0fc669c6e14635bce37a2d32117b0abd
altraman00/mdl_python
/learn_python/basedemo/test10.py
316
3.9375
4
#!/usr/bin/python3 listStr = [(123, 1), (345, 3), (234, 2)] tul_1 = (1, 2, 3) tul_2 = (11, 12, 13) tul = tul_1 + tul_2 print('before : ',tul) ltulList = list(tul) print('after : ',ltulList) print('before turn tuple', listStr) listToTuplStr = tuple(listStr) print('after turn tuple', listToTuplStr)
f8979518b0c3fabde6f1c8d5dca8f4fcf25f2b4b
Arcnet505/Collatz-Conjecture
/CollatzConjecture.py
983
3.875
4
import matplotlib.pyplot as plt from matplotlib import style style.use('fivethirtyeight') plt.xlabel('Iteration') plt.ylabel('Value') num_array = [] def calc(x): while x != 1: if x % 2 == 0: x /= 2 x = int(x) else: x = 3 * x + 1 num_arra...
403cbd2da4d2b885d16d4127007f2e2f9f01a47d
ChWeiking/PythonTutorial
/Python基础/day02(注释、变量、运算符)/demo/练习/06_比较运算符,逻辑运算符.py
188
3.859375
4
#比较运算符 l = 10 ll = 10 print(l==ll,l!=ll,l>ll,l<ll,l>=ll,l<=ll) #逻辑运算符 a = True b = False print(a and b,a or b,not a, not b) print(a and 10,b and 10,a or 10, b or 10)
81125a2c8610d4531755bb4a53cb19aa3d946c96
lebuingockhang123/L-p-tr-nh-python
/LeBuiNgocKhang_53157_CH04/Projects/page_132_exercise_02.py
640
4.40625
4
""" Author: Le Bui Ngoc Khang Date: 12/07/1997 Program: Write a script that inputs a line of encrypted text and a distance value and outputs plaintext using a Caesar cipher. The script should work for any printable characters Solution: Enter the coded text: khoor#zruog Enter the distance value: 3 hello world """ # R...
7287cb6ba3caf87cdb019bfa44cdf00676f8739d
VineeshaKasam/Leetcode
/maxDepthBinaryTree.py
703
3.796875
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 maxDepth(self, root): # node = root # while node.left!=None or node.right!=None: # if node.left!=N...
128d8703ff56cc7214212adce5ef47c15a40da7b
IvanOmel/Homework_python_cur
/chapter_02/Task9.py
299
4
4
temperature_in_Celsius_scale = float(input("показания температуры по шкале Цельсия: ")) fahrenheit_temperature = ((9 / 5) * temperature_in_Celsius_scale) + 32 print("температурa по шкале Фаренгейта: ", round(fahrenheit_temperature, 3))
2d47920b9762ae94660bb9dd84b5f36e15e133d9
kanuos/python-programs
/String 2/double_char.py
304
4.3125
4
# Given a string, return a string where for every char in the original, there are two chars. def double_char(string): result = "" for char in string: result += char * 2 print(f"double_char('{string}') -> '{result}'") double_char('The') double_char('AAbb') double_char('Hi-There')
72241acb27426be35c274db55e2fb217a751deae
gezav88/repo-to-fork
/OmarSantaCruz.py
1,187
3.71875
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: # In[4]: def fib(n): a, b = 0,1 while a < n: print(a) a, b = b, a + b # In[8]: def primos(n): numbers = [True, True] + [True] * (n-1) last_prime_number = 2 i = last_prime_number while last_prime_number**2 <= n: ...
070daa6ec1a56ce348cceb3d0f412f0335a6471c
pavdemesh/stepik_67
/stepik_67_ex_3_7_cypher.py
475
3.75
4
source_line = input() target_line = input() line_to_encode = input() line_to_decode = input() dict_encode = {} dict_decode = {} for i in range(len(source_line)): dict_encode[source_line[i]] = target_line[i] dict_decode[target_line[i]] = source_line[i] encoded_line = '' decoded_line = '' for char in line_to...
da54208d5b85256f5034f044aaca6cae9d9db98d
ppinko/python_exercises
/dynamic_programming/longest_path_in_matrix/longest_path_in_matrix_first_solution.py
1,870
4.15625
4
""" https://www.geeksforgeeks.org/find-the-longest-path-in-a-matrix-with-given-constraints/ Find the longest path in a matrix with given constraints Given a n*n matrix where all numbers are distinct, find the maximum length path (starting from any cell) such that all cells along the path are in increasing order with...
b6e7f32363939e0b9bd922ca580aadb9fc47295c
Jaeker0512/gocrack-algorithm
/二叉树专辑/863.二叉树中所有距离为-k-的结点.py
2,450
3.8125
4
# # @lc app=leetcode.cn id=863 lang=python3 # # [863] 二叉树中所有距离为 K 的结点 # # https://leetcode-cn.com/problems/all-nodes-distance-k-in-binary-tree/description/ # # algorithms # Medium (53.72%) # Likes: 223 # Dislikes: 0 # Total Accepted: 10.2K # Total Submissions: 19K # Testcase Example: '[3,5,1,6,2,0,8,null,null,7,...
9a20b1f98a6b108b83517b3d83011a428bd34a9c
janselroa/Ejercicios-Python
/ejercicio9.py
331
3.9375
4
"""un programa que pida dos números por teclado y devolver el número más alto de los dos introducidos """ num1=int(input("Introduce el primer valor:\n")) num2=int(input("Introduce el segundo valor:\n")) print("El resultado es:") if num1 >num2: print(num1) elif num1<num2: print(num2) else: print("Son ig...
4a2d0213cdff08b03d2b4797afe3a4e0cf6263ed
ahmadmowalad/python
/operators.py
122
3.875
4
num1=5 num2=6 print(num1<num2) print(num1>num2) print(True and True) num=[1,2,3,4,5,6,7,8,9,9,9,8,3,4,5,6] print(num)
1ffd41bc0fdb71fe6256397da2f9421b024ed961
Leahxuliu/Data-Structure-And-Algorithm
/Python/DP/375.Guess Number Higher or Lower II.py
2,278
3.625
4
# !/usr/bin/python # -*- coding: utf-8 -*- # @Time : 2020/04/15 # @Author : XU Liu # @FileName: 375.Guess Number Higher or Lower II.py ''' 1. 题目类型: 2. 题目要求与理解: 猜数字,猜错付猜的数字额度的钱 求至少需要拥有多少现金才能确保赢钱 由于要求最坏情况,所以左右两个区间,应取最大花费。最坏情况下,要尽可能少花费,所以最终要取所有最坏情况下的最小花费值。 3. 解题思路: 方案一:二分搜索 方案二:DP 4. 输出输入以及...
8f3196e6180f768f5dd67d5fbdff6013abac9c39
tercio/AlgorithmsAndDataStructures
/sign.py
279
3.78125
4
#with open('dictionary.txt',"r") as fd: #data= fd.read().splitlines() #for word in data: # print ("".join(sorted(word))," ",word) with open('dictionary.txt',"r") as fd: for word in fd: word = word.rstrip("\n") print ("".join(sorted(word))," ",word)
a7f79f2a4e4b820ff90968ec072dfac6c0d2339e
bossiernesto/python-snipplets
/prime_number.py
766
3.546875
4
class PrimeNumberList(object): def __init__(self, longitude): self.longitude = longitude self.array = bytearray(longitude) def iterateValues(self): for value in range(2, self.longitude): i=2 while i*value <= self.longitude-1: self.array[i*value] ...
135a186f3f3f76a5f84e21f1610c22dd33776015
shawntzx/Python_Visualizaiton_Tutorial-EDAV_CC_Group15-
/EDAV Community Contribution.py
16,205
3.875
4
#!/usr/bin/env python # coding: utf-8 # Zixiang Tang zt2292 & Chenxi Jiang cj2706 # In[2]: import numpy as np import pandas as pd import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # ### Tutorial On Commonly Used Plots # # Load Dataset Index Crimes by County and Agency: Beginni...
68a221945803b9ed533bc9522777c35ec6612c09
YunaQiu/jianzhi
/[9]斐波那契数列.py
1,118
4
4
# -*- coding: utf-8 -*- ''' 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。 n<=39 ''' def fibonacci(n): if n==0: return 0 if n==1: return 1 x1, x2, i, f = 0, 1, 2, 1 while i <= n: f = x1 + x2 x1 = x2 x2 = f i += 1 return f ''' 思路:斐波那契数列公式为f(n)=f(...
6b75a28fb5e3b0b1c24952429dbbc593a6248749
rodoufu/challenges
/HackerRank/interview/hashmaps/RansomNote.py
876
3.65625
4
#!/bin/python3 import math import os import random import re import sys # Complete the checkMagazine function below. def checkMagazine(magazine, note): magazine_dit = dict() for x in magazine: magazine_dit[x] = magazine_dit.get(x, 0) + 1 for x in note: if x not in magazine_dit or magazine_dit[x] == 0: retu...
9479df3879444f312fe2c23571aafad8dacfc954
JoaoLima-21906948/python_pw_21
/Ficha3/exercicio_3/main.py
916
3.734375
4
import os def pede_pasta(): while True: pathAtual = os.getcwd() path = input("Insira o path do ficheiro:") if os.path.exists(path): return path else: pathJunto = pathAtual + "\\" + path if os.path.exists(pathJunto): retu...
20c0849065b98ce240abd0680c51c9d19fcb57a6
arogovoy/leetcode
/py/climbing-stairs.py
384
3.65625
4
# 70. Climbing Stairs class Solution: def climbStairs(self, n: int) -> int: sum_left, sum_right = 1, 1 for x in range(2, n + 1, 1): sum_right, sum_left = sum_left, sum_left + sum_right return sum_left if __name__ == '__main__': res = Solution().climbStairs(2) print(res...
fca840a2092521f4d652ff43bf9accdc51fa559e
echocho/Leetcode
/Leetcode541_reverseString.py
307
3.625
4
# Leetcode541_reverseString.py def reverseStr(s, k): ''' :type s: str :type k: int :rtype: str ''' lst = list(s) for i in range(0, len(lst), 2*k): lst[i:i+k] = lst[i:i+k][::-1] # or reversed(lst[i:i+k]) return ''.join(lst) print(reverseStr('abcdefg', 2))
ba1d07f5ac2a7ce58ceda0951cfea6b928cc1d6a
collyrium921/tathastu_week_of_code
/day1/program2.py
104
4.3125
4
from math import sqrt x = int(input("Enter the number: ")) print("Square root of number is: ", sqrt(x))
fc1d6bd93fa2ec99e5d51e92ed144c9ed6a5217e
flacogabrielc/Selenium_Python
/Clase 2/for.py
169
3.859375
4
#de menor a mayor #for numero in range(10, 21, 2): #de mayor a menor #for numero in range(20, 10, -2): #del 10 al 20 de 2 en 2 print(numero) print(numero*5)
93c894173a78d632b6eaec62caf08f73a2ea1693
haozaijie/leeeeeetcode
/algo/1_Two_Sum.py
728
3.65625
4
# method 1 - brute force, the complexity is O(n^2) class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)-1): for j in range(i+1, len(nums)): if nums[i]+nums[j]==target: return [i,j] # method 2 - create a value ...
5d6f784a7da78aafbed4317c2482f70d2ac780d7
ohmozi/Algorithm
/Python/BOJ/2108.py
907
3.75
4
import sys from collections import Counter #빈도수 셀때 사용가능 N = int(sys.stdin.readline()) num_list=[] for i in range(N): num_list.append(int(sys.stdin.readline())) num_list.sort() def mean(list): print(round(sum(list)/len(list))) #round함수에 파라미터 안주면 소수첫째자리 반올림 def median(list): print(list[le...
80b484fa7238fd6fef57998541c771789c19d0ec
TonyDeng0514/cs107_lab3
/intersection.py
1,290
3.9375
4
""" List Comprehension (and loops) for the intersection of two lists Here are some test cases, please add others, esp. extreme cases. Beware, the first answer may be in any order and still correct -- jd >>> in_common(['NJ', 'PA', 'CA', 'WA'],['WA', 'PA', 'GA', 'VA']) ['PA', 'WA'] >>> in_common(['NJ', 'PA', 'CA', 'W...
b54bf446eace43febe64991342a5471515c39d95
Cc3sar/cursoPython
/archivos_txt_ejercicios/ejercicios_txt/horasminutossegundos.py
278
3.78125
4
segundos = input("Ingrese la cantidad de segundos: ") segundos = int(segundos) minutos = segundos // 60 segundos_resto = segundos % 60 horas = minutos // 60 minutos_resto = minutos % 60 print("tiempo: ", horas, "horas,", minutos_resto, "minutos,", segundos_resto, "segundos")
20e14df0ba78a16c7ab9b144bf53677c873ae8b4
gsy/leetcode
/is_anagram.py
656
3.6875
4
# -*- coding: utf-8 -*- class Solution: def word_count(self, word): count = {} for char in word: count[char] = count.get(char, 0) + 1 return count def isAnagram(self, s, t): if len(s) != len(t): return False count_s = self.word_count(s) ...
d600a01bf7e827d28ab7edb88687ecf9ca702313
necsi/database
/google-sheets-downloads/detailed_data_countries.py
3,066
3.6875
4
import requests import csv import pandas as pd from contextlib import closing import codecs import numpy as np def download_csv_to_dataframe(url): """ Download a CSV file and return a Pandas DataFrame. :param url: str :return: pandas.DataFrame """ with closing(requests.get(url, stream=True)) ...
1769c9dfc6bdefd6fd47ecbbb4407d8ff03c5d6b
yurifariasg/PyDestruction
/Source/PathNode.py
2,329
3.5
4
import math import Map class PathNode(object): def __init__(self, rect, isBlocked = False): self.adjacentNodes = [] self.rect = rect self.blocked = isBlocked self.parent = None # This will only be used on PathFinding Algorithms def addAdjacentNode(self, node): self...
77282b7807ab1894ec838d840ae216cd6eb29253
jonathanmann/leetcode
/python2/isMatch.py
2,739
3.65625
4
class Solution: def isMatch(self,s,p): """ :type s: str :type p: str :rtype: bool """ p = self.simplify(p) if self.fails_reqs(s,p): return False else: return self.isMatchR(s,p) def isMatchR(self,s,p): if len(p) ==...
fa7cab9956b37a647976198a22edb0baac0b21b5
edavanhalen/practices
/sum.py
569
4.3125
4
while True: try: n = int(input(" Please enter a number : ")) even_total = 0 odd_total = 0 except ValueError: print("This is not a number. Please enter a number.") continue for number in range(1, n + 1): if(number %2 == 0): even_total = even_total ...