blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
660a467f0428f2564fdeec4da7f5dc171b7a2e65 | DivijeshVarma/CoreySchafer | /Decorators2.py | 2,922 | 4.46875 | 4 | # first class functions allow us to treat functions like any other
# object, for example we can pass functions as arguments to another
# function, we can return functions and we can assign functions to
# variable. Closures-- it will take advantage of first class functions
# and return inner function that remembers and ... |
b1ebc3eeeceebdf1eb6760c88d00be6b40d9e5cd | DivijeshVarma/CoreySchafer | /generators.py | 809 | 4.28125 | 4 | def square_nums(nums):
result = []
for i in nums:
result.append(i * i)
return result
sq_nums = square_nums([1, 2, 3, 4, 5])
print(sq_nums)
# square_nums function returns list , we could convert
# this to generator, we no longer get list
# Generators don't hold entire result in memory
# it yield ... |
e328a29edf17fdeed4d8e6c620fc258d9ad28890 | DivijeshVarma/CoreySchafer | /FirstclassFunctions.py | 1,438 | 4.34375 | 4 | # First class functions allow us to treat functions like
# any other object, i.e we can pass functions as argument
# to another function and returns functions, assign functions
# to variables.
def square(x):
return x * x
f1 = square(5)
# we assigned function to variable
f = square
print(f)
print(f(5))
print(f1)
... |
e12ff9f3f050bebe315f0d0926a1ad4fcf930044 | MarkGadsby/TurtleGraphics | /SnowFlakes/FlowerVariousPetals.py | 633 | 3.6875 | 4 | from turtle import Turtle, Screen
window = Screen()
window.bgcolor("black")
elsa = Turtle()
elsa.speed("fastest")
elsa.pencolor("White")
elsa.fillcolor("White")
elsa.penup()
def DrawFlower(nPetals):
elsa.pendown()
for Petal in range(nPetals):
for i in range(2):
elsa.forward(50)
... |
c1e0993722488e329ebd63543bc5171cf55c04c2 | Joph25/ATI-Experiment | /stepper_motor.py | 2,500 | 3.59375 | 4 | import random
CLOCKWISE = 1
COUNTERCLOCKWISE = 0
class StepperMotor:
# -----------------------------------------------------------------------------------------------------
def __init__(self):
self.counter_A = 0
self.counter_B = 0
self.counter_I = 0
self.cur_rel_pos = 0 # per... |
eb7ba234432e4c448849469b58ba2a96aa151531 | vandinhovicosa/CursoLuizOtavio | /Aula7/aula7.py | 339 | 3.5625 | 4 | """
Formatando Strings
"""
nome = 'Vanderson'
idade = 41
altura = 1.75
peso = 76
ano_atual = 2021
imc = peso / (altura **2)
nasceu = ano_atual - idade
print('{} nasceu em {} e tem {} de altura.'.format(nome, nasceu, altura))
print('{} tem {} anos de idade e seu imc รฉ {:.2f} tendo Obesidade grau 3 (mรณrbida)'.format(nom... |
ab03adfb440665ca54b99af83c325217af0397ab | nathanielshak/advancedprogramming | /Projects/hangman/hangman3.py | 1,712 | 3.921875 | 4 | def start_hangman():
print("Let's Start playing Hangman!")
def start_hangman():
print("Let's Start playing Hangman!\n")
man1 = """
____
| |
|
|
|
_|_
| |_____
| |
|_________|
"""
man2 = """
____
| |
| o
|
... |
677f1b968380ff52502748fbfc013b671d52f5a4 | nathanielshak/advancedprogramming | /Lesson10/exercises.py | 9,337 | 3.84375 | 4 | import itertools
import os
import random
# 1. File exists
def file_exists(directory, file):
# TODO
return False
# 2. Choosing sums
def sum_to_target(numbers, target):
# TODO
return False
def sum_to_target_challenge(numbers, target):
# TODO
return None
# 3. Generating subsets
def subsets_of_size(it... |
68fc84dfacfe80537760cbad2cf0e8b403b060ac | Kyeongrok/python_crawler | /test/01_largest.py | 402 | 3.578125 | 4 | A = [3, 2, -2, 5, -3]
def solution(A):
positive = []
negative = []
result = []
for n in A:
if n > 0:
positive.append(n)
elif n < 0:
negative.append(n)
for ne in negative:
if abs(ne) in positive:
result.append(ne)
if len(result) == 0... |
3f7d7a26357da8a52fb3e075badd79e83f3b4c07 | Kyeongrok/python_crawler | /lecture/lecture_gn6/week2/01_print_gugudan.py | 366 | 3.765625 | 4 | # 2 * 1 = 2 ๋ฅผ console์ ์ถ๋ ฅ ํด๋ณด์ธ์.
# printGugudan() ์ด๋ผ๋ ํจ์๋ฅผ ๋ง๋ค์ด์ ์ถ๋ ฅํด๋ณด์ธ์.
# ํจ์ ์ ์ธ
def printGugudan(dan):
for num in range(1, 9 + 1):
print(dan, "*", num,"=", dan * num)
print("-------------")
# ํจ์ ํธ์ถ
for dan in range(2, 9 + 1):
printGugudan(dan)
# 2๋จ, 3๋จ ๋์์ ์ถ๋ ฅํ๊ธฐ
|
4cc0ce9f7fbb5650d901b2f834b00bc9711cefa3 | Kyeongrok/python_crawler | /lecture/taling/week1_function/12_variable.py | 196 | 3.5 | 4 | # ๋ณ์ variable
# ๋ณํ๋ ์(๊ฐ), ์์ ํญ์ ๊ฐ์ ์(๊ฐ)
result = 10
print(result)
result = 20
print(result)
# ์์ "" ๋ฐ์ดํ
grade = "A"
print(grade)
grade = "B"
print(grade)
|
9f5d037c97bf95b6866ff32f934fd85bf41ac3fc | Kyeongrok/python_crawler | /lecture/lecture_gn/week8/07_filter.py | 214 | 3.609375 | 4 | import pandas as pd
df = pd.read_json("./search_result.json")
df2 = df[['bloggername', 'link', 'title']]
df3 = df[df['bloggername'] == 'ํ๋๋๋กญ']
print(df3['title'])
for link in df3['link']:
print(link)
|
560043e5d1c9d6e31f9b9f6d4b86c02ac5bff325 | Kyeongrok/python_crawler | /lecture/lecture_gn5/week2/01_function.py | 859 | 4.21875 | 4 | # plus๋ผ๋ ์ด๋ฆ์ ํจ์๋ฅผ ๋ง๋ค์ด ๋ณด์ธ์
# ํ๋ผ๋ฉํฐ๋ val1, val2
# ๋๊ฐ์ ์
๋ ฅ๋ฐ์ ๊ฐ์ ๋ํ ๊ฒฐ๊ณผ๋ฅผ ๋ฆฌํดํ๋ ํจ์๋ฅผ ๋ง๋ค์ด์
# 10 + 20์ ์ฝ์์ ์ถ๋ ฅ ํด๋ณด์ธ์.
def plus(val1, val2):
result = val1 + val2
return result
def minus(val1, val2):
return val1 - val2
def multiple(val1, val2):
return val1 * val2
def divide(val1, val2):
return val1 / val2
resul... |
899535ec4bca9e1365bdcc425e9525f15c5dfb35 | Kyeongrok/python_crawler | /lecture/lecture_gn5/week1/05_for.py | 365 | 3.9375 | 4 | def print1To20():
for num in range(1, 10 + 1):
print(num)
# print1To20()
# print2To80 ์ด๋ผ๋ ์ด๋ฆ์ ํจ์๋ฅผ ๋ง๋ค๊ณ
# 2๋ถํฐ 80๊น์ง ์ถ๋ ฅ์ ํด๋ณด์ธ์. 2 4 6 8 10
def print2To80():
for num in range(2, 80):
print(num)
# print2To80()
def print1To79():
for num in range(0, 40):
print(num * 2 + 1)
print1To79()
|
4e4c3fcd655c2e9399dae7d84a1fec88406e9c72 | Kyeongrok/python_crawler | /lecture/taling/week1_function/14_recursive.py | 116 | 3.671875 | 4 | def multiple(n, a):
if(n == 1): return a
return multiple(n-1, a) + a
result = multiple(4, 5)
print(result)
|
0dd5af66873254961a72bfdb503f092274ff3235 | Kyeongrok/python_crawler | /lecture/lecture_gn3/week2/09_bs4.py | 729 | 3.515625 | 4 | import requests # ํฌ๋กค๋ง
from bs4 import BeautifulSoup # ํ์ฑ
def crawl(codeNum):
url = "https://finance.naver.com/item/main.nhn?code={}".format(codeNum)
data = requests.get(url)
return data.content
# return์ dictionary๋ก ํด๋ณด์ธ์.
# ํ๋(field)๋ name, price์
๋๋ค.
def getCompanyInfo(string):
bsObj = BeautifulSoup(s... |
34948205bcc26de524c5e6ff823e644f8ada980e | Kyeongrok/python_crawler | /lecture/lecture_gn3/week7/04_print_list_for.py | 189 | 3.609375 | 4 | # <li></li> ๊ฐ 5๊ฐ ๋ค์ด์๋ list๋ฅผ ๋ง๋ค์ด๋ณด์ธ์.
# .append() ์ฐ์ง ์๊ณ
list = ["<li></li>","<li></li>","<li></li>","<li></li>","<li></li>"]
for li in list:
print(li)
|
1f6f9b70f408ad17f79d7ed238de675f13520987 | Kyeongrok/python_crawler | /lecture/lecture_gn6/week3/04_crawler.py | 1,183 | 3.515625 | 4 | # crawl, parseํจ์๋ฅผ ๋ง๋ค์ด ๋ณด์ธ์.
# library ๋ผ์ด๋ธ๋ฌ๋ฆฌ, module ๋ชจ๋ -> ๋๊ฐ ๋ฏธ๋ฆฌ ๋ง๋ค์ด ๋์๊ฒ
import requests
from bs4 import BeautifulSoup # ๋ฌธ์์ด์ ์ฃผ์๋ก ์ ๊ทผํ ์ ์๊ฒ ๊ฐ๊ณตํด์ค๋๋ค
# ๋ฌด์์ ๋ฃ์ด์ ๋ฌด์์ ๋์ค๊ฒ(return) ํ ๊น?
# crawlํจ์๋ url(์ฃผ์)์ ๋ฃ์ด์ pageSting(data) return
def crawl(url):
data = requests.get(url)
print(data, url)
return data.content
# ๋ฌด์์ ๋ฃ์ด... |
c76f89d5eaf600a531f0f78e34217d71e3278acd | Kyeongrok/python_crawler | /test_data/01_slice.py | 203 | 3.5 | 4 | splitted = "hello world bye".split(" ")
print(splitted[1])
targetString = "aa=19"
start = len(targetString) - 3
end = len(targetString)
result = targetString[start:end]
print(result.replace("=", ""))
|
f6b5087d3d6bd679b4cffb8d4c2010e5713d265f | Kyeongrok/python_crawler | /lecture/lecture_gn6/week5/01_naver_shopping.py | 822 | 3.515625 | 4 | # ํจ์ function crawlํ๋ ํจ์๋ฅผ ๋ง๋ค์ด ๋ณด์ธ์
# ์ด๋ฆcrawl -> url์ ๋ฐ์์ pageString return
# parse(pageString) -> list []
import requests
from bs4 import BeautifulSoup
def crawl(url):
data = requests.get(url)
print(data, url)
return data.content
def parse(pageString):
bsObj = BeautifulSoup(pageString, "html.parser")
... |
ea8b245b513e7cf41b73cd0aea05fc2b17e63766 | Kyeongrok/python_crawler | /com/chapter03_python_begin/03_function/07_f_o_g.py | 167 | 3.515625 | 4 | # f๋ผ๋ ํจ์ ์ ์ธ
def f(param1):
return param1 + 10
# gํจ์ ์ ์ธ
def g(param1):
return param1 * 20
# ํฉ์ฑํจ์
# f o g(10) = 210
print(f(g(10))) |
847e50326329804fe47d9e68eac15a2204d9ad19 | lucabenedetto/r2de-nlp-to-estimating-irt-parameters | /r2de/utils/data_manager.py | 3,166 | 3.546875 | 4 | import pandas as pd
from r2de.constants import (
CORRECT_HEADER,
DESCRIPTION_HEADER,
QUESTION_ID_HEADER,
QUESTION_TEXT_HEADER,
)
def generate_correct_answers_dictionary(answers_text_df: pd.DataFrame) -> dict:
"""
Given the dataframe containing the text of the answers (i.e. possible choices), i... |
4f9c1ddb562de274a644e6d41e73d70195929274 | sairamprogramming/learn_python | /book4/chapter_1/display_output.py | 279 | 4.125 | 4 | # Program demonstrates print statement in python to display output.
print("Learning Python is fun and enjoy it.")
a = 2
print("The value of a is", a)
# Using keyword arguments in python.
print(1, 2, 3, 4)
print(1, 2, 3, 4, sep='+')
print(1, 2, 3, 4, sep='+', end='%')
print()
|
64c62c53556f38d9783de543225b11be87304daf | sairamprogramming/learn_python | /pluralsight/core_python_getting_started/modularity/words.py | 1,204 | 4.5625 | 5 | # Program to read a txt file from internet and put the words in string format
# into a list.
# Getting the url from the command line.
"""Retrive and print words from a URL.
Usage:
python3 words.py <url>
"""
import sys
def fetch_words(url):
"""Fetch a list of words from a URL.
Args:
url: The... |
3da8f3debbff75cf957c6c7cdc07118cb867a92d | liyaozong1991/Sorting | /src/sort.py | 2,050 | 3.703125 | 4 | # coding: utf8
to_sort_list = [1, 10, 9, 4, 5, 3]
def quick_sort(sort_list):
left_list, middle_list, right_list = [], [], []
if len(sort_list) == 0:
return []
pivot = sort_list[0]
for item in sort_list:
if item < pivot:
left_list.append(item)
elif item == pivot:
... |
94ea01591941cddf01b8a7b71d13d4328b5c7b31 | tnewham23/advent-of-code-2020 | /day01/p2.py | 364 | 3.546875 | 4 | # extract numbers from input file
with open('input.txt', 'r') as f:
nums = [int(n) for n in f.readlines()]
# first number
for i in range(len(nums)):
# second number
for j in range(len(nums)):
# third number
for k in range(len(nums)):
# three numbers sum to 2020
if nums[i] + nums[j] + nums[k] == 2020:
... |
4b592e0fb43b431e3e411705cec611989a90dff3 | gotdang/edabit-exercises | /python/time_for_milk_and_cookies.py | 576 | 3.921875 | 4 | """
Is it Time for Milk and Cookies?
Christmas Eve is almost upon us, so naturally we
need to prepare some milk and cookies for Santa!
Create a function that accepts a Date object and
returns True if it's Christmas Eve (December 24th)
and False otherwise.
Examples:
time_for_milk_and_cookies(datetime.date(2013, 12, 24... |
99bd7e715f504ce64452c252ac93a026f426554d | gotdang/edabit-exercises | /python/factorial_iterative.py | 414 | 4.375 | 4 | """
Return the Factorial
Create a function that takes an integer and returns
the factorial of that integer. That is, the integer
multiplied by all positive lower integers.
Examples:
factorial(3) โ 6
factorial(5) โ 120
factorial(13) โ 6227020800
Notes:
Assume all inputs are greater than or equal to 0.
"""
def facto... |
30d9fe50769150b3efcaa2a1628ef9c7c05984fa | gotdang/edabit-exercises | /python/index_multiplier.py | 428 | 4.125 | 4 | """
Index Multiplier
Return the sum of all items in a list, where each
item is multiplied by its index (zero-based).
For empty lists, return 0.
Examples:
index_multiplier([1, 2, 3, 4, 5]) โ 40
# (1*0 + 2*1 + 3*2 + 4*3 + 5*4)
index_multiplier([-3, 0, 8, -6]) โ -2
# (-3*0 + 0*1 + 8*2 + -6*3)
Notes
All items in the lis... |
e634a798aa245d2bb8ae9501203f62f9675bfdcb | verhagenkava/ebanx-take-home | /src/domain/use_cases/withdraw_account.py | 376 | 3.5 | 4 | from abc import ABC, abstractmethod
from typing import Dict
from src.domain.models import Accounts
class WithdrawAccount(ABC):
"""Interface for Withdraw Account use case"""
@abstractmethod
def withdraw(self, account_id: int, amount: float) -> Dict[bool, Accounts]:
"""Withdraw Account use case"""
... |
0a229bee2379b5de55b2ffafa5e09395208e3394 | rkapali-zz/copy | /set1/pygrep | 231 | 3.625 | 4 | #!/usr/bin/python
import sys, gzip
string = str(sys.argv[1])
filename = sys.argv[2]
if filename.endswith('gz'):
f = gzip.open(filename, 'r')
else:
f = open (filename, 'r')
for line in f:
if string in line:
print line
f.close |
994b398a38d8fa95d5d29a06a66a3e65f8e7e9c7 | Carine-SHS-Digital-Tech/dodge-pygame-Minecraf09 | /main.py | 2,490 | 4.09375 | 4 | # Basic Pygame Structure
import pygame # Imports pygame and other libraries
import random
pygame.init() # Pygame is initialised (starts running)
# Define classes (sprites) here
class Fallingobject(pygame.sprite.Sprite):
def _init_(self):
pygame.sp... |
20cd86be5fb538a196a84ce517659e9edac3997f | antonidass/BaumanStudy | /sem2/python_sem_2/lab4.py | 7,387 | 3.515625 | 4 | from tkinter import *
import random
# ะะพัััะพะตะฝะธะต ัะปะตะผะตะฝัะพะฒ
def create_entry():
global entry, input_l, canvas
input_l = Label(root, text="ะะฒะตะดะธัะต ะบะพะพัะดะธะฝะฐัั X ะธ Y ัะตัะตะท ะฟัะพะฑะตะป", font=("ComisSansMS", 15), bg='#FFEFD5')
input_l.place(relx=0.005, rely=0.005, relwidth=0.4, relheight=0.1)
entry = Entry(r... |
36f7db179bcc0339c7969dfa9f588dcd51c6d904 | adarshsree11/basic_algorithms | /sorting algorithms/heap_sort.py | 1,200 | 4.21875 | 4 | def heapify(the_list, length, i):
largest = i # considering as root
left = 2*i+1 # index of left child
right = 2*i+2 # index of right child
#see if left child exist and greater than root
if left<length and the_list[i]<the_list[left]:
largest = left
#see if right child exist and greater than root
if rig... |
62019a39bd185d59b2d8a861c572afa3851c70dc | adarshsree11/basic_algorithms | /data structures/linked_list_stack.py | 2,270 | 3.890625 | 4 | class node(object):
def __init__(self, data, next_node = None):
self.data = data
self.next_node = next_node
def get_next(self):
return self.next_node
def set_next(self, next_node):
self.next_node = next_node
def get_data(self):
return self.data
def set_data(self,data):
self.data = data
clas... |
b66f00cd727e040d850e8b59544ff4fd385e3063 | GabrielGhe/CoderbyteChallenges | /easy_DashInsert.py | 398 | 4.09375 | 4 | def odd(ch):
return ch in '13579'
##############################
# Inserts dashes between odd #
# digits #
##############################
def DashInsert(num):
result = []
prev = ' '
for curr in str(num):
if odd(prev) and odd(curr):
result.append('-')
result.append(curr)
p... |
3ce56297221edaccb5243050a8f4cfa7334bb709 | GabrielGhe/CoderbyteChallenges | /easy_FirstReverse.py | 99 | 3.5 | 4 | #Reverses string
def FirstReverse(str):
return str[::-1]
print FirstReverse(raw_input())
|
d3068a90f85ae19efbd46bfa65948b0ffd5a9c2c | GabrielGhe/CoderbyteChallenges | /easy_SecondGreatLow.py | 367 | 4 | 4 | """
Finds the second greatest
and second lowest value in
an array
"""
def SecondGreatLow(arr):
arr = list(set(arr))
arr.sort()
stri = "{0} {1}".format(arr[0], arr[0])
if len(arr) == 2:
stri = "{0} {1}".format(arr[0], arr[1])
elif len(arr) > 2:
stri = "{0} {1}".format(arr[1], arr[-2])
return stri
... |
bed3f009ee3c3b97119b2452df06eb78210f2f79 | lgong30/python-performance-investigate | /list_remove.py | 798 | 3.953125 | 4 | """This script compares different methods to
remove elements from it.
"""
import timeit
setup = '''
from copy import deepcopy
n = 10000
x = range(n)
y = range(20,2001)
'''
test_group = 1
test_num = 10000
s = '''
i = 20
while i < 2000:
y[i - 20] = x[i]
i += 1
'''
print "splicing: ", timeit.Timer('[z for z... |
25e90005ec5be4d6f02c2c5c188eebe06ff0c7df | joselitofilho/aulas-programacao-modulo1 | /aula2/aula_2_clausula_condicional_if.py | 137 | 3.75 | 4 | A = True
B = True
expressao = not (A and B) # (not A) or (not B) # De morgan
if expressao:
print ("Deu certo!");
print ("Terminou."); |
44fc8822ec305e0015957db20106959b8e89f33b | joselitofilho/aulas-programacao-modulo1 | /aula2/aula_2_operador_not.py | 636 | 4.03125 | 4 | A = True
B = True
resultado = A or (not B)
#print ("A OR (NOT B) =", resultado);
A = False
B = True
resultado = A or (not B)
#print ("A OR (NOT B) =", resultado);
A = False
B = False
resultado = (not A) or B
#print ("(NOT A) OR B =", resultado);
A = True
B = False
resultado = (not A) and B
#print ("(NOT A) AND B =",... |
c398f3db4c1a2be3ec6c30d0610bfe0785292ef4 | nguyenducmanh1206/nguyenducmanh-fundamental-c4e21 | /sisson4.1/baitap.py | 676 | 3.546875 | 4 | r1={
"#":1,
"name":"huy",
"level":25,
"hour":14,
}
r2={
"#":2,
"name":"hoa",
"level":20,
"hour":7,
}
r3={
"#":3,
"name":"tam",
"level":15,
"hour":20,
}
salary_list=[r1, r2, r3]
total_wage =0
wage_list= []
for salary in salary_list:
name = salary["name"]
... |
2002e154eb83119ddb9632b831eee54c64930e1f | nguyenducmanh1206/nguyenducmanh-fundamental-c4e21 | /sission3/baitap1.py | 317 | 3.578125 | 4 | menu_items = ["pho bo", "my xao", "com rang"]
# for index, item in enumerate(menu_items):
# print(index + 1,".", item, sep=" ")
# print("*" *10 )
# print(*menu_items, sep=",")
n =int(input("vi tri ma ban muon update "))
new =input("ban muon thay doi gi :")
menu_items[n-1] =new
print(*menu_items, sep=" ")
|
0a441aa633971320fa95db0068be0fa78846e6cf | JakeRoggenbuck/Paper | /src/papervars.py | 825 | 3.625 | 4 | import error
class Var:
def __init__(self, data, name):
self.data = data
self.name = name
def __repr__(self):
return f"{self.name}({self.data})"
class String(Var):
def __init__(self, data):
super().__init__(data, "String")
def __repr__(self):
return f"String... |
3ca5272ce257f3e629527f211e1225830b2e936c | tanzilsheikh/PythonWorkshop | /DAY_1/surfaceAreaofCone.py | 538 | 3.765625 | 4 | import math
pi = math.pi
# Function To Calculate Surface Area of Cone
def surfacearea(r, s):
return pi * r * s + pi * r * r
# Function To Calculate Total Surface Area
# of Cylinder
def totalsurfacearea(r, h):
tsurf_ar = (2 * pi * r * h) + (2 * pi * r * r)
return tsurf_ar
# Driver Code
... |
090e9d95c5447aeae11e799f04368d50ce8198ff | GreatStephen/MyLeetcodeSolutions | /1contest221/1.py | 353 | 3.609375 | 4 | class Solution:
def halvesAreAlike(self, s: str) -> bool:
vowel = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
def count(s):
ans = 0
for c in s:
if c in vowel:
ans += 1
return ans
l = len(s)
return... |
5a19ec86aa69b16aa92643a644e5187af8ea28a2 | GreatStephen/MyLeetcodeSolutions | /Maximum Width of Binary Tree/Maximum Width of Binary Tree.py | 853 | 3.515625 | 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 widthOfBinaryTree(self, root: TreeNode) -> int:
self.left, self.right = [1], [1]
self.an... |
a1ebdbd847a84c2adc04da4cb8a7372b3fbc7cc7 | GreatStephen/MyLeetcodeSolutions | /Inorder Successor in BST II/Inorder Successor in BST II.py | 851 | 3.75 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
self.parent = None
"""
class Solution:
def inorderSuccessor(self, node: 'Node') -> 'Node':
# ไธค็งๆ
ๅต๏ผไฝไบnode็ๅณๅญๆ ็ๆๅทฆ็ซฏ๏ผๆ่
ไฝไบnode็ๆไธไธชๅคงไบnode็parent
if node.... |
65c7e429d2a43202708f30830e0477807a43f9a1 | GreatStephen/MyLeetcodeSolutions | /Rotate List/better.py | 676 | 3.71875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def rotateRight(self, head: ListNode, k: int) -> ListNode:
if not head: return None
tail, count = head, 1
while tail.next: ... |
c2f298c6288f74dbe40243e6057bfaf04840af82 | ArtemSmirnov/smrn | /dz3/proc27.py | 676 | 3.921875 | 4 | import random
import math
def IsPowerN(K,N):
x = int(round(math.log(K,N)))
if K == N**x:
return True
return False
def IsPowerNa(K,N):
while K > 1:
K /= N
if K == 1.0:
return True
return False
s = 0
s2 = 0
N = random.randrange(2,10)
print("N = ",N)
L... |
f3a593ff7d5198379cdc341d2a1cc35cf49cb345 | alexhwoods/monte-carlo | /monte_carlo/components/models/Card.py | 2,358 | 4.09375 | 4 | # Author: Alex Woods <alexhwoods@gmail.com>
class Card(object):
"""A card from a standard card deck. Cards have the
following properties:
Attributes:
rank: 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace
suit: There are four suits - hearts, diamonds, clubs, and spades. They're
... |
5042fd49bdadc4af7ca64b0e9265c70187357332 | mattknox/twitter_sicp | /2/6_robey.py | 302 | 3.515625 | 4 | #!/usr/bin/env python
zero = lambda f: lambda x: x
def add1(n):
return lambda f: lambda x: f(n(f)(x))
one = lambda f: lambda x: f(x)
two = lambda f: lambda x: f(f(x))
def add(a, b):
return lambda f: lambda x: a(f)(b(f)(x))
# for testing:
def numberize(n):
return n(lambda x: x + 1)(0)
|
88bf240c30c8373b3779a459698223ec3cb74e24 | mliu31/codeinplace | /assn2/khansole_academy.py | 836 | 4.1875 | 4 | """
File: khansole_academy.py
-------------------------
Add your comments here.
"""
import random
def main():
num_correct = 0
while num_correct != 3:
num1 = random.randint(10,99)
num2 = random.randint(10,99)
sum = num1 + num2
answer = int(input("what is " + str(num1) + " + " +... |
4feb346e3c70cf717602c1184168a95a52095903 | mliu31/codeinplace | /section3/iat.py | 2,001 | 3.625 | 4 | import time
import random
TEST_LENGTH_S = 10
'''
This is an alternative program for sections where you are concerned
about colorblindness getting in the way. It is basically the exact same
problem. We will get you a handout with details Monday night PDT.
recall that students don't know lists yet!
'''
def main():
... |
66702fbd180f0bc54cec3fea6c57b802616d186c | mliu31/codeinplace | /section4/section_filter.py | 637 | 3.875 | 4 | from simpleimage import SimpleImage
def main():
"""
This program loads an image and applies the narok filter
to it by setting "bright" pixels to grayscale values.
"""
image = SimpleImage('images/simba-sq.jpg')
# visit every pixel (for loop)
for pixel in image:
# find the average
... |
346d3af90d21411c4265d7e232786fc4078f82fc | Tanay-Gupta/Hacktoberfest2021 | /python_notes1.py | 829 | 4.4375 | 4 | print("hello world")
#for single line comment
'''for multi line comment'''
#for printing a string of more than 1 line
print('''Twinkle, twinkle, little star
How I wonder what you are
Up above the world so high
Like a diamond in the sky
Twinkle, twinkle little star
How I wonder what you are''')
a=20
b... |
9be1cf0969c39542732f8fc56137061d3f005a90 | KarlLichterVonRandoll/learning_python | /DataStructure/sort/02-select.py | 1,272 | 3.6875 | 4 | """
้ๆฉๆๅบ
ๆถ้ดๅคๆๅบฆ๏ผ O(n^2)
้ขๅค็ฉบ้ด๏ผ O(1)
็น็น๏ผ ้ๅๆฐๆฎ้่พๅฐ็ๆ
ๅต
ๅบๆฌๆๆณ๏ผ ็ฌฌไธๆฌก๏ผๅจๅพ
ๆๅบ็ๆฐๆฎ r(1)~r(n) ไธญ้ๅบๆๅฐ็๏ผๅฐๅฎไธ r(1) ไบคๆข๏ผ
็ฌฌไบๆฌก๏ผๅจๅพ
ๆๅบ็ๆฐๆฎ r(2)~r(n) ไธญ้ๅบๆๅฐ็๏ผๅฐๅฎไธ r(2) ไบคๆข๏ผ
ไปฅๆญค็ฑปๆจ...
็ฌฌ i ๆฌก๏ผๅจๅพ
ๆๅบ็ๆฐๆฎ r(i)~r(n) ไธญ้ๅบๆๅฐ็๏ผๅฐๅฎไธ r(i) ไบคๆข
"""
import random
import time
def select_sort(list_):
for i ... |
476b151ef7163cd29a6bd86126f12263be074094 | KarlLichterVonRandoll/learning_python | /month05/AI/day03/demo04_sigmoid.py | 217 | 3.546875 | 4 | """
sigmoid ๅฝๆฐ
"""
import numpy as np
import matplotlib.pyplot as mp
def sigmoid(x):
return 1 / (1 + np.exp(-x))
x = np.linspace(-50, 50, 500)
y = sigmoid(x)
mp.plot(x, y)
mp.grid(linestyle=':')
mp.show()
|
f9f7e50a92722a94b0d387c61b00a216e556219d | KarlLichterVonRandoll/learning_python | /month01/code/day01-04/exercise03.py | 1,842 | 4.1875 | 4 | """
ๅฝๅ
ฅๅๅๅไปท
ๅๅฝๅ
ฅๆฐ้
ๆๅ่ทๅ้้ข๏ผ่ฎก็ฎๅบ่ฏฅๆพๅๅคๅฐ้ฑ
"""
# price_unit = float(input('่พๅ
ฅๅๅๅไปท๏ผ'))
# amounts = int(input('่พๅ
ฅ่ดญไนฐๅๅ็ๆฐ้:'))
# money = int(input('่พๅ
ฅไฝ ๆฏไปไบๅคๅฐ้ฑ๏ผ'))
#
# Change = money - amounts * price_unit
# print('ๆพๅ%.2fๅ
' % Change)
"""
่ทๅๅ้ใๅฐๆถใๅคฉ
่ฎก็ฎๆป็งๆฐ
"""
# minutes = int(input('่พๅ
ฅๅ้:'))
# hours = int(input('่พๅ
ฅๅฐๆถ๏ผ'))
# days = int(... |
dbb60661e2076ec21c88220cab1ced9d6547a260 | KarlLichterVonRandoll/learning_python | /month02/code/Concur_Program/day02/chat_server.py | 1,988 | 3.671875 | 4 | """
ๆๅก็ซฏ
ๆฅๅ่ฏทๆฑ๏ผๅ็ฑป๏ผ
่ฟๅ
ฅ๏ผ็ปดๆคไธไธช็จๆทไฟกๆฏ
็ฆปๅผ๏ผ
่ๅคฉ๏ผๅฐไฟกๆฏๅ้็ปๅ
ถไป็จๆท
"""
from socket import *
import os, sys
# ๅฎไนๅ
จๅฑๅ้
ADDR = ("0.0.0.0", 9527) # ๆๅกๅจๅฐๅ
user = {} # ๅญๅจ็จๆท {name:address}
# ๅค็่ฟๅ
ฅ่ๅคฉๅฎค่ฏทๆฑ
def do_login(s, name, addr):
if name in user or "็ฎก็ๅ" in name:
s.sendt... |
8869c3dd9d8e376bb073a100fa326e65ba43cbeb | KarlLichterVonRandoll/learning_python | /month01/code/day06/exercise02.py | 3,029 | 4.0625 | 4 | """
่พๅ
ฅๆฅๆ(ๅนดๆ๏ผ๏ผ่พๅบไธๅนดไธญ็็ฌฌๅ ๅคฉ๏ผๅๅฉๅ
็ป
ไพๅฆ๏ผ 3ๆ5ๆฅ
1ๆๅคฉๆฐ + 2ๆๅคฉๆฐ + 5
"""
# month_tuple = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
# month = int(input("่พๅ
ฅๆไปฝ(1-12)๏ผ"))
# day = int(input("่พๅ
ฅๆฅๆ(1-31)๏ผ"))
# total_days = 0
# # ๆนๆณไธ
# for item in range(month - 1):
# total_days += month_tuple[item]
# print("่ฟๆฏไธๅนดไธญ็... |
6d30f737753174c9454d15af8a322dea21865a9b | KarlLichterVonRandoll/learning_python | /month01/code/day11/exercise02.py | 520 | 4.0625 | 4 | """
ๅฐ่ฃ
่ฎพ่ฎกๆๆณ
้ๆฑ๏ผ่ๅผ ๅผ่ฝฆๅปไธๅ
"""
class Person:
def __init__(self, name):
self.name = name
@property
def name(self):
return self.__name
@name.setter
def name(self, value):
self.__name = value
def goto(self, str_pos, type):
print(self.__name, "ๅป", str_pos)... |
61e9e28a216ed8774fe5cd8096151d798604d348 | KarlLichterVonRandoll/learning_python | /month01/code/day08/exercise03.py | 2,194 | 4.03125 | 4 | commodity_info = {
101: {"name": "ๅฑ ้พๅ", "price": 10000},
102: {"name": "ๅๅคฉๅ", "price": 10000},
103: {"name": "ไน้ด็ฝ้ชจ็ช", "price": 8000},
104: {"name": "ไน้ณ็ฅๅ", "price": 9000},
105: {"name": "้้พๅๅ
ซๆ", "price": 8000},
106: {"name": "ไนพๅคๅคงๆช็งป", "price": 10000}
}
# ้ๆฉๅๅ
def choose_commodity():
display... |
715ca3cbf7fddbda0e8ba5ffa3e97b853feb5890 | KarlLichterVonRandoll/learning_python | /month05/datascience/day06/02-vec.py | 741 | 4.03125 | 4 | """
็ข้ๅ
"""
import numpy as np
import math as m
def foo(x, y):
return m.sqrt(x ** 2 + y ** 2)
a = 3
b = 4
print(foo(a, b))
# ๆfooๅฝๆฐ็ข้ๅ๏ผไฝฟไนๅฏไปฅๅค็็ข้ๆฐๆฎ
foovec = np.vectorize(foo)
a = np.array([3, 4, 5, 6])
b = np.array([4, 5, 6, 7])
print(foovec(a, b))
# ไฝฟ็จfrompyfuncๅฏไปฅๅฎๆไธvectorizeไธๆ ท็ๅ่ฝ
func = np.frompyfunc(foo,... |
7b8280ba67d8b79daf606d50352bb37f29c5bbce | KarlLichterVonRandoll/learning_python | /fluent_python/1.data_model/pokercard.py | 1,065 | 4.03125 | 4 | import collections
from collections import Iterable, Iterator
# collections.namedtupleไผไบง็ไธไธช็ปงๆฟ่ชtuple็ๅญ็ฑป๏ผไธtupleไธๅ็ๆฏ๏ผๅฎๅฏไปฅ้่ฟๅ็งฐ่ฎฟ้ฎๅ
็ด
# ไปฅไธๅๅปบไบไธไธชๅไธบ"Card"็็ฑป๏ผ่ฏฅ็ฑปๆไธคไธชๅฑๆง"rank"ๅ"suit"
Card = collections.namedtuple('Card', ['rank', 'suit'])
class PokerCard:
ranks = [str(n) for n in range(2, 11)] + list('JQKA')
suits = 'spades... |
a1f7cd46adb9915bacf7893eb370da1a5c0961fe | KarlLichterVonRandoll/learning_python | /month05/datascience/day01/numpy05.py | 1,183 | 3.703125 | 4 | """
ๅค็ปดๆฐ็ป็็ปๅไธๆๅ
"""
import numpy as np
ary01 = np.arange(1, 7).reshape(2, 3)
ary02 = np.arange(10, 16).reshape(2, 3)
# ๅ็ดๆนๅๅฎๆ็ปๅๆไฝ๏ผ็ๆๆฐๆฐ็ป
ary03 = np.vstack((ary01, ary02))
print(ary03, ary03.shape)
# ๅ็ดๆนๅๅฎๆๆๅๆไฝ๏ผ็ๆไธคไธชๆฐ็ป
a, b, c, d = np.vsplit(ary03, 4)
print(a, b, c, d)
# ๆฐดๅนณๆนๅๅฎๆ็ปๅๆไฝ๏ผ็ๆๆฐๆฐ็ป
ary04 = np.hstack((ary01, a... |
04be3ee93ec8a3ca44e2c2e67cddbc868e9e16d0 | KarlLichterVonRandoll/learning_python | /month02/code/Concur_Program/day02/process02.py | 611 | 3.609375 | 4 | """
multiprocessing ๅๅปบๅคไธช่ฟ็จ
"""
from multiprocessing import Process
import time
import os
def func01():
time.sleep(2)
print("chi fan......")
print(os.getppid(), '---', os.getpid())
def func02():
time.sleep(3)
print("shui jiao......")
print(os.getppid(), '---', os.getpid())
def func03()... |
bbcf509fc54e792f44a9ff9dc57aea493cd7d89c | KarlLichterVonRandoll/learning_python | /month01/code/day14/exercise02.py | 1,511 | 4.25 | 4 | """
ๅๅปบEnemy็ฑปๅฏน่ฑก๏ผๅฐๅฏน่ฑกๆๅฐๅจๆงๅถๅฐ
ๅ
้Enemy็ฑปๅฏนๅ
"""
# class Enemy:
#
# def __init__(self, name, hp, atk, defense):
# self.name = name
# self.hp = hp
# self.atk = atk
# self.defense = defense
#
# def __str__(self):
# return "%s ่ก้%d ๆปๅปๅ%d ้ฒๅพกๅ%d" % (self.name, self.hp, self.at... |
c01ac25e7c517caaf6fc23b5edab41131cba70bb | sydney0zq/opencourses | /blog-python/oop/01_student.py | 626 | 3.90625 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright ยฉ 2017-06-18 Sydney <theodoruszq@gmail.com>
"""
"""
class Student(object):
def __init__(self, name, score):
self.name = name
self.score = score
def print_score(self):
print ("%s: %s" % (self.name, self.score)... |
f284bdf3b3929131be1fe943b3bd5761119f4c2e | sydney0zq/opencourses | /byr-mooc-spider/week4-scrapy/yield.py | 1,088 | 4.53125 | 5 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
The first time the for calls the generator object created from your function, it will run the code in your function from the beginning until it hits yield, then it'll return the first value of the loop. Then, each other call will run the loop you have written in the ... |
5e4d5d10de44c2c756ce850375298baf03ec41c1 | ullasgithub/BST | /delete_node.py | 1,187 | 3.875 | 4 | def minValueNode(node):
current = node
# loop down to find the leftmost leaf
while (current.left is not None):
current = current.left
return current
def delete_node(root, data):
# Base Case
if root is None:
return root
# If the key to be deleted is smaller than the root's
... |
1773ec755bb338e87fb6a7d2db910184607fac13 | jobgunwiz/winter_raspi2020_codes | /fun.py | 203 | 3.6875 | 4 | def add(a,b,c):
res = a+b+c
return res
def sub(a,b,c):
res = a-b-c
return res
def main():
print("funct start")
print(add(1,2,3))
value = sub(3,0,1)
print(value)
main()
|
cdc60a5d0ae63254a3186e80e83dc75a149f5f1a | Sinder20/Ejercicios2Python | /EjerciciosImpares.py | 3,707 | 3.984375 | 4 | class Impares():
def ejercicio1(self):
print("* * * Programa que lee un nรบmero y muestra su tabla de multiplicar * * *")
num= int(input("Ingrese el nรบmero que desea mostrar su tabla de multiplicar: "))
for i in range(0,11):
resultado=i*num
print(("%d X %d = %d")%(num... |
853a482a0b44d1dd6883966eaabe2af9fa6103f7 | Soundphy/diapason | /diapason/core.py | 2,364 | 3.546875 | 4 | """
Core diapason code.
"""
from io import BytesIO
from numpy import linspace, sin, pi, int16
from scipy.io import wavfile
def note_frequency(note, sharp=0, flat=0, octave=4, scientific=False):
"""
Returns the frequency (in hertzs) associated to a given note.
All the frequencies are based on the standar... |
3f1884e738e6582e62ff078fd863cb6bbda9dc27 | cvickers23/Noreasters-Tic-Tac-Toe | /main.py | 9,390 | 4 | 4 | #Tic Tac Toe game
#COM 306 Software Engineering
#Noreasters: Craig Haber, Chelsea Vickers, Jacob Nozaki, Tessa Carvalho
#12/10/2020
#A command line interface tool for playing tic tac toe
import random
import logging
import logging.handlers
import os
#Create a logging object
log = logging.getLogger("script-logger")
#Co... |
941df0f3c376d06c87274a8648b0cf72ff98464e | turk0v/miptctf | /python1/tm.py | 365 | 3.515625 | 4 | password = 'e3f7d1980f611d2662d116f0891d7f3e'
print(password.lower())
if password.lower() != password:
print('loser1')
elif len(password) != 32:
print('loser2')
else:
if password != password[::-1]:
print('loser3')
try:
if int(password[:16], 16) != 16426828616880430374:
pr... |
88806f1c3ee74fe801b26a11b0f66a3c7d6c881d | Kajabukama/bootcamp-01 | /shape.py | 1,518 | 4.125 | 4 | # super class Shape which in herits an object
# the class is not implemented
class Shape(object):
def paint(self, canvas):
pass
# class canvas which in herits an object
# the class is not implemented
class Canvas(object):
def __init__(self, width, height):
self.width = width
self.heigh... |
c9a6708eaf8e4deb40eebee4cfcfb2db934fab33 | jwu424/Leetcode | /ShortestUnsortedContinuousSubarray.py | 1,442 | 3.8125 | 4 | # Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.
# You need to find the shortest such subarray and output its length.
# 1. sort the nums and compare the sorted nums with nums from begi... |
593086984f741a8ebd50163f4925b2fad3debdd9 | jwu424/Leetcode | /GameofLife.py | 4,885 | 4 | 4 | # According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
# Given a board with m by n cells, each cell has an initial state live (1) or dead (0). Each cell interacts with its eight neighbors (horizonta... |
89fcd5001ca1ea29530b5253e93440f743316083 | jwu424/Leetcode | /ContainsDuplicate.py | 594 | 3.953125 | 4 | # Given an array of integers, find if the array contains any duplicates.
# First, we use hash table. That is, using dictionary to store value.
# Time complexity: O(n)
# Second, Use set to delete duplicate value.
# Time complexity: O(n)
class Solution:
def containsDuplicate1(self, nums: List[int]) -> bool:
... |
157b4ad717a84f91e60fb5dc108bcab8b2a21a12 | jwu424/Leetcode | /RotateArray.py | 1,275 | 4.125 | 4 | # Given an array, rotate the array to the right by k steps, where k is non-negative.
# 1. Make sure k < len(nums). We can use slice but need extra space.
# Time complexity: O(n). Space: O(n)
# 2. Each time pop the last one and inset it into the beginning of the list.
# Time complexity: O(n^2)
# 3. Reverse the list t... |
b7e8607db52e485c9c5235824d1a56dfc03230a3 | Yanmo/language.processing | /py/q008.py | 856 | 3.59375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import codecs
import io
# for python 2.x
# sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
# for python 3.x
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
#ไธใใใใๆๅญๅใฎๅๆๅญใ๏ผไปฅไธใฎไปๆงใงๅคๆใใ้ขๆฐcipherใๅฎ่ฃ
ใใ๏ผ
# - ่ฑๅฐๆๅญใชใใฐ(219 - ๆๅญใณใผใ)ใฎๆๅญใซ็ฝฎๆ
# - ใใฎไปใฎๆๅญใฏใใฎ... |
b1279922b6295452d236fed7aabd572e79b662fa | Yanmo/language.processing | /py/q000.py | 335 | 4.0625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#ๆๅญๅ"stressed"ใฎๆๅญใ้ใซ๏ผๆซๅฐพใใๅ
้ ญใซๅใใฃใฆ๏ผไธฆในใๆๅญๅใๅพใ๏ผ
import sys
import codecs
str = "stressed"
print(str[::-1]) #why?
str2 =list(sum(zip(str),())) #string->tuple->list
str2.reverse() #reverse
print("".join(str2)) #join list->string
|
7ff62f8cb07d0e287e97ee0daa0ebcdc88366692 | odysseus/gopy | /goban.py | 14,923 | 4.09375 | 4 | from stone import *
from group import *
class BoardError(Exception):
"""Empty class to simply rename the basic Exception"""
pass
class Goban(object):
"""
The code to represent the Goban and the stones placed on it.
Along with the functionality associated with "whole-board" issues.
Eg: Anythi... |
0554ad87dd36f234aec71c24549d6260928436fb | euphoria-paradox/practicar | /shape.py | 688 | 3.953125 | 4 | class Shape():
def __init__(self, shape):
self.shape = shape
def what_am_i(self):
print("I am a " +self.shape)
class Rectangle(Shape):
def __init__(self, width, length):
self.width = width
self.length = length
self.shape = "Rectangle"
def calculat... |
73532432fc6684fe15a36a7ef4624ec52c8af242 | dreamnotover/Python-Shell-Script | /็ๆๅจๅ่ฟญไปฃๅจๅญฆไน py่ๆฌ/่ฟญไปฃ.py___jb_tmp___ | 688 | 4 | 4 | # d = {'a': 1, 'b': 2, 'c': 3}
# for key in d:
# print(key)
# from collections import Iterable
# print(isinstance('abc', Iterable)) # strๆฏๅฆๅฏ่ฟญไปฃ
# print(isinstance([1,2,3], Iterable)) # listๆฏๅฆๅฏ่ฟญไปฃ
# print(isinstance(123, Iterable)) # ๆดๆฐๆฏๅฆๅฏ่ฟญไปฃ
# for i, value in enumerate(['A', 'B', 'C']):
# print(i, value)
#
# for... |
b4b717df217eedd0591e36e92ebc68095fb9e269 | icescrub/data-structures-algorithms | /dynamic_programming.py | 1,741 | 3.546875 | 4 | """
coin change prob
0-1 knapsack
unbounded knapsack
edit distance
Longest common subseq (LCS)
longest incr subseq (LIS)
longest palindrome subseq (LPS)
TSP (iterative AND recursive)
min weight perfect matching (graph prob)
exec(open('/home/duchess/Desktop/dp').read())
values = [60,100,120]
weights = [10,20,30]
capaci... |
da8890ff1f941e97b8174bc6e111272b6ffa0b20 | OliverMorgans/PythonPracticeFiles | /Calculator.py | 756 | 4.25 | 4 | #returns the sum of num1 and num 2
def add(num1, num2):
return num1 + num2
def divide(num1, num2):
return num1 / num2
def multiply(num1, num2):
return num1 * num2
def minus (num1, num2):
return num1 - num2
#*,-,/
def main():
operation = input("what do you want to do? (+-*/): ")
if(operation != "+" and opera... |
d2cc189fca2ee474dcaa8ddf961517e29267df7b | milannic/intern_code | /intern_course/python/list_merge.py | 2,303 | 3.9375 | 4 | #! /usr/local/bin/python
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param head, a ListNode
# @return a ListNode
# @param head, a ListNode
# @return a ListNode
def sortList(self, head):
... |
261a8ec6e763de736e722338241d2cf39a34c9b0 | Rggod/codewars | /Roman Numerals Decoder-6/decoder.py | 1,140 | 4.28125 | 4 | '''Problem:
Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral.
Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the left... |
a7ee00fd9f9dac5ec77d96e7b1ab8c1a1dbe1b4f | Rggod/codewars | /is alphanumerical/solution.py | 592 | 4.15625 | 4 | '''
In this example you have to validate if a user input string is alphanumeric. The given string is not nil, so you don't have to check that.
The string has the following conditions to be alphanumeric:
At least one character ("" is not valid)
Allowed characters are uppercase / lowercase latin letters and dig... |
fe851161d4f3ef73f6bab3d9eef56b8fc1f38905 | OsouzaTI/URI | /URI_Python_UFRR/1012.py | 381 | 3.8125 | 4 | linha1 = input().split(" ")
pi = 3.14159
A, B, C = linha1
a_ = (float(A) * float(C))/2
b_ = pi * (float(C)**2)
c_ = ((float(A) + float(B))*float(C))/2
d_ = float(B)**2
e_ = float(A) * float(B)
print('TRIANGULO: {:.3f}'.format(a_))
print('CIRCULO: {:.3f}'.format(b_))
print('TRAPEZIO: {:.3f}'.format(c_))
print('QUADRA... |
6503af81150e0906e8ba7ddc6373962f3c11d8fd | OsouzaTI/URI | /URI_Python_UFRR/1050.py | 342 | 3.515625 | 4 | # -*- coding: utf-8 -*-
n = int(input())
err = 1
ddd = [
(61,71,11,21,32,19,27,31),
('Brasilia','Salvador','Sao Paulo','Rio de Janeiro','Juiz de Fora','Campinas','Vitoria','Belo Horizonte')
]
for i in range(len(ddd[0])):
if n == ddd[0][i]:
print(ddd[1][i])
err = 0
if(err == 1):
print... |
99839f599cf60f678ec5ff647313aa549f6e24f7 | OsouzaTI/URI | /URI_Python_UFRR/1065.py | 102 | 3.6875 | 4 | pares = 0
for i in range(5):
n = float(input())
if n%2==0:pares += 1
print('%i valores pares'%pares) |
60612f98363116d4508680cee96688c745fce41c | Changyoon-Lee/TIL | /Algorithm/programmers/์ ์ ์ผ๊ฐํ.py | 360 | 3.515625 | 4 | # DFSํ๋ ค๋ค๊ฐ ์ค๋๊ฑธ๋ฆด๊ฑฐ๊ฐ์์ ์ํจ
def solution(triangle):
for i in range(len(triangle)-2,-1,-1):
for j in range(len(triangle[i])):
if triangle[i+1][j]>triangle[i+1][j+1]:
triangle[i][j] += triangle[i+1][j]
else :
triangle[i][j] += triangle[i+1][j+1]
return tr... |
d42902b04e014ea651d0cd92ed384bebba85d2dc | uashogeschoolutrecht/ADDB-PM | /week1/uitwerkingen/som.py | 148 | 3.546875 | 4 | getal1 = input("geef het eerste getal: ")
getal2 = input("geef het tweede getal: ")
som = int(getal1) + int(getal2)
print("De som is " + str(som)) |
a2782f257e999f2e2874983ef2ba659f2876423a | jan25/code_sorted | /leetcode/weekly185/3_frogs.py | 1,621 | 3.546875 | 4 | '''
https://leetcode.com/contest/weekly-contest-185/problems/minimum-number-of-frogs-croaking/
'''
class Solution:
def minNumberOfFrogs(self, croakOfFrogs: str) -> int:
cr = 'croak'
def nextChar(c):
if c == cr[-1]: return
for i, cc in enumerate(cr):
i... |
51731f8e5b7bff4e912a640e2da7d6c0f7da5bb7 | jan25/code_sorted | /leetcode/weekly169/3_jumps.py | 615 | 3.578125 | 4 | '''
https://leetcode.com/contest/weekly-contest-169/problems/jump-game-iii/
'''
class Solution:
def canReach(self, arr: List[int], start: int) -> bool:
n = len(arr)
vis = set()
def walk(i):
if i < 0 or i >= n: return False
if arr[i] == 0: return True
... |
c5df770ffadb8bc330143a8a8766c35fb5dd2166 | jan25/code_sorted | /leetcode/weekly166/2_people_and_groups.py | 468 | 3.59375 | 4 | '''
https://leetcode.com/contest/weekly-contest-166/problems/group-the-people-given-the-group-size-they-belong-to/
'''
class Solution:
def groupThePeople(self, groupSizes: List[int]) -> List[List[int]]:
groups = []
h = {}
for n, g in enumerate(groupSizes):
if g not in h: h[g] = [... |
a50b8b9a73fb850f8c19108757e46762e0864d1c | jan25/code_sorted | /leetcode/weekly169/2_2_binary_trees.py | 753 | 3.78125 | 4 | '''
https://leetcode.com/contest/weekly-contest-169/problems/all-elements-in-two-binary-search-trees/
'''
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def getAllElements(self, root1:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.