An 'array palindrome' is an array, which, when its elements are reversed, remains the same. Write a recursive function, isPalindrome, that accepts a tuple and returns whether the tuple is a palindrome. A tuple is a palindrome if: the tuple is empty or contains one element the first and last elements of the tuple are the same, and the rest of the tuple is a palindrome

Answers

Answer 1
Answer:

Answer:

Following are the program in the Python Programming Language.

#define function

def isPalindrome(test):

#set the if condition to check tuple is empty

 if(len(test)==0):

   return True

#Check the tuple contain 1 element

 elif(len(test)==1):

   return True

#check the element of tuple is palindrome or not

 else:        

   lenth=len(test)

   #check first last element is equal or not

   if(test[0]==test[lenth-1] and isPalindrome(test[1:lenth-1] ) ):

   #then, return true

     return True

   #otherwise

   else:

   #Return False,

     return False

#define tuple type variable and initialize

test=(1,2,3,4,3,2,1)

#print and call the function

print(isPalindrome(test))

Output:

True

Explanation:

Here, we define a function "palindrome()" and pass an argument in its parameter, inside the function.

  • Set the if conditional statement to check the following tuple is empty or not if the tuple is empty then, it returns true.
  • Set the elif conditional statement to check the following tuple containing one element, then it returns True.
  • Otherwise, we set the length of the tuple in the variable "lenth".
  • Then, set if conditional statement to check the first and the last element of the tuple is the same then, returns true.
  • Otherwise, it return false.

Related Questions

A ________ topology uses more than one type of topology when building a network. crossover multiple-use fusion hybrid
Discuss and compare shared and switch Ethernet
Problem 1 (10%): You are asked to design a database for an auto-shop that satisfies the following requirements: a. Each customer has a unique customer identification number, a name, address, day time telephone number, evening telephone number. The customer name includes first name, middle initial and last name. The address includes street address, city, state, and zip code. The telephone numbers include area code and the number. b. Each car type has a unique type name, the make, model, and year of make. c. The car has a unique license number, a car type, color, type of transmission, and the customer who brings the car to the auto-shop. d. The database keeps records of repairs. The repair record includes the date of the repair, the car that the repair was done, the name of the engineer who did the repair, and the cost of the repair.
A mobile device user is having problems launching apps and texting. The user touches an app to launch it, but the app icon next to the desired app launches instead. When the user types a text message, every word in the message is misspelled. What is the most likely cause for this behavior?
What is the most important trait of the first pilot project in the AI Transformation Playbook?

A babysitter charges $2.50 an hour until 9:00 PM when the rate drops to$1.75 an hour (the children are in bed). Write a program that accepts astarting time and ending time in hours and minutes and calculates the totalbabysitting bill. You may assume that the starting and ending times are ina single 24-hour period. Partial hours should be appropriately prorated.

Answers

Answer:

print("enter starting time hours")

st_hours=int(input()) #starting time hours

print("minutes")

st_minutes=int(input()) #starting time minutes

print("enter ending time hours")

et_hours=int(input()) #ending time hours

print("minutes")

et_minutes=int(input()) #ending time minutes

cost=2.50

if (st_hours<21 and et_hours>21): #if starting time is less than 21 and ending time is greater than 21

a_hours=et_hours-21

a_minutes=et_minutes #taking time after 21 from ending time ending time-21

time_minutes=60-st_minutes #converting all the time into minutes

time_hours=21-(st_hours+1)

time_hours=time_hours*60

time=time_hours+time_minutes

cost=(cost/60)*time

time=(a_hours*60)+a_minutes

cost=cost+(1.75/60)*time

print("cost=$",cost)

elif(st_hours>=21): #if starting time is greater than 21

time_hours=et_hours-(st_hours+1)

time_minutes=(60-st_minutes)+et_minutes #converting time into minutes

time=(time_hours*60)+time_minutes

cost=(1.75/60)*(time)

print("cost=$",cost)

elif(et_hours<=21): #if ending time is less than 21

time_hours=et_hours-(st_hours+1)

time_minutes=(60-st_minutes)+et_minutes

time=(time_hours*60)+time_minutes

cost=(2.50/60)*time

print("cost=$",cost)

Explanation:

This is a conditional program, the conditions applied are if and else if.

The resultant output was gotten using this three steps:

(1) If starting time is less than 21 and ending time is greater than 21

Then I converted the time into minutes before 21

ex:- 8:30

21-9= 12*60= 720 + 30 = 750

Then I calculated the bill.

750 * (2.50 / 60)

Then I converted the time after 21 and then calculated the bill and printed it.

(2)If starting time is greater than 21

Converted time into minutes and multiplied it with (1.75 / 60) to get the bill.

(3) If ending time is less than 21

