content
stringlengths
7
1.05M
for _ in range(int(input())): j=m=0 for joao in range(3): x=list(map(int,input().split())) j+=(x[0]*x[1]) for maria in range(3): x=list(map(int,input().split())) m+=(x[0]*x[1]) print("MARIA") if m>j else print("JOAO")
#!/usr/bin/python # -*- coding: utf-8 -*- # Author: Yu Zhou # 107. Binary Tree Level Order Traversal II # 思路: # 视频参见102,直接把107的res,reverse即可 class Solution(object): def levelOrderBottom(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ self.res = [] ...
# Copyright 2017 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
''' Сжатие списка ''' a = list(map(int, input().split())) i = 0 id = -1 temp = -1 while(i < len(a)): if (a[i] == 0): id = i if (id != -1): if (temp == -1): temp = i + 1 while(temp < len(a)): if (a[temp] != 0): (a[id], a[temp]) = (a[temp], a[id]) ...
def add(x,y): return x + y def subtract(x,y): return x - y def multiply(x,y): return x * y def divide(x,y): return x / y def exponents(x,y): return x ** y while True: print('Basic Calculator\nSelect your Operator') print('1. Add') print('2. Subtract') print('3. Multiply') print('...
class Car(): chasisLength = 250 wheels = 4 power = False #self makes reference to the instance in class #self hace referencia a una instancia al objeto de la misma clase #self equivale a this en otros lenguajes def turnOn(self): self.power = True def changeLenght(self, n): self.cha...
def calcula_salario_liquido(salario_bruto): liquido = salario_bruto - (salario_bruto * 0.15) return liquido for c in range(3): salario = float(input("Informe seu salario bruto: ")) liquido = calcula_salario_liquido(salario) print(liquido)
# -*- coding: utf-8 -*- """ Spyder Editor This is the Modelscape lesson script for January 31, 2022. """ # You can also add comments like this. # The shortcut to run a line # Mac - fn + F9 # PC - FN + F9 or Ctrl + F5 print("Hello World") # Introduction to Python built-in data types text = "Data Carpentry" # strin...
x = 5 print(x) def f(): x = 2 print(x) def g(): global x x = 1 f() g() print(x)
# [] => this is an array. an array is a special type of container that can hold multipe items # arrays are indexed (their contents get assigned a number) # the index always starts at 0 choices = ["rock", "paper", "scissors"] player_lives = 5 ai_lives = 5 total_lives = 5 # True and False are boolean data type playe...
#48 Faça um programa que calcule a soma entre todos os números que são múltiplos de três e que se encontram no intervalo de 1 até 500. soma = 0 contador = 0 for c in range(0,501, 3): if c % 2 != 0 and c < 500: contador += 1 soma += c print(f'A soma dos {contador} números é {soma}')
class DST_Company: def __init__(self): self.company_code = { "건영택배": "18 ", "경동택배": "23", "홈픽택배": "54", "굿투럭": "40", "농협택배": "53", "대신택배": "22", "로젠택배": "06", "롯데택배": "08", "세방": "52", "애니트랙": "43", "우체국택배": "01", "일양로지스": "11", "천일택배": "17"...
# #1 # C=float(input('请输入一个摄氏温度:')) # F=(9/5)*C+32 # print('摄氏温度转华氏温度为:%.2f'%(F)) # #2 # r=float(input('请输入半径的数值:')) # l=float(input('请输入高的数值:')) # area=r*r*3.14 # volume=area*l # print('圆柱的底面积为:%.2f'%area) # print('圆柱的体积为:%.2f'%volume) # #3 # feet=float(input('英尺转换成米数,请输入英尺:')) # meters=feet/0.3...
verbose = True NoGood = '⊥' PHI = set([frozenset()]) leftSpace = 11 #frozensets are environments rules = list() # list of tuples of assumptions as set() and propositions as char # just use horn clauses to define rules! rules_ex1 = list() rules_ex1.append( ({'A'}, 'a') ) rules_ex1.append( ({'B','b'}, 'e') ) rules_ex1....
def hint_username(username: str) -> bool: if len(username) < 3: return False elif len(username) > 15: return False else: return True def is_even(number: int): if number % 2 == 0: return True return False
# 338-counting-bits.py class Solution(object): def countBits(self, num): ret = [0]*(num+1) for i in range(0, num+1): ret[i] = ret[i & (i-1)] + 1 return ret
class Pessoa: eyes = 2 hands = 2 def __init__(self, *filhos, nome=None, idade=35): self.nome = nome self.idade = idade self.filhos = list(filhos) def cumprimentar(self): return f'Olá {id(self)}' if __name__ == '__main__': bruno = Pessoa(nome='Bruno Portal', idade=22)...
# # PySNMP MIB module BroadworksMaintenance (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BroadworksMaintenance # Produced by pysmi-0.3.4 at Mon Apr 29 17:25:36 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
render = ez.Node() aspect2D = ez.Node() camera = ez.Camera(parent=render) camera.y = -10 #Create a mouse picker for the camera: mouse_picker = ez.collision.MousePicker(camera, mask=ez.mask[1]) #Create a mouse picker for aspect2D: mouse_picker2D = ez.collision.MousePickre2D(mask=ez.mask[1]) #Load a 2D plane and par...
s2= "I am learning Python everyday" s1="Python" def check(s2, s1): if (s2.count(s1) > 0): print("YES") else: print("NO") check(s2, s1) #b print(len(s1)) #c print(s2.replace("Python","C++")) #d print(s2.upper()) #e s2 = s2[:-1] print(s2)
# -*- coding: utf-8 -*- # SPDX-License-Identifier: MIT __all__ = [ 'commands_ip_route', 'commands_iptables_forwarding', 'is_ipv6', ] CMD_IP = '/sbin/ip' CMD_IPTABLESv4 = '/sbin/iptables' CMD_IPTABLESv6 = '/sbin/ip6tables' def is_ipv6(ip_addr): return (':' in ip_addr) def commands_ip_route(device_na...
LMS_LEVELS = { "programme_preliminaries": 1, "programming_paradigms": 1, "html_essentials": 1, "css_essentials": 1, "user_centric_frontend_development": 1, "comparative_programming_languages_essentials": 2, "javascript_essentials": 2, "interactive_frontend_development": 2, "python_es...
def main(): n, k, l, c, d, p, nl, np = list(map(int, input().split())) total_drink = k*l total_limes = c*d total_salt = p print(int(min(int(total_drink/nl), total_limes, int(total_salt/np))/n)) if __name__=='__main__': main()
input = """ ok(X) :- p(f(X)), q(f(X)). q(X) :- p(X). p(f(a)). p(f(b,a)). p(g(c)). """ output = """ ok(X) :- p(f(X)), q(f(X)). q(X) :- p(X). p(f(a)). p(f(b,a)). p(g(c)). """
""" kustomize actions """ def kustomize_build_action(ctx, srcs, deps, dir, out): """Run a build of the kustomize Args: ctx: arguments description, can be multiline with additional indentation. srcs: source files out: output directory deps: dependencies dir: dire...
# contains the processing code for the ticketer. class Processor(object): def __init__(self): pass def say(self, message): return message + "\n"
""" Event action's base class. """ class BaseEventAction(object): """ Event action's base class. """ key = "" name = "" def func(self, event, character): """ Event action's function. """ pass
EMAIL_SERVER = None PORT = None SENDER_EMAIL = None PASSWORD = None RECIEVER_EMAIL = None
# Python - 3.6.0 Test.describe('Basic tests') Test.assert_equals(volume(7, 3), 153) Test.assert_equals(volume(56, 30), 98520) Test.assert_equals(volume(0, 10), 0) Test.assert_equals(volume(10, 0), 0) Test.assert_equals(volume(0, 0), 0)
# OpenWeatherMap API Key weather_api_key = "Put Key Here" # Google API Key g_key = "Put key here"
class Node: """ Class representation of a Node for use in a Doubly Linked List """ def __init__(self, data): self.data = data self.prev = None self.next = None class DoublyLinkedList: """ Representation of a Singly Linked List Methods: - to_list() - O(N) ...
def max_number(input_num): """Create largest possible number out of the input. Parameters ---------- input_num : int Positive integer. Returns ------- max_num : int Maximum number that can be made out of digits present in input_num. """ num_to_str = str(input_num) ...
""" This script implements Min-Heaps. """ class MinHeap: def __init__(self): self.items = [] def leftIndex(self, parent): return 2*parent def rightIndex(self, parent): return 2*parent+1 def parentIndex(self, child): return (child-1)//2 def hasLeft(self, parent): return len(self.items) > s...
class Node(object): def __init__(self, value, data=None, left=None, right=None): """ Instantiates the first Node """ self.value = value self.data = data self.left = left self.right = right def __str__(self): """ Returns a string """ return...
""" Zola site builder """ load(":content_group.bzl", "ZolaContentGroupInfo") load("@bazel_skylib//lib:paths.bzl", "paths") def _site_path(ctx, path = ""): return paths.join(ctx.label.name + "_site_content", path) def _generated_html_path(ctx, path = ""): return "/".join([ctx.label.name, path]) def zola_site...
BASE_URL = 'http://api.fantasy.nfl.com/v1/players/stats?statType={}&season={}&format=json{}' STAT_URL = 'http://api.fantasy.nfl.com/v1/game/stats?format=json' USEFUL_DATA = ('name', 'position', 'stats', 'teamAbbr') ALL_WEEKS = [x for x in range(1,18)] ONE_HOUR = 3600 VALID_POSITIONS = ( 'QB', 'RB', 'WR...
class InterfaceMeta(type): def __new__(cls, name, bases, attrs): if "salad" not in attrs: attrs["salad"] = "salad" return super().__new__(cls, name, bases, attrs) class Interface(metaclass=InterfaceMeta): def __init__(self, potato): self.potato = potato def test_meta():...
# The variable number is just reference to the object 1001 number = 1001 print(id(number)) print(id(1001)) a1 = 2 print('a1: ', id(a1)) a2 = a1 + 1 print('a2: ', id(a2)) print('three: ', id(3)) b1 = 2 print('b1: ', id(b1)) print('Two: ', id(2)) # All bellow assignments to the 'something' variable is a valid code so...
# description: global # date: 2020/6/7 19:15 # author: objcat # version: 1.0 tool = None
def validate_post(post): try: anno_l1 = post['Layer1'].split(' ') anno_l2 = post['Layer2'].split(' ') text = post['text'] except KeyError: return False, 4 if len(anno_l1) != len(anno_l2): return False, 0 elif '[removed]' in text: return False, 3 elif...
def get_kwarg(self, name, **kwargs): return kwargs[name] if name in kwargs else '' def get_arg(self, name, *args): return args[0] if len(args) > 0 else ''
class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: dic = [0]*101 for n in nums: dic[n] += 1 return [sum(dic[0:n]) for n in nums]
""" A Next Level, uma moderna e conceituada universidade, necessita de um sistema de gestão acadêmico. Para o projeto piloto de implantação do sistema, você deve criar um programa que permita calcular a média semestral dos alunos. A média semestral é a média aritmética simples das médias bimestrais. As médias bimestr...
class Employee: name = "Tom Cruise" def function(self): print("This is a message inside the class.") employeeTom = Employee() employeeJerry = Employee() employeeJerry.name = "Jerry" print(employeeTom.name) print(employeeJerry.name) print(employeeJerry.function())
#declare X Data points testDataX = [1, 2, 3, 4, 5, 6, 7] lengthX = len(testDataX) n = lengthX ############## ############## ############## #declare Y Data points testDataY = [1.5, 3.8, 6.7, 9.0, 11.2, 13.6, 16.0] lengthY = len(testDataY) ############## ############## ############## #find the Variance, or square...
# time related parameters no_intervals = 144 no_periods = 48 no_intervals_periods = int(no_intervals / no_periods) # household related parameters # new_households = True new_households = False no_households = 100 no_tasks_min = 5 max_demand_multiplier = no_tasks_min care_f_max = 10 care_f_weight = 1 # pricing related...
""" 闭包-语法 步骤: 1. 有外有内 2. 内使用外 3. 外返回内 作用:外部函数栈帧执行过后不释放, 留着给内部函数反复使用. 字面意思:封闭 内存空间 """ def func01(): a = 100 def func02(): print(a) return func02 # 调用外部函数,接收内部函数 result = func01() # 反复调用内部函数 result() result() result()...
""" python + redux == pydux Redux: http://redux.js.org A somewhat literal translation of Redux. Closures in Python are over references, as opposed to names in JavaScript, so they are read-only. Single- element arrays are used to create read/write closures. """ class ActionTypes(object): INIT = '@@redux/INIT'...
""" PASSENGERS """ numPassengers = 18936 passenger_arriving = ( (6, 4, 3, 7, 5, 0, 4, 5, 1, 2, 1, 1, 0, 6, 4, 2, 3, 3, 2, 0, 1, 9, 1, 0, 0, 0), # 0 (9, 6, 4, 7, 4, 6, 0, 1, 1, 1, 1, 0, 0, 4, 7, 1, 1, 7, 2, 1, 3, 2, 2, 1, 0, 0), # 1 (7, 5, 6, 8, 4, 2, 2, 3, 3, 0, 1, 0, 0, 9, 5, 4, 1, 1, 4, 4, 0, 1, 2, 0, 0, 0), ...
# -*- coding: utf8 -*- "Files-related convertors"
""" Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Returns: True Example 2: Input: 14 Returns: False """ __author__ = 'Daniel' class Solution(object): def isPerfectSquare...
################################################ class BasePlantNonUDP(BasePlant): def init(self): pass def stop(self): pass def enable(self): pass def last_data_ts_arrival(self): # there's no delay when receiving feedback using the NonUDP classes, ...
#!/usr/bin/env python3 if __name__ == '__main__': message = """ The `awscreds` command has been deprecated. The command worked with the old shared (HSE) AWS account, but now all labs have been migrated to their own accounts. If you need help with AWS access, please email helpdesk@fredhutch.org. """ pri...
""" Take a list and write a program that prints out all the elements of the list that are less than 5. """ a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] for items in a: if (items < 5): print(items) continue
catlog = [ "New", "Macros", "Manager", "-", "Install", "Contribute", "update_plg", "-", "temporal_plg", "StackReg", "Games", "screencap_plg", ]
class A: def speak(self): return "hello" def speak_patch(self): return "world" A.speak = speak_patch some_class = A() print('some_class.speak():', some_class.speak()) some_class2 = A() print('some_class2.speak():', some_class2.speak())
def requires_userinfo(func): """ If userinfo is required and not available then skip the test """ def userinfo_available(test): return func(test) if test.tester.info else 3 return userinfo_available def return_version_on_fail(func): """ If the result from alert is false we return a...
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") _end = '_end_' def make_trie(words): root = dict() for word in words: current_dict = root for letter in word: current_dict = current_dict.setdefault(letter, {}) current_dict[_end] = _e...
def copy_not_empty_attrs(src, dst): if src is not None and dst is not None: for attribute in src.__dict__: value = getattr(src, attribute) if value: setattr(dst, attribute, value) class NoneDict(dict): def __init__(self, args, **kwargs): self.update(args...
''' 丑数 III 给你四个整数:n 、a 、b 、c ,请你设计一个算法来找出第 n 个丑数。 丑数是可以被 a 或 b 或 c 整除的 正整数 。 ''' ''' 思路: lcm = min(a,b,c)*n #求最小公倍数 if lcm> a*b skip += lcm//(a*b) if lcm> a*c skip += lcm//(a*c) if lcm> b*c skip += lcm//(b*c) if lcm> a*b*c skip -= lcm//(a*b*c) x=(n-skip) 从lcm开始,找x个数 dp[i] = min(pa*a,pb*b,pc*c,pi*c) TO...
def make_arr(data): t = {} for ov in data: if t.get(ov['resource']) is None: t[ov['resource']] = {} t[ov['resource']][ov['other_input']] = ov['value'] return t
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ============================================================================ # fap4malware - File analyzation program to detect malware # Malware definition list # Copyright (C) 2018 by Ralf Kilian # Distributed under the MIT License (https://opensource.org/licenses/MIT...
def createMatrix(rowCount, colCount): mat = [] for i in range(rowCount): rowList = [] for j in range(colCount): rowList.append(0) mat.append(rowList) return mat with open('input.txt') as file: input = (file.readline()).split(" ") n = int(input[0]) ...
def menu(): voltarMenu = 's' while voltarMenu == 's': opcao = input (''' ============================ PROJETO AGENDA MENU: [1] CADASTRAR CONTATO [2] LISTAR CONTATO [3] DELETRAR CONTATO [4] BUSCAR CONTATO [5] SAIR ============================ ESCOLHA UMA OPÇÃO: ''') if ...
# -*- coding: utf-8 -*- # Copyright 2019 Cohesity Inc. class DeployCertParameters(object): """Implementation of the 'DeployCertParameters' model. Specifies the parameters used to generate and deploy a certificate. Attributes: cert_file_name (string): Specifies the filename of the certificate. ...
num1 = 10 num2 = 20 num3 = 30 # zhansan num4 = 40 # manager num6 = 500 # manager num5 = 50 # zhansan 分支操作 num6 = 700 # manager
# Source: https://github.com/sventhijssen/pgmtocnf # Authors: Sven Thijssen and Gillis Hermans class Literal(): def __init__(self, name, positive=True): super(Literal, self).__init__() self.atom = name self.positive = positive def __str__(self): if self.positive: re...
def extractCookiesncreamtranslationsWordpressCom(item): ''' Parser for 'cookiesncreamtranslations.wordpress.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None titlemap = [ ('Phoenix Against the World Chapt...
# -*- coding:utf-8 -*- class Message(dict): """ The base message class """ pass
class PointsSet: def __init__(self, delaunay_diagram, initial_point, minimal_point_density, minimal_regression): self._delaunay = delaunay_diagram self._points = {initial_point} self._triangles = set() self._points_to_add = set(p for p in delaunay_diagram.neighbours[initial_point] ...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def flatten(self, root): """ :type root: TreeNode :rtype: void Do not return anything, modify root in-place inste...
# x = 101 # # # print no of digits in a number # print(len(str(x))) # # # def end_zeros(num: int) -> int: # # your code here # # return str(num).count('0') # return len(str(num)) - len(str(num).rstrip('0')) # # # if __name__ == '__main__': # print("Example:") # print(end_zeros(0)) # # # These "a...
myStr = "Hello World" #print(dir(myStr)) print(myStr.upper()) print(myStr.swapcase()) print(myStr.replace("Hello", "Goodbye")) print(myStr.count("l")) print(myStr.startswith("he")) print(myStr.split(" ")) print(len(myStr)) print(myStr.find("e")) print(myStr.index("e")) print(myStr.isnumeric()) print(myStr.isalpha())...
# 外观模式 class Stock: name = '股票' def buy(self): print(f'买{self.name}') def sell(self): print(f'卖{self.name}') class ETF: name = '基金' def buy(self): print(f'买{self.name}') def sell(self): print(f'卖{self.name}') class Future: name = '期货' def buy(sel...
equipamentos=[] valores=[] seriais=[] departamentos=[] resposta="S" while resposta == "S": equipamentos.append(input("Nome do equipamento: ")) valores.append(float(input("Valor: "))) seriais.append(int(input("Número do serial: "))) departamentos.append(input("Departamento: ")) resposta =...
expected_output = { "boot_loader_version": "Not applicable", "build": "4567", "chassis_serial_number": "None", "commit_pending": "false", "configuration_template": "CLItemplate_srp_vedge", "controller_compatibility": "20.3", "cpu_allocation": {"control": 1, "data": 3, "total": 4}, "cpu_r...
# # PySNMP MIB module NET-SNMP-EXAMPLES-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NET-SNMP-EXAMPLES-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:18:07 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
class Led: def __init__(self, devpath, brightness): self.devpath = devpath self.brightness = brightness def __del__(self): self.set_brightness(0) def set_brightness(self, brightness): f = open(self.devpath, "w") f.write("%d\n" % brightness) f.close(); self.brightness = brightness
notas = [] cont = 0 while cont > 4: notas = float(input('Digite uma nota do aluno: ')) cont += 1 total = 0 for nota in notas: total += nota media = total / len(notas) if media >= 7.0: print("aprovado com média:", media) else: print("reprovado com média:", media)
#!/usr/bin/env python3 def transform(s1, s2): first_list = map(int, s1.split()) second_list = map(int, s2.split()) zipped = list(zip(first_list, second_list)) final_list = [a * b for a, b in zipped] return final_list def main(): s1 = "1 51 12 4" s2 = "4 6 99 2" print(transfor...
def gradingStudents(calificaciones): for i in range(len(calificaciones)): if calificaciones[i] > 40: redondeo = int(calificaciones[i] / 5 + 1) if redondeo * 5 - calificaciones[i] < 3: calificaciones[i] = redondeo * 5 print(calificaciones) continuar = False while ...
''' Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of all the 8 surrounding cells and itself. If a cell has less than 8 surrounding cells, then use as many as you can. Example 1: Input...
''' Author: your name Date: 2021-01-27 08:45:44 LastEditTime: 2021-02-08 12:02:54 LastEditors: Please set LastEditors Description: In User Settings Edit FilePath: /mmdetection/configs/_base_/default_runtime.py ''' checkpoint_config = dict(interval=1) # yapf:disable log_config = dict( interval=50, hooks=[ ...
__doc__ = """ This module all the config parameters for bcs serevr """ # Storage config DB_FILE = 'bank.db' # Server config TCP_IP = '127.0.0.1' TCP_PORT = 5010 MAX_CONNECTIONS = 2 MESSAGE_LENGTH = 1024 # Superuser account ADMIN_NAME = 'admin' ADMIN_EMAIL = 'admin@bcs.com' ADMIN_PASSWORD = 'admin' # Log config...
print("hello Dodger fans") print("I know you haven't won a world series in a while") print("but the rest of the NL West fans don't care") print("Go Brewers!") print("Even though you beat the Rockies")
## Example #1 print("\n\n") print("*" * 80) print("Example #1") print("*" * 80) up = True down = True if up: print("Going Up!") elif down: print("Going Down!") elif up and down: print("Going No Where!!!") else: print("Error!") ## Example #2 # print("\n\n") # print("*" * 80) # print("Example #2...
#!/usr/bin/env python """Struct to define a planning problem which will be solved by a planner""" class PlanningProblem: def __init__(self, params): self.initialized = False self.params = params def initialize(self, env=None, lattice=None, cost=None, heuristic=None, start_n=None, goal_n=None, visualize=...
class Solution: def fib(self, N: int) -> int: if N==0: return 0 if N==1: return 1 dp=[0]*N dp[0]=1 dp[1]=1 for i in range(2,N): dp[i]=dp[i-1]+dp[i-2] return dp[N-1]
w=int(input()) if w>2: if w%2==0: print("YES") else: print("NO") else: print("NO")
# # PySNMP MIB module ODSLANBlazer7000-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ODSLANBlazer7000-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:32:20 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
def wiggle_sort(nums: list) -> list: """ Python implementation of wiggle. Example: >>> wiggle_sort([0, 5, 3, 2, 2]) [0, 5, 2, 3, 2] >>> wiggle_sort([]) [] >>> wiggle_sort([-2, -5, -45]) [-45, -2, -5] >>> wiggle_sort([-2.1, -5.68, -45.11]) [-45.11, -2.1, -5.68] ...
""" RiscEmu (c) 2021 Anton Lydike SPDX-License-Identifier: MIT """ # Colors """ FMT_RED = '\033[31m' FMT_ORANGE = '\033[33m' FMT_GRAY = '\033[37m' FMT_CYAN = '\033[36m' FMT_GREEN = '\033[32m' FMT_MAGENTA = '\033[35m' FMT_BLUE = '\033[34m' FMT_YELLOW = '\033[93m' FMT_BOLD = '\033[1m' FMT_NONE = '\033[0m' FMT_UNDERLI...
""" CHALLENGE - Extensions """ # ** Challenge** Add each element of the tuple1 to list1 *individually* and print the result. list1 = [6, 12, 9, 4, 10, 1] tuples = [(15,3), (6,2), (1, 8)]
def welcome(): starsintro = "*" * 38 welcomemessage = (""" ** Welcome to the Snakes Cafe! ** ** Please see our menu below. ** ** ** ** To quit at any time, type "quit" ** """) print(" " + starsintro + welcomemessage + starsintro) welcome() def menu(): Ap...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class Student(object): # 1. 类属性 name = 'student' class Student(object): count = 0 def __init__(self, name): self.name = name Student.count = Student.count + 1 if __name__ == '__main__': student = Student() name = student.name ...
class SList: class Node: def __init__(self, item, link): self.item = item self.next = link def __init__(self): self.head = None self.size = 0 def size(self): return self.size def is_empty(self): return self.size == 0 def insert_fron...
""" QuoLab Add on for Splunk """ # Assumption: All sys.path fixes have already been applied by the importer __version__ = "0.12.2"
#W.A.P TO CHECK WHETHER THE NO. IS ARMSTRONG NO. x=int(input('Enter a no.')) sum=0 t=x while(t!=0): sum=sum+(int(t%10))**3 t=t/10 if(sum==x): print('It is an armstrong no.') else: print('It is not an armstrong no.')
# coding: utf8 FILENAME_TYPE = {'full': '_T1w_space-MNI152NLin2009cSym_res-1x1x1_T1w', 'cropped': '_T1w_space-MNI152NLin2009cSym_desc-Crop_res-1x1x1_T1w', 'skull_stripped': '_space-Ixi549Space_desc-skullstripped_T1w'}
""" From Kapil Sharma's lecture 9 Jun 2020 Given the index of a node, and the head of linked list, delete the node at that index. Singly-linked list Return True if successful; False if not. """ class Node: def __init__(self, value): self.value = value self.next = None def delete_node(index, he...