blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
ee3e0c30c143389e06722b7eb147f5196359eebc | Tamilarasi2331/Tamilarasi | /sorting.py | 101 | 3.671875 | 4 | n=int(input())
mylist=[]
for i in range(n):
mylist.append(int(input()))
mylist.sort()
print(mylist)
|
3910751162c25cacebc277bb71da1da7a2a2b845 | jlsphotos/games | /roulette.py | 1,162 | 3.984375 | 4 | import random
import time
# version 0.1 in.
print("Spining Wheel")
time.sleep(random.randint(1,3))
reds = (1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36)
blacks = (2, 4, 6, 8, 10, 11,13, 15, 17, 20, 22, 24,26, 28, 29, 31, 33, 35)
st1 = range(1, 12)
st2 = range(1, 12)
def spin_the_wheel():
s... |
d50c256714f0ce5f8f6a488c2a660ebcbd8579ad | Abdk4Moura/miniproj | /Hangman Game/hangman.py | 3,045 | 4.0625 | 4 | ### Hangman game:-
import random
WORDS = 'words.txt'
class Hangman:
def __init__(self):
self.word = self.chooseWord(self.loadWords()).lower()
self.main()
def loadWords(self):
print("Loading words from file..")
file = open(WORDS, 'r')
line = file.readline()
word... |
dd67f804a137eaf24059539d676045a08f54a807 | kwinter213/ToolBox-Pickling | /counter.py | 778 | 3.734375 | 4 | """ A program that stores and updates a counter using a Python pickle file"""
from os.path import exists
import sys
from pickle import dump, load
import pickle #I'm just importing all of pickle lol
counter=0 #initializing the counter
def update_counter(file_name, reset):
if(reset==True): #if reset is true, reset to ... |
abedb461ca6eb4159d0279ea2acc52c66b832348 | jostmann/pyladiesworkshop | /task_1.py | 1,174 | 3.921875 | 4 | print()
print("Welcome to the dungeon!")
print("Do you go through door 1 or door 2?")
door = input("> ")
if door == "1":
print("There is a nice vampire asking you if you enjoy life.")
print("What do you do?")
print("1. Smile and nod")
print("2. Scream and run")
vampire = input("> ")
if vampi... |
47d33cbb3b3a8abbf266858746476ecc40e2a453 | mike-kane/Masters_Portfolio | /Data Structures and Algorithms/Sorting/selection_sort.py | 1,359 | 3.953125 | 4 | import unittest
def selection_sort(list_to_sort):
# iterate from back of list towards front of list
for slot_to_fill in range(len(list_to_sort) - 1, 0, -1):
index_of_max = 0
# iterate from index 1 to slot being filled looking for max item
# (we don't start at 0 since first item will al... |
aff47aa6ad622d552f75263fa8b45a0d435775ee | mike-kane/Masters_Portfolio | /Data Structures and Algorithms/euler_solution_9.py | 1,074 | 4.0625 | 4 | ######################################################################################
# Project Euler Problem 9 Solution -- Special Pythagorean Triplet
# Project Euler Problem 9
#
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
#
# a**... |
7f8f5fec1ab1fd0bcb3ef33b15487ba284bc5397 | lilgaage/lilgaage_scripts | /python/03.py | 6,403 | 3.859375 | 4 | '''
#字符串
name = "ghost"
print(name, id(name), id("ghost")) #id(),获取变量在内存中的地址
name = "鬼瓷"
print(name, id(name), id("鬼瓷"))
str1 = "娃琳可"
print(len(str1)) #len(),获取字符串长度
print(str1[0]) #根据索引获取元素,变量名[索引]
print(str1[1])
print(str1[-1])
str2 = "0123456789" #切片,变量名[起始索引:结束索引:步长],包头不包尾
print(str2[5:10:1])
print(str... |
cf17734acb9900d73ed70e3f039395f6ac6fff87 | lilgaage/lilgaage_scripts | /python/02.py | 3,863 | 3.703125 | 4 | '''
n=True
if n:
print("去长沙")
age=int(input("请输入您的年龄:"))
if age>=21:
print("去")
else:
print("不去")
age=int(input("请输入一个整数:"))
if 1<=age<=120:
print("该年龄输入正确!")
else:
print("您的输入有误!")
age=int(input("请输入您的年龄:"))
if age>150 or age<0:
print("您的输入有误!")
elif age<12:
print("儿童")
elif age<38:
pri... |
65ad3439b87f21fc2bb2a9ffb7fe2657cd9287d9 | hugoray/COMP9021 | /roman_arabic.py | 11,973 | 3.625 | 4 | from collections import Counter
def check_answer():
answer = input("How can I help you? ")
# set function for converting just integers
def condition_one(para):
Alist = []
val = 0
dict_arab = {0 : ("","I","II","III","IV","V","VI","VII","VIII","IX"),
1 : ("... |
61e11ee2fdf84562f184db712f05240ab7ad4eff | UltimateBlue/Python | /006-rock-paper-sissor/main.py | 2,490 | 4.0625 | 4 | from random import randint
while True:
choice = input('Rock / Paper / Sissor: ').lower()
randChoice = randint(0,2)
print(randChoice)
if choice == 'rock' and randChoice ==0:
print('You choose rock, I choose rock too! so no Winner!')
con = input('Do you want to continue? (Y/N)').lower... |
1754513c18fc5a59965a125df25cc1c8ed72bf72 | AChandel500/python-homework | /Script 3 - Separate Number by Even and Odd.py | 610 | 4.1875 | 4 | # Script to create arrays of odd and even numbers
# extracted from an array of numbers from 1-9
import numpy as np
# Create the array of 1-9 numbers
num_list = np.arange(1,10); print(f'\n{num_list}\n')
#Create empty arrays to receive odd and even numbers
even_nums = np.empty(0); odd_nums = np.empty(0)
# For each nu... |
a608a086f79fe594b8a070769a1a9943f4cd1f10 | mohdadnan0000/dwm-lab | /SimpleLinearRegression/simple_linear_regression.py | 1,266 | 3.734375 | 4 | import numpy as np
import pandas as pd
import matplotlib as mpl
#mpl.use(TkAgg')
import matplotlib.pyplot as plt
#importing dataset
dataset=pd.read_csv('Salary_Data.csv')
X=dataset.iloc[:,:-1].values
y=dataset.iloc[:,1:].values
#splitting the dataset into the training and test sets
from sklearn.model_selection impo... |
24fbb6da2f6e0678c9b2b3cb1917e0603cc5ba7f | Seandor/Principals-of-Computing | /week3/tic_tac_toe.py | 3,747 | 3.609375 | 4 | """
Monte Carlo Tic-Tac-Toe Player
"""
import random
import poc_ttt_gui
import poc_ttt_provided as provided
# Constants for Monte Carlo simulator
# You may change the values of these constants as desired, but
# do not change their names.
NTRIALS = 1 # Number of trials to run
SCORE_CURRENT = 1.0 # Score for s... |
042c4c5d8fceece56c35c7c1b2d82fe48ee88bb4 | yendefr/inf-2021 | /2.py | 333 | 4.125 | 4 |
for w in range(2):
for x in range(2):
for y in range(2):
for z in range(2):
# Вписываем сюда формулу из задания и получаем варианты переменных
if ((x <= y) or not(w <= z)) == False:
print(w, x, y, z)
|
81a2007680f9e371410c993a5f70c04471a893ad | mcrrobinson/Python-Maths-Examples | /Simple Math (practP2)/sum_of_squares.py | 472 | 4.125 | 4 | def sumOfSquares(n):
""" sumOfSquares
Output the sum of the first n positive integers, where
n is provided by the user.
passes:
n:
Output the sum of the first n positive integers, where
n is provided by the user.
returns:
Returns an array of the sum o... |
e912721f5772ed3cef2ace42d8e2ca7f8ddc8a19 | mcrrobinson/Python-Maths-Examples | /Strings and Files (practP4)/make_initalism.py | 475 | 4.5 | 4 | # Write a makeInitialism function that allows the user to enter a phrase, and then
# displays the first letters of the words in capitals for that phrase. For example, if the
# user enters “University of Portsmouth”, the function should display UOP.
def makeInitialism(phrase):
wordArray = phrase.split()
outputA... |
d78725e8930b4250c7ccdcdf40e47c5072a1e1a2 | mcrrobinson/Python-Maths-Examples | /Coursework/main.bak.py | 10,029 | 4.0625 | 4 | from graphics import *
available_colors=["red", "green", "blue", "magenta", "orange", "cyan"]
portsmouth_id="UP2022742"
def integerValidation(requestMessage):
"""integerValidation validates the integer input if the input is incorrect
it will request an input again. Once successful it will exit and return.
... |
c1d20848d4cac5a6dcf47f05c4af43c6db2134d8 | mike108sy/python_homework | /Четверть 1:4/lesson4:1.py | 491 | 3.71875 | 4 | import sys
sys.argv.insert(1, int(input('Введите выработку в часах сотрудника, руб.: ')))
sys.argv.insert(2, int(input('Введите ставку в часах сотрудника, руб.: ')))
sys.argv.insert(3, int(input('Введите размер премии сотрудника, руб.: ')))
args = sys.argv[1] * sys.argv[2] + sys.argv[3]
print('Заработная плата сотруд... |
849d81e535e5145c190aef5be1edc90648c87b08 | mike108sy/python_homework | /Четверть 1:1/lesson1:5.py | 1,030 | 3.96875 | 4 | x = int(input('Введите выручку компании за прошлый месяц (руб.): '))
y = int(input('Введите затраты компании за прошлый месяц (руб.): '))
if x > y:
print('Финансовый результат компании за прошлый месяц: ПРИБЫЛЬ')
z = ((x - y) / x) * 100
print('Рентабельность работы компании за прошлый месяц:', z, '%')
p... |
3227fcd1eb86dd37c461a3a3700637262a5d441b | mike108sy/python_homework | /Четверть 1:3/lesson3:6:2.py | 325 | 3.5625 | 4 | def int_func(word):
my_list = list(word)
print(my_list)
for i in range(len(my_list)):
my_list[i] = my_list[i].title()
s = ' '
my_resulte = s.join(my_list)
return my_resulte
print(int_func([i for i in input('Введите значения списка через пробел: ').split()]))
|
c93ebba41180cbb019f26b8d4c88612c122554ab | mike108sy/python_homework | /Четверть 1:5/lesson5:3.py | 940 | 3.765625 | 4 | with open("file5:3.txt", "r+") as f:
surname = ' '
while True:
surname = input('Введите фамилию сотрудника и нажмите "Enter": ')
if surname == '':
break
salary = input('Введите заработную плату сотрудника и нажмите "Enter": ')
print(surname, salary, file=f)
fi... |
ce61b38e5ae352c0f518c309c717e1ff0d551fde | applicationsbypaul/Module6 | /test_functions/test_valid_input_in_functions.py | 1,063 | 3.90625 | 4 | """
Program: test_valid_input_in_functions.py
Author: Paul Ford
Last date modified: 06/17/2020
Purpose: test score input function
"""
import unittest
from more_functions.validate_input_in_functions import score_input
class MyTestCase(unittest.TestCase):
def test_score_input_test_name(self):
self.assertEq... |
20893835b90f641a53e28e1c000415c31cfa26d8 | kailunfan/lcode | /213.打家劫舍-ii.py | 1,628 | 3.515625 | 4 | #
# @lc app=leetcode.cn id=213 lang=python
#
# [213] 打家劫舍 II
#
# https://leetcode-cn.com/problems/house-robber-ii/description/
#
# algorithms
# Medium (37.43%)
# Likes: 265
# Dislikes: 0
# Total Accepted: 35.6K
# Total Submissions: 93.9K
# Testcase Example: '[2,3,2]'
#
#
# 你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所... |
ec541eb464f186c4960d04b9a28f33ea815e292a | kailunfan/lcode | /508.出现次数最多的子树元素和.py | 1,946 | 3.6875 | 4 | #
# @lc app=leetcode.cn id=508 lang=python
#
# [508] 出现次数最多的子树元素和
#
# https://leetcode-cn.com/problems/most-frequent-subtree-sum/description/
#
# algorithms
# Medium (63.05%)
# Likes: 68
# Dislikes: 0
# Total Accepted: 5.9K
# Total Submissions: 9.1K
# Testcase Example: '[5,2,-3]'
#
# 给你一个二叉树的根结点,请你找出出现次数最多的子树元素和... |
b5244fae89c68217a14f7b4d180755eb5a4fd38c | kailunfan/lcode | /98.验证二叉搜索树.py | 1,707 | 3.6875 | 4 | #
# @lc app=leetcode.cn id=98 lang=python
#
# [98] 验证二叉搜索树
#
# https://leetcode-cn.com/problems/validate-binary-search-tree/description/
#
# algorithms
# Medium (29.81%)
# Likes: 584
# Dislikes: 0
# Total Accepted: 120.2K
# Total Submissions: 385.6K
# Testcase Example: '[2,1,3]'
#
# 给定一个二叉树,判断其是否是一个有效的二叉搜索树。
#
... |
f57402d9289bcb7fe797f8b32bdca9d31329ee5a | kailunfan/lcode | /222.完全二叉树的节点个数.py | 2,533 | 3.828125 | 4 | #
# @lc app=leetcode.cn id=222 lang=python
#
# [222] 完全二叉树的节点个数
#
# https://leetcode-cn.com/problems/count-complete-tree-nodes/description/
#
# algorithms
# Medium (68.30%)
# Likes: 159
# Dislikes: 0
# Total Accepted: 21.3K
# Total Submissions: 30.7K
# Testcase Example: '[1,2,3,4,5,6]'
#
# 给出一个完全二叉树,求出该树的节点个数。
#... |
6619c3860dcea1ce1791996ca718ee69dd85853a | kailunfan/lcode | /687.最长同值路径.py | 1,834 | 3.671875 | 4 | #
# @lc app=leetcode.cn id=687 lang=python3
#
# [687] 最长同值路径
#
# https://leetcode-cn.com/problems/longest-univalue-path/description/
#
# algorithms
# Easy (41.24%)
# Likes: 350
# Dislikes: 0
# Total Accepted: 23K
# Total Submissions: 55.1K
# Testcase Example: '[5,4,5,1,1,5]'
#
# 给定一个二叉树,找到最长的路径,这个路径中的每个节点具有相同值。 ... |
9bf43172c3b0343a492e77da48dc83a944c8271c | kailunfan/lcode | /143.重排链表.py | 1,775 | 3.8125 | 4 | #
# @lc app=leetcode.cn id=143 lang=python3
#
# [143] 重排链表
#
# https://leetcode-cn.com/problems/reorder-list/description/
#
# algorithms
# Medium (55.64%)
# Likes: 269
# Dislikes: 0
# Total Accepted: 33.1K
# Total Submissions: 58.9K
# Testcase Example: '[1,2,3,4]'
#
# 给定一个单链表 L:L0→L1→…→Ln-1→Ln ,
# 将其重新排列后变为: L0→... |
8efa761eeb246bd7526f8a91b109163f8ed3bac3 | kailunfan/lcode | /404.左叶子之和.py | 1,364 | 3.75 | 4 | #
# @lc app=leetcode.cn id=404 lang=python3
#
# [404] 左叶子之和
#
# https://leetcode-cn.com/problems/sum-of-left-leaves/description/
#
# algorithms
# Easy (54.26%)
# Likes: 149
# Dislikes: 0
# Total Accepted: 25K
# Total Submissions: 45.8K
# Testcase Example: '[3,9,20,null,null,15,7]'
#
# 计算给定二叉树的所有左叶子之和。
#
# 示例:
#
... |
5fe68369a6d69eaf27798199b816cadfebcac8e9 | kailunfan/lcode | /117.填充每个节点的下一个右侧节点指针-ii.py | 3,834 | 3.78125 | 4 | #
# @lc app=leetcode.cn id=117 lang=python
#
# [117] 填充每个节点的下一个右侧节点指针 II
#
# https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node-ii/description/
#
# algorithms
# Medium (47.30%)
# Likes: 143
# Dislikes: 0
# Total Accepted: 20.7K
# Total Submissions: 42.6K
# Testcase Example: '[1,2,3,4,5,... |
01922bcee6a523fea79d90b767a0066a151c6d68 | kailunfan/lcode | /449.序列化和反序列化二叉搜索树.py | 2,370 | 3.640625 | 4 | #
# @lc app=leetcode.cn id=449 lang=python
#
# [449] 序列化和反序列化二叉搜索树
#
# https://leetcode-cn.com/problems/serialize-and-deserialize-bst/description/
#
# algorithms
# Medium (51.36%)
# Likes: 71
# Dislikes: 0
# Total Accepted: 5.4K
# Total Submissions: 10.3K
# Testcase Example: '[2,1,3]'
#
# 序列化是将数据结构或对象转换为一系列位的过程,... |
0404323c3a9a60789a53571afc4750d3ad6d93c7 | kailunfan/lcode | /107.二叉树的层次遍历-ii.py | 1,424 | 3.921875 | 4 | #
# @lc app=leetcode.cn id=107 lang=python
#
# [107] 二叉树的层次遍历 II
#
# https://leetcode-cn.com/problems/binary-tree-level-order-traversal-ii/description/
#
# algorithms
# Easy (64.90%)
# Likes: 235
# Dislikes: 0
# Total Accepted: 58.7K
# Total Submissions: 89.6K
# Testcase Example: '[3,9,20,null,null,15,7]'
#
# 给定... |
0065fc2e93897e63f378c804ef6da049a3c2b053 | kailunfan/lcode | /219.存在重复元素-ii.py | 1,569 | 3.59375 | 4 | #
# @lc app=leetcode.cn id=219 lang=python
#
# [219] 存在重复元素 II
#
# https://leetcode-cn.com/problems/contains-duplicate-ii/description/
#
# algorithms
# Easy (38.29%)
# Likes: 178
# Dislikes: 0
# Total Accepted: 49K
# Total Submissions: 124.9K
# Testcase Example: '[1,2,3,1]\n3'
#
# 给定一个整数数组和一个整数 k,判断数组中是否存在两个不同的索... |
b1819f00841cb63ba6b05fa27a701727082ded74 | kailunfan/lcode | /112.路径总和.py | 2,113 | 3.6875 | 4 | #
# @lc app=leetcode.cn id=112 lang=python
#
# [112] 路径总和
#
# https://leetcode-cn.com/problems/path-sum/description/
#
# algorithms
# Easy (49.50%)
# Likes: 303
# Dislikes: 0
# Total Accepted: 76.7K
# Total Submissions: 154.5K
# Testcase Example: '[5,4,8,11,null,13,4,7,2,null,null,null,1]\n22'
#
# 给定一个二叉树和一个目标和,... |
02072167a9a222b5e2cf0042306895d4804df427 | vitclarke279/Git-Projects | /Algorithm .py files/Problem_#2.py | 2,168 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 20 10:43:39 2020
@author: vlopa
Given an array of integers, return a new array such that each element at index
i of the new array is the product of all the numbers in the original array
except the one at i.
For example, if our input was [1, 2, 3, 4, 5], the expected... |
2ab7db72bbedb171da2aec2cd116ff45de036177 | dansoh/python-intro | /python-crash-course/exercises/chapter-10/10-12-favorite-numbers-remembered.py | 798 | 3.859375 | 4 | import json
def number_check():
"""Check if favorite number already exists."""
filename = 'favorite_number.json'
try:
with open(filename) as f_obj:
favorite_number = json.load(f_obj)
except FileNotFoundError:
return None
else:
return favorite_number
def record_number():
"""Prompt for fa... |
815d4ea772884230a91e4164b4befb712566d092 | dansoh/python-intro | /python-crash-course/exercises/chapter-8/8-3-t-shirt.py | 223 | 3.59375 | 4 | def make_shirt(size, text):
print("\nYour shirt will be made in a " + size.lower() + " size and will have "
+ text + " printed on it")
make_shirt('large', 'Enron')
make_shirt(size='small', text='Giant')
|
c8384d77eb56b6cac096ffb448a6178271e97a56 | dansoh/python-intro | /python-crash-course/exercises/chapter-9/9-5-login-attempts.py | 1,636 | 4.09375 | 4 | class User():
"""
A simple attempt to model a User
"""
def __init__(self, first_name, last_name, age, gender, location):
"""
Initialize first name, last name, age, gender and location
for user
"""
self.first_name = first_name
self... |
3dd411e69c0a50bf9e90b6e65fa51ab6b46a75ac | dansoh/python-intro | /python-crash-course/exercises/chapter-9/9-8-privileges.py | 2,061 | 4.34375 | 4 | class User():
"""
A simple attempt to model a User
"""
def __init__(self, first_name, last_name, age, gender, location):
"""
Initialize first name, last name, age, gender and location
for user
"""
self.first_name = first_name
self... |
fa2d195c359374de6e2ef2ddfe72b4b4f86252f6 | dansoh/python-intro | /python-crash-course/exercises/chapter-8/8-4-large-shirts.py | 273 | 3.75 | 4 | def make_shirt(text='I love Python', size='large'):
print("\nYour shirt will be made in a " + size.lower() + " size and will have \""
+ text + "\" printed on it")
make_shirt()
make_shirt(size='medium')
make_shirt(size='small', text='I love candy')
|
ea72080c6e03ebd03cf0b9011b4be26e3937d93e | dansoh/python-intro | /python-crash-course/exercises/chapter-8/8-8-user-albums.py | 550 | 3.703125 | 4 | def make_album(artist_name, album_title, track_count=''):
album_details = {'artist_name' : artist_name, 'album_title': album_title}
if track_count:
album_details['track_count'] = track_count
return album_details
while True:
print("\nEnter album information: ")
print("(press 'q' ... |
a33b6dc9b8f6d3731c9d9e0c0cef78332476a86f | dansoh/python-intro | /python-crash-course/exercises/chapter-3/3-10-every-function.py | 453 | 3.6875 | 4 | everything = ['elon', 'jordan', ' turtles', 'space ', ' science ', '3']
everything.append('kami')
print(everything)
everything.insert(1, 'adele')
print(everything)
del everything[1]
print(everything)
temp = everything.pop(1)
print(temp)
print(everything)
everything.remove('elon')
print(everything)
... |
3698c9be29a484d5c685f632171a9ce4e7838b9e | vitorvicente/LearningPython | /Basics/Sets.py | 1,250 | 3.828125 | 4 | # Set manipulation
print("Basic Set Manipulation:")
print("s1 = {1,3,2,4,5}\n")
s = {1, 3, 2, 4, 5}
s.add(6)
print("s.add(6) =", s)
s.remove(1)
print("s.remove(1) =", s)
s.update([7, 8, 9])
print("s.update([7, 8, 9]) =", s)
len(s)
print("len(s) =", len(s))
s.discard(2)
print("s.discard(2) =", s)
print("s.pop() ... |
66588799bf98d97483ad4ed97a1a34d5b3fbc5ef | vitorvicente/LearningPython | /Control Flow/Conditionals.py | 560 | 4.21875 | 4 | a = 2
b = 5
t = True
f = False
# Basic IF / ELIF / ELSE
if b > a:
print("b > a")
elif b == a:
print("b == a")
else:
print("b < a")
# Shorthand IF / ELIF / ELSE
if a > b: print("a > b")
print("a > b") if a > b else print("a <= b")
print("a > b") if a > b else print("a < b") if a < b else print("a == b"... |
c6b2c673ddde9f6eb796146087b68a65f7b7e379 | vitorvicente/LearningPython | /Basics/Arrays.py | 308 | 3.921875 | 4 | a = ["Ford", "Volvo", "BMW"]
print(a[0])
a[0] = "Tesla"
print(len(a))
for x in a:
print(x)
a.append("Honda")
a.pop(0)
a.remove("Volvo")
b = a.copy()
a.clear()
print(a)
b.append("Honda")
print(b.count("Honda"))
b.extend(["Renault, Buggatti"])
print(b.index("Renault"))
b.reverse()
b.sort()
|
47d532055aa526a065c548580a3a0e7df2ce17c3 | shinokun/python_sample | /sample_def.py | 1,295 | 3.6875 | 4 |
###fileの一覧表示 再帰的#########################################
import pathlib
import os
return_list = []
def show_recursive(path):
path = pathlib.Path(path)
for po in path.iterdir():
if po.is_dir():
#ディレクトリだったら再帰的に自分を呼び出し、最下層まで検索する
show_recursive(po)
#matchさせたいファイルがある場合は... |
b806dd7788beaf8388ba561e9b272ba4f9207610 | lolacola/Learning | /orion.py | 2,437 | 3.625 | 4 | # This program draws a stars of the Orion constellation,
# the names of the stars, and the constallation
import turtle
# Set the windows size
turtle.setup(500, 600)
# Setup the turtle
turtle.penup()
turtle.hideturtle()
# Create named constants for the star coordinates.
LEFT_SHOULDER_X = -70
LEFT_SHOULDER_Y = 200
... |
ce08d768467896d2ce00840177f379cee6656c83 | loredanasandu/algorithms-and-data-structures | /Course 1 - Algorithmic Toolbox/algorithmic-warmup/fibonacci_sum_last_digit.py | 1,429 | 4 | 4 | # Given a non-negative integer n, finds the last digit of the sum
# F_0 + F_1 + ... + F_n.
# Input: A non-negative integer n.
# Output: Last digit of the sum F_0 + F_1 + ... + F_n.
import sys
def fibonacci_sum_naive(n):
if n <= 1:
return n
previous = 0
current = 1
total_sum = 1
for _ ... |
6d856fe488ce00916eebf18351b918fd00c3a478 | dlreach/PythonPrograms | /Fizz.py | 348 | 3.84375 | 4 |
def GetNumber():
global number
number = input('Enter a number and I will FizzBuzz that mf!')
number = int(number)
def Fizzle(number):
for i in range(number + 1):
if i % 15 == 0:
print("FizzBuzz!")
elif i %3 == 0:
print("Fizz!")
elif i %5 == 0:
print("Buzz")
else:
print(i)
... |
133b8dbc0bec4d3cbf3a1e74f45cb2c58cbee30f | bsimps01/Engineering-Communication | /LeetOne.py | 1,517 | 4.0625 | 4 | '''Given an array of integers, return indices of the two numbers such that they add up to a specific target.'''
'''You may assume that each input would have exactly one solution, and you may not use the same element twice.'''
'''Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [... |
09f654d1ad4a1ad9886153ff93a87fcd16ea1f07 | VictoriqueCQ/LeetCode | /nowcoder/华为机试/单词倒排.py | 805 | 3.703125 | 4 | line1 = input().split(" ")
line2 = []
def allalpha(word):
for i in range(len(word)):
if not word[i].isalpha():
return False
return True
def divide(word):
left = 0
right = 0
result = []
for i in range(len(word)):
if not word[i].isalpha():
right = i
... |
7a19df32f4e2c8581250cec0a6c87ae17869fab3 | VictoriqueCQ/LeetCode | /Python/71. 简化路径.py | 523 | 3.6875 | 4 | class Solution:
def simplifyPath(self, path: str) -> str:
r = []
for s in path.split('/'):
r = {'':r, '.':r, '..':r[:-1]}.get(s, r + [s])
return '/' + '/'.join(r)
class Solution2:
def simplifyPath(self, path: str) -> str:
stack = []
path = path.split("/")
... |
67ffb4a73eaaee5ad3b83984f7313d88f8b4988c | VictoriqueCQ/LeetCode | /Python/129. 求根到叶子节点数字之和.py | 1,368 | 3.65625 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
tmp = lambda self, root: [] if not root else [root.val] if not root.left and not root.right \
else [str(root.val) + str(i) for i in self.t... |
fa245431fcd03adac8593cb2cb071bcd661afb72 | VictoriqueCQ/LeetCode | /Python/844. 比较含退格的字符串.py | 1,371 | 3.515625 | 4 | class Solution:
def backspaceCompare(self, S: str, T: str) -> bool:
i, j = len(S) - 1, len(T) - 1
skipS = skipT = 0
while i >= 0 or j >= 0:
while i >= 0:
if S[i] == "#":
skipS += 1
i -= 1
elif skipS > 0:
... |
c2b2965356607f01961ebb365d7265d5a1807b7d | VictoriqueCQ/LeetCode | /Python/637. 二叉树的层平均值.py | 1,543 | 3.8125 | 4 | # Definition for a binary tree node.
import collections
from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def averageOfLevels(self, root: TreeNode) -> List[float]:
def dfs(root: TreeNode, level: int):
... |
67193ebc157c5d5e32ad5517c07dddc3cc0d6c91 | VictoriqueCQ/LeetCode | /Python/504. 七进制数.py | 376 | 3.640625 | 4 | class Solution:
def convertToBase7(self, num: int) -> str:
if num == 0: return "0"
is_negative = num < 0
if is_negative:
num = -num
ans = ""
while num:
a = num // 7
b = num % 7
ans = str(b)+ans
num = a
if is_... |
3b9f152b99111e87342586189fc9bfdb560fecc2 | VictoriqueCQ/LeetCode | /Python/215. 数组中第k个最大元素.py | 2,612 | 3.578125 | 4 | from typing import List
import heapq
class Solution:
# 使用容量为 k 的小顶堆
# 元素个数小于 k 的时候,放进去就是了
# 元素个数大于 k 的时候,小于等于堆顶元素,就扔掉,大于堆顶元素,就替换
# def findKthLargest(self, nums: List[int], k: int) -> int:
# size = len(nums)
# if k > size:
# raise Exception('程序出错')
#
# L =... |
cae5d2a446aa97922d9dcb1bf5c16349683cbcb4 | VictoriqueCQ/LeetCode | /Python/257. 二叉树的所有路径.py | 966 | 3.9375 | 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 binaryTreePaths(self, root: TreeNode) -> List[str]:
if not root:
return []
q = [[root, []], ]
res = []
... |
4097b43fdb1099329bce9738f32a2ee3bf4a4005 | VictoriqueCQ/LeetCode | /nowcoder/NC69.链表中倒数第k个结点.py | 702 | 3.53125 | 4 | # class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param pHead ListNode类
# @param k int整型
# @return ListNode类
#
class Solution:
def FindKthToTail(self , pHead , k ):
# write code here
if not pHead or k <= 0... |
3f2ce78da3d03a774167c29016a053585d837caf | VictoriqueCQ/LeetCode | /Python/56. 合并区间.py | 648 | 3.75 | 4 | from typing import List
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
intervals.sort(key=lambda x: x[0])
merged = []
for interval in intervals:
# 如果列表为空,或者当前区间与上一区间不重合,直接添加
if not merged or merged[-1][1] < interval[0]:
... |
0304d07f3deff58be2a2593f4a618886f85cf6b5 | VictoriqueCQ/LeetCode | /Python/微软Task2.py | 3,240 | 3.671875 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
class Verticle:
def __init__(self, key):
self.key = key
self.value = None
# def add_key(self,key):
# self.key = key
def add_value(self, value):
self.value = value
class Edge_set:
... |
2c188b56e17aa69e16d629c615a4f7dec745eac7 | VictoriqueCQ/LeetCode | /nowcoder/华为机试/求小球落地5次后所经历的路程和第5次反弹的高度.py | 233 | 3.5625 | 4 | while True:
try:
high = int(input())
sm = high
for i in range(4):
high /= 2
sm += 2 * high
high /= 2
print(sm)
print("%.5f" % high)
except:
break |
7bcf16a65297b97d65d3ed6c78002cdf637731e1 | VictoriqueCQ/LeetCode | /Python/138. 复制带随机指针的链表.py | 1,422 | 3.5625 | 4 | # Definition for a Node.
class Node:
def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None):
self.val = int(x)
self.next = next
self.random = random
class Solution:
def copyRandomList(self, head: 'Node') -> 'Node':
lookup = {}
def dfs(head):
if... |
e2d1da1842182648c91cb8c60cf667b4420823a6 | Fernando0107/Doscker | /Demo_Interpretados.py | 492 | 3.921875 | 4 | a = 0
t = 0
b = ["Este", "es", "un", "ejemplo", "de", "lenguaje", "interpretado"]
print("Que opción quiere utilizar?")
print("1.Loop")
print("2.Recursion")
print("3.Simple Print")
choice = int(input("Ingrese el número de la opción: "))
def Loop():
for i in range(len(b)):
print(b[i])
def Recursion(x):
if... |
5ec32171b14076cc9de19dbfc7c6fd0dd9edb799 | isabiiil/CTCI-python | /01-06-stringCompression.py | 707 | 4.375 | 4 | # String Compression:
# Implement a method to perform basic string compression using the counts of repreated characters. For example, the string aabccccaaa would become a2b1c5a3. If the "compressed" string would not become smaller the original string, your method should return the original string. You can assume the st... |
39bf4f2f7134f09fa4c4528329f8239e02b044e2 | henrymlongroad/COMP4Coursework | /Implementation/prescription_menu.py | 6,926 | 3.578125 | 4 | import sys
import sqlite3
from prescription_management import*
from customer_menu import*
from product_management import*
#menu for managing customer
class prescription_menu():
def __init__(self):
self.running = None
self.active_detail = prescription_manage()
self.active_repl... |
3e538ebaf66ab4c90beff5d881659ee7075df9ac | raunakbhojwani/Atari-Pong | /pong.py | 8,302 | 4.1875 | 4 | # Author: Raunak Bhojwani
# Monday 6 October 2014
# Lab 1 - Pong
# This program is designed to open a new window, in which a game of Atari Pong will begin. The game should accommodate two
# players. They should use the keys A&Z or K&M to control the paddles at either end of the window. The ball should accelerate
# as ... |
16a042ba78b99abc3b0501f765ce8aa7522d74f9 | idin/slytherin | /slytherin/collections/get_intersection.py | 323 | 3.828125 | 4 | def get_intersection(l1, l2):
""" Finds the intersection of 2 lists including common duplicates"""
intersection_set = set(l1).intersection(set(l2))
intersection_list = []
for i in intersection_set:
num = min(l1.count(i), l2.count(i))
for j in range(num):
intersection_list.append(i)
return intersection_list... |
2f6c22cbf06370ca1e62da63d9171bdd5b8ff618 | idin/slytherin | /slytherin/collections/dictionary.py | 1,167 | 3.90625 | 4 |
# The Dictionary class is the same as dict with additional methods
DICT_DIR = dir(dict)
class Dictionary(dict):
def copy(self):
return Dictionary(super().copy())
# the map method allows you to run a function on all values of the dictionary
def map(self, func, inplace = False):
if inplace:
copy = self
e... |
ed8c2b442b8f2f6c007edf474fa6a223a07572c7 | idin/slytherin | /slytherin/collections/flatten.py | 216 | 3.6875 | 4 | def flatten(l):
"""
flattens a list
:param list l:
:rtype: list
"""
flat_list = []
for item in l:
if isinstance(item, list):
flat_list += flatten(item)
else:
flat_list.append(item)
return flat_list
|
c234dc8933ffaefcae4713527f7e0b2c02123da6 | Vaskovics/Study_phyton | /function_exercices.py | 546 | 3.890625 | 4 | def fizz_buzz(x:int) -> int:
"""
Fuction is playing fizz buzz game
if `x` divisible 3 or 5 is printin "fizz" or "buzz"
if `x` divisible for 3 and 5 is printin "fizz buzz"
:param x: int
:return: str `x` if number is divisible for 3 and 5
"""
if x % 3 == 0 and x % 5 == 0:
return '... |
5277724e97d70d17446ab4c158e2fc698325294e | achoi2/python-exercises | /strings/matrix.py | 316 | 3.546875 | 4 | m1 = [[1,3] [2,4]]
m2 = [[5,2], [0,1]]
def create_empty_matrix(width, height):
result = []
for i in range(0, height):
result.append([])
for j in range(0, width):
result[i].append(0)
return result
height = len(matrix1)
width = len(matrix1[0])
matrix = create_empty_matrix() |
96e3f74f188cc681811affceecd5a2a1003c571d | achoi2/python-exercises | /python103/tip_calc2.py | 433 | 3.921875 | 4 | total = float(raw_input('Total bill amount:'))
tip = float(raw_input('Total tip amount:'))
total_amount = total + tip
print 'Your total amount is %f' % total_amount
level = tip / total
if level >= .20:
print 'good'
elif level >= .15:
print 'fair'
else:
print 'bad'
print level
split = float(raw_input('... |
a68d25871b22de43a18f656d39acea98091e16f4 | ishantk/JPMorganAdvancePythonJuly2021 | /S1RegularExpressions.py | 1,914 | 3.78125 | 4 | # Regular Expressions
# Flexible Pattern Matching
# PEP Standard -> https://pep8.org/
import re
regex = re.compile("\s+")
quote = "search the candle rather than cursing the darkness"
print(regex.split(quote))
data = [" ", "john ", " jennie"]
for value in data:
if regex.match(value):
print(value,... |
515ecff6244dd6905bb4168bce2c73940e734302 | ishantk/JPMorganAdvancePythonJuly2021 | /S3Slots.py | 421 | 3.90625 | 4 | """
__slots__
"""
class User:
__slots__ = ['name', 'email']
def __init__(self, name, email):
self.name = name
self.email = email
def show(self):
print("{} | {}".format(self.name, self.email))
def main():
user1 = User("john", "john@example.com")
print(user1.__slots__)... |
68468f5f877a561ed55723e1b9ed2cdba1a61a98 | ishantk/JPMorganAdvancePythonJuly2021 | /S3OOPS1.py | 1,457 | 4.25 | 4 | """
Standardize the Object
"""
class Dish:
# Constructor -> its a function and gets executed automatically when we create object
# Any function in class will take the first input as self
# self is a reference variable which holds the reference to the object in action
"""def __init__(self):
... |
61781a74645f48352c5343cef5e9dd4c337bbd8d | ishantk/JPMorganAdvancePythonJuly2021 | /S2Functions10.py | 1,496 | 3.6875 | 4 | restaurant1 = {
"title": "McDonalds",
"pricePerPerson": 150,
"timeToDeliver": 20,
"ratings": 4.5,
"cuisines": "burger,fries,icecream"
}
restaurant2 = {
"title": "Pizza Hut",
"pricePerPerson": 350,
"timeToDeliver": 25,
"ratings": 4.7,
"cuisines": "pizza,fries,sandwich"
}
restaur... |
392f7a299d0d71ad585798843c05c93665b86379 | ishantk/JPMorganAdvancePythonJuly2021 | /S1Strings.py | 2,506 | 3.6875 | 4 | # Strings in Python are Sequences
# Strings are IMMUTABLE, we cannot change them
names = "john, jennie, jim, jack, joe. are ALL my friends."
print("names is:", names)
print("names HashCode", hex(id(names)))
# Formatting of Strings with built in String Functions
new_names = names.upper() # lower()
print("names now is:"... |
98e5c5d39e9c34a7bf073422d0c306a655763dcc | ishantk/JPMorganAdvancePythonJuly2021 | /S1Set.py | 1,952 | 3.765625 | 4 | johns_followers = {"jennie", "jack", "mark", "harry", "fionna", "jack"}
fionnas_followers = {"mark", "jennie", "ed", "george", "lee", "kia", "lee"}
print(johns_followers)
print(fionnas_followers)
# Nested Set
# my_data = {"John", (98, 78, 88), ("john@example.com", "john@abc.edu")}
numbers = [98, 78, 88, 97, 88, 78]
s... |
2fec044bf7155191640bf48e8d464474948081cc | ishantk/JPMorganAdvancePythonJuly2021 | /S4Numpy.py | 1,466 | 3.75 | 4 | """
Data Analysis
We work on data to give insights to help take decisions in business
Steps:
> Transform the raw data into some desired format
> pre processing of data
> Prepration of Models
> Analyse trends and make decisions
"""
# Numpy -> Numerical Python -> We can do sci... |
8690caa4ce84d3c19cf23bf05354ed5e6694b7d5 | ishantk/JPMorganAdvancePythonJuly2021 | /S4Testing2.py | 147 | 4.0625 | 4 |
def multiply_numbers(num1, num2):
return num1 * num2
def factorial(num):
if num <= 1:
return 1
return num * factorial(num-1) |
3e48968bf12c4f41fb31bc72b32bce666501a78f | ishantk/JPMorganAdvancePythonJuly2021 | /S1ZomatoUseCase.py | 3,046 | 3.546875 | 4 | restaurant1 = {
"title": "McDonalds",
"pricePerPerson": 150,
"timeToDeliver": 20,
"ratings": 4.5,
"cuisines": "burger,fries,icecream"
}
restaurant2 = {
"title": "Pizza Hut",
"pricePerPerson": 350,
"timeToDeliver": 25,
"ratings": 4.7,
"cuisines": "pizza,fries,sandwich"
}
restaur... |
57aadd2a18f6180dd5a641617bab5e74868aac9c | ishantk/JPMorganAdvancePythonJuly2021 | /S2Namespaces.py | 877 | 4.28125 | 4 | """
Namespaces
They are key value pairs
1. Built In
to view them -> dir(__builtins__)
2. Global
Belongs to the main program i.e. program in execution
3. Enclosing
4. Local
"""
# Global
x = 100
#Outer Function
def fun():
# enclosing
age = 10
... |
c88fdd8c5b238796d67c3e22ebbac1d06c529415 | andrea-w/470project | /src/common/predict_test_scores.py | 4,116 | 3.515625 | 4 | import pandas as pd
import config
import sys
"""
Creates and returns a "predicted_scores_df" pandas dataframe, consisting of
the predicted average test score for 1 of 4 possible tests and the absolute error
of the predicted score vs the actual score for a given (state,year).
A candidate's weights are dot-producted wit... |
853e26b949c2a1a06b54e611c6aee02a74949d1a | comrade747/git-repo | /Python First Steps/Python Basics/From GeekBrains/HW2.py | 2,530 | 3.984375 | 4 | #Задание №1
#Разность множеств
a = [2, 5, 8, 2, 12, 12, 4]
b = [2, 7, 12, 3]
for number in a:
if number in b:
a.remove(number)
print(a)
print(my_list_1-my_list_2)
#Задание №2
#Дата, из числа в текст
data = input('Введите день: '), input('Введите месяц: '), input('Введите год: ')
day = {"01": "первое ", ... |
63fa99edeaa50594a5755d0ae7d8d0b6a36a4cc8 | comrade747/git-repo | /Python First Steps/OOP_Python/Lib/Dict-exampe.py | 4,407 | 3.53125 | 4 |
tel = {'jack': 4098, 'sape': 4139}
#Добавление новое значение по новому ключу
tel['guido'] = 4127
print(tel)
{'jack': 4098, 'sape': 4139, 'guido': 4127}
#получение значения по ключу (выдаст ошибку если такого ключа нет
print("Use key: ",tel['jack'])
#получение значения через метод get (НЕ выдаст ошибку если такого клю... |
113f65086b5080fdb1a57d17c6e4c11b9bce5faf | danielsada/100daysofalgorithms | /algorithms/intervals/merge-intervals.py | 1,829 | 4.09375 | 4 | """
Given a list of intervals, merge all the overlapping intervals to produce a list that has only mutually exclusive intervals.
Intervals: [[1,4], [2,5], [7,9]]
Output: [[1,5], [7,9]]
Explanation: Since the first two intervals [1,4] and [2,5] overlap, we merged them into
one [1,5].
"""
from typing import List
impor... |
87da8399580697d9acaca9365fb2cad446d7dabc | danielsada/100daysofalgorithms | /algorithms/bfs/bfs.py | 1,249 | 3.734375 | 4 | from algorithms.ugraph import UGraph
__author__ = "Daniel Sada"
__license__ = "MIT Licence"
__email__ = "hello@danielsada.tech"
class BreadthFirstPaths:
""""
This is a Breadth First Search.
This will also calculate the distances
between the nodes preemptively.
Finds a path between start s, and all other indexes.... |
255a358c05b2aa0232d917d2a379758226017598 | danielsada/100daysofalgorithms | /algorithms/sorts/selectionsort.py | 771 | 3.546875 | 4 |
__author__ = "Daniel Sada"
__license__ = "MIT Licence"
__email__ = "hello@danielsada.tech"
class SelectionSort:
""""
We are sorting elements with selection sort.
"""
def __init__(self, arr):
self.arr = arr
self.selectionSort()
self.sorted = arr
def selectionSort(self):
... |
1c8bbbf47104fe4c969f321f46359fc5da4e11e3 | danielsada/100daysofalgorithms | /algorithms/twopointers/subarrays-product-lt-target.py | 1,487 | 4.09375 | 4 | """
Subarrays with Product Less than a Target (medium)
Problem Statement
Given an array with positive numbers and a positive target number, find all of its contiguous subarrays whose product is less than the target number.
Example 1:
Input: [2, 5, 3, 10], target=30
Output: [2], [5], [2, 5], [3], [5, 3], [10]
Expla... |
6671e0c8d62de2e5530e56f692d69ab85743e3c2 | danielsada/100daysofalgorithms | /algorithms/problems/binary_search_fredo.py | 1,454 | 3.859375 | 4 | import math
"""
Fredo is assigned a task today. He is given an array A containing N integers.
His task is to update all elements of array to some minimum value x, that is, A[i] = x, 1 <= i <= N
such that product of all elements of this new array is strictly greater than the
product of all elements of the initial array.... |
6fa3076b90f0fc78f2ed7de867f7b3f81c9ab896 | danielsada/100daysofalgorithms | /algorithms/stack/stack_parenthesis_check.py | 1,199 | 3.609375 | 4 | __author__ = "Daniel Sada"
__license__ = "MIT Licence"
__email__ = "hello@danielsada.tech"
class StackParenthesisCheck:
""""
Implement a stack that checks if match of square brackets,
tags and parenthesis match their level.
Accepts <> () [] {}
"""
def __init__(self, string):
self.stri... |
68f7ad6131a0299a4547e3831ec59d06304fcd67 | danielsada/100daysofalgorithms | /algorithms/unionfind/quickunion.py | 667 | 3.578125 | 4 | #!/usr/bin/env
__author__ = "Daniel Sada"
__license__ = "MIT Licence"
__email__ = "hello@danielsada.tech"
"""
Implementation of QuickUnion
Complexity:
Initialize => O(n)
Union => O(n)
Connected => O(n)
"""
class QuickUnion(object):
def __init__(self, n):
self.id = [None]*n
for i in range(0... |
73f6ab7b7b60038817b48d8f5e9958ae52fb4c57 | sadieh0ugh/NEA_pathfinding | /maze_gen1.py | 22,262 | 3.671875 | 4 | import pygame
import random
import sqlite3
from ExplanationAndQuiz import *
ScreenWidth = 978
ScreenHeight = 650
# Colours
white = (255, 255, 255)
black = (0, 0, 0)
orange = (255, 200, 0)
green = (71, 255, 107)
purple = (165, 0, 236)
selected_purple = (218, 128, 255)
textcol = (204, 153, 255)
blue ... |
9d8b1832205749a04b291dfef730fb297320b9dc | deenjohn/Udacity-Assignments | /Project 1 - movie trailer/Class_Objects/movies.py | 397 | 3.796875 | 4 | """This module defines a class with name 'Movie'"""
class Movie ():
"""Instances of this class contain information on a given movie"""
def __init__(self, name, URL, Link, summary):
"""assigns the values of the class' arguments to their corresponding members on instantiation"""
self.title = name
self.poster_im... |
4c7f3b79a49684c1e5757356a16fb6ae13a4703d | oleg7521/Althoff_1 | /code/03/ex069.py | 164 | 4.0625 | 4 | x = 2
if x == 2:
print("Число: 2.")
if x % 2 == 0:
print("Число: четное.")
if x % 2 != 0:
print("Число: нечетное.")
|
374ad58cecd114c8912191871efb1114db690769 | oleg7521/Althoff_1 | /code/15/ex270.py | 1,434 | 3.640625 | 4 | from random import shuffle
class Card:
suits = ["пикей","червей","бубей","треф"]
values = [None,None,"2","3",
"4","5","6","7","8","9","10",
"валета","даму","короля","туз"]
def __init__(self, v, s):
"""suit и value - целые числа"""
self.value = v
... |
5a7b0233e9cc61578b5aafcf215797f17922882d | oleg7521/Althoff_1 | /code/13/ch3.py | 571 | 3.734375 | 4 | class Shape:
def what_am_i(self):
print("Я - фигура")
class Rectangle(Shape):
def __init__(self, width, height):
self.width = width
self.height = height
def calculate_perimeter(self):
return 2 * (self.width + self.height)
class Square(Shape):
def __init__(... |
b39ad5ace6f3e8a3f531d6b8f018468a48575a19 | oleg7521/Althoff_1 | /code/13/ch2.py | 485 | 3.8125 | 4 | class Rectangle():
def __init__(self, width, height):
self.width = width
self.height = height
def calculate_perimeter(self):
return 2 * (self.width + self.height)
class Square():
def __init__(self, side):
self.side = side
def calculate_perimeter(self):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.