Answer:
userInput = str(input("Enter your sentence here.\n")).upper()
def getPigLatin(userInput):
splitInput = userInput.split(" ")
newList = []
for word in splitInput:
firstLetter = word[0]
if len(word) == 1:
word += 'AY'
newList.append(word)
else:
word = word.strip(word[0])
word += firstLetter
word += 'AY'
newList.append(word)
print(*newList, sep= " ")
getPigLatin(userInput)
Explanation:
This solution is done in Python
First the user is prompt to enter a statement, the statement converted to string and also capitalize using str and upper() built-in function. The user input is assigned to userInput variable.
The getPigLatin function is defined and it accept a string as parameter. Inside the getPigLatin function, the userInput is splitted and assigned to splitInput variable.
An empty list is also initialized and assigned to newList. Next, we loop through the splitInput. During the loop; we first check if the length of an element is one, then we just add 'AY' to the element and add the element to the newList. Else, if the element length is more than one; we strip the first letter from the word and also re-assign it to word, then the stripped first letter is added to the end of the word. Next, 'AY' is added to the word and the element is add to the newList.
The last line of the getPigLatin function display the entire element of the list using a space seperator.
The last line of the entire solution call the function passing in the userInput as argument.
Answer:
Merge Sort algorithm uses Divide and Conquer technique.
Explanation:
The technique used by merge sort algorithm is Divide and Conquer because merge sort in it's every iteration divides the array in two equal halves and then sorts them.
Merge sort keeps on dividing the array in two equal halves until there is only one element left in the array.Then it merges every element in sorted order.
Answer:
Check the explanation
Explanation:
.data
prompt: .asciiz "Please enter your string :"
result_str: .asciiz "\nYour captalized string :"
error_prompt: .asciiz "\nInvalid Entry !"
buffer: .space 20
.text
.globl __start
__start:
ASKING_STR:
la $a0,prompt
li $v0,4
syscall
li $v0,8 #take in input
la $a0, buffer #load byte space into address
li $a1, 20 # allot the byte space for string
move $t0,$a0 #save string to t0
syscall
li $v0, 4
li $t0, 0
loop:
lb $t1, buffer($t0)
beq $t1, 0, exit
slti $t2,$t1,91
bne $t2,$0,UPPER_CHECK
slti $t2,$t1,123
bne $t2,$0,LOWER_TO_UPPER
UPPER_CHECK:
slti $t2,$t1,65
bne $t2,$0,INVALID_ENTRY
slti $t2,$t1,90
bne $t2,$0,NEXT
j INVALID_ENTRY
LOWER_TO_UPPER:
sub $t1, $t1, 32
sb $t1, buffer($t0)
NEXT:
addi $t0, $t0, 1
j loop
INVALID_ENTRY:
li $v0, 4
la $a0, error_prompt
syscall
j ASKING_STR
exit:
li $v0, 4
la $a0, result_str
syscall
li $v0, 4
la $a0, buffer
syscall
li $v0, 10
syscall
Isolation. Also is known as Lockout-Tagout. I hope this helps.