Manipulating Strings
Manipulating strings are an important part of programming. When I first started I had quite a few assignments on just taking the strings apart and doing different manipulations to them. This helped me understand programming logic and ended up helping me a lot with future database programs. String manipulations can be done in programming, database, and reports which make it essential to know.
Class, have you been practicing some string manipulations? Any tips or tricks?
Dealing with Python Code language: Any enlightenment on this subject would help not just with the discussion question but to better understand this topic.
Thanks,
In: Computer Science
In C++, cstring is implemented as an array of characters. What is the difference between cstring and a regular array of characters? In other words, how do you distinguish them?
In: Computer Science
In: Computer Science
Python Programming, Could you also show the right indents in Python Shell. Below are the skeleton of the program, and the input and output.
# Initialize list
mylist = [ ]
# Set up loop to put menu on screen
num = 1
while num != 0:
print(" ")
print(" ")
print(" Menu ")
print ("0 - Quit")
print ("1 - Add item to list")
print ("2 - Pop item off list and print it")
print ("3 - Print list")
print ("4 - Sort list")
print ("5 - Reverse list")
snum = input("Enter choice from menu ")
num = int(snum)
print (" ")
Put your if or if-else or if-elif statements here
(They will be inside the while
loop)
You should start this lab by entering the above program and saving it as Week5LabA in your Python Programs folder. Then run it to see how it displays the menu. Note that you can enter 0, 1, 2, 3, 4, or 5 in response to the menu choices. Your entry will be assigned to the variable num. Entering a 0 will end the program.
Your other entries (1, 2, 3, 4, or 5 ) should cause something to be done with the list that is called mylist. You will note that mylist has been initialized to the empty list with the mylist = [ ] statement.) For example, if you enter a 1 (value of num is 1), the program should ask you to enter a value to be placed on the list and then append it onto the list. As another example, if you enter a 3 (value of num is 3), the program should print the list using the statement, print(mylist).
The video below shows what the original program (the one I gave you above) should do and how you can enter the if statement for a value of 1 for num.
View video to get started=> https://youtu.be/PxTwMpBFFas
The following is a sample execution of the program. The following integers were placed on the list: (Values entered by the user are in red.)
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 1
Enter value to put on list 3
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 1
Enter value to put on list 7
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 1
Enter value to put on list 9
The following operations were performed on the list:
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 3
[3, 7, 9]
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 4
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 5
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 3
[9, 7, 3]
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 2
Value popped = 3
Menu
0 - Quit
1 - Add item to list
2 - Pop item off list and print it
3 - Print list
4 - Sort list
5 - Reverse list
Enter choice from menu 3
[9, 7]
In: Computer Science
Respond to the following in a minimum of 175 words:
One of the most important concepts of programming is handling input and output. The following activity will allow you to get familiar with this concept specifically when using PYTHON.
Write a function to add two values and display the results. (Please show me where indentation goes as well, I'm not only seeking guidance on answers I'm trying to understand this so I can learn).
Discuss the steps in your thought process as you created the code, any issues you encountered, and how you solved those issues.
In: Computer Science
Read the following code:
x = 1
while(x < 26)
print(x)
x = x + 1
There is an error in the while loop. What should be fixed?
Add a colon to the end of the statement Begin the statement with the keyword count Change the parentheses around the test condition to quotation marks Use quotation marks around the relational operator
Question 2(Multiple Choice Worth 5 points)
(03.03 LC)
Python uses __________ to determine whether the condition of a
while loop is true or false.
algebra artificial intelligence Boolean logic input
Question 3(Multiple Choice Worth 5 points)
(03.03 LC)
What is the proper syntax for writing a while loop in Python?
Begin the statement with the keyword repeat End the statement with a semicolon Place the test condition outside of parentheses Use relational operators to indicate test conditions
Question 4(Multiple Choice Worth 5 points)
(03.03 LC)
What is the purpose of using a while loop in Python?
To repeat an action when the condition is false To repeat an action when the exact number of repetitions is known To repeat an action when the exact number of repetitions is unknown To repeat an action when the condition is not stated
Question 5(Multiple Choice Worth 5 points)
(03.03 MC)
Read the following code:
n = 2
while(n < 5):
print(n)
n = n + 1
What output would be produced for the given values of n?
0 1 2 3 4 1 2 3 4 5 2 3 4 2 3 4 5
In: Computer Science
Create JAVA PROGRAM, and write comment for codes also.
1) Let the user enter in candidate names for a ballot. Then imagine the program is moved to a voting booth. Each voter enters their unique name and who they vote for, and when there are no more voters display who won. (Imagine something outside your program is telling it there are no more voters.)
In: Computer Science
PLEASE DO IN JAVA
4.15 Palindrome
A palindrome is a string that is the same spelled forward as it is spelled backward. So, "abcba" is a palindrome, as are "eye" and "madam". This program takes as input from the user, a string and outputs whether the string is a palindrome.
(1) Modify the given program to use a loop to output the string one character at a time. (1 pt)
Example output for word = radar:
Word Entered: radar r a d a r
(2) Now modify the program to use a loop to output the string in reverse order one character at a time. (2 pt)
Example output for word = read:
Word Entered: read r e a d Word Reversed: d a e r
(3) Finally, modify the program to check character-by-character the string given by the user to see whether or not the string is a palindrome, and then prints either "Yes" or "No". For example, if the input string is "abba" or "rotator", the output would be "Yes". If the input string is "cat" or "garbage", the output would be "No". You may ignore punctuation, in that the test strings used for this program do not contain any. You may also assume all lowercase letters will be used in the test strings.
Note: The strings may be of odd or even length, as in "cat", "dad", "racecar", or "hannah". (8 pt)
Example output for word = radar:
Word Entered: radar r a d a r Word Reversed: r a d a r Yes
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
/* Your Code Here */
return;
}
THANK YOU SO MUCH
In: Computer Science
Design and construction of a multipurpose security
system with alarm and display
A. Provide the activities sequence with bar chart.
B. work breakdown structure
In: Computer Science
Use the Chinese remainder theorem. Say that:
x = 6 mod 10
x = 4 mod 9
x = 2 mod 7
Find what is x modulo 10 · 9 · 7.
Please show all work and the correctness of your analysis.
In: Computer Science
Objective
This assignment is to review what you should have learned in CSC 142 and learn how I want you to do pseudocode and commenting for 143. Here’s the highlights this assignment will focus on:
Indefinite Loops
File Processing
Arrays
Classes
Description
You will choose a subject that’s familiar to you and create a program to read an inventory of items. You will create a java Class to hold the items, store them into an array of that class, and print a filtered set of them using a fencepost loop.
As an example, I created an inventory of fly fishing rods. Here’s a sample input file and console output:
Manufacturer Type Weight Length
Sage Standard 5 108
Sage Spey 9 132
TFO Standard 8 108
Orvis Standard 4 96
Which Field to filter on? Manufacturer
Enter the string: sage
Rod [Manufacturer=Sage, Type=Standard, Weight=5, Length=108]
Rod [Manufacturer=Sage, Type=Spey, Weight=9, Length=132]
Which Field to filter on? type
Enter the string: spey
Rod [Manufacturer=Sage, Type=Spey, Weight=9, Length=132]
Which Field to filter on? w
Enter the value: 5
Rod [Manufacturer=Sage, Type=Standard, Weight=5, Length=108]
Which Field to filter on? l
Enter the value: 108
Rod [Manufacturer=Sage, Type=Standard, Weight=5, Length=108]
Rod [Manufacturer=TFO, Type=Standard, Weight=8, Length=108]
Requirements
Your inventory must have the following:
At least 10 items
At least 4 fields with 2 different data types
The names of the fields should start with different letters to make it easier to code
Phase 1 - Pseudocode
You will write some brief pseudocode for your code so I can give you feedback your project before you go through writing the code.
Start by identifying a subject you’re familiar with which has a list of items you can put together. Then create the design for a Java Class to hold those items.
See the “What is Pseudocode” page for information on how to write pseudocode and “Simple Guidelines” for what is correct pseudocode.
Phase 2 - Coding
You will write the complete code for your project and submit both the code, output, and debugging.
Code Requirements
Name the client class with main “Inventory” with matching case. This is extremely important or your code won’t run in my test environment.
Put all classes into one file by omitting the “public” from all but the first
Javadoc function headers with explanations of the function purpose, inputs, and returns
Comments above each code block, blank lines separating blocks that carry out one purpose, but none within the block
Do not comment each line, or lines which are obvious (e.g. print a blank line)
Data must be encapsulated as best as you can
Your main() should be a small as possible
All the real work should be in several very methods with clear purposes.
Ignores upper and lowercase
Accepts any input with the correct first letter in upper or lowercase
In: Computer Science
java programming question: "Write a program that displays a page on a topic of interest to you (e.g., a sport, a city). Include at least one image and one shape (which can be text). " I wanted to do a soccer page but I don't know how to put pictures from the internet on Java. As for my object, I wanted to make a soccer ball. My professor has been really confusing in explaining graphics so any help is appreciated!
In: Computer Science
Create JAVA PROGRAM, and write comment for codes also.
4) Prompt the user for how much stuff a truck can carry, in pounds. Then ask them for the weight of each thing they add until they stop. Don't forget to be safe.
In: Computer Science
Create JAVA PROGRAM, and write comment for codes also.
2) Every extra 3500 calories means gaining a pound. Falling short by 3500 means losing a pound. Get the base amount of calories the person needs in a day (BMR). Then have the user enter in calorie totals for each day and display their weight every week. They might eat more than once in a day.
In: Computer Science
Create JAVA PROGRAM, and write comment for codes also.
3) You want to keep track of your progress towards running a 10K. There are two kinds of races - 5K and 10K. The program needs to ask what race was run and what the time was in seconds until the user quits. When they quit, display the average and best time for each type of race in minutes.
In: Computer Science