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 |
|---|---|---|---|---|---|---|
373ea31569d28fdfde9edd3ad787c79b8e0be363 | jordoin/nute | /MagicThings/MagicOrb/intSqrt.py | 688 | 3.640625 | 4 | from math import sqrt
def intQuadro(v, n, shift = 1):
return v * v / n
def intSqrtTable(n, shift = 1):
return (intQuadro(v, n, shift) for v in xrange(n + 1))
def strIntSqrtTable(n, shift = 1):
return ', '.join(str(v) for v in intSqrtTable(n, shift))
def printIntSqrtTable(n, indent, maxLength,... |
a5cd3caa423ec6774f53b111184ad7ba85308fc6 | mdagaro/pyminesweeper | /Menu.py | 1,782 | 4.03125 | 4 | import pygame
class Button:
"""
Button to exist on the main menu. Does a function when clicked.
"""
def __init__(self,location,on_click=None,text='button',size=(100,30),buffer = (0,0)):
"""
Constructor
:param location: where the button will appear on the screen
:param on_click: what function the button wi... |
496bf4547a2eb0b1dc7b05d501e8fe642dcc6349 | eduardoanj/cursopyton | /Nova pasta (2)/exercGuanabara/ex3542.py | 951 | 4.125 | 4 | lado1 = float(input('Digite o primeiro lado: '))
lado2 = float(input('Digite o segundo lado: '))
lado3 = float(input('Digite o terceiro lado: '))
if ((lado1 + lado2) <= lado3):
print('não forma um triangulo!!')
else:
if ((lado2 + lado3) <= lado1):
print('não forma um triangulo!!')
else:
if (... |
f2a437e213e27cef99d7a8767bacc30e77698ff4 | joohyun333/programmers | /백준/DP/외판원 순회.py | 203 | 3.59375 | 4 | # https://www.acmicpc.net/problem/2098
def isIn(i, a):
print(bin(i)[2:])
print(bin(a)[2:])
if a & (1 << (i - 2)) != 0:
return True
else:
return False
print(isIn(8, 9))
|
a57e2c9bb84bc6cf57996e1b8413aa8c4744fbc9 | JohnGoure/leetcode-solutions | /compress.py | 527 | 3.734375 | 4 | def compress(word):
letterCount = {}
compress = False
for letter in word:
if letter in letterCount:
letterCount[letter] += 1
else:
letterCount[letter] = 1
if letterCount[letter] > 1:
compress = True
if compress == True:
compressed... |
ca6fda4171e630dd1c22d307280e086d63dc79dd | ZahraAnam/Audio_work | /file_reader.py | 830 | 3.53125 | 4 | import os
import sys
def scan_folder(parent):
# iterate over all the files in directory 'parent'
for file_name in os.listdir(parent):
if file_name.endswith(".wav"):
# if it's a txt file, print its name (or do whatever you want)
print(file_name)
else:
current_... |
8cd2c469671ab21d73cf73a6a71ad1073c245465 | scriptclump/algorithms | /small-program/2power_range.py | 206 | 4.0625 | 4 | def power(num):
# use anonymous function
result = list(map(lambda x: 2 ** x, range(num)))
print("The total num are:",num)
for i in range(num):
print("2 raised to power",i,"is",result[i])
power(10) |
c068f6fb1db2fdad4414f362391a22fbb631cc64 | Teja2229/assignment | /list7.py | 169 | 3.859375 | 4 | list7=[22,11,33,44,55]
print("original list:")
print(list7)
for i in list7:
if(i%2 == 0):
list7.remove(i)
print("list after removing even numbers:")
print(list7) |
b6cee2c4586775679583ae70aa482c238258f2de | MatthewPlemmons/holbertonschool-higher_level_programming | /0x06-python-classes/102-square.py | 888 | 4.09375 | 4 | #!/usr/bin/python3
class Square:
def __init__(self, size=0):
self.size = size
@property
def size(self):
return self.__size
@size.setter
def size(self, value):
if type(value) is not int and type(value) is not float:
raise TypeError('size must be an number')
... |
7d979f2ff52e84058bc39d8d41010db28c1abb0d | lindameh/cpy5p2 | /q05_find_month_days.py | 1,153 | 4.15625 | 4 | def check_leap():
if year % 4 == 0:
if year % 100 != 0 or year % 400 == 0:
return True
else:
return False
else:
return False
year = int(input("Enter year: "))
month = int(input("Enter month in number: "))
if month == 1:
print("January {} has 31 ... |
fa0846885e3555ba03d9ef2629f0445ecaeed937 | JDSanto/intro-distribuidos-tp1 | /src/lib/server.py | 673 | 3.53125 | 4 | class Server:
def __init__(self, host, port, logger):
"""
Creates the Server object, which will be used to receive and send files.
`dest_folder` is the folder where the files will be saved.
"""
self.host = host
self.port = port
self.logger = logger
def st... |
695ecfc3ec8b381b55543cd20700428eb6de5e8f | chenchcgt/python-challenge | /PyBank/main.py | 2,624 | 3.703125 | 4 | import os
import csv
csvpath = os.path.join("Resources","budget_data.csv")
months = 0
total_amount = 0
maximum = 0
minimum = 0
amount_prior = 0
difference_current = 0
difference_sum = 0
avg_month = 0
avg = 0
compare_current = 0
with open(csvpath) as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
h... |
2ae3ca2f068a403a397f63f375cfe3a4872212f0 | al-mahi/AI_II_CS5793 | /BasicClassifiers/BasicClassifiersComplexData.py | 6,039 | 3.703125 | 4 | #!/usr/bin/python
"""
Author: S M Al Mahi
CS5793: Artificial Intelligence II
Assignment 1: Basic classifiers
Solution for Part 5
"""
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from KDTree import cKDTree
if __name__ == "__main__":
"""
Part#5 Increasing complexity
... |
1c480ed31d1e97753bca63aeb689fbff9c25b6b8 | TheAlgorithms/Python | /data_structures/binary_tree/binary_tree_traversals.py | 5,373 | 4.09375 | 4 | # https://en.wikipedia.org/wiki/Tree_traversal
from __future__ import annotations
from collections import deque
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any
@dataclass
class Node:
data: int
left: Node | None = None
right: Node | None = None
... |
47168d5f8825aeecf06143d1a2a53983055798bb | 10354828/programming_big_data_pp | /CA1/functions_calculator.py | 1,325 | 4.15625 | 4 | # Name: Paul Prew
# Student Number: 10354828
# Programming for Big Data
# CA 1
# The following are functions that are called by the program named
# 'app_calculator.py'.
import math
def calc_add(num1,num2) :
result = num1 + num2
return result
def calc_subtract(num1, num2) :
result = n... |
50b91525131379a69dc3c2319b57aea7a21e687e | parasjain-12/HackerEarth-Solution | /Monk Takes a Walk.py | 224 | 3.53125 | 4 | t = int(input())
for _ in range(t):
s = input()
s = s.lower()
c=0
for i in range(len(s)):
if s[i] =='a' or s[i] =='e' or s[i] =='i' or s[i] =='o' or s[i] =='u':
c+=1
print(c)
|
d7f6b461023c28ba3427b8c2ecef83eefcf31eac | Amenable-C/Python_practice | /sumAndDifference.py | 406 | 3.703125 | 4 | codeMate = '''
def sum(a, b):
return a + b
def diff(a, b):
return abs(a - b)
'''
with open('sumAndDiff.py', 'w') as f:
f.write(codeMate)
import sumAndDiff
s = input("Input two numvers: ")
nums = s.split(', ')
n1 = int(nums[0])
n2 = int(nums[1])
print("Sum =", sumAndDiff.sum(n1, n2)) # 바로 sum 쓰면 안됨. 모듈이름... |
ceea1a81fad56ccbed8e3ac1671fb24b91bf1104 | aedaniel411/uaf-programacion-python | /2020b/fibo2.py | 128 | 3.890625 | 4 | n = int (input('Cuantos numeros de fibonacii?'))
i = 0
a, b = 0, 1
while i < n :
print(a)
a, b = b, a+b
i = i + 1 |
c16ae19bc18c042bd972333a50d654f1d23d21ab | sandeepmaxpayne/Udacity_Computer_Vision_Nanodegree | /Computer Vision Intro/Project1_Facial_Key_Point/models.py | 2,245 | 3.796875 | 4 | ## TODO: define the convolutional neural network architecture
import torch
import torch.nn as nn
import torch.nn.functional as F
# can use the below import should you choose to initialize the weights of your Net
import torch.nn.init as I
class Net(nn.Module):
def __init__(self):
super(Net, self).__init_... |
2b6a39584d2eddb70f05663e5d7d3139c190a077 | ksshin21/python_basic | /11 integer_summing.py | 687 | 3.5625 | 4 | # 11일차
#합계구하기 - for 반복문 1차시도(KS)
# 이 프로그램은 음수를 포함한 두 정수 범위(양 끝 수 포함)의 합계를 구합니다.
# 프로그램을 종료하기 위해서는 문자 'q'를 입력하세요.
while True:
print('\nIf you want to stop, press q ...')
start = input('시작 수(음수 포함 정수) : ')
if start == 'q': # 음수도 처리하기 위해 마침 문자를 따로 지정
break
first = int(start) # first = ... |
7df192d0e3690c813e6990b4f5db3d8944f5e6e1 | nkhanhng/namkhanh-fundamental-c4e15 | /session3/homework/update_guess_my_number.py | 486 | 3.890625 | 4 | from random import randint
print('''Think of a number from 0 to 100
"c" if my guess is 'C'orrect
"s" if my guess is 'S'maller than your number
"l" if my guess is 'L'arger than your number''')
x = randint(1, 100)
loop = True
count = 0
while loop:
print("Is", x," your number", end=' ')
ans = input()
count ... |
e2ca594e02ec1f91db93f238bdc7e629bc6ae135 | cassieeric/python_crawler | /网络爬虫实战基础章节学习记录/chapter3--正则表达式的使用/re.sub.py | 148 | 3.578125 | 4 | # -*- coding: utf-8 -*-
import re
st = "忙完这阵子,就可以接着忙下阵子了"
new_st = re.sub(r'忙', '过', st)
print(new_st)
|
c91c33b7dcd989cac8a2defa1ee31054c0b85b68 | devedu-AI/Data-Flair-Python-Course | /5.Working_On_Python_Part-3/High Low.py | 199 | 3.609375 | 4 | def high_low(n):
for row in range(1,n+1):
for col in range(row,n+1):
print(col,end=' ')
for col in range(n-1,row-1,-1):
print(col,end=' ')
print()
|
ff4fbdc774f1cc800026d05bfdb7fe0d9a0986f0 | FelipeRodri03/Trabajos-algoritmos-y-programaci-n | /Taller python/Ejercicio6.py | 345 | 3.796875 | 4 | """
Entradas
Cantidad de hombres-->int-->a
Cantidad de mujeres-->int-->b
Salidas
Porcentaje de hombres-->float-->d
Porcentaje de mujeres-->float-->e
"""
inp=(input(). split(" "))
a,b=inp
a=int(a)
b=int(b)
#caja negra
c=a+b
d=(a*100)/c
e=(b*100)/c
print("El porcentaje de hombres es "+str(d)+"%" )
print("El porcentaje de... |
ad6f8af9a027ced4b44b07a1fc0039175cc87077 | htang22/python_simple_projects | /question_3.py | 841 | 4.53125 | 5 | def swap_pair(user_input):
new_word = ""
last_letter = ""
list_word_char = [letter for letter in user_input]
odd_char = [letter for letter in list_word_char[:-1:2]] #List comprehension does the same thing a a for loop but better. Example of a fore loop below
# odd_char = []
# for letter in... |
562b93e3e33458fbf8893b14b5030b7aa3819c3e | AlexPlatin/Grokking_Algorithms_book | /Recursive_tryings.py | 788 | 3.984375 | 4 | def recursive_factorial(x: int) -> int:
if x == 1:
return 1
else:
return x * recursive_factorial(x - 1)
def loop_factorial(x: int) -> int:
if x == 1:
return 1
else:
for i in range(x - 1, 0, -1):
x *= i
return x
def recursive_sum(list_values: list) ... |
69b38898844a70dbfd3e693c3842de37c29a0e7a | vinayvsalunkhe/pythonex | /LISTex.py | 317 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 4 09:14:06 2020
@author: Admin
"""
#python program to find largest number in a list
a=[]
n=int(input("enter the number of elements:"))
for i in range(1,n+1):
b=int(input("enter element:"))
a.append(b)
a.sort()
print("Largest element is:",a[n-1]) |
930f10b3d7a0a50350360fd5a143023782a7b530 | encorechow/CS519 | /homework3/xyz.py | 937 | 3.875 | 4 | #import pdb
def find(arr):
''' Find all triples (x, y, z) that meet the form x + y = z. '''
sort_arr = sorted(arr)
result = []
#pdb.set_trace()
# For each element in an array we find the corresponding x and y by two pointers.
for i, ele in enumerate(sort_arr):
p1 = 0
p2 = len(arr... |
00151d27d5747091603f83967363362a19cbcf6f | gilady19-meet/yl1201718 | /cheack.py | 823 | 3.625 | 4 | rom turtle import *
import random
import time
colormode(255)
tracer(0)
hideturtle()
class Circle(Turtle):
def __init__(self,x,y,dx,dy,radius):
Turtle.__init__(self)
self.pu()
self.goto(x,y)
self.dx = dx
self.dy = dy
self.shape("circle")
self.shapesize(radius/10)
self.radius = radius
r = random.... |
a90b175edf7be4a4fa7ab961a3497332d949212a | smanilov/sisyphus-boulder | /sishead.py | 9,981 | 3.9375 | 4 | import sys
def print_usage():
# Print usage
if len(sys.argv) < 5:
format = """
Usage: %s source_file token_file unroll_factor output_file
source_file
a file containing c/c++/java source code
token_file
a file containing one token per line;... |
dba95cae497d6770ff037751e15112b76b930625 | shubham-pal-au9/DSA | /basic_code/array/max_min.py | 415 | 4 | 4 | # Maximum and minimum of an array using minimum number of comparisons
# Solution
def max_min(lst):
lst.sort()
for i in range(len(lst)-1,-1,-1):
print "Maximum is",lst[i]
break
for i in range(0,len(lst)):
print "Minimum is:",lst[i]
break
""" print(max(lst))
... |
3fd8d678591c5b1024758a3bfb5a36b7cc31bb28 | dvega920/IT-140-Mod-6 | /6.12_LAB:Varied-amount-of-input-data.py | 745 | 4.4375 | 4 | # 6.12 LAB: Varied amount of input data
# Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max.
#
# Ex: If the input is:
#
# 15 20 0 5
# the output is:
#
# 10 20
#
user_input = input()
# used list comprehensions ... |
8a1d6359dc9e4e5ea623f0eb3e1fd9ee7ab15432 | davidharvey1986/timeDelay | /PlaneLenser/ContourCounter.py | 2,979 | 3.703125 | 4 | import math
class ContourCounter:
"""
Counts the lengths of contours on a 2d array and the surfaces within them.
"""
def __init__(self, data):
self.data = data
def Measure(self, contourLevels):
"""
Measures the length of contours of specified levels, and the surface within... |
4253f4ed293eecb43ece3e64fccda1ff1344c3bb | tclap27/CS104 | /conditions.py | 154 | 4.09375 | 4 | temp = input("please enter a value: ")
temp = int(temp)
if(temp >= 70):
print("no jacket required")
elif(temp < 70):
print("Wear a jacket")
|
0d5490a0135cf873ab4bf1cc909bbc86fae2af7e | yszpatt/PythonStart | /pythonlearn/train/prac21.py | 461 | 4.03125 | 4 | #!/usr/bin/env python
# coding:utf-8
# 猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个第二天早上又将剩下的桃子吃掉一半,又多吃了一个。
# 以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。
x2 = 1
for day in range(9, 0, -1):
x1 = (x2 + 1) * 2
x2 = x1
print(x2)
|
d9b123b9d76b724eb31eb89916fccb4d19a52307 | 1024Person/LearnPy | /Day5/string_find.py | 933 | 3.609375 | 4 | # find string and replace string
# method : find() rfind() lfind() rinsex() lindex() replace()
s1 = 'transport'
result = 'l' in s1
print(result)
# s2 = 'ASdsadf'
# print(s2.casefold()) # casefold ---->funcation:make every charater字母
postion = s1.find('r') # return index of find str
while postion != -1:
pri... |
909606bcce11782b89b5a861e4b089453a1a44d8 | Changkyuuu/Chapter3 | /condition.py | 653 | 4.03125 | 4 | # if -elso
a = 1
if a > 5:
print('big')
a = 1
if a < 5:
print('big') # 요고만 출략
a = 3
if a > 5:
print('big')
else:
print('small')
# a가 5보다 크면 big를 출력하고 아니면 small을 출력해라
# if - elif -
n = -1
if n > 0:
print('양수')
elif n < 0:
print('음수')
else:
print('0')
# spam : 100
# egg : 500
# spagetti :... |
a137f7177d9fc069e1449a52eaa41925f5e4fc02 | karthik-siru/practice-simple | /DP/dsa_31.py | 1,264 | 3.671875 | 4 | '''
-> Always look for these two properties
1) Optimal substructure
2) Overlapping
The longest common suffix has following optimal substructure property.
If last characters match, then we reduce both lengths by 1
LCSuff(X, Y, m, n) = LCSuff(X, Y, m-1, n-1) + 1 if X[m-1] = Y[n-1]
If last chara... |
9025eab34b12a318393bc182d6755f678f935aa5 | Dragon91011/Camp-Code | /pirate.py | 1,019 | 4.25 | 4 | speech = {"hello":"arrrrr", "friend": "matey", "scallywags": "people", "water": "rum" ,"food": "turkey leg"}
def engtopirate(englishstring):
#need dictonary, e.g speech = {'hello':'arrrrr'}
#split english string into list of words
englishlist = englishstring.split(" ")
piratees = ""... |
4e2e445d8bce337333e3f5a2c1b2d11ea3b71cb1 | shivamchandra3/test_python_scripts | /largest_so_far_for_loop.py | 227 | 3.9375 | 4 | largest_so_far= -1
print('Before1', largest_so_far)
for the_num in [21, 31, 15, 23, 45]:
if the_num>largest_so_far:
largest_so_far= the_num
print(largest_so_far, the_num)
print('After', largest_so_far)
|
2baadada39ecbd0ae4ffc4406a7ba0e5b099a427 | Ananya-KU/Best-Enlist-CV-2021-Python-tasks | /Day10.py | 915 | 4.1875 | 4 | # Create a real time scenario for inheritance example Banking concept
class bank_Account:
def __init__(self):
self.balance=400
print("Welcome to Canara Bank")
def display(self):
print("\n Net Available Balance=",self.balance)
#Inheritance
class Deposit(bank_Account):
def d... |
6ff2be1eedd5129134be656ca875e56916c34a3e | ehsan-keshavarzian/pythonlangutil | /pythonlangutil/tests/overload.py | 520 | 3.828125 | 4 |
import unittest
from pythonlangutil.examples.overload import OverloadTest
class Test(unittest.TestCase):
def test_overload(self):
hit = OverloadTest()
self.assertEqual(hit.my_method("Joe"), "Dear Joe", "msg")
self.assertEqual(hit.my_method("Joe", True), "Mr. Joe", "msg")
self.as... |
9370a148b388438432498c7d106d78738d66c3b3 | shriya246/Python-Internship | /Day3task3.py | 110 | 3.953125 | 4 | #IF ELSE STATEMENT
n1=20
n2=30
if n1>n2:
print("n1 is greater")
else:
print("n2 is greater") |
f5237b8d9b3c0f860132ef6792bc2bb9de781d33 | chebizarro/foss4gna-python-qgis | /pyqgis_code/python_basics/point.py | 370 | 4.09375 | 4 | class Point:
""" Class to model a point in 2D space."""
""" Size of our marker in pixels """
marker_size = 4
def draw(self):
"""Draw the point on the map canvas"""
print "drawing the point"
def move(self, new_x, new_y):
""" Move the point to a new location on the
... |
960999417971c0b44c1be7b4e3ec98ef1b360fd6 | Ltre/python2-demo | /test3.py | 1,043 | 4.09375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Administrator'
print '===================================='
if 1 > 2:
print 'fuck'
else:
print 'nima'
print '===================================='
if 1 > 2:
print 'fuck'
print 'fuck'
print 'fuck'
else:
print 'nima'
print 'nima'... |
c9826fb1512f8185564a7a3099d4f8168fcc4aaa | emhart/Misc_Func | /MontyHall.py | 1,943 | 3.65625 | 4 |
'''
Python version of the Monty Hall problem
by EM Hart 2/20/2012
Change scenario by changing the code
in strat_dictionary (0,1,2)
'''
#from matplotlib import pyplot
import numpy.random as np
import numpy
from scipy import *
from matplotlib import pyplot
#create an array for Wins
pwins = zeros(1000)
#####Create an... |
69c2ebd3d6b771f2c7e33df9c9c1d3fa1ddc5eaf | Logan-cruz/Laccpythondocs | /program/chickenCalculator.txt | 551 | 4.09375 | 4 | #Logan Cruz+
#Chicken cooking calculator
def coalNeeded(chickens):
chickens/8
return chickens
def chickenNeeded(coal):
coal*8
return coal
answer = input("do you want to calculate chickens or coal today mortal? ")
if answer == "Coal" or "coal":
chickens= input("How many chickens do you have? ")
c... |
27f575ad6356cacce633e018daf292c9e7922040 | Daniiarz/neobis-1-file-projects | /python/Functions/voting.py | 312 | 3.5 | 4 | num = int(input())
result = []
def voting_result(kek):
c0 = 0
c1 = 0
for k in kek:
if k == "1":
c1 += 1
else:
c0 += 1
return (c0 > c1 and "0") or "1"
for i in range(num):
result.append(voting_result(input().split(" ")))
print("\n".join(result))
|
b4729b95c5cee845f664bec45aea6a8bf049f598 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_199/3294.py | 691 | 3.671875 | 4 | cases = int(raw_input().split()[0])
def to_bool_array(line):
return [c == '+' for c in line]
def apply(arr, pos, k):
for i in range(pos, pos + k):
arr[i] = not arr[i]
def is_ok(bool_array):
return reduce(lambda a, b: a and b, bool_array, True)
for i in range(cases):
data = raw_input().split(... |
3df9eb78c6bb8ec24acc16c50008f076bf0c73aa | xpessoles/Informatique | /P_05_AlgorithmiqueProgrammation/01_Recursivite/TD_02/programmes/Exercice_0n_dragon_v2.py | 596 | 3.5625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from math import cos,sin,pi
def TracerSegment(L,ori,x,y):
#print("appel",x,y)
x.append(x[-1]+L*cos(ori*pi/2))
y.append(x[-1]+L*sin(ori*pi/2))
print("appel",x,y)
return x,y
def DessineDragon(n,ori):
... |
8493f37401bae4da7c0bc5376861ece6b521dcfc | neil-ash/pe | /pe10_redo.py | 1,110 | 3.609375 | 4 | # 10 redone
# The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
#
# Find the sum of all the primes below two million.
##############################################################################################################
# Sieve of Eratosthenes method
# get input (end point)
endpt = int(input('Find all... |
a65e7d17b420e710c5c220970356ea7f67692168 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2216/60586/309449.py | 103 | 3.984375 | 4 | s=input()
if s==("-1/2+1/2"):
print("0/1")
elif s==("5/3+1/3"):
print("2/1")
else:
print(s) |
517d5e7c28efca7fb6ff62f02acbbf99fa0b1b6a | GGL12/myStudy | /leetcode/剑指offer/min_stack.py | 1,676 | 3.859375 | 4 | class Solution:
# def __init__(self):
# '''
# 映射栈的最小值情况
# '''
# self.stack = []
# self.min_map_stack = []
# def push(self, node):
# if self.min_map_stack:
# if self.min_map_stack[-1] < node:
# self.min_map_stack.append(self.min_map... |
80b56ee06f67edf6bace5b54bc4b3ea9cd402637 | rijorobins/LuminarDjangoPython | /LuminarProject/RegularExpressions/quantifiers.py | 437 | 4.21875 | 4 | import re
#QUANTIFIERS
pattern="aaaaabbbbaabaaabahbaa"
#x="a+" #it will check single and sequence a
#x="a*"
#x="a?"
#x="^a" #checks if given string starting with a or not ?
#x="a$" # checks if given string ends with a or not?
#x="a{2}" #it will check for 2 number of a's
#x="a{2,3}" #minimum 2 a and maximum 3 a
x="a{2... |
d97bfaa38f7b3dcee4ac3bd5f7283a702e137088 | zuowutan/stu_python | /condition_stu.py | 1,760 | 4.3125 | 4 | #!/usr/bin/python
# coding=utf-8
# Python 的条件语句 if else 学习:
# a = 6
# if a > 10:
# print "a大于10"
# else:
# print "a小于10"
# # ---------------------------------------------------------
#
# # Python 的多重条件语句 if elif elif ... else 学习:
# if a > 2:
# print "a大于2"
# elif a < 9:
# print "a小于9"
# elif a > 7:
... |
ab57753aa6cdf5987ff4c1a7e8914c4304103d6b | zhangchizju2012/LeetCode | /524.py | 1,213 | 3.59375 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 11 12:22:37 2017
@author: zhangchi
"""
class Solution(object):
def findLongestWord(self, s, d):
"""
:type s: str
:type d: List[str]
:rtype: str
"""
result = ""
for item in d:
i... |
6e473f04c0e0496c2fa2c326033f6db9c9ead2a6 | itsanti/uii_py_dev | /HW02/tasks.py | 2,730 | 4.21875 | 4 | '''
Задача 1
Вывести на экран циклом пять строк из нулей, причем каждая строка должна быть пронумерована.
'''
for k in range(1, 6):
print(k, 0)
'''
Задача 2
Пользователь в цикле вводит 10 цифр. Найти количество введеных пользователем цифр 5.
'''
fives = 0
for k in range(1, 11):
if int(input('Введите число ... |
3801beeb59f1775edc396b0a6ef60a1bfa04ce76 | mengyuliu/question_leet | /34.search-for-a-range.py | 1,763 | 3.859375 | 4 | #
# [34] Search for a Range
#
# https://leetcode.com/problems/search-for-a-range/description/
#
# algorithms
# Medium (31.59%)
# Total Accepted: 180.5K
# Total Submissions: 571.3K
# Testcase Example: '[5,7,7,8,8,10]\n8'
#
# Given an array of integers sorted in ascending order, find the starting and
# ending positio... |
5e57794a02e70854b23be97efdfbbaff65914144 | ashwinitangade/PythonProgramming | /PythonAss1/10.py | 666 | 4.5625 | 5 | #Using assignment operators, perform following operations
Addition, Substation, Multiplication, Division, Modulus, Exponent and Floor division operations
num1 = 50
num2 = 20
result = 0
result = num1 + num2
print('Value of result using + operator:',result)
result += num1
print('Value of result using += operator:',res... |
836ae1ff548b0f70289a4bac2ed886a4cf00c114 | erdemru/Recipe-propose | /Recipe.py | 1,814 | 4.03125 | 4 | recipe_book = open('recipes.txt','r') #recipes book, should be in the same directory with the py file
print("Hello! Are you starving? I am here for you:)") #welcome, only one time
def main_menu(): #main menu, we want to go back to this list to keep the user in the software
go_back = True
while go_back == True:
... |
9e1a1ffb9bf08f7d9b02c4f3071702abf7349435 | mistersiddd/Balloon-Shooter | /balloonshooter.py | 3,051 | 3.59375 | 4 | import turtle
wn = turtle.Screen()
wn.title("Balloon")
wn.bgcolor("black")
wn.setup(width=800,height=600)
wn.tracer(0)
score = 0
missed_score = 0
# Balloon
baloon=turtle.Turtle()
baloon.speed(0) # not the speed of the paddle
baloon.shape("circle")
baloon.shapesize(stretch_wid=3, stretch_len=3)
baloon.color("whit... |
11cd3cb7dc2676ac12ee613b0e77fbd5b8db8ae8 | Vladk550/SomeCode | /Filter.py | 517 | 3.59375 | 4 | class Filter:
def __init__(self, iterable, filter_function):
self.iterable = iterable
self.filter_function = filter_function
self.iter = None
def __iter__(self):
#self.iter = iter(self.iterable)
for elem in self.iterable:
if self.filter_function(elem... |
9810ad535809e83846c48907194aab0dc8c130c7 | sheepinriver/pyML | /pyML/visualization.py | 2,125 | 3.578125 | 4 | import numpy as np
import matplotlib.pyplot as plt
from .kNN import KNNClassifier
def draw_2D_kNN(X, y, X_predict, k=5):
"""画一个二维的散点图和折线图,用以演示kNN算法"""
assert X.shape[1] == X_predict[1] == 2, \
'X and x_predict must have two features '
assert X.shape[0] == y.shape[0], \
'The size of X must ... |
516e263fe9c5bd394306d9785752f5f552c79159 | Igjanka/pte_et_c2_2021 | /ora4/max.py | 280 | 3.828125 | 4 | import random
random.randint(3, 5)
random.random()
my_list = []
for i in range(20):
my_list.append(random.randint(1, 101))
print(my_list)
max = my_list[0]
for i in range(len(my_list)):
if max < my_list[i]:
max = my_list[i]
print(max)
my_list.sort(reverse=True)
|
81dd88c3a9b6e1ca8061fe0a5a9cee4d716daaa7 | Bikashacharaya/Jspider_Python | /Right_Angle_Triangle/pat_5.py | 219 | 3.9375 | 4 | '''
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
'''
n = int(input("Enter any value: "))
x = 1
for row in range(1, n+1):
for col in range(1, row+1):
print(x, end=" ")
x = x+1
print()
|
7d2ef4dd2b3565fbd812df99149ddbef2a9f3c49 | HardeepGill2395/python-learning | /First Program.py | 162 | 3.96875 | 4 | print ("Hello everyone")
s = input(" Enter your name \n")
age = int(input(" Enter your age \n"))
print("Hi " +s*5 + " your age is " +str(age*10))
print("Hello")
|
2136bcf42459f0964ff3f28681949d694acbfd45 | mmikhalina/colloquium | /26.py | 582 | 3.78125 | 4 | """
Напишіть програму аналізу значень температури хворого за добу:
визначте мінімальне і максимальне значення, середнє арифметичне. Заміри
температури виробляються шість раз на добу і результати вводяться з клавіатури у
масив T.
Mikhalina Myroslav 122D
"""
T = []
for i in range(1, 6):
T.append(float(inpu... |
91747062361d9b1b171f6ef1c441c23d467a7cba | weiguangjiayou/LeetCode | /LeetCode/LeetCode61rotate-list.py | 858 | 3.921875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/10/31 10:08 AM
# @Author : Slade
# @File : LeetCode61rotate-list.py
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def rotateRi... |
5ae7a4e7119c4e109db0f325a0c97ae65388ea10 | rez433/python | /kmom06/file/string.py | 1,610 | 3.96875 | 4 | #!/usr/bin/env python3
# pylint: disable=missing-function-docstring, missing-module-docstring
filename = "items.txt"
def menu():
print(
"""
1. Show file content
2. Add item, append
3. Replace content
4. Remove an item
"""
)
return int(input("Choice: "))
def choice(inp):
if inp =... |
10725c03b0cc0a00aff11a7558990468d229ea5c | garthus23/holbertonschool-higher_level_programming | /0x03-python-data_structures/5-no_c.py | 233 | 3.65625 | 4 | #!/usr/bin/python3
def no_c(my_string):
result_str = ""
for i in range(0, len(my_string)):
if my_string[i] != 'c' and my_string[i] != 'C':
result_str = result_str + my_string[i]
return (result_str)
|
513e2c95e67791ea5f27e3352efbd87b1afc6fd4 | Fulvio7/curso-python-guppe | /guppe/exercicios_secao_8/ex_13.py | 1,001 | 4.375 | 4 | """
13- Faça uma função que receba dois valores numéricos e um símbolo.
Este símbolo representará a operação que se deseja efetuar com os números,
conforme a tabela abaixo:
+ -> adição
- -> subtração
* -> multiplicação
/ -> divisão
"""
def calculadora(n1, n2, operacao):
if operacao == '+':
return n1 + n2
... |
be40d10b229e6b257d86f6fff04850e245e9cc2c | dana-gz/pythonProject | /05_methods/new_hunt_the_thimble.py | 382 | 3.765625 | 4 | secret_number = 5
previous_guess = -100
while True:
user_number = int(input("Give me your guess: "))
if user_number == secret_number:
break
if abs(user_number - secret_number) < abs(previous_guess):
print('warm!')
previous_guess = abs(secret_number -user_number)
else:
... |
bfbe2276306b9590c636a2ae28f70277ae2b1866 | n-chaitanya/Prolem-Solving-Q | /stringWordReverse.py | 952 | 3.640625 | 4 | # #string reverse
class TestCases:
def __init__(self,input,output):
self.input = input
self.output = output
c1 = TestCases('My name is Chaitanya Nagulapalli','yM eman si aynatiahC illapalugaN')
c2 = TestCases('uppercase','esacreppu')
c3 = TestCases(' ',' ')
testList = [c1,c2,c3]
def stringWordReve... |
3e4bad68e6f27404712c8c81d23285bd8f07844a | Akrog/project-euler | /016.py | 330 | 3.921875 | 4 | #!/usr/bin/env python
"""Power digit sum
Problem 16
Published on 03 May 2002 at 06:00 pm [Server Time]
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?
"""
result = sum(map(int, str(1 << 1000)))
print "The sum of the digits of the number 2^1000 is... |
9f2d728e62edaa986ac8b5eb9877c8ddcad6976a | watchtree/Algorithms_python | /testOffer/printMatrix.py | 4,825 | 4.09375 | 4 | #!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:wttree
# datetime:2018/10/13 19:20
# software: PyCharm
# question:输入一个矩阵(不一定是标准的n*n),按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下4 X 4矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.
class Solution:
#v1.0分为两个部分函数完成,一是PrintMatrixI... |
8b88edb5a75a2c8ae021163bdbe11089b88b6f6b | tmoriartywcc/week10 | /makename.py | 192 | 4.03125 | 4 | first_name = input('enter first name: ')
middle_name = input('enter middle name: ')
last_name = input('enter last name: ')
name = first_name + ' ' + middle_name + ' ' + last_name
print(name) |
b18609cde09810784b1c2ce40381ee7ab7ee6d43 | samaro19/Random_Code | /decode_ceaser.py | 717 | 3.859375 | 4 | dict = {
-2: '!',
-1: '?',
0: ' ',
1: 'a',
2: 'b',
3: 'c',
4: 'd',
5: 'e',
6: 'f',
7: 'g',
8: 'h',
9: 'i',
10: 'j',
11: 'k',
12: 'l',
13: 'm',
14: 'n',
15: 'o',
16: 'p',
17: 'q',
18: 'r',
19: 's',
20: 't',
21: 'u',
22: '... |
ae90340100414a975d8a06b22d1affd2a213ecba | SiervoDeAnubis/el_python | /functions.py | 831 | 3.8125 | 4 | # A function is a block of code which only runs when it is called. In Python, we do not use parentheses and curly brackets, we use indentation with tabs or spaces
def sayHello(name='Cecilia'):
"""
Prints Hello and the name
"""
print('Hello ' + name)
# Return Value
def getSume(num1, num2):
tota... |
04d566f13e2bc89d2adcc98cc7ecfed641e3ab88 | SpooderManEXE/Hacktoberfest2020-Expert | /Python Programs/Huffman_Coding.py | 1,326 | 3.8125 | 4 | string = 'BCAADDDCCACACAC'
# Creating tree nodes
class NodeTree(object):
def __init__(self, left=None, right=None):
self.left = left
self.right = right
def children(self):
return (self.left, self.right)
def nodes(self):
return (self.left, self.right)
def __str__(sel... |
8c7c0437f9dd4c99f1a4800b7eca62dfeaf96c20 | Ingrubenl/appTest7 | /basic_calc2.py | 373 | 3.859375 | 4 | #Basic calc to junior insers
#Developer : Ruben Dario lasso
#Libraries##############################
import os
#########################################
#Funtion##############################
def calc(x,y):
suma = x + y
print("la suma es: ",suma)
#Main##############################
print("press number 1: "... |
9ff1f8b51435f8eed93b7e32d3886897a16ebcf2 | qiuyucc/pythonRoad | /BasicReview/01String.py | 5,377 | 4.0625 | 4 | # 字符串中的字符可以是特殊符号、英文字母、中文字符、日文的平假名或片假名、希腊字母、Emoji字符
# s1 = 'hello, world!'
# s2 = 'hello, world!'
#
# print(s1, s2)
#
# s3 ='''
# hello,
# world
# '''
#
# print(s3, end=' ')
# r 原始字符串, 使用了R或者r, 转义字符串就会变成原始字符串
s1 = '\time up \now'
print(s1)
#字符串s2中没有转义字符,每个字符都是原始含义
s2 = r'\time up \now'
print(s2)
# 字符串中 \ 后面可以接一个8进制,... |
ce4c1157007406cf548c019bd2bd09ddbe026478 | sdierauf/uw-cse | /143/PyHelloWorld/moar.py | 702 | 3.640625 | 4 | '''
Created on Feb 28, 2013
@author: Stefan
'''
colors = ['red', 'blue', 'green']
print(colors)
sum = 0
for i in range(100):
sum += i
print(sum)
sum = 0
numbers = [1, 3, 5, 6, 7, 5, 6, 7, 9, 0, 1, 2, 6, 7, 4]
for i in numbers:
print(i)
sum += i
print('sum is: ' + str(sum))... |
8a3c376715d74a068077eeb55da2591f2e73f733 | Grawlin/Bootrain-Data-Science | /BootrainAssignment4.py | 2,218 | 3.859375 | 4 | title = 'Exercise N°{}'
print(title.format(1), '\n')
my_list = [34, 56, 76, 45, 2, 12, 67, 98, 37, 54, 66]
min_list = my_list.copy()
min_1 = min(my_list) #Save de lowest number
min_list.pop(min_list.index(min(min_list))) #Removes the lowest number from the copy of the original list
min_2 = min(min_list)... |
99e93ead13224349ce471d58667be97ac726e6fa | awestover/python-ev3 | /arm/arm/tablev/Vector.py | 1,210 | 3.953125 | 4 | """
vector class for representing 2d arrays
"""
import math
class V():
"""
either pass a 2D array or x,y
"""
def __init__(self, *args):
self.x = 0
self.y = 0
if len(args) == 1:
self.x = args[0][0]
self.y = args[0][1]
if len(args) == 2:
self.x = args[0]
self.y = args[1]
# to string method
d... |
821577bf9245a4bb64c541b7846edd3cda3eae25 | thomasbreydo/little-scripts | /alphabet_info.py | 378 | 3.625 | 4 | #!/usr/bin/env python3
from string import ascii_lowercase as al
from termcolor import cprint
a = 0
print()
for i, c in enumerate(al):
if a > 25:
print(' '*8, end='')
else:
cprint(al[a:a+5].ljust(5).upper(), 'white', 'on_blue', end=' | ')
a += 5
cprint(c.upper(),'white', end=':')
... |
bd2a607a605da5d2cfb1c15665eb981363dd7065 | erjan/coding_exercises | /the_most_similar_path_in_graph.py | 5,570 | 3.796875 | 4 | '''
We have n cities and m bi-directional roads where roads[i] = [ai, bi] connects city ai with city bi. Each city has a name consisting of exactly three upper-case English letters given in the string array names. Starting at any city x, you can reach any city y where y != x (i.e., the cities and the roads are forming ... |
58f50ad0109156fb7f61062042bb4ccaf823fe6a | rafaelperazzo/programacao-web | /moodledata/vpl_data/126/usersdata/233/29902/submittedfiles/ap2.py | 423 | 4.03125 | 4 | # -*- coding: utf-8 -*-
a=float(input('Digite um número:'))
b=float(input('Digite um número:'))
c=float(input('Digite um número:'))
d=float(input('Digite um número:'))
if a>=b and a>=c and a>=d:
if b<=c and b<=d:
print('%d'%a)
print('%d'%b)
if c<=b and c<=d:
print('%d'%a)
print('... |
9e1bd00a437ee331cd97e6f3b030d9c53d7f0c7e | hivauz/grokking_git_commands | /e.py | 1,343 | 3.859375 | 4 | import time
n = 6
result_matrix = [[0 for x in range(n)] for y in range(n)]
def print_matrix( r):
for i in range(n):
for j in range(n):
print(r[i][j], end = '\t')
print()
counter = 1
k = n
# row left to right
print("the middle is" + str((n//2+1)))
for i in range(n//2+1):
time.sleep(2)
print("*... |
7b4c3951ba452363a57faa3d67d579ee6c88146b | melisarv/holbertonschool-higher_level_programming | /0x03-python-data_structures/7-add_tuple.py | 349 | 3.96875 | 4 | #!/usr/bin/python3
def add_tuple(tuple_a=(), tuple_b=()):
while len(tuple_a) < 2:
tuple_a += (0,)
while len(tuple_b) < 2:
tuple_b += (0,)
first_tuple = tuple_a, tuple_b
sum1 = sum([par[0] for par in first_tuple])
sum2 = sum([par[1] for par in first_tuple])
last_tuple = sum1, ... |
ae21c061854b509f7e92bce6821b2eb09951df5d | LucasWarner/ISC4U_CULM | /Main/MonthlySchedule.py | 4,557 | 3.828125 | 4 | # -------------------------------------------------------------------------------
# Name: MonthlySchedule.py
# Purpose: File to create and display the monthly schedule
# Author: Warner.Lucas, McKeen.Kaden
#
# Created: 13/04/2018
# ---------------------------------------------------... |
5d44b555ef290ba906dbed7d592f73faba537a35 | yeshixuan/Python | /05-Spider/01-爬虫基础/02-requests模块相关/v25-session.py | 661 | 3.671875 | 4 | """
session 模拟一次回话
ss = requests.session()
ss.post(url,data=data,headers=headers)
rsp = ss.get(url)
ssl证书
rsp = requests.get(url,verify=False)
"""
import requests
proxy = {
"http":"211.23.149.29:80",
# "https":"163.172.215.202:3128"
}
# 创建session对象,可以保持cookie值
ss = requests.session()
url = "h... |
8a871902f3cce1cc9ccdc503a305687ef00360c2 | letspython3x/erp_department_store | /forms/validate_forms.py | 7,321 | 3.59375 | 4 | from abc import ABC, abstractmethod
class ValidatePayload(ABC):
"""
Abstract Class for validating the forms
"""
@abstractmethod
def __init__(self, **kw):
pass
@abstractmethod
def validate(self):
"""Validate the received payload"""
class ValidateProduct(ValidatePayload):... |
65a081225916f30775835b66fc5629c97c57ce8b | hambali999/Let-s-Study-Python | /FUNCTIONAL/file-handling/lab4/3a.py | 2,195 | 3.765625 | 4 | import random
def method1():
diceCount = [0, 0, 0, 0, 0, 0, 0]
throws = 100
diceList = []
for i in range(1, throws+1):
randomThrow = (random.randrange(1,6+1))
diceList.append(randomThrow)
face1 = diceList.count(1)
face2 = diceList.count(2)
face3 = diceList.count(3)
face4... |
4f9f79af7a81dec36c1a4b31317670cbaa1216a6 | MicaelSousa15/PTS | /16.py | 205 | 3.875 | 4 | string = ['Arroz','Macarrão','Carne']
print(string)
p_string = string.pop()
print(string)
print(p_string)
# O metodo pop tira da lista, mas pode ser salvo em alguma outra variavel se colocado
# string.pop |
7700a0bf63d35899e0931026d650450121a76ee6 | AzimAstnoor/BasicPython | /ToFindTheMultiplicationTableOfAnyNo.py | 227 | 4.09375 | 4 | a = float(input('Enter the Number you want the multiplication table'))
d = float(input('Enter the N. you want to find the multiplaction table till'))
c = 1
while c < d:
b = a*c
print(c, ' * ', a, ' = ', b)
c = c + 1 |
438f1379de0583f53a170aebfef0ba37b8bc57b9 | LeanderLXZ/learning-python | /Python Notes/6_07_Sets.py | 1,181 | 4.5 | 4 | # Sets
num_set = {1, 3, 4, 5}
word_set_1 = {"spam", "eggs", "sausage"}
word_set_2 = set(["spam", "eggs", "sausage"])
print(3 in num_set)
print(word_set_1)
print(word_set_2)
print("spam" in word_set_1)
# Create an empty set
my_set = set()
# Create an empty dictionary
dict = {}
# Sets are unordered, which means they ... |
2e63fd6f8cd68f225b291b12b34d95e5105c18b8 | thiejen/python_excercises | /pilot/28.max_of_three.py | 282 | 4.125 | 4 | #! /usr/local/bin/python
# -*- coding: utf-8 -*-
def find_max(a,b,c):
tmp = a
if tmp < b:
tmp = b
if tmp < c:
tmp = c
return tmp
x = raw_input("Input 3 numbers: ")
xs = x.strip().split(' ')
print 'Max is {}'.format(find_max(xs[0], xs[1], xs[2]))
|
7250c672ad1b6b10dcf6a5703899e5c95bfc80d2 | h-mora10/miso-agiles | /src/Fibonacci.py | 591 | 4.21875 | 4 | # -*- coding: utf-8 -*-
def fibonacci(numero):
if numero <= 1:
return numero
else:
return fibonacci(numero - 1) + fibonacci(numero - 2)
# Número que será el límite superior de la serie
numMax = int(raw_input("Ingrese hasta cuál número desea calcular la Serie de Fibonacci?: "))
# Ciclo que calc... |
6d1957a10c716e4d1a9a18824d2fc87b7529b3fb | miky-roze/python-unittest | /04_shopping_basket_project/tests/test_shopping.py | 2,274 | 3.671875 | 4 | import unittest
from main_codes.shopping_basket import ShoppingBasket
from parameterized import parameterized
class TestShoppingBasketWithNoProducts(unittest.TestCase):
@classmethod
def setUpClass(cls):
print('\n[INFO] Setting up basket without any product...')
cls.basket = ShoppingBasket()
... |
40c00c4ac0aaa8c06afab26f8daaacbd35d24fdd | Honoriot/Python_code | /OOP/Class Code4.py | 1,214 | 4 | 4 |
class transport:
def __init__(self, People_sit):
self.People_sit = People_sit
def Num_Of_People(self):
print("People travels " + str(self.People_sit))
@staticmethod
def Dur_Of_Travel(value):
print("Travelling for " + str(value) + " time.")
class automobile:
def __init... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.