text
stringlengths
5
121k
""" Time Based Key-Value Store Create a timebased key-value store class TimeMap, that supports two operations. 1. set(string key, string value, int timestamp) Stores the key and value, along with the given timestamp. 2. get(string key, int timestamp) Returns a value such that set(key, value, timestamp_prev) was cal...
""" Permutation Sequence The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following sequence for n = 3: "123" "132" "213" "231" "312" "321" Given n and k, return the kth permutation sequence. Note: Given n will be between 1 and 9...
""" Verify Perorder Sequence In Binary Search Tree Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree. You may assume each number in the sequence is unique. Consider the following binary search tree: 5 / \ 2 6 / \ 1 3 Example 1: Input...
""" Find Common Characters Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the ...
''' Written by Benny Hwang 12/09/2017 Extends the module, linked_list_adt by adding a remove duplicate value feature ''' from linked_list_adt import * class ExtendedLinkedList(LinkedList): def __init__(self, L = None): super().__init__(L) def remove_duplicates(self): ...
""" A binary tree has the binary search tree property (BST property) if, for every node, the keys in its left subtree are smaller than its own key, and the keys in its right subtree are larger than its own key. It has the heap property if, for every node, the keys of its children are all smaller than its own key. You a...
""" Given 2 strings s and t, determine if you can convert s into t. The rules are: You can change 1 letter at a time. Once you changed a letter you have to change all occurrences of that letter. Example 1: Input: s = "abca", t = "dced" Output: true Explanation: abca ('a' to 'd') -> dbcd ('c' to 'e') -> dbed ('b' to '...
""" Compare String One string is strictly smaller than another when the frequency of occurrence of the smallest character in the string is less than the frequency of the occurrence of the smallest character in the comparison string. For example, string "abcd" is smaller than string "aaa" because the smallest charac...
""" Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "leetcode" Output: "leotcede" Note: The vowels does not include the letter "y". """ class Solution: def reverseVowels(self, s: str) -> str: if not s: ...
""" Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths ...
""" Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next() and hasNext() should run in average O(1) time and uses O(h) memory, where h is the height of the tree. You may assume ...
""" Largest Subarray Length K Array X is greater than array Y if the first non matching element in both arrays has a greater value in X than Y. For example: X = [1, 2, 4, 3, 5] Y = [1, 2, 3, 4, 5] X is greater than Y because the first element that does not match is larger in X. and if A = [1, 4, 3, 2, 5] and K = 4...
""" 2 Keys Keyboard Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Copy All: You can copy all the characters present on the notepad (partial copy is not allowed). Paste: You can paste the characters which are copied last time. Given a number ...
""" Reconstruct Itinerary Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK. Note: If there are multiple valid itineraries, you should ...
""" Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum element in the stack. """ class MinStack: def __init__(self)...
""" There are some processes that need to be executed. Amount of a load that process causes on a server that runs it, is being represented by a single integer. Total load caused on a server is the sum of the loads of all the processes that run on that server. You have at your disposal two servers, on which mentioned pr...
a, b = [int(i) for i in input().split()] def computeGCD(a, b): while(b): a, b = b, a % b return a print (computeGCD(a,b))
def simpleiterusingfor(a): x = a for loops in range (1,101): x_new = (2*x**2 + 3)/5 print(loops, x_new) if abs(x_new - x) <0.00001: break else: x = x_new print(f"The number of iteration is {loops} and the root is {x_new}") simpleit...
import codecs def normalize(s): """ (str) -> str Given a string, return a copy of that string with all alphabetical characters turned lowercase and all special characters removed and replaced with a space. >>> normalize("Hey! How are you? I'm fine. ;D") 'hey how are you i m fine d' ...
import tkinter mainWindow = tkinter.Tk() mainWindow.title("Main Window") mainWindow.geometry('640x480+8+400') label = tkinter.Label(mainWindow, text = 'Hello') label.pack(side="top") canvas = tkinter.Canvas(mainWindow, relief = 'raised', borderwidth = 1) canvas.pack(side = 'top') button1 = tkinter.Button(mainWin...
cog = input ("Dime tu apellido: ") num = input ("Dime un numero: ") c= "" for i in range(len(cog)): if i%2 !=0: c +=cog[i] else: c+=(num) c.replace (" ", "") print (c)
__author__ = 'Tong' priority = {"+": 0, "-": 0, "*": 1, "/": 1, "mod": 1, "(": -99, ")": -999} n_operands = {"+": 2, "-": 2, "*": 2, "/": 2, "mod": 2} def get_next(infix): infix = infix.strip() index = float("inf") operator = "" for op in priority: try: if index > infix....
__author__ = 'Tong' class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isSameTree(self, p, q): if not p and not q: return True elif (not p) ^ (not q): return False ...
st="hello" l=[] for i in st: l.append(i) print(l)
def factorial(a): c=1 for i in range(1,a+1): c=c*i return c a=int(input("enter the value")) f=factorial(a) print("factorial is",f)
n=(int(input('Enter the value '))) if (n==1): print('Today is Monday') elif (n==2): print('Today is Tuseday') elif (n==3): print('Today is Wednesday') elif (n==4): print('Today is Thasday') elif (n==5): print('Today is Friday') elif (n==6): print('Today is Starday') elif (n==7): print('Today...
n=int(input("enter the range")) s='' for i in range(1,n): s=s+"*" print(s) """for i in range(1,n): for j in range(i): print("*",end="") print("\n") """
a=int(input("enter the value")) for i in range (1,a): if i%2 is 0: print("no is even",i) else: print("no is odd")
number=int(input("enter the number")) if number==1: print("monday") elif number==2: print("tuesday") elif number==3: print("wednesday") elif number==4: print("thursday") elif number==5: print("friday") elif number==6: print("saturday") elif number==7: print("sunday") else: ...
A=input('Enter the product name ') B=input('Enter the price of the product ') C=input('Enter the quantity of the product ') Total=B*C if (C>=10): dis=(Total)*0.05 print('you have got as moch discounte',dis) elif (C>=15): dis=(Total)*0.10 print('You have got discounte',dis) elif (C>=20): d...
value = int(input("Enter value ")) if(value%2==0): print("This is even value ") else: print("this is odd value ")
a=input("enter the first value") b=input("enter the second value") if a>b: print("a is greater") elif(a==b): print("both are equal") else: print("b is greater")
import sqlite3 as sql import pandas as pd con=sql.connect("new.db") command="insert into stud values('Dhruv',10,99)" command1="insert into stud values('Raftaar',11,95)" command2="insert into stud values('Muhfaad',10,99)" command3="insert into stud values('Divine',10,99)" con.execute(command) con.execute(command...
def subtraction(a,b): f=a-b return f def addition(a,b): d=a+b return d def multiplication(a,b): e=a*b return e a=int(input("enter the first value")) b=int(input("enter the second value")) c=int(input("enter the user choice")) if c==1: f=subtraction(a,b) print("subtraction",f) elif c==2:...
from math import * value = int(input("Enter a value ")) sq = sqrt(value) print (sq)
def power (a,b): c=1 for i in range (b): c=c*a return c value=int(input("value")) p=int(input("power")) z=power(value,p) print("no is",z)
import os fileName = str(input("Please Enter the file Name: ")) fileName = fileName.strip() while not fileName: print("Name of the File Cannot be left blank.") print("Please Enter the valid Name of the File.") fileName = str(input("Please Enter the file Name: ")) fileName = fileName.strip() if not...
tup = (1, 2, 3, "Hello", "World") print(tup) for item in tup: print (item) b = 4 in tup print(b) b = 4 not in tup print (b)
import sys assert(len(sys.argv) == 2), "Please pass in the filename to count its unique words." originalfile = sys.argv[1] with open(originalfile, 'r') as file: data = file.read().replace('\n', ' ') og = data.split(" ") og = [word.lower() for word in og if word != ""] og_set = set(og) print(f"{originalfile} has ...
from sys import argv script, filename = argv print(f"We're goint to erase {filename}.") print("If you don't want that, hit CTRL-C (^C).") print("If you do want that, hit RETURN.") input("?") print("Opening the file...") target = open(filename, 'w') print("Truncating the file. Goodbye!") targ...
''' ---------------------------------- #Developed by | @user: Katherine Sánchez | #id: 201612408 | #e-mail: sanchezkathy29@gmail.com | ---------------------------------- This example demonstrates how to build a stack, we only need 2 classes: 1)Node: only has a constructo...
print('enter currency, USD or CAD:') currency = input().upper() print('Enter value:') value = float(input()) if (currency == 'USD'): print('The value in CAD is: $' + str(value * 1.27)) elif (currency == 'CAD'): print('The value in USD is: $' + str(value * 0.79)) else: print('Currency not found.')...
def fact(n): f=1 if n==0:print("The factorial of ",n,"is 1") elif(n<0):print("factorial does not exit for negative numbers") else: for i in range(1,n+1): f=f*i print("The factorial of ",n,"is",f) n=int(input("To find factorial:enter a number = ")) fact(n)
def pyramid(n): for i in range(1,n+1): for j in range(1,i+1): print(i*j,end=" ") print("\n") n=int(input("To construct number pyramid:Enter number of rows and columns: ")) pyramid(n)
print("To find the largest among three numbers") A = int(input("Enter first number = ")) B = int(input("Enter second number = ")) C = int(input("Enter third number = ")) if A>B and A>C: print(A," is greatest") elif B>C: print(B," is greatest") else: print(C,"is greatest")
a = float(input("Length of first side: ")) b = float(input("Length of second side: ")) c = float(input("Length of third side: ")) if a == b and b == c and a ==c : print("This is a equilateral triangle") elif a == b or a == c or b == c: print("this is a isoseles triangle") elif (a == b or a == c or b ...
import random randomNumber = random.randint(1,100) numberGuesses= 0 guessRemain = 5 userGuess = int(input("please enter a number between 1 and 100: ")) guessRemain -= 1 numberGuesses += 1 lowerBound = 0 upperBound = 101 if userGuess == randomNumber: print("Your Correct!") else: while guess...
firstItem = float(input(" Enter price of first item: ")) secondItem = float(input ("Enter price of second item: ")) total = firstItem + secondItem if firstItem > secondItem: secondItem1 = secondItem * 0.5 firstItem1 = firstItem elif secondItem > firstItem: firstItem1 = firstItem * 0.5 second...
from PIL import Image def convert_to_gray_image(image): return image.convert("L") if __name__ == '__main__': image_input_path = "/media/cv-bringupy/test.jpg" image_output_path = "/media/cv-bringupy/test_gray.png" img = Image.open(image_input_path) img_gray = convert_to_gray_image(img) img_...
import pygame import json import math class Map: def __init__(self, filename, display): self.filename = filename self.display = display self.width = 10 self.height = 10 self.thicknes...
import pyautogui, pyperclip def main(): print(selectAllFromNotepadAndCopy()) def selectAllFromNotepadAndCopy(): notepadWindows = pyautogui.getWindowsWithTitle('Notepad') strings = [] for notepadWindow in notepadWindows: notepadWindow.activate() pyautogui.hotkey('ctrl'...
import copy def main(): tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] printTable(tableData) def printTable(table): colWidths = [0] * len(table) for i in range(len(table)): l...
def commaList(spam): commaListStr = '' if len(spam) == 0: return commaListStr for index, item in enumerate(spam): if index == len(spam) - 1: commaListStr = commaListStr + 'and ' + str(item) else: commaListStr = commaListStr + str(item) + ', ' return comm...
import os, bs4, requests def main(): searchTerm = input('Imgur Search: ') searchTermForURL = '+'.join(searchTerm.split()) URL = 'https://imgur.com/search?q=' + searchTermForURL os.makedirs(searchTerm, exist_ok=True) res = requests.get(URL) res.raise_for_status() ...
'''CardDeck class to represent a deck and pull a card out at random''' import random class CardDeck: nameMap = { 1:'Ace', 2:'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', 7: 'Seven', ...
from tkinter import * from tkinter.messagebox import * root=Tk() root.geometry("500x500") root.title("Leap or Not By Nishant Patil.") root.iconbitmap("calci.ico") def Leap(): year=int(ent.get()) if year%4==0: showinfo("Result","Leap Year.") else: showinfo("Result","Not a Leap Year.") f=("Times ...
import art print(art.logo) def add (n1, n2): return n1 + n2 def substract (n1, n2): return n1 - n2 def multiply (n1, n2): return n1 * n2 def divide(n1, n2): return n1 / n2 opperators = { "+": add, "-":substract, "*": multiply, "/": divide } def calculator(): num1 = float(input("What's t...
n = int(input('DIGITE UM NUMERO: ')) if n % 2 == 0: print('NUMERO PAR') else: print('NUMERO IMPAR')
turno = input('QUAL TURNO VC ESTUDA: ') if turno == 'm': print('ESTUDA PELA MANHÃ!') elif turno == 't': print('ESTUDA PELA TARDE!') elif turno == 'n': print('ESTUDA PELA NOITE!') else: print('ERRO!')
peso = int(input('QUANTOS DE PEIXE? ')) if (peso <= 50): print('SEM MULTA!') elif(peso > 50): m = (peso - 50)*4 print('MULTA DE {}'.format(m))
from ctlz import exceptions def color(text, fg=None, bg=None): """Function to easily color printed text fg and bg kwargs can be set to any standard 4 bit terminal color, prefix with bright (as in 'bright_red') for the bright variant""" if fg == None and bg == None: return text elif fg == None:...
import requests import argparse HOST_NAME = 'http://127.0.0.1' PORT_NUMBER = "9000" def get_file(path, port): file = requests.get(HOST_NAME + ":" + port + "/" + path) print(file.text) return file def save_file(file): with open('web_response_1.txt', 'w') as f: f.write(file.text) def get_ar...
""" Created on Tue Aug 13 23:36:24 2019 @author: yuribyk """ a= "(a-b)(a-b)(a-b)" def simplify_b(a): b="" for i in a: if i=="(" or i==")": b+="_" else: b+=i termz= b.split("_") terms= [] for i in termz: if i!= "": terms.app...
""" Mask computations """ from utils import Rect def find_intersection_rect(rect_one, rect_two): """ Given two rectangles, find the common section. """ new_tl_x = max(rect_one.tl_x, rect_two.tl_x) new_tl_y = max(rect_one.tl_y, rect_two.tl_y) new_br_x = min(rect_one.br_x, rect_two.br_x) new_br_y ...
""" Searches deep inside a directory structure, looking for duplicate file. Duplicates aka copies have the same content, but not necessarily the same name. """ __author__ = "Simon Lee" __email__ = "lees118@my.erau.edu" __version__ = "1.0" from os.path import getsize, join from time import time from p1utils ...
import economics import resources import settings class City: def __init__(self, name, x, y, population): self.x = x self.name = name self.y = y self.population = population self.commodity_stocks = [0] * len(resources.resources) self.prices = [0] * len(resources.reso...
print("Solving equations...") print("4 * 8 = " + str(4 * 8)) print("12 / 2 = " + str(12 / 2)) print("-5 - 6 * 3 = " + str(-5 - 6 * 3)) age = input("What is your age?") age = int(age) + 10 print("in ten years you will be... " + str(age)) print("Go Vipers!\n" * 20) myNum = 20 myNum = myNum + 5 myOtherN...
NUM_HOURS = 9 def get_number_of_meeting_rooms(schedule): schedule_block = [0] * NUM_HOURS for start, end in schedule: schedule_block[start] = schedule_block[start] + 1 schedule_block[end] = schedule_block[end] - 1 num_rooms = 0 counter = 0 for entry in sche...
def force1(num): return num * 1 + 0 def force2(num): return num * 1 + 0 def press1(num): return num * 1 + 0 def press2(num): return num * 1 + 0 def format(data): out = [0,0,0,0] for i in range(4): num = float(data[i]) if i == 0: num = f...
DIGITS = 4; MIN = 1000; MAX = 9999; def getBest(prev, cur) : maximum = max(MIN, prev); for i in range(maximum, MAX + 1) : cnt = 0; a = i; b = cur; for k in range(DIGITS) : if (a % 10 != b % 10) : cnt += 1; a //= 10; b //= 1...
import math class Structure1: _fields = [] def __init__(self, *args): if len(args) != len(self._fields): raise TypeError('Expected {} arguments'.format(len(self._fields))) for name, value in zip(self._fields, args): setattr(self, name, value) class St...
class lazyproperty: def __init__(self, func): self.func = func def __get__(self, instance, cls): if instance is None: return self else: value = self.func(instance) setattr(instance, self.func.__name__, value) return value import math cla...
class Calculator: def __init__(self): self.number_of_operations = 0 @staticmethod def _is_number(number): return type(number) == int def add(self, number1, number2): self.number_of_operations += 1 if not self._is_number(number1) or not self._is_number(number2): ...
import pandas as pd import unittest nested_dict = {'white_wine': {1998:1, 1999:1, 2000:2}, 'red_wine': {1998:3, 1999:2, 2000:0}} df = pd.DataFrame(nested_dict) class TestForBasicMath(unittest.TestCase): def test_df_white_wine_1998(self): pass if __name__ == '__main__': un...
import re N = int(input()) pattern = '^[_\.]\d+[a-zA-Z]*[_]?' for n in range(0, N): text = input() m = re.search(pattern, text) if m != None: if m.end() == len(text): print('VALID') else: print('INVALID') else: print('INVALID')
class posting: def __init__(self): self.file_name = None self.word_num = None self.term_f = None self.next = None class posting_list: def __init__(self): self.head = None self.tail = None self.length = 0 def add(self, fn, wn): self.length += 1 nn = posting() nn.file_name = fn nn.word_nu...
import re def checkio(text): text = text.replace(' ', '').lower() text = re.sub(r'!|,|\.|-|\d', '', text) new_text = set(text) if len(new_text) != len(text): count = 0 letter = [] for i in text: if text.count(i) > count: letter = [] c...
import csv with open('st.csv', 'r') as f: q = csv.reader(f, delimiter=',') for row in q: print(','.join(row))
class Square(): def __init__(self, s1): self.side = s1 def change_size(self): return self.side + 5 squ = Square(3) print(squ.change_size())
""" Created on Fri Oct 19 20:57:48 2018 @author: OREVAS """ def soal_1(): jumlah_orang=input(" ") lists_orang=[] lists_duit=[] for i in range(int(jumlah_orang)): uang=input(" ") lists=uang.split(" ") lists_orang.append(lists[0]) lists_duit.append(lists[1]...
def word_score(word): total = 0 for i in word: i = i.lower() total += score[i] return total score = {"a":1,"b":2,"c":3,"d":4, "e":5,"f":6,"g":7,"h":8, "i":9,"j":10,"k":11,"l":12, "m":13,"n":14,"o":15,"p":16, "q":17,"r":18,"s":19,"t":20, ...
names = ['Stiven', 'Dennis', 'Adrian', 'Jerico','Javier'] ages= [18, 60, 23, 22, 26] names_with_ages = zip(names,ages) for student in names_with_ages: print(student)
class Student: university = 'ESPE' def __init__(self,_id,_name,_age,_career,_cell_number): self.id = _id self.name = _name self.age = _age self.career = _career self.cell_number = _cell_number class Phone: def __init__(self, _number): ...
class Collision_Detection: def takra(self, rect1, rect2): if rect1.x > rect2.x: rect1,rect2 = rect2,rect1 if rect1.x + rect1.w > rect2.x: if rect1.y + rect1.h < rect2.y: return False elif rect1.y > rect2.y + rect2.h: retu...
import operator def accumulate(iterable, func = operator.add, *, initial=None): it = iter(iterable) total = initial if initial is None: try: total = next(it) except StopIteration: return yield total for element in it: total = func(total, element) ...
""" name = input("Hello whats your name? ") print("Good morning " + name) age = input("and how old are you? ") print("thats cool") """ """ list = ["Volvo", "Chevrolet", "Audi"] print(list[2]) """ """ list = ["Volvo", "Chevrolet", "Audi"] list.insert(1, "Corona") list.remove("Corona") list.clear() list.pop() list.in...
import random first_primes_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 1...
user_input = input('What would you like the cat to say') text_length = len(user_input) print(' {}'.format('_' * text_length)) print(' < {} >'.format(user_input)) print(' {}'.format('-' * text_length)) print(' /') print(' /\_/\ /') print(' ( 0.0 ) ' ) print(' > ^ ...
import math def convertidor(): i=0 while i==0: opcion=int(input("Por favor,ingre el numero de la opcion que quiera :")) if opcion == 1: altura=float(input("Ingrese la altura del cilindro:")) radio=float(input("Ingrese el radio del cilindro:")) volumen=m...
def even_list(nums): return [i for i in nums if i%2 == 0 and nums.index(i)%2 == 0] if __name__ == "__main__": nums = [0,1,2,3,4,5,6,7,8,9,10] print(even_list(nums))
class Test: __list = [] def __init__(self): print("construction") def __del__(self): print("destruct") def __str__(self): return "a string version of Test" def __getitem__(self, key): return self.__list[key] def len(self): return len(self.__list) ...
from random import randint data = randint(0,21) guess = int(input("> ")) if guess > data: print ("What you guess is bigger") elif guess < data: print ("What you guess is smaller") else: print ("Excellent, you are right") i = 0 while guess != data and i < 9: times = 9 - i print ("You only have ...
def cheese_and_cracker(cheese_count, boxes_of_crackers): print("You have %d chesses!" % cheese_count) print("You have %d boxes of crackers!" % boxes_of_crackers) print("Man that's enough for a party!") print("Get a blanket. \n") print ("We can just give the function numbers directly") cheese_and_cr...
def print_banner(text: str, header_char: str = "-", footer_char: str = "-", size: int = 50) -> None: """ Print a nicely formatted banner with a line of header and footer characters :param text: :param header_char: :param footer_char: :param size: :return: """ print(header_char * size...
true = True true = bool(17) true = bool(-1.25) false = bool(None) false = bool(0) false = False true = True and True false = True and False false = False and False false = False and True false = False or False true = True or False true = False or True true = True and False or True false = True and False...
usuario = str(input("id: ")) password = str(input("pass: ")) print("usuario creado") print(" ") print("loguearse:") us =str(input("id: ")) contra = str(input("pass:" )) cont= 0 while cont <5: if us != usuario or contra != password: us =str(input("id: ")) contra = str(input("pass:" )) cont+= ...
import math ''' 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 ''' def spiral(x): diagonals = [] count = 0 increment = 2 i=1 while(i <= x**2): diagonals.append(i) count += 1 i += increment if count % 4 ==0: increment += 2 return(diagonals) def is_prime(x): if(x<2): retu...
''' 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 ''' def cycle(x): total = 0 count = 0 increment = 2 i=1 while(i <= x**2): total += i count += 1 i += increment if count % 4 ==0: increment += 2 return(total) print(cycle(10))
t=int(input()) while(t>0): s=input() c=s.count("1") if(c%2==1): print("WIN") else: print("LOSE") t=t-1
"""Encrypting an entire file""" f1=open("input.txt",'r') f2=open("output.txt",'w') for m in f1: for i in m: if i==' ': f2.write(' ') elif i=='.': f2.write('.') elif i=='\n': f2.write('\n') elif ord(i)>=65 and ord(i)<=90: j=ord(i)+5 if j>ord('Z'): k=j-ord('Z') j=ord('A')+k-1 f2.write...