blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
89012008dd98dda6ba2c72aa709904fe7ef45753 | ngocminhdao88/dao_masterarbeit | /messungen/auswertung_skipt/kurve_bearbeiten/capacitance_histogram.py | 5,016 | 3.5 | 4 | """
Plot the histogram of all capacitance
Usage:
python capacitance_histogram.py -i <file_name>
"""
import sys
import getopt
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import RectangleSelector
class MeasurementData:
"""
Class to hold data of ... |
45227ad36d2569f275e72628a9de819d13faeea3 | AnaMariaBiliciuc/Instructiunea-FOR | /prob3.py | 95 | 3.765625 | 4 | n=int(input("Introduceti un nr: "))
for n in range(1, nr):
if n %2== 0:
print(n) |
b49f6a5d065a908e85e419a6094502a5e23ebdc5 | Specker/Python-Basics-learnPython- | /Advanced/Sets.py | 257 | 4.0625 | 4 | # In the exercise below, use the given lists to print out a set containing all the participants from event A which did not attend event B.
a = ["Jake", "John", "Eric"]
b = ["John", "Jill"]
eventA = set(a)
eventB = set(b)
print(eventA.difference(eventB)) |
4c254ad46e079b2b422bc539c82b992fdbf1470d | Specker/Python-Basics-learnPython- | /Advanced/Introspection.py | 350 | 3.734375 | 4 | # Print a list of all attributes of the given Vehicle object.
class Vehicle:
name = "UAZ"
kind = "car"
color = "Black-ish"
value = -100.00 # Take it of my hands...
def description(self):
desc_str = "%s is a %s %s worth $%.2f." % (self.name, self.color, self.kind, self.value)
return... |
1c70f2b2dcc75929cccf77b57ca78e8b4b3bc478 | Kingson4Wu/python2-demo | /src/runoob/08.字符串.py | 1,372 | 3.984375 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
var1 = 'Hello World!'
var2 = "Python Runoob"
print "var1[0]: ", var1[0]
print "var2[1:5]: ", var2[1:5]
# 字符串连接
var1 = 'Hello World!'
print "输出 :- ", var1[:6] + 'Runoob!'
# 字符串运算符
# r/R 原始字符串 - 原始字符串:所有的字符串都是直接按照字面的意思来使用,没有转义特殊或不能打印的字符。 原始字符串除在字符串的第一个引号前加上字母"r"(可以大小写)以外,与普通... |
698b9eff215302919ab8a33fc3961bdf081438be | kakabei/leetcode | /squares-of-a-sorted-array/squares-of-a-sorted-array.py | 766 | 3.9375 | 4 |
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
https://leetcode-cn.com/problems/squares-of-a-sorted-array/
977. 有序数组的平方
给定一个按非递减顺序排序的整数数组 A,返回每个数字的平方组成的新数组,要求也按非递减顺序排序。
示例 1:
输入:[-4,-1,0,3,10]
输出:[0,1,9,16,100]
思路: 很简单
"""
def sortedSquares(A) :
return sorted([a**2 for a in A])
if __name__ == '__main__':
... |
93cbc0bdf6d4dc0647907d001f6064a2bde459dc | kakabei/leetcode | /calculator-lcci/calculator-lcci.py | 951 | 3.875 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
##
# https://leetcode-cn.com/problems/calculator-lcci/
# 计算器
##
"""
思路小结:
1. 用栈
2. 第一个数字前面加+
3. 把+和-后面的值加入栈中,如果是*和/就从栈中拿出第一个数字,然后运算后加回去
4. 把栈中的所个数字相加
5. 正则分离数字
"""
import re
def calculator_lcci(args):
stack = []
args ='+'+ args
patt = re.compile(r'\d+|\+|\*|-|/')
args... |
e8a03962a702d7d5798086f731201b8fc612d270 | youngseong/hackerrank | /algorithm/non_divisible_subset.py | 1,011 | 3.5625 | 4 | # https://www.hackerrank.com/challenges/non-divisible-subset/problem
import math
import os
import random
import re
import sys
# Complete the nonDivisibleSubset function below.
def nonDivisibleSubset(k, S):
modcnts = [0] * k
for s in S:
modcnts[s % k] += 1
maxsz = 0
def elementCount(i):
... |
ea2bed64cb1b1c463a614ec92f180f5532d639d1 | youngseong/hackerrank | /algorithm/candies.py | 960 | 3.59375 | 4 | # https://www.hackerrank.com/challenges/candies/problem
import math
import os
import random
import re
import sys
# Complete the candies function below.
def candies(n, arr):
cs = [0] * n
# set 1 for each local minima
for i in range(n):
if (i == 0 or arr[i] <= arr[i-1]) and (i+1 == n or arr[i] <= arr... |
9cec4fdfd1fc74f9a060f4a45e8d7114627642f1 | keshavsbhandari/CS4347 | /assignment1_regression/utils/RandomDataGenerator.py | 1,231 | 3.828125 | 4 | import numpy as np
class Data:pass
E = lambda x: np.insert(x, 0, 1, axis=1)
"""
THIS IS THE ANALYTICAL APPROACH FOR SOLVING LINEAR EQUATION
TRY TO UNDERSTAND THIS FUNCTION by playing with this with some random data, and theory behind it
We will use this only for our smaller dataset with only 1 feature in x and 1 yd... |
1598b8742e1273bfae703428c6fdc631d100ca55 | parkeraddison/coding-challenges | /validating-postal-codes.py | 4,238 | 4.15625 | 4 | # Parker Addison
# 2019.04.03
# ########################################################################### #
# Paraphrased from:
# https://www.hackerrank.com/challenges/validating-postalcode/problem
#
# A valid postal code must fulfill the following requirements:
#
# 1. It must be consist of digits in the range of 1... |
9c261ac888c18c8bbe578a65d5f99a08fa69e3f9 | jgnunes/solucoes_Esperanca | /formata_paragrafo.py | 3,124 | 4.0625 | 4 | def formata_paragrafo(texto, n):
palavras = texto.split() #cria uma lista com todas as palavras do texto
linhas = [] #inicia a lista que ira conter todas as linhas do paragrafo formatado
contador_caracteres = 0 #inicia um contador de numero de caracteres
linha = [] #inicia a lista que ira conter o conj... |
5fb5e6b496a427ec925d07e2e4202074057ba2a0 | prasad-muddala/Learn-Python-Coding | /Basic_calculator_using_python.py | 661 | 4.125 | 4 | #addition
def add(m,n):
return m+n
# subtraction
def sub(m,n):
return m-n
#multiplication
def mul(m,n):
return m*n
##division
def div(m,n):
return m/n
print(""" Select the operation you want to perform
1.Addition
2.Subtraction
3.Multiplication
4.Division
""")
print("enter two values to perform the operation")... |
d2de282c84e92c1fb5f1fb27df6988834b3c5fc7 | ZoliQua/python-home-kezdo | /otos-lotto-pair3.py | 2,269 | 3.578125 | 4 |
# PAIR3
#
# This program is part of a series of programs for the Hungarian public lucky game (ötöslottó)
# This game is a national-wide lottery:
# -- There are 5 draws from 90 numbers (01-90)
# -- There is one draw in each week
# -- Game began in 1957 back in the communist era
# -- We have the data from all the dra... |
4a9e2db73a1f838b3cdd920b94b9b8b670d47f57 | ZoliQua/python-home-kezdo | /otos-lotto-pair2.py | 2,790 | 3.578125 | 4 |
# This program is part of a series of programs for the Hungarian public lucky game (Ötöslottó) to test Python
# This game is a national-wide lottery:
# -- There are 5 draws from 90 numbers (01-90)
# -- There is one draw in each week
# -- Game began in 1957 back in the communist era
# -- We have the data from all th... |
96694d6f3a631b36b95f251b481438309015a9a0 | ZoliQua/python-home-kezdo | /test-string-functions-3.py | 1,269 | 3.734375 | 4 | #
# Test to mask a text
# Written by Zoltan Dul, DMD, Phd
# 2021
#
import string
import random
list_of_sources = [
string.ascii_letters,
string.ascii_lowercase,
string.ascii_uppercase,
string.digits,
string.hexdigits,
string.octdigits,
string.punctuation,
string.printable]
#
#... |
b92216513ca4670ef9843949cefbcfe03ffa7a56 | scriptk1tty/messinround | /childrenamount.py | 520 | 3.796875 | 4 | import random
print("Hello dearie!")
response = input()
childrenAmount = random.randint(1, 20)
found = False
while not found:
print ("Can you guess how many children I have?")
guess = int(input())
if int(guess) == childrenAmount:
found = True
print("That's right! Can you be... |
8d9397fa094612f89562510c2b8a2c6391f2d277 | DongdongL/coins | /coins.py | 725 | 3.625 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*- 10
import math
def kk(m):
return int(math.log(m,2));
def coin(num,k,list):
mk=kk(num);
if mk>k:
mk=k;
if mk >= 0:
num1=num-2*int(2**mk);
if num1>0:
coin(num1,mk-1,list);
if num1==0:
list.append(1)
... |
594c74e572bf40383268b84a5c3ef4fda73ab876 | xxg2/pythonl | /ch7/1.py | 448 | 3.734375 | 4 | s = "spam's spam's spam's"
S = 's\np\ta\x00m'
a = """test"""
print(a)
b = b'spam' # 字节字符串
print(b)
c = "a %s parrot" % a
print(c)
d = "a %s parrot".format(a)
print(c)
e = "asdjfljsdflksadf".find('a')
print(e)
print(s.rstrip()) # 移空行
print(s.replace('pa', 'xx'))
print(s.split("'"))
print(s.isdigit())
print(s.lower())
p... |
f791ecb0163975e64f9d60ae1704c770a2f04b6b | xxg2/pythonl | /scrapy/get_start/printTable.py | 311 | 3.53125 | 4 | # -*- coding=UTF-8 -*-
class PrintTable(object):
def __init__(self):
self.print99()
def print99(self):
for i in xrange(1, 10):
for j in xrange(1, i+1):
print '%dX%d=%2s ' % (j,i,i*j),
print '\n'
if __name__ == '__main__':
pt = PrintTable() |
f9f3fe1bfb3252aba32f848ab10ed18985d00c9e | xxg2/pythonl | /ch3/listp.py | 665 | 3.59375 | 4 | # 列表可以包含任何类型的
L = [123, 'spam', 1.23]
print(len(L))
print(L[1])
print(L[:-1])
L.append('NI')
L = L + [4,5,6]
print(L)
# remove the third item
L.pop(2)
print(L)
# ------------------------------
M = ['bb', 'cc', 'aa']
M.sort()
print(M)
M.reverse()
print(M)
# ---------------列表解析表达式
matrix = [[1,2,3],[4,5,6],[7,8,9]]
prin... |
2f12233fb60f855be2e1d44b18345e14a39ffdc0 | MouradLachhab/Algorithms | /TP2/code/test_constante.py | 759 | 3.734375 | 4 | import sys
import numpy as np
import matplotlib.pyplot as plt # To visualize
import pandas as pd # To read data
from sklearn.linear_model import LinearRegression
data = pd.read_csv(sys.argv[1]) # load data set
X = data.iloc[1:, 0].values.reshape(-1, 1) # values converts it into a numpy array
Y = data.iloc[1:, 1].v... |
c7ac6e154125e8bfa97d68d0dee7ab5dee267445 | alistair-mclean/practice | /Python/openCV/sentdex/ex12/ex12.py | 548 | 3.5 | 4 | import cv2
import numpy as np
import matplotlib.pyplot as plt
# CORNER DETECTION
img = cv2.imread('img2.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# CONVERT TO FLOAT32 TO SATISFY THE CORNER DETECTION AGLO
gray = np.float32(gray)
corners = cv2.goodFeaturesToTrack(gray, 100, 0.01, 10) # (on what, how many, i... |
80090c61590892d3021eb1ed0546f22b4efe854d | Alst0wn/infa_2020_bugrova | /lab8/pygameguncool.py | 10,261 | 3.65625 | 4 | import pygame
from pygame.draw import *
from random import randrange as rnd, choice
import math
pygame.init()
FPS = 30
screen = pygame.display.set_mode((800, 600))
RED = (255, 0, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
GREEN = (0, 255, 0)
MAGENTA = (255, 0, 255)
CYAN = (0, 255, 255)
BLACK = (0, 0, 0)
WHITE = (2... |
a0a6d2649072d2b9861fc9b271238149df24f603 | adityakankariya/Artificial-Intelligence-Projects | /8-puzzle/puzzle.py | 12,370 | 3.859375 | 4 |
from __future__ import division
from __future__ import print_function
import sys
import math
import time
import queue as Q
import resource
import heapq
#### SKELETON CODE ####
## The Class that Represents the Puzzle
class PuzzleState(object):
"""
The PuzzleState stores a board configuration and implement... |
84e9d1c2a9b1836a0679d13e239672f107dc3162 | raissaazaria/week6forumAlgoProg | /No 3 forum files.py | 631 | 4.21875 | 4 | file= open("plainText.txt","r") #open the text and read
content = file.read()
splitWords=content.split() #split the word in content file
wordTokenLength = sum(len(word)for word in content.split()) #sum the length of the word lin content.split
wordToken =len(content.split()) #basically it just couunt the length in... |
23b84727cd3d57c5476ed0365343654c857e594c | beneditomacedo/datacamp_i_dl_python | /Chapter2/calc_slope.py | 1,072 | 4.40625 | 4 | # You're now going to practice calculating slopes. When plotting the
# mean-squared error loss function against predictions, the slope is 2 * x *
# (xb-y), or 2 * input_data * error. Note that x and b may have multiple
# numbers (x is a vector for each data point, and b is a vector). In this case,
# the output will als... |
4d7738f035f146e63d1f4221965b85554f5b30d8 | sanjeevk1999/Assignment2 | /q1/caesar.py | 233 | 3.8125 | 4 | def decrypt(text):
for i in range(1, 27):
result = ""
for j in range(len(text)):
result += chr((ord(text[j]) + i) % 26 + 65)
print("Key: " + str(i) + " Plain-Text: " + result)
text = "YOAXLAQKQGPTVWQCQXXSRXJGTQYORCRNAKQKGVNWUQRTXOQBGYVLACBTQRYWAXBVXYKGJJRRCWSRNFQWGPPYOQWGTJGVXQP... |
b2d8e5ffd75c32a24aafd93ed0f8086dfce40e5a | pmrowla/aoc2019 | /day22.py | 2,756 | 3.578125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Advent of Code 2019 day 22 module."""
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)
def modinv(a, m):
g, x, y = egcd(a, m)
if g != 1:
raise Exception('modular... |
d338e75bd3f13c6ce4ea9a888f51762299f4d4c6 | srikrishna777/python | /celtofah.py | 125 | 4.03125 | 4 | Celsius = int(input("Enter Celsius:"))
Fahrenheit = (Celsius * 9/5) + 32
print("the value of Fahrenheit is:" ,Fahrenheit)
|
7222160f1ec5ebe21ff01783ba4ace560f4faf0e | srikrishna777/python | /simple_interest_def.py | 262 | 3.609375 | 4 | def simple_interest(p,t,r):
print("the principle is",p)
print("the time period is",t)
print("the rate of interset",r)
simpleinterest= (p * t * r)/100
print("the simple_interest is",simpleinterest)
return;
simple_interest(8,6,8) |
c42863610a847f8f0822ad3fe8893dd0d82f8fc9 | srikrishna777/python | /My Python Programs/equalequal2.py | 101 | 3.5 | 4 | a=777
b=777
if(a==b):
print("the values are equal")
else:
print("the values are not equal") |
9492c67bdefa0359df4921bf4b8bcaba8dc80437 | srikrishna777/python | /My Python Programs/simple interest.py | 236 | 3.625 | 4 | def simple_interest(p,t,r):
print("the principal is",p)
print("the time period is",t)
print("the rate of interest is",r)
si=(p*t*r)/100
print("the simple interest is",si)
return si
simple_interest(9,8,7)
|
eca67589c63caacb1685d83cd40a7cca0d1614ae | Winlang/own_code | /hello.py | 254 | 3.75 | 4 | # class Hello(object):
# def hello(self,name='world'):
# print('hello %s.'%name)
# h = Hello()
# h.hello()
def fn(self,name='world'):
print('Hello,%s . '%name)
Hello = type('Hello',(object,),dict(hello=fn))
h = Hello()
h.hello()
#this is a test
|
7569fca0920e08fb4955c3ace85c0aadaf2d6679 | hernanjkd/interview-questions | /sorting-algorithms.py | 5,175 | 3.71875 | 4 | from time import time
from random import randrange, randint
# lst length 10
# inser 1.3074874877929688e-05
# bubbl 2.1622180938720703e-05
# quick 4.0788650512695315e-05
# merge 5.470514297485351e-05
# lst length 100
# bubbl 4.2753219604492186e-05
# inser 4.7523975372314456e-05
# quick 0.0005417561531066894
# merge 0.... |
c11b0c3aaabda70f961d405841a6a4a21536b2c7 | rumeysaer/python_-dev1 | /ödev_1/ödev_1/ödev_1.py | 191 | 3.9375 | 4 | list1 = [1,3,5,7,9]
list2 = [2,4,6,8]
list1.extend(list2)
list1.sort()
print(list1)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers = [i*2 for i in list1]
print(numbers)
[2, 4, 6, 8, 10, 12, 14, 16, 18]
|
5eb05cc8c16f2a6aefba6b54b57d098456fa0296 | yang4978/Huawei-OJ | /Python/0287. 字符串匹配.py | 566 | 3.875 | 4 | # If you need to import additional packages or classes, please import here.
def func():
# please define the python3 input here.
# For example: a,b = map(int, input().strip().split())
# please finish the function body here.
# please define the python3 output here. For example: print().
word = input... |
828bcbfeb8881463cee6aca04cb6387e86a0a8ff | yang4978/Huawei-OJ | /Python/1822. 【认证试题】电话拦截.py | 1,322 | 3.546875 | 4 | '''
Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
Description: 考生实现代码
Note: 缺省代码仅供参考,可自行决定使用、修改或删除
'''
class Solution:
def get_phone_record(self, records):
call = dict()
white = []
for r in records:
t, num = r
if t == 'C':
... |
599c0eeaf39bd2ce11496ed1b495794c4e94a934 | yang4978/Huawei-OJ | /Python/0151. 熊猫钓鱼.py | 1,020 | 3.703125 | 4 | # If you need to import additional packages or classes, please import here.
def func():
# please define the python3 input here.
# For example: a,b = map(int, input().strip().split())
# please finish the function body here.
# please define the python3 output here. For example: print().
n = int(inpu... |
895de8ea3c3079f0e7785b33504c9a8c07069463 | yang4978/Huawei-OJ | /Python/0026. Who Love Solo Again.py | 639 | 3.90625 | 4 | # If you need to import additional packages or classes, please import here.
import re
def func():
# please define the python3 input here.
# For example: a,b = map(int, input().strip().split())
# please finish the function body here.
# please define the python3 output here. For example: print().
whi... |
3b69120b97f4ed45575d00ea96bea53e640415ca | yang4978/Huawei-OJ | /Python/0005. N进制小数.py | 795 | 3.984375 | 4 | # If you need to import additional packages or classes, please import here.
def func():
# please define the python3 input here.
# For example: a,b = map(int, input().strip().split())
# please finish the function body here.
# please define the python3 output here. For example: print().
while True:
... |
ad4f71d6a4005dc7e27652aaabec99a6cc6c8a90 | Ajay70452/Python_projects | /Quiz game/Quiz game.py | 2,159 | 4.1875 | 4 |
"""
def new_game():
guesses = []
correct_ans = 0
question_num = 0
for key in questions:
print("-------------------------------")
print(key)
for i in options[question_num]:
print(i)
question_num += question_num
if question_num ==3:
... |
1903ba5aab662764a931e0ac349f5fa5463d2d7f | Manisha3112/Python-programs | /fizz.py | 991 | 4.15625 | 4 | # Write a python generator function which generates fizz buzz tuples infinitely.
# Every successive call to next on the generator should return (index, <content>)
# where index starts from 1 and increases by one every call.
#
# The content should be "fizz" for multiples of 3, "buzz" for multiples of 5 and "fizz", "buzz... |
059cab7c3a630862b5a8c3d0cc5e387535ef43a4 | Manisha3112/Python-programs | /generator.py | 233 | 3.859375 | 4 | def topTen():
first=int(input('Enter first number: '))
last=int(input('Enter last number: '))
while first<=last:
square=first*first
yield square
first+=1
value=topTen()
for i in value:
print(i) |
e9f26141d8b7e4338276d516c972da536bcb5fc9 | asta-ness/30-Days-Of-Python | /day_5/ex_level_2.py | 326 | 3.9375 | 4 | ages = [19, 22, 19, 24, 20, 25, 26, 24, 25, 24]
ages.sort()
print(ages)
# ages.append(ages[0])
# ages.append(ages[-2])
# print(ages)
a = len(ages)//2
print(a)
print(ages[a])
def Average(age):
return sum(ages) / len(ages)
average = Average(ages)
print("Average of the ages =", round(average, 2... |
68e950356ebf57916cf07ebab0c1920ef2dc6ac4 | asta-ness/30-Days-Of-Python | /day_4/example_day4.py | 2,151 | 4.625 | 5 | multiline_string = '''I am a teacher and enjoy teaching.
I didn't find anything as rewarding as empowering people.
That is why I created 30 days of python.'''
print(multiline_string)
# Another way of doing the same thing
multiline_string = """I am a teacher and enjoy teaching.
I didn't find anything as rewarding ... |
88971f919ef1ec0dfb2a1fc0af3ad8c2c449139b | asta-ness/30-Days-Of-Python | /day_3/rectangle_area_perimeter.py | 277 | 4.09375 | 4 | length_rectangle = input('Enter rectangle lenght: ' )
width_rectangle = input ('Enter width rectangle: ')
print('The area og rectangle is: ', int(length_rectangle)*int(width_rectangle))
print('The perimeter og rectangle is: ', 2*(int(length_rectangle)+int(width_rectangle))) |
498df0acefbd81710b6212d8f29d31f0b09a186b | asta-ness/30-Days-Of-Python | /day_3/day_3_16.py | 197 | 3.5 | 4 | # day 3, ex 16
length_python = len('python')
lenght_to_float = float(length_python)
lenght_to_string = str(length_python)
print(length_python)
print(lenght_to_float)
print(lenght_to_string) |
c0ecdbb4283db496b593f8f26901f6ad31d81004 | ragu6963/kfq_pyhton | /basic/02_if_for/fortest1.py | 523 | 3.640625 | 4 | str1 = "abcdefg"
list1 = [1, 2, 3, 4, 5, 6]
tuple1 = (1, 2, 3, 4, 5)
dic1 = {1: "첫 번째", 2: "두 번째"}
set1 = {1, 2, 3, 4, }
for i in range(2, 10):
i = int(i)
for j in range(2, 10):
j = int(j)
print("{} * {} = {}".format(i, j, i*j))
print("-"*10)
for i in range(1, 10):
i = int(i)
for j... |
333f150d0fdf47abdfb0121d4fd95474cd67e353 | ragu6963/kfq_pyhton | /basic/05_class/class_test01.py | 535 | 3.609375 | 4 | # 2020 07 07
# 클래스 기본 수업 1
class FourCal:
mode = 1
def __init__(self,first=1 ,second = 4):
self.first = first
self.second=second
print("생성자")
def __str__(self):
return "num1 = %d, num2 = %d"%(self.first,self.second)
def setdata(self,first,second):
self.first ... |
726e02ac331824b7e8a2dba6d4aabe7a4e787796 | ragu6963/kfq_pyhton | /basic/05_class/fourcaltest.py | 763 | 3.53125 | 4 | class FourCal:
def __init__(self,first=1 ,second = 4):
self.first = first
self.second=second
print("생성자")
def __str__(self):
return "num1 = %d, num2 = %d"%(self.first,self.second)
def setdata(self,first,second):
self.first = first
self.second = second
... |
d6272a2e0db86ed127ac229261580b1ed6506f81 | quinn-n/A-Star | /node.py | 828 | 3.859375 | 4 |
import math
class Node:
"""Class to manage a node's data"""
def __init__(self, pos, walkable=True):
self.parent = None
self.walkable = walkable
self.g = math.inf
self.h = math.inf
self.f = math.inf
self.pos = pos
self.closed = False
def calc_... |
f5991346a1fb2019fa57112c159c6ba167bad2d3 | jianq1994/leetcode | /python/2_add_two_numbers.py | 1,006 | 3.5 | 4 | class Solution:
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
if not l1 and not l2:
return None
head = ListNode(0)
cur = ListNode(0)
head.next = cur
carry = 0
while(... |
980e5133d9ea18be3b08c356aa068c94e0dbdc9a | jianq1994/leetcode | /python/515_find_largest_value_in_each_tree_row.py | 609 | 3.640625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def largestValues(self, root: TreeNode) -> List[int]:
if not root:
return []
ans = [root.val]
lans = ... |
03084a9ef1a77130cbbf401271743a98850f202c | jianq1994/leetcode | /python/412_fizz_bizz.py | 562 | 3.53125 | 4 | class Solution:
def __init__(self):
self.memo = []
def fizzBuzz(self, n: int) -> List[str]:
L = len(self.memo)
if (n <= L):
pass
else:
for i in range(L+1,n+1):
if i%3 == 0 and i%5 == 0:
self.memo.append('FizzBuzz')
... |
770d0a7ac6febfaddf6ad1c763d76532a099a814 | jianq1994/leetcode | /python/142_linked_list_cycle_ii.py | 544 | 3.5625 | 4 | #13~98,77
class Solution(object):
def detectCycle(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head or not head.next:
return None
p0 = head.next
p1 = head.next.next
while(p0 and p1 and p1.next and p0 != p1):
... |
f87b9ae8193edafacf53a1d2d9772710802b1407 | sijoonlee/algorithm_study | /Algorithm_Coursera/Shortest_Paths/Assignment1/solution_2.py | 1,680 | 3.5 | 4 | # Floyd-Warshall Algorithm
# Compute all pairs shortest path
from collections import defaultdict
import math
import sys
sys.setrecursionlimit(5000)
class Floyd_Warshall(object):
def __init__(self, filename):
file = open(filename, "r")
# [number of vertices][number of edges]
# [head] [tai... |
3a87a2ad1e697392d333166035a8cde1a9311100 | sijoonlee/algorithm_study | /Algorithm_Coursera/Graph_Search/Assignment1/solution_iterative(too slow).py | 3,894 | 3.609375 | 4 | from collections import defaultdict
class Solution(object):
def __init__(self, file, sep):
self.edges = []
with open(file, 'r') as f:
for str in f:
line = [int(s) for s in str.rstrip().split(sep)]
self.edges.append(line)
... |
5ee796729ac3e51fb10eb00588007952d356fcb2 | shubhamnaikk/Dictionary-using-python | /dictionary.py | 213 | 4.0625 | 4 | dic1={
"junkfood":"unhealthy",
"vegan":"non-dairy products",
"sweets":"sugary food",
"pen":"used to write"}
print("Please enter the word whose meaning you want")
a=input()
print(dic1[a]) |
df2b15861e2139dd54a61f3ac54afd7248856e44 | misterpandaa/Introduction-to-Computer-Science-and-Programming-Using-Python | /Week2/problem1.py | 325 | 3.78125 | 4 | balance = 484
monthlyPaymentRate = 0.04
annualInterestRate = 0.2
for i in range(12):
minPayment = balance * monthlyPaymentRate
unpaidBalance = balance - minPayment
interest = (annualInterestRate / 12.0) * unpaidBalance
balance = round(unpaidBalance + interest, 2)
print('Remaining balance: ' + str(bala... |
13c678ef8ae0e6fbe8409beb6aeabd5e1ce07951 | abiliokrismanuel/Prakalpro | /pengelolaan String.py | 779 | 3.5625 | 4 | # Nama : Abilio Krismanuel
# Nim : 71190498
# Grub B
# Universitas Kristen Duta Wacana
'''
Seorang siswa sd kebingungan tentang menentukan panjang/pendek di suatu kalimat
maka dari itu buatkanlah program yang dapat mencari kata terpendek dan terpanjang untuk membantu anak sd tersebut
input = masu... |
d9eb80daed0538112072943144cce24c0185f9ef | Ducminh-BB/Code | /session_7/btvn/btvn8.py | 256 | 3.890625 | 4 | n = int(input("nhap thang "))
if n > 8 and n % 2:
print("30 ngay")
elif n > 8 and n // 2:
print("31 ngay")
if 2 < n <= 8 and n % 2:
print("31 ngay")
elif 2 < n <= 8 and n // 2:
print("30 ngay")
if 0 < n <= 2:
print("28 hoac 31 ngay")
|
32ab2c89d3c9dbe48f16cb2e5d46ead3888249e6 | DawidHatlapa/python-analyser | /python_analyser.py | 1,142 | 4.0625 | 4 |
def count_lines(filename):
# this function returns number of all file lines
pass
def count_not_empty_lines(filename):
# this function returns number of non-empty lines
pass
def count_comment_lines(filename):
# this function returns number of comment lines
# dont forget that comment starts wi... |
39fff8d2897903c85fcd06c9834edefd5936ba2d | tsubame-misa/Atcoder | /ABC175/A.py | 184 | 4.0625 | 4 | s = input()
if s == "SSS":
print(0)
elif s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR":
print(1)
elif s == "RRS" or s == "SRR":
print(2)
else:
print(3)
|
84181ff8d8f7eb512fca5174bb89fa0d6d4fd4ed | sanjana1599/Queue-Algorithm | /CountingMS.py | 1,864 | 4.15625 | 4 | import random
import time
def splitList(firstList):
'''
Function to split list in half
'''
midPoint = len(firstList) // 2 #3
return firstList[:midPoint], firstList[midPoint:] #1
def mergeSortedList(listL, listR, order):
'''
Function to take two sorted lists, and merge them in order
'''
indexL... |
0de7bef363403906c09edf60314637543a6d6c3d | OzumOzmen/system_scripts | /thread_intro.py | 4,399 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 23 20:40:44 2021
@author: doğancan torun
"""
#Threadlerle çalışma:
#bir programda farklı akışlar yaratmak istersem threadleri kullanıyorum
#bir programın farklı iki akışı olsun veya yeni akışlarla kordineli işlemler yapsın istersem thread kullanıyorum
#Her program bi... |
7cf308243cca3a2ba33689f4231cb566a11c8913 | jlucasrods/git-tutorial | /arquivo_3.py | 223 | 3.59375 | 4 | def divide(a, b):
print(f"{a} dividido por {b} é igual a {a / b}")
def subtrai(a, b):
print(f"{a} - {b} = {a - b}")
def soma(a, b):
printf(f"{a} + {b} = {a + b}")
soma(10, 2)
subtrai(43, 1)
divide(10, 2) |
5fcad3d80306af9ed01ef828a927e600fe26781f | TsukasaAoyagi/Atcoder | /beginar/0814/1.py | 108 | 3.5 | 4 | n = int(input())
if 1<=n<=125:
print('4')
elif 126<=n<=211:
print('6')
else:
print('8')
|
fcc2108eb60cfdca339bd427d0ea231be580aac7 | TsukasaAoyagi/Atcoder | /beginar/0904/1.py | 133 | 3.53125 | 4 | s,t = input().split()
ans = []
ans.append(s)
ans.append(t)
ans=sorted(ans)
if ans[0]== t:
print("Yes")
else:
print("No") |
afa09d4107c677e4b1043053336ef8ebd176bb5b | comprehensivegene649837/Mini_Calculator | /Mini_Calculator.py | 817 | 4.4375 | 4 | print("****** WELCOME! ******")
print(" ")
a= (float(input("enter the number here: ")))
b= (float(input("enter the number here: ")))
print(" PLEASE SELECT THE OPERATOR THAT YOU WOULD LIKE TO USE: ")
print("1. '*' - for multiplication")
print("2. '+' - for addition")
print("3. '-' - for subtraction")
pri... |
a917254a19223193faef9b80567a32d4986d9614 | Lost2019/dianalabs | /dianalabs/2lab/lab2Num2.py | 407 | 3.578125 | 4 | my_string = "Иванов;Иван;Иванович;23 года;Студент 3 курса;_Петров;Семен;Игоревич;22 года;Студент 2 курса"
print(" ФИО " + "О студенте " )
data_list = [a.split(';') for i,a in enumerate(my_string.split('_'))]
for a in data_list:
print(a[0], a[1], a[2] + ' ' , a[4] + ',',... |
5a29bf7fc57da1bf4f686b63b5ccb36d79c62805 | ShreyaPrasad1209/Hack-the-Technical-Interview | /Zigzag.py | 300 | 3.671875 | 4 | def zigzag(a):
flag=True
for i in range(len(a)-1):
if(flag==True):
if(a[i]>a[i+1]):
a[i],a[i+1]=a[i+1],a[i]
else:
if(a[i]<a[i+1]):
a[i],a[i+1]=a[i+1],a[i]
flag=1-flag
return a
if __name__ == "__main__":
a=list(input())
ans = zigzag(a)
print(ans)
|
c0c4556aedf9bf4dc2a2461a8e887a75467814ca | sjlawson/DS_Eva | /src/Planets.py | 1,474 | 3.515625 | 4 | import pygame
from abc import ABCMeta, abstractmethod
class AbstractPlanet(pygame.sprite.Sprite):
__metaclass__ = ABCMeta
currentPlanet = 0
def update(self):
self.rect.center = (600, 350)
class Space(AbstractPlanet):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
sel... |
fd8b32fcb964a102ae431eeb321dc0e758d8d313 | snitivan/Smart_calculator | /calculator.py | 12,864 | 3.5 | 4 | from collections import deque
def result(cc):
#print(cc)
res = deque()
for i in cc:
if i.isdigit():
res.append(int(i))
else:
if i == "+":
a = res.pop()
b = res.pop()
c = a + b
res.append(c)
... |
2253d850f7c51e370bc8806fd50df34d9f62799f | Tolsti/GraduationProjectPython08.2019 | /HOMEWORK/HomeworkFrom22.09.2019/Task 2.py | 578 | 4.28125 | 4 | """Создайте класс Circle с методом area, подсчитывающим и возвращающим площадь круга.
Затем создайте объект Circle, вызовите в нем метод area и выведите результат.
Воспользуйтесь функцией pi из встроенного в Python модуля math."""
import math
class ClsCircle:
def __init__(self, r):
self.radius = r
... |
fa090e73004f12bfd3896a996bef5490ebac7524 | smartlyc/test | /loop.py | 302 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jul 08 19:07:15 2016
@author: SMARTLYC
"""
count=0
import random #声明调用random函数
while count <5:
print count+1
print random.randint(100,999)
print 'hello world'
print random.randint(100,999),'hello world'
count =count+1
|
7c84f2e02655a475966533598b4c0014882ff4d3 | spencerzhang91/LeetCode | /036#ValidSudoku_20150423.py | 1,339 | 3.921875 | 4 | '''
To check a sudoku board is valid or not.
'''
class Solution:
def isValidSudoku(self, board):
colums = [[row[i] for row in board] for i in range(9)]
blocks = [[board[i+k][j+l] for i in range(3) for j in range(3)]
for k in range(0,9,3) for l in range(0,9,3)]
def isvalid... |
37d7cb75e17b107a7685ffb67fc02f046eeb7d50 | spencerzhang91/LeetCode | /429#N-aryTreeLevelOrderTraversal.py | 499 | 3.671875 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val, children):
self.val = val
self.children = children
"""
class Solution:
def levelOrder(self, root: 'Node') -> List[List[int]]:
if not root:
return []
queue = [root]
res = []
while queue:... |
27ce53b6e5a91973b2c39b949fd06c2b1a00a19c | spencerzhang91/LeetCode | /013#roman_to_integer_20150429.py | 736 | 3.53125 | 4 | class Solution:
def romanToInt(self, string):
double_dict = {'IV': 4, 'IX': 9, 'XL': 40, 'XC': 90, 'CD': 400, 'CM': 900}
single_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C':100, 'D': 500, 'M': 1000}
res = 0
remove_list = []
for key in double_dict.keys():
if key i... |
6dec54d48e6f45b91a46a5652a92bc690d7b6336 | spencerzhang91/LeetCode | /145#BinaryTree_Postorder_20150731.py | 909 | 3.84375 | 4 | class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Solution:
def postorderTraversal(self, root):
if not root: return []
L = []
stack = []
lastvisited = None
while root or stack:
if root:
... |
13ceb2589f45b68761be1ed3b015f9cf52d0fc48 | spencerzhang91/LeetCode | /147#InsertionSort_20151107.py | 2,584 | 3.671875 | 4 | #147 InsertionSort_20151107
'''
rule breaking shameless approach below:
Final correct solution will be done within 20 minutes
'''
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def insertionSortL... |
2018c4e6dbfeed651983cad87e09feee78efa61d | spencerzhang91/LeetCode | /102#LevelTraversal_20151127.py | 1,192 | 3.875 | 4 | # 102 Binary Tree Level Order Traversal
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def __repr__(self):
return str(self.val)
class Solution(object):
def levelOrder(self, root):
""... |
b5820c278b36eb70c0dd251881f8af33adacb9df | Jenishbh/CS487 | /HW8/hw81.py | 4,410 | 3.953125 | 4 | import sys
bookings_holi = dict()
bookings_magic = dict()
waiting_list = list()
def schedule(): #method to schedule bookings
cust = input("Enter Customer name: ").upper()
i=1
for holi_name in bookings_holi.keys(): #prints all holiday names
print("%d. %s"%(i, holi_name))
i=i+1
ho... |
18af379d295c17554f189b65f56eb65144d0c4a6 | Jenishbh/CS487 | /computer.py | 1,246 | 4.03125 | 4 | class Computer:
def __init__(self,cpus,storages,memory,model,price):
self.__memory=memory
self.__model=model
self.__price=price
self.__cpus=cpus
self.__storages=storages
def __init__(self,memory,model,price):
self.memory=float
self.model=str
sel... |
482bc567c2ce208a81e34708c6ec6fedc1ebb6f2 | Jenishbh/CS487 | /HW8/a1.py | 707 | 3.65625 | 4 | class Math:
def divide(self, x,y):
quotient = x // y
remainder = x % y
print("Quotiet =", quotient)
print("Reminder =", remainder)
class Math2:
def divide(self, x, y):
quotient = x // y
remainder = x % y
return(quotient, remainder)
class Mathadp(Math2):
... |
8d7e03f6f36ab556b2468364fe82c85a7b1252ce | lusuon/NEU_experiment_lesson_homework_1to4 | /4.3.py | 1,012 | 3.53125 | 4 | n,MA,MB,MC,MCr,SUM,count,COUNT,C=0,[],[],[],[],0,0,0,0
while n<=0:
n=eval(input("Enter matrixs' rows and columns,should be postive:"))
print("Matrix A")
for i in range(n):
row = input("Enter numbers less than Maxtix's column,use space to seperate:")
while len(row.split())!=n:
row = input("Enter num... |
792ce8febe53b4d6b7adfd7c5ba417c1c2907712 | micahevans24/codeclass | /filter_map_reduce.py | 1,584 | 4.0625 | 4 | def filter(pred, l):
""" Accepts a predicate (pred) and a list (l).
Returns a new list containing only the items from li
where pred(l) matches (returns true).
"""
pass
assert filter(lambda x: x % 2 == 0, [1, 2, 3, 4, 5]) == [2, 4]
assert filter(lambda x: x % 3 != 0, [1, 2, 3, 4, 5]) == [1, ... |
82d6bd54ff4f00961be99bd960afb015a1dedb23 | micahevans24/codeclass | /counting.py | 560 | 3.96875 | 4 | counting.py
#def count(pred, l):
""" Accepts a predicate (pred) and a list (l).
Returns the number of items in l where pred(l) matches (returns true).
"""
# pass
#assert count(lambda x: x % 2 == 0, [1, 2, 3, 4, 5]) == 2
#assert count(lambda x: x % 3 != 0, [1, 2, 3, 4, 5]) == 4
def count(pred,... |
9691fcdebdce632851c5bb648baaeaf260642349 | sctjgz/python_study | /Newton_get_sqrt.py | 263 | 3.703125 | 4 | import math
def NewtonSqrt(n):
result = n
EPS = 0.000001
while True:
tmp = result
result =result/ 2 + n/(2* result)
if abs(tmp-result)<= EPS:
break
return result
print(NewtonSqrt(16.54))
print(math.sqrt(16.54)) |
77726ae53f87766b8545c357099c790fc3938fd2 | franciscomelov/Git-practice | /platzi_pyrthon_basico/scripts/adivina_el_numero.py | 518 | 3.765625 | 4 | import random
def game():
counter = 1
number = random.randint(1,100)
print(number)
while True:
user = int(input("Escoje un numero del 1 al 100: "))
if user > number:
print("elije un numero mas chico")
elif user < number:
print("Elije un numero mas grande"... |
1b926f132690f667f24ebc514c9276bb7c3514d9 | Mamun-Developer/Python-Training-Materials | /Class4/OOPBasic.py | 377 | 3.640625 | 4 | class ClassName:
def __init__(self,nam,age):
print(self)
self.nam = nam
self.age = age
def getProperties(self,mult):
return self.nam,self.age*mult
def getName(self,param2):
return param2
def getName2(self):
return self.nam
ob1 = ClassName("name",32)
o... |
6b23227849f5dc18060a97c4016fdeaeb954f7f5 | Mamun-Developer/Python-Training-Materials | /Class1/basicsum.py | 1,085 | 4.3125 | 4 | import time
# 1. Input N of Numbers
# 2. Run loop and input all number into list
# 3. Run look and sum all number
# 4. Print the result
def thisIsthechange():
pass
def numberN(message):
'''
This function receives an input from an user and returns an integer number
:param message: That you want to print... |
34788b5d77bf4aea2d8ca83f626c7f839835a5e6 | Mamun-Developer/Python-Training-Materials | /Class5/Assignment.py | 840 | 3.96875 | 4 | class penguins:
def __init__(self,name, age, color, walk,stop="yes"):
self.age = age
self.name = name
self.color = color
self.walk = walk
self.stop = stop
def getWalk(self):
return f"{self.name*2} is {self.walk}ing"
def notWalking(self):
return "{0} is... |
e40b12f8913f22e90cfebc32ecf906bc978cb534 | wuyun19890323/sanjiaoxing_csv-xml-json-txt | /Code/sjx.py | 366 | 3.65625 | 4 |
class Sjx():
def sjx(self, a, b, c):
if a + b > c and a + c > b and b + c > a :
if a == b and b == c:
return '等边三角形'
elif a == b or b == c or a == c :
return '等腰三角形'
else:
return '普通三角形'
else:
return '不是... |
f430575032ac7119af406bcb8478d8da65c94afd | Atharv-Attri/HacktoberFest-Projects | /Projects/Python/MorseCode.py | 2,562 | 3.53125 | 4 | #Python program to encrypt and decrypt morse code
# Dictionary representing the morse code chart
MORSE_CODE_DICT = { 'A':'.-', 'B':'-...',
'C':'-.-.', 'D':'-..', 'E':'.',
'F':'..-.', 'G':'--.', 'H':'....',
'I':'..', 'J':'.---', 'K':'-.-',
... |
855815e90bee6ae91c752539a78eaf5c415e2dcb | Atharv-Attri/HacktoberFest-Projects | /Projects/Python/Decision Tree and Naive Bayes Classifier From Scratch/Decision Tree Classifier/main.py | 1,632 | 3.65625 | 4 | import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
import math
import ClassifierTree as Tree
import Categorization as C
# getting raw csv data
raw_dataset = pd.read_csv("/data/toy_dataset.csv")
# dropping N/A
raw_dataset.dropna(inplace=True)
print('Raw Dataset... |
f727bf1de963b59a70231f2c0a4799bcd6adcdf0 | sawyermade/advanced-python | /as4/bigfiles.py | 662 | 3.53125 | 4 | '''
Daniel Sawyer Assignment 4 bigfiles Fall 2017
'''
import os
def bigfiles(basepth):
#file size we are looking for and file list
# minfsize = 100000000 #1000^2 * 100
minfsize = 104857600 #1024^2 * 100
flist = []
#goes through all dir and files and finds files >= minfilesize
for root, dirs, files in os.walk(... |
9d8f3f122a40f1851579242c9ceec5e35d1cc87c | agnesliang/week4-lists | /week4listchallenge.py | 834 | 4.09375 | 4 | # Black-Owned Restaurant Finder: Lists exercises
#Part 1-
cuisines = {'Japanese', 'Korean', 'Italian', 'Mexican', 'Greek', 'Argentenian', 'French'}
cuisine = input ('What cuisine are you interested in?')
if cuisine in cuisines:
print ('Restaurant found!')
else:
print ('Please choose one of these cuisines fr... |
a2363d9eac9141635ec75929ed44d51e1aa34cdd | mason2047/Tencent-Tutorial | /Module1/os_library/os.py | 1,773 | 3.875 | 4 | import os
# os 是python自带的非常实用的标准库
# 顾名思义,就是与操作系统相关的库。如:文件,目录,执行系统命令等。
#*************************************#
# 常用函数
# 1. `os.getcwd` 查看当前目录 Check the current working directory of the file
print(os.getcwd())
# 2. `os.listdir` 列举当前目录里所有文件名
print(os.listdir())
#*************************************#
# 3. `os.makedirs... |
89a837b2281c056e734095b2665a7c4249d9a121 | mason2047/Tencent-Tutorial | /Module1/read_files/readwrite.py | 1,734 | 4.34375 | 4 | # 读写数据 open() 函数用于创建或打开指定文件
#*************************************#
# 1. Old practice (不推荐用第一个方法)
f = open('the_adventures_of_sherlock_holmes.txt', 'r')
print("文件名:", f.name) # 文件名
print("文件权限:", f.mode) # 文件权限: 'r' = only read, 'w' = only write, 'r+' = read and write
f.close()
# 2. Better practice: context mana... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.