Answer:
Hmm.. Try researching, I'm sure you'll find something there..
Building a String Library
Sometimes when programming you need to introduce a new data type and develop a library of functions for manipulating instances of that data type. Often this is done as methods on a new class but not always.
In this assignment, you'll be defining a collection of functions on strings, most of which already exist as methods on the str class. However, you should pretend that they don't already exist and define them as functions. Of course, you can't just use the existing methods. This will give you a bunch of practice on manipulating strings and also on defining functions.
In this assignment, you'll be defining a collection of functions on strings. You should define each of these as a new function with a function header as below. The description of each is in the comment supplied. Recall that strings are immutable, so you will have to return a new copy of the string for those that call for you to return a string. If you are returning the same string as the input, just return it; there is no need to make a new copy, and it wouldn't anyway.
The only string functions/methods to use:
ord, chr
indexing and slicing
append (i.e., ``+'')
len, in, not in
equality comparison (== or !=))
Looping over strings (while or for loops) and selection (if statements) are allowed. BUT You cannot convert the strings to other types such as lists.
Define each of the following functions, with semantics as indicated by the comment. In each of the following ch is a single character, str, str1, str2 are strings, and i is a non-negative integer. You do not have to validate the inputs, except as indicated; you can assume these types.
At least one question asks you to return two values. That really means returning a tuple (pair) of values. You do that as follows:
return value1, value2
This actually returns the pair (value1, value2). The caller can then assign the members of the pair to two variables:
x, y = pairReturningFunction() # assumes function returns a pair
z, w = (value1, value2) # assigning a tuple to 2 variables
If you like, you can use earlier functions in later ones, or define helper functions, though it shouldn't really be necessary. Note that some of these are trivial to write, while others are a bit harder. I have done the first one for you.
def myAppend( str, ch ):
# Return a new string that is like str but with
# character ch added at the end
return str + ch
def myCount( str, ch ):
# Return the number of times character ch appears
# in str.
def myExtend( str1, str2 ):
# Return a new string that contains the elements of
# str1 followed by the elements of str2, in the same
# order they appear in str2.
def myMin( str ):
# Return the character in str with the lowest ASCII code.
# If str is empty, print "Empty string: no min value"
# and return None.
def myInsert( str, i, ch ):
# Return a new string like str except that ch has been
# inserted at the ith position. I.e., the string is now
# one character longer than before. Print "Invalid index" if
# i is greater than the length of str and return None.
def myPop( str, i ):
# Return two results:
# 1. a new string that is like str but with the ith
# element removed;
# 2. the value that was removed.
# Print "Invalid index" if i is greater than or
# equal to len(str), and return str unchanged and None
def myFind( str, ch ):
# Return the index of the first (leftmost) occurrence of
# ch in str, if any. Return -1 if ch does not occur in str.
def myRFind( str, ch ):
# Return the index of the last (rightmost) occurrence of
# ch in str, if any. Return -1 if ch does not occur in str.
def myRemove( str, ch ):
# Return a new string with the first occurrence of ch
# removed. If there is none, return str.
def myRemoveAll( str, ch ):
# Return a new string with all occurrences of ch.
# removed. If there are none, return str.
def myReverse( str ):
# Return a new string like str but with the characters
# in the reverse order.
Expected output:
>>> from MyStringFunctions import *
>>> s1 = "abcd"
>>> s2 = "efgh"
>>> myAppend( s1, "e" )
'abcde'
>>> myCount( s1, "e")
0
>>> myCount( s1, "a")
1
>>> myCount( "abcabc", "a")
2
>>> myExtend( s1, s2 )
'abcdefgh'
>>> myMin( "" )
Empty string: no min value # Note the None doesn't print
>>> myMin( "zqralm" )
'a'
>>> myMin( "Hello World!" )
' '
>>> myInsert( "abc", 0, "d")
'dabc'
>>> myInsert( "abc", 2, "d")
'abdc'
>>> myInsert( "abc", 4, "d")
Invalid index # Note the None doesn't print
>>> myPop( "abcd", 1 )
('acd', 'b')
>>> myPop( "abcd", 0 )
('bcd', 'a')
>>> myPop( "abcd", 5)
Invalid index
('abcd', None)
>>> myFind( "abcdabcd", "a")
0
>>> myFind( "abcdabcd", "c")
2
>>> myFind( "abcdabcd", "f")
-1
>>> myRFind("abcdabcd", "d")
7
>>> myRFind("abcdabcd", "e")
-1
>>> myRemove( "abcdabcd", "a")
'bcdabcd'
>>> myRemove( "abcdabcd", "x")
'abcdabcd'
>>> myRemove( "abcdabcd", "d")
'abcabcd'
>>> myRemoveAll("abcabcabca", "a")
'bcbcbc'
>>> myReverse( "abcd" )
'dcba'
>>> myReverse( "" )
''
Does technology always follow the science, yes or no and explain the reason your choice
Answer:
NOExplanation:
because Technology does not always follow science but it may actually lead science in some instances. An example is weather forecasting.Mark me brainliest plzYou can enter common data in multiple worksheets by __________.
a) Grouping Worksheets
b) Data Validation
c) PivotTable
d) Consolidating Data
Answer:
A.) Grouping Worksheet.
Explanation:
Hope this helps!
who invent cars and who invent bikes and who invent pc
Answer:
Cars were invented in 1886 by Karl Benz.The term bicycle was coined in France in the 1860s, but The first verifiable claim for a practically used bicycle belongs to German Baron Karl von Drais in 1817The first computer was by Charles Babbage, an English mechanical engineer and polymath he originated the concept of a programmable computer.different types of programming languages
the main types are machine language, assembly language and high level language
Answer:
At the time of writing, some of the top programming languages include:
C
Java
Python
C++
C#
Visual Basic
JavaScript
PHP
SQL
Assembly language
R
Groovy
If you are trying to create a game that involves a mystery, what colors would work best to support the mood?
dark colors
bright colors
neutral colors
greyscale colors
i gave up in life
Answer:
the answer is dark colors
Answer:
Dark colors
Explanation:
Dark colors are very ominous and support a mood of mystery
Which part of the computer is responsible for managing memory allocation for all applications
A. Word processor
B. Operating system
C. Web browser
D. Intergrated development environment
I think it’s B but I’m not sure so I want to see if I’m right before answering
Answer:
Option B
Explanation:
The operating system is the type of software that is responsible for managing the processor time and also the memory allocation in the system. The operating system mainldeals with the processor time by scheduling the processor work done in the system.
The OS mainly controls the system and then schedule the execution of various types of function by the central processing unit (CPU). It also controls the memory allocation in the system.
The part of the computer responsible for managing memory allocation for all applications is the operating system. The correct option is B.
What is an operating system?The operating system is the kind of software in charge of controlling the system's memory allocation and CPU usage. By scheduling the system's processor work, the operating system primarily manages processor time.
The operating system (OS) primarily manages the system and schedules the central processor unit's performance of many types of functions. Additionally, it manages the system's memory allocation.
The CPU is the brain of the computer. It manages all the functions of the computer. It is a small rectangle chip-like structure present inside the box with other parts.
Thus, the part of the computer that is responsible for managing memory is the operating system. The correct option is B.
To learn more about the operating system, refer to the link:
https://brainly.com/question/6689423
#SPJ2
You would like the word "Employee" to appear in cells A1, B1, C1, D1, and E1. To be efficient, you should
type the label in Al and drag down column A
use the merge and center command
type the label in Al and use autofill
type the label in each of the cells
To be efficient, type the label in Al and use autofill. Check more about excel below.
What is Excel used for?Microsoft Excel is known to be a kind of software that helps its users to be able to edit, organize and calculate data through the use of a spreadsheet.
Note that one can be able to duplicate a word such as "Employee" on excel by typing the label in Al and use autofill.
Learn more about Excel from
https://brainly.com/question/25879801
#SPJ2
What is the impact of Customer Centricity?
See if you can do better then I did
Answer:
no i can't do better ggs
Explanation:
im not smart (also I did answer the question ;) )
use JAVA
Create a HighestGrade application that prompts the user for five grades between 0 and 100 points and stores
the grades in an ArrayList. HighestGrade then traverses the grades to determine the highest grade and then
displays the grade along with an appropriate message.
Output:
Enter a grade (between 0 and 100): 87
Enter a grade (between 0 and 100): 65
Enter a grade (between 0 and 100): 98
Enter a grade (between 0 and 100): 89
Enter a grade (between 0 and 100): 55
The highest grade is: 98
Answer:
import java.util.*;
public class HighestGrade
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int n = 5;
ArrayList<Integer> grades = new ArrayList<Integer>(n);
for (int i = 1; i <= n; i++)
{
System.out.print("Enter a grade (between 0 and 100): ");
int num = sc.nextInt();
grades.add(num);
}
int max = grades.get(0);
for (int i = 1; i < n; i++) {
if (grades.get(i) > max) {
max = grades.get(i);
}
}
System.out.print("The highest grade is: "+max);
}
}
Explanation:
The class HighestGrade application rompts the user for five grades between 0 and 100 points and stores the grades in an ArrayList. HighestGrade then traverses the grades to determine the highest grade and then displays the grade along with an appropriate message.
Which cloud computing model allows users to create their own applications given a specific set of tools
I believe Windows or Apple computers. Sorry if I’m not helpful.
Distinguish between principles, guidelines and standards, using examples of each to illustrate
Explanation:
principles is what governs a place
guidelines is what you read to guide you
standards is what build up in your self
Answer:
A principle is a basic truth to live by, such as “All human beings are equal in the eyes of God.” A guideline is a general rule or piece of advice such as “don't burn your bridges.” A standard is a rule to be upheld such as the Ten
Can someone help me do this who ever does it first get 100 points :)
Answer:
Wired: Means a cable or a wire connected thats the opposite of wireless.
Wireless is bascially a device with no cable needed.
3G: GB
4G: GB
5G: GB
Explanation:
Wired: Means a cable or a wire connected thats the opposite of wireless.
Wireless is bascially a device with no cable needed.
3G: GB
4G: GB
5G: GB
Marci enjoyed the restaurant's meatloaf so much, she asked for the recipe. She wants to make 1/6 of the recipe. How much garlic powder does Marci need?
Answer:
she needs 1/6 of the garlic powder in the original recipe
Hope This Helps!!!
The operation of an enable input on a multiplexer chip is.
Answer:
is used to activate the chip.
Explanation:
when enable is high the chip works (ACTIVE), when enable is low the chip does not work (MEMORY).
What does this Python expression evaluate to?
100 != 100
True
False
“True”
“False”
Answer: False
Explanation:
A wireless ________ extender is a network device that enhances transmission of your wireless signal.
Explanation:
A wifi range extender,sometime called a range expander,is type of wireless repeater used to exten wifi range.
Question 3 You are working with the ToothGrowth dataset. You want to use the skim_without_charts() function to get a comprehensive view of the dataset. Write the code chunk that will give you this view.
There are different kinds of chunk options. The code chunk that will give me this view is skim_without_charts(ToothGrowth)
This code chunk can gives me a comprehensive view of the dataset. When you look into the parentheses of the skim_without_charts() function, you will see the name of the dataset that you intended looking into/viewing.
The code is known to return or give a short detail with the name of the dataset and the number of rows and columns therein.
It also makes one to see the column types and data types that are found/ contained in the dataset. The ToothGrowth dataset is known to have 60 rows.
Learn more about Code Chuck from
https://brainly.com/question/25525005
conclusion for project for computer
OK this question is answer easy the computer important of future
What is the new programming language for developing iOS and Mac app
Answer:
Swift
Explanation:
I'm not sure about new, but IOS developers have been using Swift ever since the begining of time!
def test() : # do not change this line!
values = [4, 7, 8, 9, -5] # do not change this line!
# write your code here so that it modifies values
# be sure to indent your code!
print(values)
return values # do not change this line!
# do not write any code below here
test() # do not change this line!
# do not remove this line!
The definition of "nested statements" is _____.
a. elements of HTML that work within other elements of HTML
b. elements of specific text that work within elements of HTML
c. elements of specific code that work within elements of HTML
d. elements of HTML that work outside of elements of HTML
P3. Produce a plan to use social media in a business to meet its business requirements.
The plan to use social media in a business include:
It is important to audit the current social presence. The company should document who their Ideal customer is. A mission statement should be created. One should identify the key success metrics. An engaging content should be created. The company should also invest in a social media management tool.It should be noted that using social media in a business is an effective way to meet its business requirements and achieve organizational goals.
Learn more about social media on:
https://brainly.com/question/1163631
Please answer these questions.
For question 15 the answer is option C. I don't know the answers to the other questions
types of digital divide
Explanation:
introduction. desktop computer,tablet computer,storage devices such as flash drivers, mobile phone...
I want know answer for best way to copy formula on MS Access
Answer:
copy and paste is alternate
How can you create a messages to look like an IMessage?
Answer:
An article about the company in a city newspaper are consumers most like to trust.
Explanation:
explain different users of computer in briefly?
Answer:
The question is invalid; there are many types of computer user. Why on earth do you think there are five?
From the top of my head.
Casual- someone at home browsing the web, reading email.
IT Consultant. Advising people.
Software developer- writing software
Secretary - manages email for a company
Academic. Writing research papers.
Monitors. Monitor a computer system.
That’s six off the top of my head. There are probably a dozen more. So why do you think there are five?
The term for an operator that may not evaluate one of its subexpressions is
Answer:
short-circuit
Explanation: