Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
In python, the function slice_middle takes a string parameter, word.
- If the length of word is less than 3, the function returns the empty string.
- Otherwise, the function returns a substring made of all but the first and last characters in word.
For example:
Test | Result |
---|---|
print(slice_middle("onion")) | nio |
print(slice_middle("?")) | |
print(slice_middle("slicing")) | licin |
Expert Solution
arrow_forward
Step 1
The Python code is given below with code and output screenshot
Happy to help you ?
Step by stepSolved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- from surround import surround inputs = [] [] answers = L = ["tank", "godzilla", "tank"] ["tank"] inputs.append (L) answers.append(a) a = TESTS len(inputs) passed = 0 for i in range(TESTS): try: result = surround (inputs[i]) if result not in answers[i]: print("Error found for input: " + str(inputs[i])) else: passed += 1 except Exception: pass result = "Tests passed: + str(passed) + "/" + str(TESTS) print(result)arrow_forwardhow do i make a test a function in javascript with instructions as follows allAnagrams( words ) This function accepts a single string. The string contains zero or more words, each separated by spaces. This function must return true if each of the words is an anagram of the others and return false otherwise. Examples allAnagrams("naps pans span") => true allAnagrams("") => true allAnagrams("part tarp rappt") => false allAnagrams("span span") => true allAnagrams("spear pears parse pares reaps") => true this HAS to take in one string as the inputarrow_forwardPls help ASAP. Language is C#arrow_forward
- Python Qu Write a Python program (not a function!) that asks the user for nonnegative integers,one integer per line.When the user is finished entering their integers, they enter a negative integerto tell the program to stop asking them for more integers.Once the input is complete, the program prints "No integers to average"if the user provided no nonnegative integers,and the average of the nonnegative integers otherwise.You must NOT use lists, tuples, or dictionaries in your code.Here is a sample program run where the user enters 4 and then 8 and then -1.The program outputs Average: 6.048-1Average: 6.0Here is another run where the user types -3 to the first prompt.The program outputs No integers to average-3No integers to averagearrow_forwardGiven the following pseudocode: function fun(n) { var outer_count=0; var inner_count=0; var sum = 0; for (var i=0; i 0, as an expression of normal arithmetic and n, what is the value of outer_count that counts the number of times the outer loop executes? Enter an expression Fun.1.inner: Assuming n EN and n > 0, as an expression of normal arithmetic and n, what is the value of inner_count that counts the number of times the inner loop executes? Enter an expressionarrow_forwardPython languagearrow_forward
- 2. count_fred_and_ted Given a list of strings called names , count up how many of those names are either "fred" or "ted", and return the count. Sample calls should look like: >>> count_fred_and_ted(["sarah", "bimmy", "fred", "eliza", "ted", "ted"]) 3 >> count_fred_and_ted(["sarah", "bimmy", "bimmy", "bimmy", "bimmy"]) >>> count_fred_and_ted(["fred", "ted", "fred", "ted"]) 4 >>> count_fred_and_ted([])arrow_forwardHow would I go about programming this code?arrow_forwardQ3: Given a 2d list that contains a list of strings and a list of integers, write a Python program that prints each string repeated as many times as the corresponding integer (separated by a space). For example: A [["this", "is", "a", "text"], [2, 4, 1, 5] The output is: this this is is is is text text text text textarrow_forward
- The function sum_evens in python takes a list of integers and returns the sum of all the even integers in the list. For example: Test Result print(sum_evens([1, 5, 2, 5, 3, 5, 4])) 6 print(sum_evens([5, 5, -5, -5])) 0 print(sum_evens([16, 24, 30])) 70arrow_forwardCan this python code be done without using the isdigit() function. Please try to change the following code in the picture so it doesn't use isdigit().arrow_forwardComplete the rotate_text() function that takes 2 parameters, a string data and an integer n. If n is positive, then the function will shift all the characters in data forward by n positions, with characters at the end of the string being moved to the start of the string. If n is 0 then the text remains the same. For example: rotate_text('abcde', rotate_text('abcde', rotate_text('abcde', 1) would return the string 'eabcd' 3) would return the string 'cdeab' 5) would return the string 'abcde' rotate_text('abcde', 6) would return the string 'eabcd' ... and so on. If n is negative, then the function will shift the characters in data backward by n positions, with characters at the start of the string being moved to the end of the string. For example: rotate text('abcde', -1) would return the string 'bcdea'arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education