blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
f8bcfb87dd564bd702bdcdcdf57c7aa2b4c35a4c
Inaguma1110/ProgTech2018
/as5/ans/p1.py
67
3.515625
4
a = input() if a == "Toyota": print("A") else: print("B")
006c527539deef32db46c9a6255620889f8fa46e
Liana03/Python-Tutorials
/Homework_7_checked.py
4,594
4.375
4
"""RECURSION""" import math # 1. Write a recursive function to calculate the sum of reciprocals of powers of 2. Try increasing the n and see the # magic. # Գրել ռեկուրսիվ ֆունկցիա, որը կհաշվի երկրաչափական գումարը, որտեղ r = 1 / 2 է։ Փորձեք բացրձրացնել n-ի արժեքը հետաքրքիր # արդյունք ստանալու համար։ #Պահանջը չեմ հ...
c9c406d647be8bd161d76c5ded0b0a79828d11b4
Mishebah/Python-Snippets
/floatFormat.py
656
3.921875
4
'''Test float formatting.''' x = 23.457413902458498 print(x, 'to 5 places:', format(x, '.5f'), 'to 2 places:', format(x, '.2f')) x = 2.876543 y = 16.3591 print('x:', x, 'y:', y) print('x long: {:.5f}, x short: {:.3f}, y: {:.2f}.'.format(x, x, y)) print('Same from locals dictionary:')...
cc268314fcb38ba18415973af2c958f8ee450659
samir-0711/Leetcode-Python
/48. Rotate Image.py
2,244
4.46875
4
""" You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. Example 1: Given input matrix = [ [1,2,3], [4,5...
280ee1c490758a3461abc9802165133964362cc4
lfdyf20/Leetcode
/Path Sum II.py
815
3.5625
4
class Solution(object): def pathSum(self, root, target): """ :type root: TreeNode :type sum: int :rtype: List[List[int]] """ res = [] def dfs(node, target, path): if not node: return if not node.left and not node.right: ...
1fc05a89981e600f2da4f3008d9b52ddb836d598
DaviDosCompiuter/Robo-Raspberry-Pi
/Software/Carrinho.py
1,732
3.859375
4
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library from time import sleep # Import the sleep function from the time module GPIO.setwarnings(False) # Ignore warning for now GPIO.setmode(GPIO.BOARD) # Use physical pin numbering GPIO.setup(3, GPIO.OUT, initial=GPIO.LOW) # Set pin 8 to be an output pin and s$ GPIO....
2519cac969dbd311788610823b0e8c17794ac5b0
Tamabcxyz/Python
/th1/testmymind.py
178
3.75
4
# test my mind I don't know it's true or false a=input("nhap so") if int(a)>1: print(a); a=int(a)+1 print("day la a sau if ",a) else: print("day la a sau if ",a)
e2cc0a9e3de8dac6a4fd88b3615b482d17966ca4
Ercion/learning_python
/print_debugging.py
435
3.953125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 17 20:29:15 2020 @author: Ercan Karaçelik """ def add(L): ''' Adds the integer items of a list ''' size =len(L) total=0 iterator=0 print('Reached the wile loop') while iterator < size: total +=L[iterator] i...
e3ca9a878edb4161a68461ec161be9382252bb2e
newpheeraphat/banana
/Algorithms/Dictionary/T_FindValuesInKey.py
136
3.671875
4
def find_values_in_key(dict1): if str1 in dict2.values(): for key in dict2: if str1 == dict2[key]: return key
bac27fecfd7183d55366628346c87a0e141e2afb
eduardogomezvidela/Summer-Intro
/10 Lists/Excersises/16.py
712
4.1875
4
"""Starting with the list of the previous exercise, write Python statements to do the following: Append “apple” and 76 to the list. Insert the value “cat” at position 3. Insert the value 99 at the start of the list. Find the index of “hello”. Count the number of 76s in the list. Remove the first occurrence of 76 from ...
e809c82492890189b078b0a0a754824d0b07b69f
anumala2/cs3b
/CS3B/midterm-2.py
654
3.5
4
#program1 """ file_in = open("twotest.txt", "r") lines = file_in.readlines() file_in.close() file_out = open("delta.txt","w") for index in range(0, len(lines)): file_out.write(lines[index]) file_out.close() #program2 file_in = open("twotest.txt", "r") lines = file_in.readlines() file_in.close() file_o...
b4b97dfe220d799e8e0e65c7c9e33aff0dc255e5
yzl232/code_training
/mianJing111111/Google/Remove “b” and “ac” from a given string.py
1,730
4.0625
4
# encoding=utf-8 #Google考过 ''' Remove “b” and “ac” from a given string Given a string, eliminate all “b” and “ac” in the string, you have to replace them in-place, and you are only allowed to iterate over the string once. (Source Google Interview Question) Examples: acbac ==> "" aaac ==> aa ababac ==> ...
95b99e52e2882b787080e52f012ae367f4908ab6
sheriline/python
/D9/Activities/roman.py
946
4
4
# Patrick Banares # using classes, write a python program that converts a roman numeral to integer class Roman_numeral_to_int: def __init__(self, numeral): self.numeral = numeral def convert(self): roman_numerals = { "I": 1, "V": 5, "X": 10, "L"...
cd0ba64c9f98c774487c499f79abb75cd170cbb5
Noorul834/PIAIC
/assignment14.py
363
4.09375
4
# 14. Digits Sum of a Number # Write a Python program to calculate the sum of the digits in an integer # Program Console Sample 1: # Enter a number: 15 # Sum of 1 + 5 is 6 # Program Console Sample 2: # Enter a number: 1234 # Sum of 1 + 2 + 3 + 4 is 10 num=input("Enter any num: ") sum=0 for s in num: su...
2d114f9d26752940d9e23be1b2bf670086c874f4
flinteller/unit_three
/d4_unit_three_warmups.py
307
4.03125
4
def area_of_rectangle(length, width): """ This function multiplies the long side times the short side to get the area :param length: long side of rectangle :param width: short side of rectangle :return:returns area of rectangle returned """ area = length * width return area
32d20d5ea2cac30711a02ca63cd359711354aadc
pieterDekker/modeling-and-simulation-2020
/init.py
4,958
3.96875
4
from math import cos, pi, pow, radians, sin, sqrt import numpy from numpy.core.numeric import Inf def initialize(masses, eccentricities, rmin, thetadeg, nrings, ninner, ring_spacing, ngal, maxp): """ Initializes the simulation Parameters ---------- masses : list The masses of each galaxy eccentrici...
cd702451429b1d134f4e14df57d24fb646e241f2
saravankumar777/fibonoci
/primernot.py
252
4.25
4
##check the number is prime are not## num=int(raw_input("Enter a Number:")) if num > 1: for i in range (2,num): if (num%i)==0: print(num,"is not a primenumber") break else: print(num,"is a prime number")
73c6fecb46ca0a16a3c4fa85d52d2bbd94cfa704
ColinFendrick/cleaning-data-in-python
/cleaning-data-for-analysis/extracting-numerical-values-from-strings.py
168
3.78125
4
import re # Find the numeric values: matches matches = re.findall( '\d+', 'the recipe calls for 10 strawberries and 1 banana') # Print the matches print(matches)
d454cd1ab90ab69d94d00177433efbdf4c0265bd
brunodantascg/listaExercicioPythonBR
/2_Estrutura_Decisão (novo)/6estD.py
489
3.96875
4
# 6 - Faça um Programa que leia três números e mostre o maior deles. msn = str("Informe ") msn1 = str(" primeiro número: ") msn2 = str(" segundo número: ") msn3 = str(" terceiro número: ") num1 = float(input(msn + msn1)) num2 = float(input(msn + msn2)) num3 = float(input(msn + msn3)) if((num1 > num2) and (num1 > num...
ab8c1eb0e0f0517a41b9e5adce587aaf27d034da
sivakartheek/SortingAlgorithms
/Sorting.py
1,931
4.34375
4
### This program implements the following sorting algorithms: ## 1. Bubble Sort ## 2. Insertion Sort ## 3. Selection Sort ## 4. Quick Sort ## Input: unsorted array def BubbleSort(array): array_len = len(array) for i in xrange(array_len): for j in xrange(array_len - 1): if...
ec9c517a29db3dd63a045046d48dd3496cfb2894
nfarah86/Hackbright-Curriculum
/dataStructures/stacksQueueDequeue/stacksQueueDequeue.py
8,233
4.0625
4
from pythonds.basic.stack import Stack from pythonds.basic.queue import Queue def revstring(mystr): """ given a string, create another string that reverses the word """ myStack = Stack() #create an instance of Stack class for ch in mystr: #given a string, iterate over of O(n) myStack.push(ch)...
28d4ffd7cd4d98b7ce4f5511960441d719eaa737
GavinSellars/Year9DesignPythonGS
/Class Activities/addinglist.py
238
4.09375
4
#creates a list list = [1,2,3,4,5,6,7,8] #write a loop that will print out each index value #list is a length of 6 there for print out 0-5 #create a variable called sum sum = 0 for i in range(0, 6, 1): sum = sum + list[i] print(sum)
8dc9790a4e6c8bcef59b73a7114893bf5972ccb7
IvanLJF/MachineLearning
/A1/1_A_B_C_Program.py
862
3.578125
4
import numpy as np import sys #2.7.12 |Anaconda 4.0.0 (64-bit) #Get version of python print (sys.version) #(a) Create an nxn array with checkerboard pattern of zeros and ones. #Declare and initialize value of n n = 15 Z = np.zeros((n,n),dtype=int) Z[1::2,::2]=1 Z[::2,1::2]=1 print('Checker board pattern') print(Z) #...
079280449290468f328a2124b12b8757eac5c3ba
MingGeng/linux_devops_lou_plus
/calculator.py
763
3.765625
4
#!/usr/bin/env python3 import sys input_income = sys.argv[1]; try: input_income = int(float(input_income)) except ValueError: print("Parameter Error") exit() taxing_income = input_income - 3500 discount = 0 rate = 0 if taxing_income > 0: rate = 0.3 else: taxing_income = 0 if taxing_in...
553ab267f000d1b187ffecd4597493fba844ced9
zwt0204/python_
/LeetCode/两数相加.py
1,253
3.640625
4
# -*- encoding: utf-8 -*- """ @File : 两数相加.py @Time : 2020/2/28 12:49 @Author : zwt @git : @Software: PyCharm """ """ 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 4...
ec93cb5aec329c9044b74cc02338ade1b93c535f
rafaelzanirato/homework25
/fly_lion210524.py
448
3.796875
4
# Question 2 name="rafael" # Question 3 last="zanirato" # Question 4 all=name+" "+last # Question 5 print (all) # Question 6 print (all.title()) # Question 7 print (all.upper()) # Question 8 print ("rafael\nzanirato") # Question 9 print (100-23) # Question 10 print (97+12) # Question 11 print ...
2c98ce3d2bc792a591a3682e7cd4019423a6c6c8
mmkvdev/leetcode
/June/Week-1/Day4/workArea/reverseString.py
46
3.65625
4
s = ["h","e","l","l","o"] s.reverse() print(s)
f6ddbb25b4dccb2af683ff2ac866434a58ed69c0
LeeJongHyeons/tf
/tf07_cost1.py
1,103
3.5
4
# Minimizing Cost import tensorflow as tf import matplotlib.pyplot as plt x = [1, 2, 3] y = [1, 2, 3] w = tf.placeholder(tf.float32) # ===================== compile ============================================ # Our hypothesis for linear model x * w # bios b를 생략, 즉 hypothesis(weight) = x * w hypothesis =...
6e2396e417683a2629207de0e5d3a1f26a78e188
anthonymfowler15/interview_questions
/python/solutions/notes.py
1,709
3.640625
4
# Two fermenters # A B A = None B = None # List key value pairs of bars want different beers # time is time from 0 that they need the beer by. OK to let them fall through, but they will not pay for the beer after this date. orders = [ {"la_brew": { {'kegs': 5}, {'type': 'pilsner'}, {'time': 5}}}, {"sf_brew...
6dc2566580ad104129d96e9c9a3908537b91dfc8
daniel-reich/ubiquitous-fiesta
/Y2AzE8m4n6RmqiSZh_21.py
67
3.65625
4
def reverse_list(num): return [int(i) for i in str(num)][::-1]
6d73306d65a3dae2ce2538c804fba272322fa545
wanggaa/leetcode
/848.shifting-letters.py
1,635
3.71875
4
# # @lc app=leetcode.cn id=848 lang=python3 # # [848] Shifting Letters # # https://leetcode-cn.com/problems/shifting-letters/description/ # # algorithms # Medium (42.24%) # Total Accepted: 6.1K # Total Submissions: 14.3K # Testcase Example: '"abc"\n[3,5,9]' # # 有一个由小写字母组成的字符串 S,和一个整数数组 shifts。 # # 我们将字母表中的下一个字母称为原...
5bf15340476bc535fd59007dbf95daae5b094d3c
Srinivasaraghavansj/Python-Programs
/read_list_make_int_list.py
196
3.953125
4
#Read a list as input and make it a list (integers) lst = input("Enter elements of list") lst = lst.replace("[","").replace("]","") lst = lst.split(',') lst = list(map(int, lst)) print(lst)
aa4f3a2176da1d7817598d0dc676d956c9e188f1
HarryZhang0415/Coding100Days
/100Day_section1/Day36/Sol1.py
580
3.578125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def kthSmallest(self, root: TreeNode, k: int) -> int: self.values = [] def search(n...
e389047253e35cf028bc5d75a462fba30e8f0030
osoa9manuelmunoz/70-ejercicios
/ejercicio 13.py
265
3.9375
4
A = float(input("Digite la aceleracion del objeto en m/s: ")) T = float(input("Digite el tiempo del objeto en segundos: ")) V = float(input("Digite la velocidad inicial del objecto en /S: ")) X = (V*T)+(1/2*A*(T**2)) print("la distancia recorrida es de: ",X)
3a52ddb229f902e8edc3c7f2115c026535b1fa9e
yoana91/Programming0-Solutions
/Week1/If, elif, else/compare.py
298
4.09375
4
a = input ("Enter a:") a = int (a) b = input ("Enter b:") b = int (b) if a>b: print("a(" + str(a) + ") is bigger than b(" + str(b) + ")!") elif a<b: print ("b(" + str(b) + ") is bigger than a(" + str(a) + ")!") else: print ("a(" + str(a) + ") is equal to b(" + str(b) + ")")
0537fb2e5c88251dd6438d655194d8621bcd8eef
hanwgyu/algorithm_problem_solving
/Leetcode/1293.py
1,173
3.78125
4
# 모든 방향으로 + visited # bfs로 이동하면 step이 작은 순서대로 이동해서 제대로 나오게됨. (이 로직을 이해하는게 제일 중요하다. ) # REMIND: 어려움. 이 패턴에 익숙해져야함. class Solution: def shortestPath(self, grid: List[List[int]], k: int) -> int: dq = deque([(0,0,0,0)]) # (x,y,r,step) visited = set([(0,0,0)]) # (x,y,r) M, N = len(grid), len(gr...
13fdf0683e385b9f5d36209cf5d888cf7e4cfb2f
lovedrones/Control-Flow-Lab
/exercise-5.py
694
4.1875
4
# exercise-05 Fibonacci sequence for first 50 terms # Write the code that: # 1. Calculates and prints the first 50 terms of the fibonacci sequence. # 2. Print each term and number as follows: # term: 0 / number: 0 # term: 1 / number: 1 # term: 2 / number: 1 # term: 3 / number: 2 # term: 4 / nu...
1c3e9155f3cec5e1baf8e7e30d7f3870eca010ed
uncleyao/Leetcode
/320 Generalized Abbreviation.py
738
3.84375
4
""" Write a function to generate the generalized abbreviations of a word. Example: Given word = "word", return the following list (order does not matter): ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"] """ class Solution(object): def generateAb...
a44b0ba690f9c3d61a3a7fdae0cf820dda00e2cf
aniketsingh98571/Zensar_Python
/Day1.py
2,398
4.1875
4
#print function --->comments print("Hello") print(123) print("World") #variable abc=123 print("The value of abc is ",abc) stringdemo="Hi there" print(stringdemo) _variable=456 print(_variable) #type function--->to get the data type of variable print(type(abc)) print(type(stringdemo)) a=12.54 print(type(a)) #assignin...
fb41cd63e8935e12e743e6ea3602bb52746384fd
sayantansls/utilities
/pp_csv.py
454
3.734375
4
#!/usr/bin/python """ @author - sayantan """ from __future__ import print_function import csv import sys def pretty_print_csv(inputfile): f = open(inputfile) data = csv.DictReader(f) i = 0 for entry in data: i = i + 1 print('\n') print("Row Number :", i) for key,value in entry.items(): print(key, ":", ...
e6302640bae34dde332f06de720e3876dc0257e8
Breakfast-for-Pigeons/Unicorn-HAT
/Choose Your Own Colors/moving_diagonal_rainbow_1.py
2,073
3.65625
4
#!/usr/bin/python3 """ Moving Diagonal Rainbow 1 - Choose Your Own Colors Retrieves the rainbows and sends them to the move function. With the GPIO pins at the top of the Raspberry Pi, the rainbows move from the top right to the bottom left. .................... Functions: - moving_diagonal_rainbow_1: Retrieves the ...
930c2e60370e10158ee1d6e28b02f73e3a3d9227
allenlucke/python_hello_world
/while_loop.py
326
3.734375
4
import sys MASTER_PASS = "multi_pass" password = input("please enter your password: ") attempt_count = 1 while password != MASTER_PASS: if attempt_count > 3: sys.exit("To many invalid attempts") password = input("invalid password please try again") attempt_count += 1 print("Welcome to funky town...
c370d6c0419d0e0037eb86db2d5c2cecc5230204
Jiawei-Wang/Artificial-Intelligence
/02 Informed Search/PancakeFlip-AStar.py
3,222
3.734375
4
""" # Comp 131 AI # HW2 # Jiawei Wang # 02/23/2020 """ """ # Please read the attached document 'HW2-pancake-readme.doc' before executing this program # A random stack will be generated each time you run this program so no input is needed # Just click 'RUN' and enjoy! # PS: the initial and goal pancake stacks are set t...
8f6e6cb67a872167f9eb01592cc3589fefeb30c0
amdad7/sampoorna_scraper
/datatest.py
180
3.71875
4
import sqlite3 con=sqlite3.connect('8Bdatabase.sqlite3') cur=con.cursor() cur.execute('SELECT id,name FROM data WHERE gender=?',('Female',)) for row in cur: print(row)
40cd406221a4c9c63814590971b71744cb0b6461
smahs/euler-py
/2.py
1,325
3.9375
4
#!/usr/bin/python2 """ Statement: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the s...
5f88270474218ae421d98d0e1a654b8803dd21a5
Parizval/CodeWars
/LongestPalindrome/Sol.py
299
3.625
4
from collections import Counter def longest_palindrome(s): s = s.lower() letter = Counter(s) ans = 0 ; check = False for k,v in letter.items(): if k.isalnum(): if v % 2 == 1 : check = True ans += int(v/2)*2 if check: ans += 1 return ans
85f6a8f104c5e643ca7a14c65c42362e1e6a1ca2
Johndsalas/ds-methodologies-exercises
/regression/explore.py
3,095
3.53125
4
# Our scenario continues: # As a customer analyst, I want to know who has spent the most money with us over their lifetime. # I have monthly charges and tenure, so I think I will be able to use those two attributes as features to estimate total_charges. # I need to do this within an average of $5.00 per customer. #...
55bfb7c083638da65ba3f00dcbcdc1b43443657e
yamada46/Python_class
/hw7.py
2,176
3.921875
4
''' The comments down at the bottom are what ran just fine before I added the 'def main()' I don't understand what making it work at the command line means hw7.py This script will scrape a website from user input, use Beautiful Soup to parse and return all the tags from user input, use the tag.text property, open an a...
fca430ec957ff0bb45ee9687d5fa1b6a65589d42
Drowlex/Estadistica
/formulas/desviacion.py
527
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created: on Sunday September 13 11:07:22 2017 Project developed by: @autor: DKL&Derek @Sub-Autor: Pedro Ortiz Luis Roberto This program calculates the deviation of a list of numbers Copyright © 2017-2020 UV ESTADISTICA DKL Version 1.0, Build 0001 """ import ma...
06fd09798e11e2e4dedda54e46d5ba203877a6e1
anthonycurtisadler/ARCADES
/coordlinkedlist.py
1,640
3.5
4
class CoordLinkedList: # a linked list object def __init__ (self,node=None,y=None,x=None,up=None,down=None,left=None,right=None): self.up = up self.down = down self.left = left self.right = right if isinstance(node,(list,set,tuple)) and len(n...
a39bc827118664f2f9b0bb046f3072a1bb818075
Edson73/pythonfundamentals
/exercicios/pagamento.py
1,051
4.03125
4
# -*- coding: utf-8 -*- print('Software de folha de pagamento!') vr_hora = float(input('Digite o valor da hora:')) qtd_hora = float(input('Digite a quantidade de horas trabalhadas: ')) salario_bruto = vr_hora * qtd_hora if salario_bruto >= 4600: aliquotaIR = 27 elif salario_bruto > 3700 and salario_bruto < 4600...
778bf03d1277c6bd1e31ef5eeb31ddd144807681
JyotsnaNakte95/ML-NLP
/Homework_02_dacc.py
4,006
3.71875
4
""" Author : Jyotsna Namdeo Nakte jnn2078 This code takes the pre-processed document file finds the minimum and maximum length of the sentences in the text file. The program even finds the mean, standard deviation of the file. Later, we then perform POS tagging on the longest sentence """ from __future__ import di...
df6616ea317fafeb9ee2d712da873c916fc325a6
monkeyboy107/RSAKeyGenInPythonForLearningRSAWorks
/RSA Key example2.0.py
2,967
3.609375
4
import random #import binascii import decimal import py_compile import functools from math import sqrt #import base64 py_compile.compile('RSA Key example.py') decimal.getcontext().prec = 9999999 ''' def binToString(num): print("Converting back into a string") value = int2base(value, 10) value = binascii.b2a_hex...
b4542809019e092de6e70f7198374b1a892f5761
NishargManvar/Data-Structures-and-Algorithms
/EE4371-DSA/Assignment-2/Assign2_Q3.py
8,683
3.96875
4
#*********************************************************************************************************************************************** #PURPOSE : EE4371 Assignment 2 - Q3 (Find k greatest numbers in sequence of n numbers) #AUTHOR : Manvar Nisharg (EE19B094) #DATE : #INPUT : k, sequence of numbers, if repetat...
9ad88bec365e436cc2f5ac5fbdc8c931e83f74c4
flysaint/Sword_Offer
/chapter/2_3_4_重建二义树.py
5,279
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 12 17:20:00 2019 @author: DELL 要求:用前序和中序遍历结果构建二叉树,遍历结果中不包含重复值 思路:前序的第一个元素是根结点的值,在中序中找到该值,中序中该值的左边的元素是根结点的左子树, 00右边是右子树,然后递归的处理左边和右边 提示:二叉树结点,以及对二叉树的各种操作,测试代码见six.py 案例:输入先序遍历 {1,2,4,7,3,5,6,8}中序遍历 {4,7,2,1,5,3,8,6} 重新用树将节点组合起来,返回根节点 学习点。 1. 还是不要忘了递归边界。 2. self可以不用作为参...
dde6e3fbcc3995a45ebdcb1d3f21cc7c3c16914d
ashutoshdhondkar/basic-python
/prime.py
296
4.25
4
#pogram to check whether the number entered is prime or not num=int(input("Enter number : ")) for x in range(2,num): flag=0 if num%x ==0: flag=1 break if flag ==0: print("The number ",num,"is prime number!") else: print("The number ",num," is composite number!")
7ac1a887f2315b6cd1116ca6132a143e39d734c6
sharmarkara/Data-structure-Programs
/Algorithms/1 Linear serch.py
233
3.890625
4
def Linear_Search(arr,n,element): for i in range(0,n): if arr[i]==element: print("Indes is",i) return -1 arr=[2,5,8,9,3,8,9] n=len(arr) element=8 print(Linear_Search(arr,n,element))
e7651eb60b9424df902cfdb7fd8a59f1946e6253
Vijay-Ky/Rooman_JSD_MAY_5TO9_BATCH
/Python_Programming/Numbers/A.py
154
3.96875
4
""" There are three numeric types in Python: int float complex """ x = 1 #int y = 2.5 #float z = 1j #complex print(type(x)) print(type(y)) print(type(z))
2e145d1f3c9f6ded3187226b1d437bc1f9c35608
sanghwa1026/algorithm
/Promgrammers/PRO위장.py
373
3.53125
4
c = [["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]] def solution(clothes): answer = 1 dic = {} for item,cate in clothes: if cate in dic: dic[cate]+=1 else: dic[cate] = 1 print(dic) for c in dic: answer*...
29edb6e074d5358d376630dc0e5f0b60cf1e4923
cmeza432/Football_Predictor
/API/webscrape_OYG.py
1,758
3.625
4
from bs4 import BeautifulSoup as soup from urllib.request import urlopen import csv # Function will scrape the data for each teams allowed yard per game def get_teams_OYG(team1, team2): opp_ypg_url = 'https://www.teamrankings.com/nfl/stat/opponent-yards-per-game' opp_ypg_data = urlopen(opp_ypg_url) opp_ypg...
4027be8eed7cccebd5586b6c07692d00e83bcb2a
qixiaoxioa/data_structure
/text1.py
1,448
3.578125
4
class Node: def __init__(self,data): self.data = data self.next = None def __repr__(self): return f"Node({self.data})" class Solution: def twoChangePoint(self,s1:Node,s2:Node): dummy = Node(0) pre = dummy while s1 or s2: if s1.data < s2.data: ...
c5522a3d0a1c8bfe18bb0bc46bcfbbfeacdf7c6a
abijithring/classroom_programs
/42_classes_objectoriented/inheritance/3_hierarchical.py
248
3.671875
4
class x: def m1(self): print "In method1 of X" class y(x): def m2(self): print "In method2 of Y" class z(x): def m3(self): print "In method3 of Z" y1 = y() y1.m1() y1.m2() z1 = z() z1.m1() z1.m3()
cf2e7143b0c2920da44a65e393c1fdbd137608e4
lcnodc/codes
/09-revisao/practice_python/birthday_json.py
2,802
4.5625
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Exercise 34: Birthday Json This exercise is Part 2 of 4 of the birthday data exercise series. The other exercises are: Part 1, Part 3, and Part 4. In the previous exercise we created a dictionary of famous scientists’ birthdays. In this exercise, modify your program f...
f97507243682c63523e255e35bd9bf947cc2a753
ElaineBalgos/Balgos_E_PhythonHW
/gameFunctions/compare.py
1,581
3.515625
4
from random import randint from gameFunctions import compare, winlose, gameWars # what are you trying to compare inside this function? # you will need to pass those things in as arguments # inside the round brackets def comparechoices(computer, player): if gameWars.player == "quit": exit() elif gameWars.computer ...
4155357a7f8912781ad273aed28c5fe683b2db5b
AmericanEnglish/Academic-Conclusions
/old/helper.py
6,504
3.53125
4
#LABEL THING THING NAME_NAME from random import randint def convert_to(original, output): with open(original, 'r') as filein: with open(output, 'w') as fileout: string = filein.read() for char in string: if char == ' ': fileout.write('_') ...
b708af3d30e6bdff84b411ccd77b6a7085691657
jxie0755/Learning_Python
/SimpleLearnings/py_vars.py
465
4.3125
4
""" 将字符串变成变量名 string as variable_name """ test = "aaa" vars()[test] = 999 print(aaa) test = "123" vars()[test] = "zzz" print(123) # 显然string不能是全数字 test = "bbb" vars()[test] = "zzz" print(bbb) vars()[test] = "yyy" print(bbb) # 可以被覆盖 # 可以是数据结构 test = "ccc" vars()[test] = [1,2,3] print(ccc) vars()[test] = (1,2,3) p...
9781bef6d93a64538712276014407f24a93f5ca0
luiscascelli/Linguagem-de-Programa-o-2
/AC_01/ac01.py
1,887
3.78125
4
# INSIRA ABAIXO OS NOMES DOS ALUNOS DO GRUPO (máximo 5 alunos) # ALUNO 1: Luis Antonio Matile Cascelli RA 1903598 # ALUNO 2: # ALUNO 3: # ALUNO 4: # ALUNO 5: ''' Escreva uma função com o nome quantidade, que recebe como argumentos de entrada uma tupla e um item e retorna quantas vezes esse item aparece na tupla. ''' ...
333ec8701edfd150abc1e0a9cf6eff5019b3ae70
GuangyuZheng/leet_code_python
/70_Climbing_Stairs.py
442
3.8125
4
class Solution: def climbStairs(self, n: int) -> int: if n == 1: return 1 elif n == 2: return 2 else: result = 0 prev_one_step = 2 prev_two_step = 1 for i in range(3, n + 1): result = prev_one_step + prev...
9537e15b5dabcdc6d34afca471fc3819eef13455
hiroshi415/pythonweek2
/Database/HW.py
409
3.546875
4
''' In this world, there are 15 days in even month, and 13 days in odd month and 13 month in one year. Festival takes place when the year's modulus of 4 is 1. Input [yyyy mm dd] Festival date is [mm dd] Given the input and the festival date, calculate the days until the next festival ''' # 28 currentDay1 = '2000 12 ...
ee3784e894e82f1eaea98d69c2bd63a77e7bc7db
scvalencia/algorist
/03. Arrays and ADT's/examples/Range.py
507
3.6875
4
class Range(object): def __init__(self, start, stop = None, step = 1): if step == 0: raise ValueError('step cannot be zero') if stop is None: start, stop = 0, start self.__length = max(0, (stop − start + step − 1) // step) self.__start = start self.__step = step def __len__(self): return self....
424b33b472350efd0699514ca5cbd1f16a6da04e
thezones1/py-world-st
/Day3-6.py
666
4.0625
4
height = int(input("hat is your height in cm? ")) bill = 0 if height >= 120 : print("can ride") age = int(input("hat is your age ")) if age < 12: bill = 5 print("Child tickets are 5.") elif age <= 18: bill = 7 print("Youth tickets are 7") ...
ccad33d896a6a2adcb3070c5b40d01cd2222e907
CatherineDumas/Change.org
/change2csv.py
1,391
3.578125
4
# convert Change.org pseudo-JSON file to csv # command format: #$ python change2csv.py changefile newfile.csv import sys, re, ast, csv # strip HTML, from # http://stackoverflow.com/questions/9662346/python-code-to-remove-html-tags-from-a-string TAG_RE = re.compile(r'<[^>]+>') def remove_tags(text): return TAG_RE...
6bd29576a744c70dde211093610f7393e38d0e23
Max-Dy/Problem-Solving-with-Algorithms-and-Data-Structures-using-Python
/c3_stack_parenthesis.py
2,065
3.6875
4
from pythonds.basic import Stack # 从list发展出stack # class Mystack(): # def __init__(self): # self.items = [] # # def myisEmpty(self): # return self.items == [] # # def mysize(self): # return len(self.items) # # def mypop(self): # return self.items.pop() # # def mypus...
9e5b48544246b36a9d59e2e78cbc2ababcf377ee
Zahidsqldba07/LanguageExercises
/IMCSaude.py
1,743
3.875
4
enderecoClient= {"rua": "Avenida periquito Roxo", "numero": 51, "referencia": "Ao lado do posto dos irmãos"} ##Declaração de dict # # print("Vamos receber seus dados:\n") ##entrada de dados pesoAltura = [float(input("Peso\n")), float(input("altura\n"))]##conversão para float calcIMC = pesoAltura[0] / (pesoAltura[1...
b27cd0ecbf98add2c8877829c3666c555ed80537
MertUzeken/codes
/Python Codes/Labor7_Aufgabe1.py
424
3.953125
4
class Time: def __init__(self,hour,minute,second): self.hour = hour self.minute = minute self.second = second def display(self): self.hour = str(self.hour) self.minute = str(self.minute) self.second = str(self.second) print(self.hour + ":" + self...
59783d7e9b4a460ecbfc701967e9e384366e42da
mirlan1987/lesson1
/zadanie1.2.py
617
3.75
4
def qualifier(s): if 0<=s<7: print("Вам в детский сад") elif 7<=s<=18: print("Вам в школу") elif 19<=s<25: print("Вам в профессиональное учебное заведение") elif 25<=s<60: print("Вам на работу") elif 60<=s<=120: print("Вам на пенсию") elif s<0 or s>120: ...
2f2f99cabaffdafbf547832329c6d180c4e0c43b
soulorman/Python
/practice/practice_4/mer.py
692
3.8125
4
import random print("归并排序") lst = [] for _ in range(20): lst.append(random.randint(0,200)) #合并两列表 def merge(a,b):#a,b是待合并的两个列表,两个列表分别都是有序的,合并后才会有序 merged = [] i,j=0,0 while i<len(a) and j<len(b): if a[i]<=b[j]: merged.append(a[i]) i+=1 else: merged.ap...
2197604c6ad060659ce05d5456e284a6014644f6
crazymanpj/python
/leetcode/maxarea.py
1,256
3.71875
4
''' 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。 说明:你不能倾斜容器,且 n 的值至少为 2。 示例: 输入: [1,8,6,2,5,4,8,3,7] 输出: 49 ''' class Solution(object): def maxArea(self, height): """ :type height: List[int] :rtype: int ...
091288e2b72cd1dcf93381b0e53a2f70012f1888
Michelleoc/myWork
/Week04-flow/testFor.py
421
3.9375
4
# Messing with for loops # Author : Michelle O'Connor # for elem in list # do something # for number in range (1,10) # do something boats = [ "Sigma", "beneteau", "Swan"] for boat in boats: print ("i'd prefer to be out on a " + boat) vehicles = [ "Car", "Bus", 208] for vehicle in vehicles: ...
1ae3eb43a4adae7da6c81c53278f4dd6bcbaa028
devashishnyati/BFS-2
/cousins.py
894
3.875
4
# Time Complexity : O(n) # Space Complexity : O(n) # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : Logic # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None cla...
95b996ecb55e127ed1214c19906e0ba32e4af73a
ezember/Ezekiel-Bustillo
/BUE1CM.py
1,111
3.5625
4
""" R. COLLEEN PENETRANTE DATALGO Prelims Feb. 26, 2020 I have neither received nor provided any help on this (lab) activity, nor have I concealed any violation of the Honor Code. """ class Airplane: def __init__(self): self.speed = 0 def set_speed(self,speed): self.spe...
b4e972b2f07ee863ed22c1498a9d1b2550a242d1
Abdelhamid-bouzid/problem-Sovling-
/Easy/trailingZeroes.py
725
3.96875
4
''' Given an integer n, return the number of trailing zeroes in n!. Follow up: Could you write a solution that works in logarithmic time complexity? Example 1: Input: n = 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: n = 5 Output: 1 Explanation: 5! = 120, one trailing zero. Example 3: Inp...
c95421a31de5fa05dbdc16f69f418147a20ecc6e
IceDerce/learn-python
/learning/veryone.py
166
4.125
4
#for i in range(5): # print('fku') x=10 y=9 if x<y: print('x ix less than y') elif x>y: print('x is greater than y') else: print('x is equal to y')
ebe6284394aeae4191487d588061f79b0a664121
P-Madhulatha/become-coder
/amstrong number.py
233
3.96875
4
#amstrong or not n=int(input()) order=len(str(n)) sum=0 temp=n while temp>0: r=temp%10 sum+=r**order temp//=10 if n==sum: print(n,"is an amstrong number") else: print(n,"is not an amstrong number")
55910249db8c0bed94a2dd3bad5ba13882f3f8a3
Cisplatin/Snippets
/euler/python/P179.py
1,656
3.5625
4
""" Consecutive Positive Divisors Problem 179 """ LOWER_BOUND = 2 UPPER_BOUND = 10000000 # We save some time by finding all primes, as we know that each of them has # only one divisor (itself). We also use these to calculate divisors def prime_sieves(): erato, primes, exists = [True] * UPPER_BOUND, [], {} for...
8ed748a83fab6ff5793b08611ec7b2144257829c
olimadhav1997/Humanoid
/Jarvis.py
1,492
3.59375
4
#!/usr/bin/env python3 # Requires PyAudio and PySpeech. import speech_recognition as sr from time import ctime import time import os from gtts import gTTS r = sr.Recognizer() with sr.Microphone() as source: print("Say something!") audio = r.listen(source) def speak(audioString): print(audioString) tts = gTTS(t...
7052c275562eaa0535f89aac022c27388573fd8e
scikit-learn/scikit-learn
/examples/neighbors/plot_caching_nearest_neighbors.py
2,672
3.671875
4
""" ========================= Caching nearest neighbors ========================= This examples demonstrates how to precompute the k nearest neighbors before using them in KNeighborsClassifier. KNeighborsClassifier can compute the nearest neighbors internally, but precomputing them can have several benefits, such as f...
de580c76787c5302d6b54205a6ca3ed748aeb6eb
C-CCM-TC1028-102-2113/tarea-1-programas-que-realizan-calculos-Varuneishon
/assignments/22DigitosPares/src/exercise.py
739
3.765625
4
def main(): #escribe tu código abajo de esta línea n = (input('Dame un número: ')) l = int (len(n)) try : if (l == 4) : n = int (n) i = 1 e = 0 o = 0 z = 0 while (i <= l) : d = int (n % 10) if ...
e6309e90bca6380b2d77136ccbb775a513eb473c
watinya/zerojudge
/python/a003.py
338
3.5625
4
# coding:UTF-8 import sys s = sys.stdin.readline() while (s != ""): s = s.replace("\r", "").replace("\n", "") s = s.split() s = ( ( int(s[0]) * 2 + int(s[1]) ) % 3) if (s == 0): print("普通") if (s ==1): print("吉") if(s == 2): print("大吉") s = sys.stdin.re...
232ce253520d887a95c2c0cdd9a1b13840be2677
GabriellyBailon/Cursos
/CursoEmVideo/Python/Mundo 3/ex081.py
680
3.96875
4
# Ler vários números, colocando-os em uma lista e analisar informações sobre eles lista = []; while True: lista.append(int(input('Digite um número: '))); #Limpa a opção e garante o funcionamento correto do loop opcao = ' '; while opcao not in 'SN': opcao = str(input('Deseja continua...
b212b3bd1254a85e0ede29a13b5396c41a7b4d71
huxx-j/python-ex
/ex07.py
326
3.71875
4
num = input("숫자를 입력하세요: ") sum = 0 if num.isdigit(): if int(num)%2==0: for i in range(2, int(num)+1, 2): sum += i else: for i in range(1, int(num)+1, 2): sum += i print("결과값 : {0}".format(sum)) elif num.isalpha(): print("숫자가 아닙니다.")
4138f13a707a2d8f7a25f937de8af973a19c2cb8
dylanbaghel/python-complete-course
/section_19_OOP_part_1/03_class_methods_attributes.py
2,529
4.34375
4
""" Class Attributes: --> This attribute belongs to whole class not to the instance and this attribute is shared by all instances of a class and the class itself. Class Methods: --> Class methods are methods (with the @classmethod decorator) that are not concerned with instances, but the class itself. """ cl...
4b607b24549d7d16ee5c71a171c9bf4088f3285c
GucciGerm/holbertonschool-higher_level_programming
/0x03-python-data_structures/#0-print_list_integer.py#
89
3.921875
4
#!/usr/bin/python3 my_list = [1, 2, 3, 4, 5] for n in my_list: print("{}".format(n))
4a8fa290e9b3efb00ff032ce3d614b3806886099
SarcoImp682/Hangman2
/Topics/For loop/Lucky 7/main.py
101
3.53125
4
n = int(input()) for num in range(n): p = int(input()) if _p % 7 == 0: print(p ** 2)
05fc84f1cd451869ed5360ece53491b3bff7578c
Tamasd9182/EasySiklo
/menu2.py
833
3.515625
4
from ujfajl import creat_newf from hozzaadas import addPainting from törlés import törlés from modositas import modositas from main import main def f1(label): #print(label) input_words="" while True: input_words=input("""\n\t1.Új fájl létrehozása \t2.Festménynév és ár hozzáadása \t3.Módosítás \...
55c1d23c1481167a7c399510ec9a8b6b521dba1a
HaminKo/MIS3640
/misc/roster.py
984
3.5
4
import random class_roster = {'Aaron Wendell': 0, 'Alden Pexton': 2, 'Allison Fernandez': 1, 'Angela Tsung': 2, 'Christian Thompson': 3, 'Christine Lee': 1, 'Connie Li': 1, 'Defne Ikiz': 0, '...
31a3a78d6a99216c55f4af801d70dca3a126808f
vibsaa/P7DoC_py
/question2.py
561
4.15625
4
"""Write a program which can compute the factorial of a given numbers. The results should be printed in a comma-separated sequence on a single line. Suppose the following input is supplied to the program: 8 Then, the output should be: 40320""" x=input("enter the no whose factorial is to be found") def fact(a): f=...
7c1424fca23b8e274136ea198ab8897991bed71b
Sarveshgopi/Projects-of-Sarvesh
/simple calculator.py
2,332
3.796875
4
from tkinter import * root=Tk() root.geometry("400x310") root.title("Simple calculator") e=Entry(root,width=35,borderwidth=5) e.grid(row=0,column=0,padx=30,pady=10,columnspan=4) def click(num): curr=e.get() e.delete(0,END) e.insert(0,curr+num) def clear(): e.delete(0,END) def operation(operator): fi...
284c3ef59503d8eb703b70093e1079879f38e97e
Nebsorg/AdventOfCode
/Day3.py
879
3.578125
4
slope = [] f = open("Z:\donnees\developpement\Python\AdventOfCode\day3.txt", "r") for line in f: slope.append(list(line.rstrip("\n"))) f.close() def calculateCollision(shiftX, shiftY, slope): currentPositionX = 0 currentPositionY = 0 finishLine = len(slope) slopeWidth = len(slope[0]) ...
c34507ee2a52522cd1f65d7ab75ee19803bac978
Aishwarya-260180/260180_pythonproject
/2_Implementation/Student.py
3,422
4.15625
4
print("-----Program for Student Information-----") D = dict() #define function to add student details def enter_details(): n = int(input('How many student record you want to store?? ')) # Add student information # to the dictionary for i in range(0,n): x, y = input("Enter the complete n...