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.
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.
Enter the length of a side: 5
***** *****
***** * *
***** * *
***** * *
***** *****
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.
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.
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):This program first prints a filled square and a hollow square using conditionals to distinguish between the edge and inner positions of the squares.
#SPJ3
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.
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:
Virus
Keylogger
Timebomb
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.
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.