text
stringlengths
37
1.41M
from collections import namedtuple filename = "input.txt" #filename = "example_input.txt" with open(filename, "r") as f: data = f.readlines() data = [line.strip() for line in data] Instruction = namedtuple('Instruction', ['op', 'has_run']) instructions = {} for i, line in enumerate(data): instructions[i] =...
with open('input.txt', 'r') as f: data = f.readlines() data = [line.strip() for line in data] def convert_char(char): """ Convert input to binary so that we can reuse the same function for both rows and columns """ if char == 'F' or char == 'L': return 0 return 1 def bsp(line, curren...
#Compound Interest = P(1 + R/100)**t #Where, #P is principle amount #R is the rate and #T is the time span p = float(input("principle amount: \n--->> ")) r = float(input("rate: \n--->>")) t = float(input("time: \n--->>")) result = p * (1 + (r / 100)) ** t print("compound is: ", int(result))
num1 = int(input("Enter a Number: ")) num2 = int(input("Enter another Number: ")) sum = num1 + num2 print(f"The sum of {num1} and {num2} is {sum}")
import sys ''' Converts a string of ints into a list of ints and finds the product ''' def getProd(numStr): return reduce(lambda x, y: x * y, [int(i) for i in numStr]) ''' Main execution ''' try: inNumber = sys.argv[1] numAdj = int(sys.argv[2]) except: sys.exit("Script execution must follow the follow...
import json from collections import Counter wordlist = open("minidic-WORDLIST.txt") wordlist = [x[:-2] for x in wordlist] # first thousand print wordlist rawlog = open("lesswrong_logs.json") print "Loading JSON..." logdict = json.load(rawlog) logs = [] users = set() for day in logdict.keys(): for line in logdict[...
print "Bucket List Time!" print "Let's create an awesome Bucket List of the things you've always dreamed of doing!" responses = {} question1="What's the most dangerous thing you want to do? " question2="What's the scariest thing you want to do? " question3="What languages do you want to learn? " question4="What countr...
def convert(s): try: x = int(s) print("Conversion succeeded! x = ", x) except ValueError: print("Conversion failed!") x = -1 except TypeError: print("Conversion failed!") x = -1 return x print(convert("6ddd")) def convert(s): try: ...
# Support Vector Machine from Scratch using SMO """Support Vector Machines are a type of supervised machine learning algorithm that provides analysis of data for classification and regression analysis. While they can be used for regression, SVM is mostly used for classification. We carry out plotting in the n-dimens...
#====================================================================== # Logistic Regression from SKLearn over MNIST Dataset (Multi-Class Classification) """ Logistic regression is a statistical model that in its basic form uses a logistic function to model a multiple dependent variable, although many more complex ext...
import random arr_card_types = ['red', 'blue', 'green', 'yellow'] arr_card_numbers = [x for x in range(1, 11)] class Card: def __init__(self, card_type=None, card_number=None): self.card_type = card_type self.card_number = card_number class Deck: def __init__(self, cards): self.deck...
import pygame ,sys,random,math #general setup # snake class Snake(): def __init__(self,pixel_size): self.snake_color= pygame.Color(0,206,0) self.snake_head_color= pygame.Color(0,100,0) self.size=1 self.tail=[] self.history= [] self.state = [0,0,0,1] self.f...
#!/usr/bin/env python """ """ from unittest import TestCase, main from land import Land class TestLand(TestCase): """ """ def setUp(self): pass def tearDown(self): pass def test_init(self): """Test Land's init. Expect certain attributes can be used as kwargs while ...
from random import randint def is_valid(isbn): result = False isbn = validation(isbn) if isbn: if (isbn[0] * 10 + isbn[1] * 9 + isbn[2] * 8 + isbn[3] * 7 + isbn[4] * 6 + isbn[5] * 5 + \ isbn[6] * 4 + isbn[7] * 3 + isbn[8] * 2 + isbn[9] * 1) % 11 == 0: resu...
def latest(scores): if not scores: return "There's no score in the ranking..." return scores[-1] ## I'm assuming that when you put a new score in the list, you will use append method def personal_best(scores): if not scores: return "There's no score in the ranking..." return ...
import sqlite3 conn = sqlite3.connect('imdb.db') c = conn.cursor() c.execute("select * from name_basics limit 10") for row in c: print(row) conn.close() import sqlite3 class database: #https://docs.python.org/3/library/sqlite3.html def __init__(self, base): self.base = "" def con...
'''Use Queue for example Create two process in parent process, one write data to Queue, another one read data from Queue. But this time, not terminate the read process. What if I just leave the read process keep running? ''' from multiprocessing import Process, Queue import sys import os, time, random # write to queue...
'''Difference between run() and start(): If you invoke run() directly, it's executed on the calling thread, just like any other method call. When you call Thread.start(), it starts a new thread, and calls the run() method of the runnable instance internally to execute it within that thread. ''' import time, threading, ...
import os import urllib.request, urllib.parse, urllib.error print('Please enter a URL like http://data.pr4e.org/cover3.jpg') urlstr = input().strip() if len(urlstr) < 5: print('Using default url') urlstr = 'http://data.pr4e.org/cover3.jpg' img = urllib.request.urlopen(urlstr) # Get the last "word" of the url...
# Search for lines that start with 'F', followed by # any 2 characters, followed by 'm:' import re hand = open('mbox-short.txt') for line in hand: line = line.rstrip() # call re.search(regular_expression, from_which_sentence) # ^ stands for re starts, . stands for any character except \n, \r if re.searc...
stuff = list() stuff.append('python') stuff.append('chuck') # this sort do some magic things for the stuff list stuff.sort() #print(stuff) # all the three sentence does exactly the same thing print (stuff[0]) # this will get the sorted `chunck` print (stuff.__getitem__(0)) print (list.__getitem__(stuff,0))
'''read data from json file ''' import json class student(): def __init__(self, name='default', score=0): self.name = name self.score = score def speak(self): print('My name is %s and my score is %d' % (self.name, self.score)) filename = 'students.json' with open(filename, 'r') as f: ...
# with open as f # f.readline() with open('foo', 'r') as f: while True: r = f.readline() if len(r) < 1: break print(r, end='')
'''When call con.notify() the thread will just continue the last wait() line. ''' from threading import Condition, Thread con = Condition() count = 0 class wait_notify(Thread): def run(self): global count while True: if con.acquire(): print(self.name, 'acquired the lock...
def compute_exponent_base_two(exp): return 2 ** exp def int_to_string(integer): return str(integer) def main(exp): exponent = compute_exponent_base_two(exp) string_int = int_to_string(exponent) result = 0 for i in string_int: result += int(i) return result if __name__ == "__main__...
# make a while loop, printing out numbers user inputs for how many times. num = (int(input("Enter a number to start from: "))) MAX = (int(input("Enter ending number: "))) while (num <= MAX): print (num) num += 1
#imports #================================================================================================== import time from time import sleep import sys #defines #================================================================================================== def slowtype(text): for char in text: # this is to...
'''Unit4 Lesson4: K-Nearest Neighbors''' import pandas as pd import matplotlib.pyplot as plt import numpy as np import random df = pd.read_csv('iris/iris.data.csv') df.columns = ['sepal_len', 'sepal_wid', 'petal_len', 'petal_wid', 'iris'] features = ['sepal_len', 'sepal_wid', 'petal_len', 'petal_wid'] # print(df.info...
#!/usr/bin/env python3 # coding: UTF-8 p = 'パトカー' t = 'タクシー' result = '' for (a, b) in zip(p, t): result += a + b print (result)
class MysteryString(str): def __new__(cls, word, guesses, delimiter='-'): result = [ (letter if (letter in guesses or word in guesses) else delimiter) for index, letter in enumerate(word)] match = ''.join(result) obj = str.__new__(cls, match) obj.w...
age = input("Enter your age: ") new_age = int(age) + 50 # int() converts to integer # str() converts to string print(new_age)
""" name: puzzle_generator.py language: python 3.7 description: generates a word search puzzle text from a given list of words author: awallien """ import random import sys EMPTY_FILL = " " class WordSearchPuzzle: """ The class that constructs the puzzle board and word list """ ...
"""grid class""" import pygame from utils.tiles import Tile class Grid(): """class representing the gird of tiles""" tiles = [] start_node = None finish_node = None def __init__(self, number_of_nodes, block_size, screen): self._initialize_empty_list(number_of_nodes, block_size, screen) ...
ff=int(input()) if ff>1: for i in range(2,ff): if(ff%i==0): print("no") break; else: print("yes") else: print("no")
yy=int(input()) if(yy%4==0 or yy%400==0 and yy%100!=0): print("yes") else: print("no")
''' You are going to write a program that tests the compatibility between two people. To work out the love score between two people: Take both people's names and check for the number of times the letters in the word TRUE occurs. Then check for the number of times the letters in the word LOVE occurs. Then combine th...
# Filter Even numbers using list comprehension if __name__ == '__main__': numbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] even_list = [num for num in numbers if num % 2 == 0] print(even_list) # OUTPUT :- [2, 8, 34]
class MoneyMachine: def __init__(self): self.total_money = 0 def make_payment(self, cost): print("Please enter Money.") quarters = float(input("How many Quarters:")) nickle = float(input("How many nickles:")) dimes = float(input("How many dimes:")) pennies = floa...
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
#issue was that type checking "int" was not there at the time of accepting input year = int(input("Which year do you want to check?")) if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: print("Leap year.") else: print("Not leap year.") else: print("Leap year.") else: print("Not le...
n1= int(input('Digite um número: ')) resultado= n1 % 2 if resultado == 0: print('É par! ') else: print('É ímpar!!')
# Matrix Algebra import numpy # m * n = rows by columns # 1. matrix dimensions A = numpy.matrix([[1,2,3],[2,7,4]]) # 2 row by 3 columns B = numpy.matrix([[1,-1],[0,1]]) # 2 rows by 2 columns C = numpy.matrix([[5,-1],[9,1],[6,0]]) # 3 rows by 2 columns D = numpy.matrix([[3,-2,-1],[1,2,3]]) # 2 rows by 3 columns u = ...
#string = "atgctaccatcattagctaccata" # validation def validate_nucleotide(string_new, state): for nucleotide in string_new: if nucleotide == "G" or nucleotide == "C" or nucleotide == "T" or nucleotide == "A": pass else: return ("bad") # nucleotidecounter def nucleotid...
""" CTEC 121 <your name> <Grant Parkinson> <assignment/lab description """ """ IPO template Input(s): list/description Process: description of what function does Output: return value and description """ def main(): ''' # definite loop example for i in range(0, 11, 2): print(i) print() # ...
#!/usr/bin/env python import string from collections import defaultdict from Queue import PriorityQueue from math import radians, cos, sin, asin, sqrt import sys # All the heuristic logics, and ways of handling the data inconsistency explained below. # Assuming the end_city given as input will have lat, lon values as ...
# FIXME (1): Prompt for four weights. Add all weights to a list. Output list. users_weight = [] for i in range(0,1): x = input('Enter weight 1: \n') users_weight.append(float(x)) x = input('Enter weight 2: \n') users_weight.append(float(x)) x = input('Enter weight 3: \n') users_weight.ap...
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: Arianna # # Created: 08/04/2014 # Copyright: (c) Arianna 2014 # Licence: <your licence> #------------------------------------------------------------------------------- def print...
# # Author: Arianna # # Created: 12/12/2013 #------------------------------------------------------------------------------- def bogusFunction(stng): diCt={} for n in range(len(stng)): s=stng[n:n+1] #get the individual character if s not in diCt.keys(): diCt[s]=1 ...
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: Arianna # # Created: 24/04/2014 # Copyright: (c) Arianna 2014 # Licence: <your licence> #------------------------------------------------------------------------------- POPSIZE=8...
""" Helper functions to construct image pyramids """ import cv2 import numpy as np # Function to downsample an intensity (grayscale) image def downsampleGray(img): """ The downsampling strategy eventually chosen is a naive block averaging method. That is, for each pixel in the target image, we choose a block comp...
def check(i,j,matrix): isp=0 if(j==0): isp=1 if(matrix[i][j+1]>0): return(True) elif(j==len(matrix[i])-1): isp=1 if(matrix[i][j-1]>0): return(True) if(isp==1): if(i==0): if(matrix[i+1][j]>0): return(True) else: return(False) elif(i==len(matrix)-1): if(matrix[i-1][j]>0): return...
def moveElementToEnd(array, toMove): # Write your code here. k=[] l=[] for i in range(0,len(array)): if(array[i]==toMove): k.append(array[i]) else: l.append(array[i]) for j in k: l.append(j) return(l)
Do not edit the class below except for # the insert, contains, and remove methods. # Feel free to add new properties and methods # to the class. class BST: def __init__(self, value): self.value = value self.left = None self.right = None def insert(self, value): # Write your cod...
import requests # Safari Animals # Below are safari animals, however, each letter has been replaced by its position in the alphabet, # but the spaces between the resulting numbers have been removed. # e.g. DOG=4.15.7=4157 animals = [ '18891415', '3181531549125', '79181665', '38552018', ...
import copy class Vertex(object): def __init__(self, node1, node2): self.node1 = node1 self.node2 = node2 def __lt__(self, other): return self.node1 < other.node1 and self.node2 < other.node2 def __repr__(self): return f'{self.node1},{self.node2}' class Node(object): ...
from itertools import permutations # See oct_29_2020.jpg class Sweet(object): colour = None def __init__(self, colour): self.colour = colour def __repr__(self): return f'{self.colour}' def __eq__(self, other): return self.colour == other.colour def is_colour(self, colo...
#Ikbel El Amri #CodeAcademy unit 8 Project #Command Line Calendar """In this project, we'll build a basic calendar that the user will be able to interact with from the command line. The user should be able to choose to: View the calendar Add an event to the calendar Update an existing event D...
import unittest class Node(object): def __init__(self, data, next=None): self.data, self.next = data, next def delete_middle(node): next = node.next node.data = next.data node.next = next.next class Test(unittest.TestCase): def test_delete_middle(self): head = Node(1, Node(2, ...
import unittest class NodeT(): def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right class NodeLL(): def __init__(self, data, next=None): self.data = data self.next = next def print(self): res = '' n...
def RealZeros(equation): numerator,denominator, answer = [],[],[] firstcoe,lastcoe = equation[0],int(equation[-1]) for i in range(1,lastcoe/2 + 1): if lastcoe % i == 0: numerator.append(i) numerator.append(lastcoe) if firstcoe.isdigit() is False: denominator = [1...
from random import * msg = "Mass bunk today" def encipher(): msg = input("\n\nGimme something to encrypt: ") key = keygen(msg) ct = "".join([ chr(ord('a') + (ord(msg[i].lower()) + key[i] - ord('a') )%26) if msg[i].isalpha() else msg[i] for i in range(len(msg))]) print( "\n=======Encrypting the data========") ...
def minimumDays(rows, columns, grid): # WRITE YOUR CODE HERE n = 0 while (haszero(rows, columns, grid)): n+=1 new_grid = list(grid) # copy grid to new_grid for i in range(rows): for j in range(columns): if grid[i][j] == 0: if hasonearo...
# # @lc app=leetcode id=168 lang=python # # [168] Excel Sheet Column Title # # https://leetcode.com/problems/excel-sheet-column-title/description/ # # algorithms # Easy (29.62%) # Likes: 886 # Dislikes: 184 # Total Accepted: 192.3K # Total Submissions: 643.3K # Testcase Example: '1' # # Given a positive integer,...
# # @lc app=leetcode id=28 lang=python # # [28] Implement strStr() # # https://leetcode.com/problems/implement-strstr/description/ # # algorithms # Easy (32.66%) # Likes: 1043 # Dislikes: 1495 # Total Accepted: 493.8K # Total Submissions: 1.5M # Testcase Example: '"hello"\n"ll"' # # Implement strStr(). # # Retu...
# # @lc app=leetcode id=229 lang=python # # [229] Majority Element II # # https://leetcode.com/problems/majority-element-ii/description/ # # algorithms # Medium (34.83%) # Likes: 1423 # Dislikes: 159 # Total Accepted: 135.3K # Total Submissions: 388.4K # Testcase Example: '[3,2,3]' # # Given an integer array of ...
# # @lc app=leetcode id=268 lang=python # # [268] Missing Number # # https://leetcode.com/problems/missing-number/description/ # # algorithms # Easy (50.92%) # Likes: 1581 # Dislikes: 1940 # Total Accepted: 423.9K # Total Submissions: 832.2K # Testcase Example: '[3,0,1]' # # Given an array containing n distinct ...
# # @lc app=leetcode id=29 lang=python # # [29] Divide Two Integers # # https://leetcode.com/problems/divide-two-integers/description/ # # algorithms # Medium (16.16%) # Likes: 783 # Dislikes: 3787 # Total Accepted: 217.4K # Total Submissions: 1.3M # Testcase Example: '10\n3' # # Given two integers dividend and ...
# # @lc app=leetcode id=60 lang=python # # [60] Permutation Sequence # # https://leetcode.com/problems/permutation-sequence/description/ # # algorithms # Medium (34.20%) # Likes: 989 # Dislikes: 266 # Total Accepted: 151.8K # Total Submissions: 443.5K # Testcase Example: '3\n3' # # The set [1,2,3,...,n] contains...
# # @lc app=leetcode id=56 lang=python # # [56] Merge Intervals # # https://leetcode.com/problems/merge-intervals/description/ # # algorithms # Medium (36.20%) # Likes: 2346 # Dislikes: 183 # Total Accepted: 380.2K # Total Submissions: 1.1M # Testcase Example: '[[1,3],[2,6],[8,10],[15,18]]' # # Given a collectio...
# # @lc app=leetcode id=199 lang=python3 # # [199] Binary Tree Right Side View # # @lc code=start # 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 right...
# # @lc app=leetcode id=96 lang=python # # [96] Unique Binary Search Trees # # https://leetcode.com/problems/unique-binary-search-trees/description/ # # algorithms # Medium (47.90%) # Likes: 2101 # Dislikes: 82 # Total Accepted: 225K # Total Submissions: 468.1K # Testcase Example: '3' # # Given n, how many struc...
# # @lc app=leetcode id=213 lang=python # # [213] House Robber II # # https://leetcode.com/problems/house-robber-ii/description/ # # algorithms # Medium (36.13%) # Likes: 1533 # Dislikes: 47 # Total Accepted: 162.3K # Total Submissions: 449.3K # Testcase Example: '[2,3,2]' # # You are a professional robber plann...
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: # @param l1: the first list # @param l2: the second list # @return: the sum list of l1 and l2 def addLists(self, l1, l2): # write your code here ...
import numpy as np __author__ = 'Otilia Stretcu' def normalize(data, axis, offset=None, scale=None, return_offset=False): """ Normalizes the data along the provided axis. If offset and scale are provided, we compute (data-offset) / scale, otherwise the offset is the mean, and the scale is the std (i....
import ktanlib def solution1(S, P, Q): mapping = {'A':1, 'C':2, 'G':3, 'T':4} result = [0] * len(P) for i in range(len(P)): # print P[i],Q[i],S[P[i]:Q[i]+1] result[i] = mapping[min(S[P[i]:Q[i] + 1])] return result def solution2(S, P, Q): result = [] DNA_len = len(S) mapping = {"A":1, "C":2, "G":3, "T":4...
# -*- coding: utf-8 -*- """ Created on Sat Jan 23 12:41:13 2021 @author: Windows """ F = [[1,1],[1,0]] T = [[1,2],[3,4]] def copy(A, B): #copies matrix B into matrix A. Matrixes must be 2 by 2. A[0][0] = B[0][0] A[0][1] = B[0][1] A[1][0] = B[1][0] A[1][1] = B[1][1] p...
print("Enter your name:") somebody = input() # 콘솔 창에서 입력한 값을 somebody에 저장 print("Hi", somebody, "How are you today?")
sexo = input('Informe seu sexo por gentileza: ') if sexo == 'F' or sexo == 'f': print('Voce é do sexo feminino') elif sexo == 'M' or sexo == 'm': print('Voce é do sexo masculino') else: print('Sexo invalido')
print('#################################### M E N U ####################################') print('File Duplo') print('Alcatra') print('Picanha') print('#################################################################################') file_duplo_ate_5kg = 4.90 file_duplo_acima_5kg = 5.80 alcatra_ate_5kg = 5.90...
pergunta1 = input('Telefonou para a vitima ?: ') pergunta2 = input('Esteve no local do crime ?: ') pergunta3 = input('Mora perto da vitima ?: ') pergunta4 = input('Devia para a vitima ?: ') pergunta5 = input('ja trabalhou com a vitima ?: ') total = 0 if pergunta1 == 'sim': total = total + 1 if pergunta2 ...
quantidade = 5 numeros = [] soma = 0 for n in range(quantidade): nota = float(input('nota: ')) numeros.append(nota) soma = soma + nota print('Notas: ',numeros) print('Soma das notas: ',soma) media = soma / 5 print('Media: ',media)
valor1 = int(input("Digite o primeiro valor: ")) valor2 = int(input('Digite o segundo valor: ')) soma = valor1 + valor2 print('A soma dos valores é: ',soma)
import math import fractions a = int(input('Digite o valor do a: ')) if a == 0: print('Não é uma equação do segundo grau') else: b = int(input('Digite o valor do b: ')) c = int(input('Digite o valor do c: ')) delta = (b**2) - (4*a*c) print('Delta: ',delta) if delta < 0: print('A equa...
letra = input('Digite uma letra: ') if letra == 'a' or letra == 'e' or letra == 'i' or letra == 'o' or letra == 'u': print('A letra ', letra ,' é uma vogal') elif letra != 'a' or letra != 'e' or letra != 'i' or letra != 'o' or letra != 'u': print('A letra',letra,'é uma consoante')
numero = int(input('Digite um numero: ')) total = 0 total_divisoes = 0 divisores = [] for n in range(1 , numero + 1): if numero % n == 0: total += 1 total_divisoes = total divisores.append(n) if total == 2: print('Foi feito: ',total_divisoes,'divisoes') print('O numero: ...
numero = float(input('Digite um numero: ')) if numero == round(numero): print('Inteiro') else: print('Decimal')
import io def q1(): r = range(0,5) l = [i for i in r] l = [[i for i in r] for j in r] print (l) # NB: I had to look this up. I would not have come up with that on my own def q2(): l = [[1,2,3],[4,5,6],[7,8,9]] out = [j for sub in l for j in sub] print (out) def q3(): planets = [['Merc...
import unittest from app.models import Article class ArticleTest(unittest.TestCase): ''' Test class to test behaviours of the Article class Args: unittest.TestCase : Test case class that helps create test cases ''' def setUp(self): ''' Set up method to run before each test...
#!/usr/bin/env python #-*- coding:utf-8 -*- def pawns_ratio(plansza, kolor): assert kolor in ['W', 'B'] whites, blacks = plansza.count_pawnsWB() if kolor == 'W': return float(whites)/blacks else: return float(blacks)/whites def pawns_difference(plansza, kolor): assert kolor in ['W'...
""" Tahsin Islam Sakif 25 February 2018 CS 293B Homework 3 """ from statistics import * Berkeley = [16,22,16,22,28,33,46,46,48] McDowell = [18,23,23,24,26,15,22,22,28] Mercer = [25,29,14,34,51,37,25,47,38] Raleigh = [22,19,12,45,60,58,37,39,62] def functionAverage(String,list1): average=mean(list1) return (...
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import abc class MiColeccionIterador(abc.Collection, abc.Iterator): def __init__(self): self.siguiente_valor_a_devolver = 0 def __len__(self): return 3 def __contains__(self, x): return x is "PRIMERO" or x is "SEGUND...
#!/usr/bin/env python # -*- coding: utf-8 -*- class MisDeportes(object): def __init__(self, listado_deportes=None): if listado_deportes is None: self.listado_deportes = [] else: self.listado_deportes = listado_deportes def add_deporte(self, deporte: str): self...
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import abc class IteradorIterable(abc.Iterator): def __init__(self): self.siguiente_valor_a_devolver = 0 def __next__(self): self.siguiente_valor_a_devolver += 1 if self.siguiente_valor_a_devolver == 1: retur...
#!/usr/bin/env python # -*- coding: utf-8 -*- def busca(cosa_a_buscar): listado_cosas = ["boligrafo", "taza", "cuchara"] for cosa in listado_cosas: if cosa == cosa_a_buscar: print("Encontrado") return print("No encontrado") return # El return vacío al final de la dec...
from tkinter import* import sys import sqlite3 import tkinter.messagebox class ATM1(): def __init__(self, top): self.mOffsets = Toplevel(top) self.mOffsets.geometry("1400x900+0+0") self.mOffsets.title("STATE BANK OF INDIA") self.mOffsets.configure(bg='blue') d...
# ===YOU SHOULD EDIT THIS FUNCTION=== def mean_naive(X): """Compute the mean for a dataset by iterating over the dataset Arguments --------- X: (N, D) ndarray representing the dataset. Returns ------- mean: (D, ) ndarray which is the mean of the dataset. """ N, D = X.shape ...
w=int(input()) if (w%2==0 and w!=2) : print('YES') else : print('NO')
str = input() for i in str: if i=='A' or i=='a' or i=='O' or i=='o' or i=='Y' or i=='y' or i=='E' or i=='e' or i=='U' or i=='u' or i=='I' or i=='i' : print("", end='') else : if i > 'a': print(".%c" %i, end='') else : print(".%c" %i.lower(), end='')
#!python #cython: language_level=3, boundscheck=False # CS 4341 Project 2 # Last updated: 9/26/2017 # Chad Underhill, Daniel Kim, Spyridon Antonatos # # Usage: # Contains methods for running the alpha-beta pruning algorithm. import math import time import Evaluation import Board # Depth allowed to...
#!python #cython: language_level=3, boundscheck=False # CS 4341 Project 2 # Last updated: 9/26/2017 # Chad Underhill, Daniel Kim, Spyridon Antonatos # Based on the theory described here: http://www.renju.nu/wp-content/uploads/sites/46/2016/09/Go-Moku.pdf """ Functionality we need from Board: size: the size of...