Write a function that takes a string as an argument checks whether it is a palindrome. A palindrome is a word that is the same spelt forwards or backwards. Use similar naming style e.g. name_pal. E.g. If we call the function as abc_pal(‘jason’) we should get FALSE and if we call it a abc_pal(‘pop’) we should get TRUE.
Hint: define your function as abc_pal(str). This indicates that string will be passed. Next create two empty lists L1=[] and L2=[] . Also create counter and set it to zero (e.g. i = 0). Now use a while loop e.g. while i < len(str) and use the append method to fill both empty lists i.e. List1.append(str[i]] and for list2 you need to reverse the order of filling i.e. L2 will be filled from the last letter to the first letter of the argument string. Lastly check if L1 is equal to L2 if the string is an anagram, simply use return L1==L2 this will return TRUE or FALSE as the case may be.
NB: Please use spider in anaconda(python) and include a picture of the code
In: Computer Science
HOW CAN I USE a string instead of array tries and res on this assignment, with out impacting the program or modifying too much on conditions check code bellow
import java.util.Scanner;
import java.util.Random;//starter code provided
public class inputLap
{
public static char roller;
public static String playerName;
public static int printed=0;
public static int rounds=8,lives=0,randy;
public static int tries[]=new int[4];//use arrays to store number
of tries in each life
public static int res[]=new int[4];
public static String getName(String aString){
Scanner sc= new Scanner(System.in);
System.out.println("enter player's Name:");aString=sc.next();
playerName=aString;
return playerName;
}
public static void menu()
{
Scanner sc= new Scanner(System.in);
if(lives<=4){
System.out.println("Do you want to continue?(y/Y):\n (x/X) to exit.
");roller=sc.next().charAt(0);
}
}
public static int getGame() {
Scanner sc = new Scanner(System.in);
System.out.println("make a guess from 1-20");
int Guessed = sc.nextInt();
return Guessed;
}
public static void main(String[] args) {
String name=getName(playerName);
Random r = new Random();
int answer=0;
int f=0;
while(true) {
randy=r.nextInt(20);
for (int i=0;i<=7;i++)
{
answer=getGame();
rounds--;
if(answer==randy)
{
lives++;
System.out.println("congratulation you are right");
tries[lives-1]=8-rounds;
res[lives-1]=1;
rounds=8;
break;
}
else
{
System.out.println("you have "+(rounds)+" remaining");
}
if(rounds==0){
if(lives!=4){
tries[lives]=8;
lives++;
System.out.println("hard luck\nyou have "+(4-lives)+" lives
left");
f=1;
}
}
if(f==1){
f=0;
break;
}
}
menu();
switch( roller)
{
case 'y':
case 'Y':rounds=8;break;
case'x':
case 'X':
lives=5;
System.out.println("Game No Game 1 Game 2 Game 3 Game 4");
System.out.print("Number of tries ");
printed=1;
for(int i=0;i<4;i++)
System.out.print(tries[i]+" ");
System.out.println();
System.out.print("Result \t");
for(int i=0;i<4;i++){
if(res[i]==1)
System.out.print("Success ");
else
System.out.print("Fail");
}
System.out.println("\nbye bye "+playerName+" !!");
break;
}
if(lives>4)
break;
}
if(printed!=1){
System.out.println("Game No Game 1 Game 2 Game 3 Game 4");
System.out.print("Number of tries ");
for(int i=0;i<4;i++)
System.out.print(tries[i]+" ");
System.out.println();
System.out.print("Result\t");
for(int i=0;i<4;i++){
if(res[i]==1)
System.out.print("Success ");
else
System.out.print("Fail");
}
System.out.println("\nbye bye "+playerName+" !!");
}
}
}
In: Computer Science
NEED at least 1000 Words on this Please
Discuss how physical security plays a huge role in the security information security infrastructure. Include discussions on Risk Assessment and Business Continuity Planning.
In: Computer Science
If you run the binary search method on a set of unordered data, What happens? Why? How you would correct this issue?
In: Computer Science
3. For this week’s assignment, you are asked to modify the above Java program to include the following: - When the user clicks on the help menu, a drop-down list will appear with an item called About, then when the user clicks on it, the window will show some instructions about the functionality of the menu, e.g, what the edit menu does, etc. - When the user clicks on the File menu, a drop-down list will appear with one item called Show Picture, and when the user clicks on it, a picture of your choice will appear
import javax.swing.*;
public class MenuFrame extends JFrame {
public MenuFrame() {
setTitle("Menu Frame");
setSize(500, 500);
MenuListenerExample myMenu = new
MenuListenerExample();
setJMenuBar(myMenu);
setLayout(null);
add(myMenu.textArea);
}
public static void main(String[] args) {
MenuFrame frame = new MenuFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
import javax.swing.*;
import java.awt.event.*;
public class MenuListenerExample extends JMenuBar
{
JMenu fileMenu, editMenu, helpMenu;
JMenuItem cut, copy, paste,
selectAll,about,showPicture;
JTextArea textArea,textArea1;
public MenuListenerExample() {
cut = new JMenuItem("cut");
copy = new JMenuItem("copy");
paste = new JMenuItem("paste");
selectAll = new JMenuItem("selectAll");
about=new JMenuItem("about");
showPicture=new JMenuItem("show");
textArea = new JTextArea();
textArea1 = new JTextArea();
cut.addActionListener(new MenuAction());
copy.addActionListener(new MenuAction());
paste.addActionListener(new MenuAction());
selectAll.addActionListener(new
MenuAction());
about.addActionListener(new MenuAction());
showPicture.addActionListener(new
MenuAction());
fileMenu = new JMenu("File");
editMenu = new JMenu("Edit");
helpMenu = new JMenu("Help");
editMenu.add(cut);
editMenu.add(copy);
editMenu.add(paste);
editMenu.add(selectAll);
helpMenu.add(about);
fileMenu.add(showPicture);
add(fileMenu);
add(editMenu);
add(helpMenu);
textArea.setBounds(30, 30, 430, 400);
textArea1.setBounds(30, 30, 430, 400);
}
private class MenuAction implements ActionListener
{
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cut) {
textArea.cut();
}
if (e.getSource() == paste) {
textArea.paste();
}
if (e.getSource() == copy) {
textArea.copy();
}
if (e.getSource() == selectAll) {
textArea.selectAll();
}
if (e.getSource() == about) {
JFrame frame = new JFrame("about");
textArea1.setText("This is simple Notepad
Application\n"+"1.File : It has show picture option\n"
+"Edit : It has three option
cut,copy,selectall\n"+
"help : It has about option which show
function\n");
textArea1.setEditable(false);
frame.add(textArea1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
Replace if statements and use the switch statement
i need output show pictures in file menu
Image path is
C:\\Users\\DGL2\\Desktop\\3840.jpg_wh860.jpg
In: Computer Science
(Duplicate Elimination) Use a one dimensional array to slove the following problem. Read 20 numbers, each of which is 10 and 100, inclusive. As each number is read, print it only if it's not a duplicate of a number already read. Provide for the "worst case" in which all 20 numbers are different. use the smallest possible array to slove this problem.
Add the following functionality to your solution. Sort the array in ascending order and print the elements of the sorted array.
if you could please explain each line of the code that would be wonderful.
In: Computer Science
For each of the following statements, state whether the statement is true or false AND justify your answer.
In: Computer Science
Question 4
4.1. Explain each of the ways data can be inputted into a programming environment. (10)
4.2. Discuss each step in the requirements analysis phase of programming. (20)
In: Computer Science
In Python: Program. At the university, passwords for the campus computer system must meet the following requirements:
Start by translating the pseudocode below into a python function. Add the last two requirements to your function.
In: Computer Science
Write a Java program that defines two boolean variables a and b and shows that regardless of the values of a and b, the expressions (a && (a || b)) and a are always the same.
In: Computer Science
Using any existing 2D or 3D graphics library ( such as Java 2D, Java 3D or OpenGL ) draw a scene featuring various elements. You are to choose from one of the following categories:
3. Any visual landscape element of your choice (Using OpenGL with Java or Python )
You are free to create whatever you choose but it must conform to the following guidelines.
In: Computer Science
1. In the command fprintf within the string statement what operator executes a linefeed?
() (4 points).
A. \n B. \l C. \d D. /n
2. To multiply two arrays element-by-element, what operator must you use? ( ) (4 points).
A. + B. * C. .* D. ./
3. The default base of log function in MATLAB is ( ) (4 points).
A. e B. 2 C. 10 D. 5
4. Which one of the following is a valid placeholder in an fprintf statement ( ) (4
points).
A. %d B. %n C. %p D. %r E. %v
5. Which of the following names is NOT a valid name for a user-defined function? ( )
(4 points).
A. Poker B. Bla4jack C. Solitare8 D. Card-Pickup
6. If mathematical expressions are written in MATLAB without required parentheses,
operations start from left to right in order. (True or False) ( ) (4 points).
7. A MATLAB code is saved with .m extension while functions are saved with .f
extension. (True or False) ( ) (4 points).
8. Every variable used in a MATLAB code appears in the workspace until they are
cleared. (True or False) ( ) (4 points).
9. MATLAB automatically puts comments in our codes when we create codes and save
them in an M-File. (True or False) ( ) (4 points).
10. A function must return numerical outputs. (True or False) ( ) (4 points).
11. Write commands to generate a 3x5 array containing random numbers between 1 to 21 and then assign this array to A. Transpose A and assign to B. Sort the rows of B based on the 2nd column in a descending order and assign it to C. (15)
12. Write commands to create the following graph using the following parameters. All the elements in the graph must be addressed by commands. (20
-? < ? < ?
Y=sin(?),
Z=log(?).
13. According to the trajectory line (below), the height(m) y=v0sin(?)t-gt2/2. Given the initial velocity is 2 m/s, please write a user-defined function to calculate the initial ? degree, and write commands to test your function program to calculate ? in degree when height=0.0786 m and t=0.2 s. (25)
In: Computer Science
How do we separate end-users security policies from the infrastructure security policies on the windows server?
In: Computer Science
Computer Architecture:
Write a MIPS program to compute f = g - (f + 5)
Assume registers $to, $s1 hold values for g and f
respectively.
The program should display the following prompts and read value
entered by the user “Enter a value for f:"
“Enter a value for g:"
The program the prints: "Answer for f = g - (f + 5):"
The program should repeat the above steps 3 times for each input
pair, f and g
Make certain that your assembly code is properly organized (indented, commented, contains your name at the top of the code). Comment any assumptions at the top and include results showing the working code via screen prints
In: Computer Science
1. The community college you work for would like to
get a security test performed, explain the different test types and
the advantages and disadvantages of them
.2. The community college now wants to have a security company come
in and perform security tests. Explain what they should expect
before, during, and after the testing.
In: Computer Science