Database System Concepts
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
Bartleby Related Questions Icon
Related questions
Question
please use your own code for better explanation
Transcribed Image Text:Create a Python function, called nonlntegers (characterList), which takes a characterList list as a parameter, and which returns a string of characters. The elements of
the listList are all of type string (str). These strings can contain characters which are positive integers such as '10' or '3' or else characters which are not positive integers
(such as letters of alphabets, special characters, etc.).
The return string consists of all the elements in the list that are not positive or zero integers, as well as the sum of positive or zero elements. If there is no positive or zero
element then this sum will be zero.
The format of the returned string must be as shown in the executions below.
Use isdigit () to test whether an item in the list is a positive or zero integer. The program should not crash due to type conversions.
Respect the type contract of the function: (list) -> str
The returned string must be exactly as shown in the examples below.
Examples (several executions):
>>> nonlntegers (['1', '#', 'a', 'b', '3', 'r', 'O'])
'Non-positive integers: #abr - Sum of positive integers: 4'
>>> nolntegers (['*', '17', '6', 'yes', '+', 'no'])
'No positive integers: * yes + no - Sum positive integers: 23'
>>> nonlntegers (['22', '10', '8'])
'Non-positive integers: - Sum of positive integers: 40'
>>> nonlntegers (['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
'Saturday Sunday' ])
" Not integers positive: Monday Tuesday Wednesday Wednesday Friday Saturday Sunday Sunday
- Sum positive integers: 0'
Expert Solution
Check Markarrow_forward
Explanation
Here I have created a function named nonIntegers().
In this function, I have used for loop to iterate over the elements of the list.
Next, I have checked whether the element is a digit or not.
If the element is a digit then, I have checked whether the number is greater than 0 or not, if yes then added it to the sum else added it to the string.
If the element is not a digit then, I have added it to the string.
Then, I have formatted the string as per the output and returned it from the function.
In the main block, I have called the function inside the print statement to get the result to the console.
bartleby
Step by stepSolved in 2 steps with 1 images
Knowledge Booster
Background pattern image
Similar questions
- Replace all the 0 (Zero) digits in your ID by 4. Example: If your ID is 382200448 , it becomes 382244448 Take the first 6 digits and substitute them in this expression (( A + B) / C) * ((D-E)/F)-2) according to the following table; [1 mark] Letter Replace by Digit Example Digit A 1st 3 B 2nd 8 C 3rd 2 D 4th 2 E 5th 4 F 6th 4 After substitution your expression ? Draw a rooted tree that represents your expression. [3 marks] What is the prefix form of this expression. [3 marks] What is the value of the prefix expression obtained in step 2 above? [3 marks]arrow_forwardPlease help with this question?arrow_forwardthis is not correct. i am not suppose to use that header. stdio.h i am not suppose to use. everything is there in the question. please follow the guideline in the questionarrow_forward
- NEED HELP WITH PYTHON CODE. ALSO, PLEASE PROVIDE DETAILS SEPARATELY ON HOW AND WHAT DID U USE TO GET UR CODE DONE.arrow_forwardThis is a new homework assignment. Fill in the blanks.arrow_forwardIn the main.asm file, you are to create a few arithmetic calculations using the following instructions: mov add sub Then after each expression is calculated, you will print the result using: mov rdi, XXX call print_num call print_lf The value of XXX will depend on which register your final result landed. Do this at least 3 times using only the registers ( rax, rbx, rcx and rdx). For example, if you wanted to print the result of 32 + 5 - 10, you could do something like: mov rax, 32 add rax, 5 sub rax, 10 mov rdi, rax call print_num call print_lf Remember that in order for the print_num subroutine to print your number, you must move the result into rdi.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education