How would I implement this in pseudocode?
def isValidScore(score): if len(score) == 0:
return False
if score[0] in ['-','+'] and score[1:].isdigit() == False:
return False
if score.isdigit()== False:
return False
return int(score)<=100 and int(score)>=0
The pseudocode is given below
do give a thumbs up and in case there are doubts leave a comment.
How would I implement this in pseudocode? def isValidScore(score): if len(score) == 0: return False if...
HELP! HOW WOULD I WRITE THIS IN PSEUDOCODE? from itertools import accumulate from collections import Counter def addvalues(a, b): if type(a) is str: a = a.strip("\n") if type(b) is str: b = b.strip("\n") return int(a) + int(b) def maxValues(a, b): if type(a) is str: a = a.strip("\n") if type(b) is str: b = b.strip("\n") a = int(a) b = int(b) return max(a, b) def main(): counter = 0 total = 0 maximum_cars = 0 file = open("MainAndState.dat", "r") maximum =...
LOVOU AWN 1. def remove_all_from_string(word, letter): i=0 3. while i<len(word)-1: if word[i] = letter: num = word.find(letter) word - word[:num] + word[num+1:] i=0 i=i+1 return word 10 print remove_all_from_string("hello", "1") 5 points Status: Not Submitted Write a function called remove_all_from_string that takes two strings, and returns a copy of the first string with all instances of the second string removed. This time, the second string may be any length, including 0. Test your function on the strings "bananas" and "na"....
# Tests for isNumber def test_isNumber_1(): assert isNumber("1") == False def test_isNumber_2(): assert isNumber(-1) == True def test_isNumber_3(): assert isNumber(True) == False def test_isNumber_4(): assert isNumber(3.14) == True def test_isNumber_5(): assert isNumber([0]) == False def isNumber(item): ''' - Return True if item is of type int or type float, otherwise return False. - You can check if item is an int with type(item) == int, and a float with type(item) == float ''' return "stub"
HI I would like to ask how to write the function when my list is
[[1,2,4],[0,3,2]]. Like merging them. I managed to do it separately
only. The mean for [1,2,4] is 2.33 and so xbar return me
[-1.33,-0.33,1.67] (is like [1,2,4] minus the 2.33. I need help for
more lists. Thanks
>>> def mean(Ist): return sum(Ist)/len(Ist) >>> def xbar(data): i = 0 a = mean(data) for i in range(len(data)): data[i] -= a i += 1 return data >>> xbar([1,2,4]) [-1.3333333333333335,...
def sorted(numbers): num = numbers[0] for i in numbers: if i < num: return False num = i return True State a best-case and a worst-case scenario for your algorithm. Explain the Big-O complexity of each scenario. Use comparison as the basic unit of computation. Take into account the complexity of any list operation you use
Write a PSEUDOCODE for the following print screen:
def houseCalc (salary) payment((float (salary) 0.25))/12; return payment annualsalary = int (input ("Enter your yearly salary: ")) payment houseCalc (annual_salary) print ("The monthly housing payment shouldn't be more than: ", payment) -
convert the following code from python to java.
def topkFrequent(nums, k): if not nums: return [ ] if len(nums) == 1: return nums [0] # first find freq freq dict d = {} for num in nums: if num in d: d[num] -= 1 # reverse the sign on the freq for the heap's sake else: d[num] = -1 h = [] from heapq import heappush, heappop for key in di heappush(h, (d[key], key)) res = [] count = 0...
def slice_list(lst: List[Any], n: int) -> List[List[Any]]: """ Return a list containing slices of <lst> in order. Each slice is a list of size <n> containing the next <n> elements in <lst>. The last slice may contain fewer than <n> elements in order to make sure that the returned list contains all elements in <lst>. === Precondition === n <= len(lst) >>> slice_list([3, 4, 6, 2, 3], 2) == [[3, 4], [6, 2], [3]] True >>> slice_list(['a', 1, 6.0, False],...
def average_word_length(string): num_words = 0 if not type(string)==str: return "Not a string" if not "A" or not "B" or not "C" or not "D" or not "E" or not "F" or not "G" or not "H" or not "I" or not "J"\ or not "K" or not "L" or not "M" or not "N" or not "O" or not "P" or not "Q" or not "R" or not "S" or not "T"\ or not "U" or not "V" or not...
identify the code that sorts the numbers in descending order. def selection_sort(numbers): for i in range(len(numbers) - 1): index = i XXX temp = numbers[i] numbers[i] = numbers[index] numbers[index] temp for j in range(i + 1, len(numbers): if numbers[j] > numbers[index]: index اله for j in range(i - 1, len(numbers): if numbers[j] > numbers[index]: index j for j in range(i + 1, len(numbers)): if numbers[j] < numbers[index]: index j for j in range(i 1, len(numbers): if numbers [j] < numbers[index]:...