text
stringlengths
5
121k
n = input("Enter number n: "); counter = 1; while counter <= n: print("*"*counter); counter = counter +1;
def normalize(name): return name[0].upper()+name[1:].lower() L1 = ['adam', 'LISA', 'barT'] L2 = list(map(normalize, L1)) print(L2) def prod(L): def f1(x,y): return x*y return reduce(f1,L) print('3 * 5 * 7 * 9 =', prod([3, 5, 7, 9])) if prod([3, 5, 7, 9]) == 945: print('Գɹ!') else: pri...
import random import radio from microbit import button_a, Image, display, sleep random.seed(463473567345343) my_id = 'foo' tool = 0 while True: if button_a.was_pressed(): tool = random.randrange(3) display.clear() sleep(1000) display.show(tools[tool]) sleep(1...
""" Memory Usage Test using Function and List """ def fibonacci_fun(max): nums = [] a, b = 0, 1 while len(nums) < max: nums.append(b) a, b = b, a + b return nums for n in fibonacci_fun(100000): print(n)
a = int(input("enter the value of a:")) b = int(input("enter the value of b:")) print("the values of a and b are:",a,b) a = a+b b = a-b a = a-b print("the swapped varaibles of a and b are:",a,b)
celcius = int(input("enter the celcius rate:")) farenheit = celcius * 32 print("the farenheit of the given celcius is:",farenheit,'farenheit')
""" 短冒泡排序 """ def shortBubbleSort(alist): exchanges = True item = len(alist) - 1 while item > 0 and exchanges: exchanges = False for i in range(item): if alist[i] > alist[i+1]: exchanges = True temp = alist[i] alist[i] = ...
import threading import time g_num = 0 def test1(num): global g_num mutex.acquire() for i in range(num): g_num += 1 mutex.release() print("------in test11111 g_num = {}".format(g_num)) def test2(num): global g_num mutex.acquire() for i in range...
""" Created on Fri Oct 30 23:39:55 2020 @author: Prathyusha Vaigandla """ array = [9, 10, 11, 0, -4 ,-5, -6, -1] count = 0 target = 0 triplets = [] array.sort() for i in range(len(array)-3): for j in range(i+1,len(array)-2): left = j+1 right = len(array)-1 while left<right: cn ...
def largestRange(array): dupHash = {} largeArray = [] longValue = 0 for i in array: dupHash[i] = True for i in array: if not dupHash[i]: continue dupHash[i] = False currentValue = 1 left = i-1 right = i+1 while left in dupHash: ...
""" A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an grid of integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous). Example 1: Input: [[4,3,8,4], [9,5,1,9], ...
''' Given a 32-bit signed integer, reverse digits of an integer. E.g. Input: 123 Output: 321 Input: -123 Output: -321 Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of t...
""" Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [4,9] Note: Each element in the result should appear as many times as it shows in both arrays. The result can be in ...
import math X = int(input()) now = 100 count = 0 while(True): count += 1 now = math.floor(now * 1.01) if now >= X: print(count) break
import copy def combination(num): result_combination = [[0]] recursion([], 1, num, result_combination) return result_combination def recursion(combination_list, i, max_num, result_combination): if i > max_num: if len(combination_list) > 0: result_combination.append(combination_l...
content = ["Wayne is the toughest guy in Letterkenny.", list(range(0,101,10)), ("Wayne", "Dan", "Katy", "Daryl"), 10.4] for i in range(0, len(content)): if type(content[i]) is tuple: print ("{} is a {}".format(content[i], type(content[i]))) elif type(content[i]) is str: content[i] +=...
import datetime now = datetime.datetime.now() year = now.year name = input("Please enter your name: ") age = int(input("Please enter your age: ")) yearsToHundred = 100 - age turnHundred = int(year) + yearsToHundred message = name + " will turn 100 in the year "+ str(turnHundred) print(message) repeat = int(inpu...
modCheck = int(input("Please enter an integer: ")) if (modCheck % 4) == 0: print(str(modCheck) + " is a multiple of 4") elif (modCheck % 2) == 0: print(str(modCheck) + " is even") elif (modCheck % 2) != 0: print(str(modCheck) + " is odd") num, check = input("Enter 2 numbers:").split() num = int(num) check = i...
import requests class Qiushi(...
a=int(input('请输入总资产')) goods = [ {'name': '电脑', 'price': 1999}, {'name': '鼠标', 'price': 10}, {'name': '游艇', 'price': 20}, {'name': '美女', 'price': 998} ] for i,j in enumerate(goods): print(i+1,j['name'],j['price']) print('已进入购物车,按exit退出购物车')
def commonPrefix(strs): lcp="" if (len(strs)==0): return lcp minLen = len(strs[0]) for i in range(len(strs)): minLen = min(len(strs[i]), minLen) strng= strs[0] for i in range(minLen): for j in range(1,len(strs)) : print(strs[j][i]) i...
lst=[] size = int(input("enter the size of the array")) for i in range(size): val = int(input("enter the elements in the array on by one")) lst.append(val) x=int(input("enter the elements to be searched")) for i in range(0,size): if i==size-1: print("No") elif x==lst[i...
def check(strng,substrng): count=0 j=0 for i in range(len(strng)): if j==len(substrng): print("true") exit(1) elif strng[i]==substrng[j]: count+=1 j+=1 print(count) else: j=0 print("False") ...
import heapq vowels=['a','e','i','o','u'] strng=str(input("enter the string")) dic={} max_heap=[] heapq.heapify(max_heap) for i in range(len(strng)): if strng[i] in dic: dic[strng[i]]+=1 else: dic[strng[i]]=1 for key,value in dic.items(): heapq.heappush(max_heap,[-value,key]) ...
size=int(input("enter the size of the array")) print("enter the elements of the array") lst = list(map(int,input().split(" "))) for i in range(size//2): temp= lst[i] lst[i]= lst[size-i-1] lst[size - i - 1]=temp print(lst)
def anti_diagonal(mat): m=len(mat) n=len(mat[0]) for col in range(m): startcol=col startrow=0 while startcol>=0 and startrow<m: print(mat[startrow][startcol], end=" ") startrow+=1 startcol-=1 print() for i in range(1,n)...
tag = 'h1' text = 'This is a headline' sentence = '<{0}><{1}></{0}>'.format(tag, text) print(sentence) first_name = 'Corney' last_name = 'Schafer' from datetime import datetime birthday = datetime(1990, 1, 1) sentence = f'Jenn has a birthday on {birthday:%B %d, %Y}' print(s...
class Employee: raise_amt = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.email = first + '.' + last + '@email.com' self.pay = pay def fullname(self): return '{} {}'.format(self.first, self.last) def apply_raise(self): ...
import locale class BankAccount(): def __init__(self): self.balance = 0 self.account = None def add_money(self, amount): """Add money to a bank account Arguments: amount - A numerical value by which the bank account's balance will increase """ self.balance += float(amount) def w...
class BinarySearchTree: def __init__(self, value): self.value = value self.left = None self.right = None def insert(self, value): if value > self.value: if self.right is None: self.right = [value] else: self.right.append(value) elif value < self.value: if self....
def parseline(line,format): """ Return the line split and with particular formats applied. Format characters: x Skip this record s Convert the record to a string f Convert the record to a float d Convert the record to an int i Convert the record to an int Exampl...
from rock_paper_scissors import * class Server: my_choice = 0 def __init__(self, address, port): self.server(address, port) def server(self, address, port): connection = runSocket(address, port) answer = 0 while answer == 0: while True: try: ...
from checker import has_3 from checker import has_5 def buzz(n): a=False for i in range (1,n+1): a="" if i%3==0 or has_3(i): a+="Fizz" if i%5==0 or has_5(i): a+="Buzz" if a=="": a=i print(a) return a buzz(150)
Cards = ['w/b/s/o', 'w', 's/b', 's'] make = "WWSS" def sort(cards, make): for i in cards: i.split("/") cards.sort() need = list(make) need.sort() while len(need) > 0: for i in cards: if not [n for n in need]: print("nope") else: need.remove(n) print("it works!") sort(...
import itertools import datetime import time class SubsetCalculator(object): def get_subset(self, my_list, target_number): for i in range(1, len(my_list)+1): total_tupple = itertools.combinations(my_list, i) subset_tupple = self.test_sublist(total_tupple, target_number...
import cv2 as cv def scale(image, w, h): scale_x = w / 320 scale_y = h / 240 width = int(image.shape[1] * scale_x) height = int(image.shape[0] * scale_y) return cv.resize(image, (width, height), interpolation=cv.INTER_AREA)
a = ' --FAKE-- ' lorem = '''Lorem Ipsum is simply dummy text {0} of the printing {0} and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled {0} it to make a type specim...
print('online shipping from AliEx') print('way to pay for airpods') way = (input('PAYMENT: ')).lower() balance = 6000 acer = 3500 if way == 'mastercard': print('sorry... MS is not maintainig!') elif way == 'elcard': print('sorry...Ed is not maintaing!') elif way == 'visa' or way == 'paypal': print('...
calculation_to_hours = 24 name_of_unit = "hours" def days_to_units(num_of_days): return(f"{num_of_days} days are {num_of_days * calculation_to_hours} {name_of_unit}") def validate_and_execute(): if user_input.isdigit(): ...
from math import floor import helpers @helpers.timer def solve_01(): masses = [int(line) for line in open("../inputs/day01.txt", "r").read().splitlines()] fuel_needs = [(floor(mass / 3) - 2) for mass in masses] return fuel_needs @helpers.timer def solve_02(): masses = [int(line) for line in open("...
from months import Month def year_function(): temp_year = Year() year = tuple(temp_year.month_list) entry = int(input('which number month are you looking for a holiday in?')) - 1 if year[entry].holidays is not None: print(f'{year[entry].name} has {year[entry].holiday_name} on {year[entry].holida...
from Bank import Bank ING = Bank() comand = 1 while comand > 0: comand = int(input("For creating a new account enter 1, for log in enter 2, for delete an account enter 3, for stop enter 0: ")) if comand == 1: ING.newAccount() if comand == 2: a...
from tkinter import * from tkinter import ttk import random from sortAlgos import bubble_sort, merge_sort data = [] def display_data(data, color_list): """ This function will clear the old data from canvas and display the new data data is normalized to allow bars to be sized relative to one another ...
""" a = int(input("Enter your value of a: ") ) b = int(input("Enter your value of b: ") ) print("Adding a and b") print(a+b) print("Subtract a and b") print(a-b) print("Multiply a and b") print(a*b) print("Divide a and b") print(a/b) print("Remainder left after dividing a and b") print(a%b) # Program 2 name=input("Ent...
def squared(x, y): result = x**2 + y**2 return result print(squared(10, 2)) def born (country): return print("I am from " + country) born("greensboro")
print ("N1", '\t', "N2", '\t', "N1 * N2",) print ("-----", '\t', "-----", '\t', "-------") for x in range (5,21): print (x, '\t', x, '\t', x*x)
mahasiswa1 = {"NIM":106, "Nama":"Anang Nugraha", "Prodi":"Teknik Informatika", "Status Mahasiswa":"Aktif"} mahasiswa2 = {"NIM":104, "Nama":"Aerosh Nugraha", "Prodi":"Sistem Informasi", "Status Mahasiswa":"Aktif"} print(mahasiswa1["Nama"]) p...
namaband = ['Noah', 'Ungu', 'Vagetoz', 'Kangen Band', 'Kadal Band'] kumpulanlagu = ['Menunggumu', 'Laguku', 'Kehadiranmu', 'Aku kau dan dia', 'Cinta tak direstui'] for i,band in enumerate(namaband, start=1...
Barang = ['laptop','mouse','cangkir','mangkok','piring'] Barang.append('sendok') print(Barang) Barang.insert(3,'keyboard') Barang.insert(3,'laptop') print(Barang) Jumlahlaptop = Barang.count('laptop') print('jumlah laptop dalam list',Jumlahlaptop) Barang.remove('cangkir') print(Barang) Barang.reverse() print(B...
import random import sys args = sys.argv if len(args) < 2 : print("put number") else : samplenum = int(args[1]) for line in open('word.txt', 'r') : wordList = line[:-1].split(',') listlen = len(wordList) if samplenum > listlen : print("引数は",listlen,"以下にしてください") else : sampleWords = random.sample(wordList...
""" 模拟注册登录 """ import pymysql db = pymysql.connect(host='localhost', port=3306, user='root', password='123456', database='dict', charset='utf8') cur = db.cursor() def register(): name = input("用户名:") ...
class Board(): def __init__(self): self.state = [['-', '-', '-'], ['-', '-', '-'], ['-', '-', '-']] self.num_pad = [['7', '8', '9'], ['4', '5', '6'], ['1', '2', '3']] self.number_of_moves = 0 def print_avail_spots(self): ''' Prints the available spots in a...
import os import csv election_data = os.path.join( 'Resources', 'election_data.csv') with open(election_data, 'r') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') print(csvreader) csv_header =next(csvreader) counter = 0 candidates = [] comparison_list = [] ...
from sys import stdin def intersection(arr1, arr2, n, m) : arr1.sort() arr2.sort() i=0 j=0 while i<n and j<m: if arr1[i]==arr2[j]: print(arr1[i],end=" ") i+=1 j+=1 else: if arr1[i]<arr2[j]: i+=1 ...
''' A series is defined in the following manner: Given the nth and (n+1)th terms, the (n+2)th can be computed by the following relation Tn+2 = (Tn+1)2 + Tn So, if the first two terms of the series are 0 and 1: the third term = 12 + 0 = 1 fourth term = 12 + 1 = 2 fifth term = 22 + 1 = 5 ... And so on. Given thre...
import pandas as pd import plotly.express as px df = pd.read_csv("data.csv") graph = px.scatter(df,x="Population",y="Per capita",color = "Country",size="Percentage") graph.show()
class SimpleTreeNode: def __init__(self, val, left=None, right=None) -> None: self.val = val self.left = left self.right = right class AdvanceTreeNode: def __init__(self, val, parent=None, left=None, right=None) -> None: self.val = val self.parent = parent self....
from account import * def main(): accList = [] accNum = 0 while True: showMenu() choice = int(input("선택: ")) if choice == 1: accList.append(openAcc()) accNum += 1 elif choice == 2: depositAcc(accList, accNum) elif choice == 3: ...
array =["futbool", "pc", 18, 16, [2, 3, 5], True, False] array.append(66) array.append(True) array.insert(1,88) array.extend([1, 88, True, 100]) print("lista: ",array) print("longitud: ",len(array)) '''Concatenando listas''' array2=[200, 250, "hola"] array3=array+array2 print("----------------------...
'''En las listas podemos almacenar cualquier tipo de datos, es decir no tiene que ser de un solo tipo la lista''' array =["futbool", "pc", 18, 16, [2, 3, 5], True, False] print("\n\nlista: ", array) print("\nprimer elemento: ", array[0]) '''el numero se conoce como indice''' print("penultimo elemento: ", arr...
import unittest from shipment import optimal_shipping, warehouse_purchase class TestCase(unittest.TestCase): def test_zero(self): shipment_order_0 = {} warehouses = [{ "name": "owd", "inventory": { "apple": 6,"mango": 1, "potato": 1} }, { "name": "oz", "inventory": {}}, { "name": "dm", "inventory": {...
from sys import stdin def sort_list(A): less, equal, greater = [], [], [] if len(A) > 1: pivot = A[0] for num in A: if num > pivot: greater.append(num) elif num == pivot: equal.append(num) else: less.append(...
from sys import stdin def flexradix(A, d): list3 = sort_length(A) return counting_sort(list3, d) def counting_sort(A, d): list = [0] * d for word in A: list[len(word) - 1] = list[len(word) - 1] + 1 for i in range(d - 1, 0, -1): list[i - 1] = list[i - 1]...
from numpy import array import numpy as np def sklearn_pca(data_array): from sklearn.decomposition import PCA pca = PCA(2) pca.fit(data_array) eigenvalues = pca.explained_variance_ eigenvectors = pca.components_.T return eigenvalues, eigenvectors def get_eigenvector(data_array): cen...
def wordSplit(wordList, word): listoutputword = [] listword = [[False for i in range(len(word))] for x in range(len(word))] for i in range(1, len(word) + 1): for j in range(len(word) - i + 1): if word[j:j + i] in wordList: listword[j][j + i - 1] = True lis...
def concatenate(first_things, second_things): concatenated_list = [] for element in first_things: concatenated_list.append(element) for element in second_things: concatenated_list.append(element) return concatenated_list def main(): concatenated_list = [] ...
from .card import * from .utility import * from .textstrings import * class Player: """A player in the game""" mana = 1 mana_used = 0 overload_now = 0 overload_next = 0 health = 30 armour = 0 damage = 0 attack = 0 def __init__(self, ct, npc=False): self.classtype = ct ...
import sys def rock_paper_scissors(n): outcome = [] choices = ['rock', 'paper', 'scissors'] def inner_rps(rounds_left, result=[]): if rounds_left == 0: outcome.append(result) return False for c in choices: inner_rps(rounds_left...
""" Created on Sat Oct 24 09:51:18 2020 @author: legen """ from clear_console import cls import numpy as np cls() data = np.random.randn(2,3) print(data) data=data*2 print(data) print(data + data) print(data.shape) print(data.dtype) cls() data1 = [1, 2, 9.7, 0, 4] data2 = np.array(data1) print(data2) data...
""" Created on Tue Sep 22 22:29:46 2020 @author: legen """ from clear_console import cls cls() tup = 1,2,3.5,'hello',['a','b','c'] print(tup) tup[4].append('d') print(tup) nested_tup='a','b','c',(1,3,4), 'd',(6,7) print(nested_tup) print(tuple("mike world!")[0].upper()) print(tuple(['a','b','c'])) print(tuple("...
import os, sys from itertools import islice count = 0 def merge_sort(li, c): if len(li) < 2: return li m = len(li) / 2 return merge(merge_sort(li[:int(m)],c), merge_sort(li[int(m):],c),c) def merge(l, r, c): result = [] l.reverse() r.reverse() while ...
class Timer: def __init__(self, count: int =0): if not isinstance(count, int) or count < 0 or count > 255: raise ValueError('Timer count must be integer value in range [0;255]') self._count = count def decrease(self): if self._count != 0: self._count -= 1 ...
originalPrice = float(input("Please enter thr price: ")) if originalPrice < 128: discountRate = 0.92 else: discountRate = 0.84 discountedPrice = discountRate * originalPrice print("Price $%.2f" % discountedPrice)
str1 = "string1" str2 = "some other stuff" str3 = "still more stuff" print(str1) print (str2,str3) str4 = str3 + str3 print(str4) x = 4 outstr = "the value of x is" + "x" print(outstr) in_val = input("Enter an integer diameter of a circle") print(in_val) out_val = int(in_val) print (out_val) x = out_val...
def main(): windSpeed = 0 temp = 0 for i in range (1, 11): V=i*5 WC = 35.74+0.6215*temp-3.75*V**0.16+0.4275*temp*V**0.16 for temp in range (-45, 40, 5): print (2*" ",temp, end=" ") print("\n"," "*2,"-"*105) for windSpeed in range (0, 60, 5): ...
valid = False while not valid: value = int(input("Please enter a positive vlaue < 100: ")) if value > 0 and value < 100: valid = True else: print("The value is not valid")
hours = float (input("ENTER THE HOURS WORKED AS INTEGER")) rate = float (input("Enter the hourly pay rate as an integer")) if hours > 40: gross = 40 * rate + (hours - 40) * rate * 1.5 print ("Overtime") else: gross = hours * rate print("no overtime:") print("The gross wage is", gross) num...
def printTriangle(sideLength): if sideLength < 1 : return printTriangle(sideLength - 1) print("[]" * sideLength) printTriangle(2)
import random secret_number = random.randint(1,101) guess = int(input("Guess what number I'm thinking of (between 1 and 100): ")) while guess != secret_number: if guess > secret_number: guess = int(input("Too high! Guess again: ")) if guess < secret_number: guess = int(input("Too low! Guess again: ")) if gues...
from tkinter import * def btnc(number): global operator operator=operator+str(number) text_str.set(operator) def btnclr(): global operator operator="" text_str.set(operator) def btneval(): global operator try: s=str(eval(operator)) text_str.set(s) ...
print('*******Starting a transaction*****') amount=int(input("Enter amount to withdraw: ")) discount=0 if amount <1000: discount=amount *0.45 print('Net amount is: ', amount+discount) elif amount <2000: discount=amount*0.5 print('Net amount is: ', amount+discount) else: discount=amount *0.7 print( 'Net am...
def main(): pot=int(input("Please enter the amount of money you would like to play with: ")) play= 0 maxvalue=0 while pot > 0: import random die1value= random.randint(1,6) die2value= random.randint(1,6) sum=die1value + die2value ...
from graphics import * def main(): radius = 5 clicks = int(input("How many clicks do you want: ")) win = GraphWin("Click Me", 300,300) center = Point(150,150) label = Text(center, "Click randomly times around the screen") label.draw(win) for i in range (clicks): ...
from graphics import * win = GraphWin("My Graphics Window", 400,400) p = Point(50,60) p2 = Point(140,100) x = p.getX() y = p.getY() print(x,y) p.draw(win) p2.draw(win) center = Point(100,100) circ = Circle(center,30) circ.setFill("red") circ.setOutline("green") circ.setWidth(5) circ.draw...
from rectangleKolodziej import Rectangle def main(): userChoice = 'X' print("Welcome to the rectangle builder") print("W: Assign the width") print("H: Assign the height") print("F: Assign the fillstyle") print("A: Calculate the area") print("P: Calculate the pe...
from itertools import combinations def read_file_to_array(file): with open(file, 'r') as file: report = [line.strip() for line in file] return report def find_the_sum_of_two_numbers(report): for x, y in combinations(report, 2): if int(x) + int(y) == 2020: return int(x) * ...
from datetime import date, datetime from functools import wraps def find_time_for_execute(func): @wraps(func) def cover(*args, **kwargs): start = datetime.now() my_current_age = func(*args, **kwargs) before_20000_days = 20000 - int(my_current_age) end = datetime.now() ...
import sqlite3 conn = sqlite3.connect("my_friends.db") с = conn.cursor() с.execute("SELECT * FROM friends WHERE closeness > 5 ORDER BY closeness") print(с.fetchall()) conn.commit() conn.close()
from random import random def flip_coin(): r = random() if r > 0.5: return "Heads" else: return "Tails" print(flip_coin()) def flip_coin(): if random() > 0.5: return "HEADS" else: return "TAILS" print(flip_coin()) def generate_evens(): ...
import tkinter from tkinter import * top = tkinter.Tk() CheckVar1 = IntVar() CheckVar2 = IntVar() tkinter.Checkbutton(top, text = "Machine Learning", variable=CheckVar1, onvalue=1, offvalue=0).grid(row=0, sticky=W) tkinter.Checkbutton(top, text = "Deep Learning", variable=CheckVar2, onvalue=0, offvalue =1).gr...
import numpy as np import matplotlib.pylab as plt def function_1(x): return 0.01 * x ** 2 + 0.1 * x def numerical_diff(f, x): h = 1e-4 return (f(x+h) - f(x-h)) / (2 * h) x = np.arange(0.0, 20.0, 0.1) y = function_1(x) print(numerical_diff(function_1, 5)) print(numerical_diff(function_1, 10))
import numpy as np def step_function(x): y = x > 0 return y.astype(np.int) print(step_function(np.array([-1.0, 2.0])))
import random def give_clue(word): hinti1 = random.randrange(len(word)) hinti2 = random.randrange(len(word)) def replace_all(hinti): for i in range(len(word)): if word[i] == word[hinti]: cluelist[i] = word[hinti] return cluelist while hinti2 == hinti1: hinti2 = random.randrange(...
for i in range(5): print(' ' * (5 - i), end='') print('*' * (i * 2 + 1)) for i in range(5, -1, -1): print(' ' * (5 - i), end='') print('*' * (i * 2 + 1))
from itertools import product largest_palindrome = 0 def check_palindrome(num): str_num = str(num) if str_num == str_num[::-1]: return True else: return False palindromes = [i * j for i in range(999) for j in range(999) if check_palindrome(i*j)] print(max(palindromes...
height = input("Please enter pyramid Hieght: ") height = int(height) row = 0 while row < height: NumOfSpace = height - row - 1 NumOfStars = ((row + 1) * 2) - 1 string = "" i = 0 while i < NumOfSpace: string = string + " " i += 1 i = 0 while i < NumOfStars: string = string + "*" i +=1 print(s...
ToDo=list() Done=list() print("************************************") print("To Add New Item Press 1") print("To Print the To Do List Press 2") print("To Mark an item as Done Press 3") print("To Print the Done list Press 4") print("************************************") i=1 while i > 0 : choice=input("Please enter you...
def read_large_file(file_handler): for line in file_handler: word_arr= [] for i in line: if(i != " " and i != "/n"): word_arr.append(i) else: yield word_arr word_arr = [] with open('/Python ...
import homework3 as hw3 import itertools def var_name_generator(): name_tab = ['x', 'y', 'z', 'w', 'p', 'q'] counter = itertools.count(1) while True: num = next(counter) stack = [] name = '' while num: num -= 1 stack.append(name_tab[num % 6]) ...
import MoveRobot import SenseLandmarks NUMBER_OF_ITERATIONS = 15 def calibrate_move(): count = 0 while (True): count += 1 if count > NUMBER_OF_ITERATIONS: break MoveRobot.go_forward(MoveRobot.ROBOT_LENGTH_CM) raw_input("Press Enter to continue") def calibrate_turn(): angle = 5 count = 0 w...