Converted time into minutes and multiplied it with (2.50 / 60) to get the bill.

Please check attachment for program code screenshot.

What is not an operating system

Answers

The answer is MS-Word

Write a program that reads an integer and displays, using asterisks a filled and hollow square, placed next to each other. for example if side length is 5 the program should display like so.This program prints a filled and hollow square.
Enter the length of a side: 5
***** *****
***** * *
***** * *
***** * *
***** *****

Answers

Answer:

Here is the JAVA program.

import java.util.Scanner; //Scanner class to take input from user

 public class HollowFilledSquare {

          public static void main(String[] args) { //start of main() function body

    Scanner sc= new Scanner(System.in); // Scanner class object

          System.out.print("Enter an integer to display a filled and hollow square "); //prompts user to enter an integer

           int n = sc.nextInt(); // reads integer input from the user

          StringBuilder filled = new StringBuilder(n);

// creates objects filled and hollow of class StringBuilder

          StringBuilder hollow = new StringBuilder(n);

          for (int i = 1; i <= n; i++) { // outer loop for length of the square

              for (int j = 1; j <= n; j++) { // inner loop for width of square

                  filled.append("*"); //displays asterisks

                    if (i == 1 || i == n || j == 1 || j == n) // condition to display stars

                       {hollow.append("*");}

                   else

                     {  hollow.append(" ");  }             } // to display empty spaces

           System.out.println(filled + "   " + hollow);

// places hollow and filled squares next to each other

           filled. delete(0, filled.length());  

//removes characters from 0 to the length of filled square

           hollow. delete(0, hollow.length());      

//removes characters from 0 to the length of hollow square } }  }

Explanation:

The program first prompts the user to enter an integer. It uses outer loop for length of the square and inner loop for width of square in order to display the asterisks. append () function is used to display the sequence of asterisks. delete () function removes the  asterisks from the sequence of asterisks. String Builder is a class used for to create a string of n characters. It basically works like String but this is used to create modifiable objects.

The screen shot of the code along with the output is attached.

Final answer:

A Python program can be written to read an integer that is then used to print out two squares of that side length with asterisks, one filled and one hollow. The provided Python code uses nested loops and conditionals to generate the squares accurately.

Explanation:

To complete your request, we would need to write a program to read an integer input and utilize this integer value to generate two squares with asterisks, one filled and one hollow. Here is a simple Python program:

def print_squares(n):
# Full square
for i in range(n):
 for j in range(n):
  print('*', end=' ')
 print()

# New line between squares
print()

# Hollow square
for i in range(n):
 for j in range(n):
  if i==0 or i==n-1 or j==0 or j==n-1:
   print('*', end=' ')
  else:
   print(' ', end=' ')
 print()

# Run the function
print_squares(int(input('Enter the length of a side: ')))

This program first prints a filled square and a hollow square using conditionals to distinguish between the edge and inner positions of the squares.

Learn more about Python programming here:

brainly.com/question/33469770

#SPJ3

IN PYTHON Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value.

Ex: If the input is:

Enter the number of integers in your list: 5
Enter the 5 integers:
50
60
140
200
75
Enter the threshold value: 100
the output is:

The integers that are less than or equal to 100 are:
50
60
75

The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. Such functionality is common on sites like Amazon, where a user can filter results. Your code must define and call the following two functions: def get_user_values() def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold) Utilizing functions will help to make your main very clean and intuitive.

Answers

Answer:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

 for value in user_values:

     if value < upper_threshold:

         print(value)  

def get_user_values():

 n = int(input())

 lst = []

 for i in range(n):

     lst.append(int(input()))

 return lst  

if __name__ == '__main__':

 userValues = get_user_values()

 upperThreshold = int(input())

 output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)

Explanation:

A(n) _____ is a harmful program that resides in the active memory of the computer and duplicates itself.Worm
Virus
Keylogger
Timebomb

Answers

Answer: Worm

Explanation: Worm is the malicious software program which acts as the infection in the computer system. It has the ability to replicate itself and spread in the other systems .It is found in those parts that have automatic operation and non-noticeable.

The effect of the worm is slowing down the operations ,disturb the network etc.Other options are incorrect because virus is the malicious program that infects the host, key-loggers are used for monitoring of system and  time bomb is the program for releasing the virus in computer network. Thus, the correct option is worm.

What type of object can offer the mosteffective way to display data and calculations in a presentation?

Answers

I think the answer would be a chart. It is important for researchers to use the most effective chart to display their data results.

A graph or a table.

You can use a graph or a table to make the point muchstronger than just describing the data. A graph can be used to represent one ofmore sets of data graphically. A table in this case as compared to a graph isless effective because it only shows the data whereas the graph shows an interpretationof data. However, you can use a table from an excel sheer to enter raw data and make some complex andsimple calculations.