Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLS USE WHhile The only allowed loop is while def addListElements(alist): -write a funciton that takes in a list (alist) of items and returns a

image text in transcribedimage text in transcribedPLS USE WHhile The only allowed loop is while

def addListElements(alist): -write a funciton that takes in a list (alist) of items and returns a tuple of length 2. - The oth element of this tuple should be a sum of all the ints and floats in alist, and the 1st element of the tuple should be a concatenation of all the strings from alist -Other types (e.g., bool) should be ignored -If there are no ints or floats, the sum should be zero. If there are no strings, the second element of the tuple should be an empty string ***Hint: think of creating a variables that you initialize to the default values (o and "'), which will, for example, help you keep track of the running sum. *** return "stub" from labo3 import addListElements # Test cases for addListElements: def test_addlistElements_1(): assert addListElements(["I", 13, "Love", 12, "Shrek", 11]) == (36, "ILoveShrek") def test_addListElements_2(): assert addListElements(["", True, "groot", ""]) == (0,"groot") def test_addlistElements_3(): assert addListElements ([]) == (0,"") def test_addListElements_4(): assert addListElements([ "What", True, "Are", "Those?"]) == (0, "WhatAreThose?")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Peoples understanding of what is being said

Answered: 1 week ago

Question

2. How should this be dealt with by the organisation?

Answered: 1 week ago

Question

explain what is meant by the term fair dismissal

Answered: 1 week ago