Question

Language: Python 3.6 Include Comments in the code - Given the following list: myList = ["Hello",...

Language: Python 3.6

Include Comments in the code

- Given the following list:

myList = ["Hello", "name", 6, 3.1, 7.2, 9.4, "Good bye", 11.1, 22]

Write a program that will total the numbers only

0 0
Add a comment Improve this question Transcribed image text
Answer #1

myList = ["Hello", "name", 6, 3.1, 7.2, 9.4, "Good bye", 11.1, 22]

sum1 = 0
for i in myList:
try:
sum1 += float(i)
except ValueError:
pass

print("%.1f"%sum1)

Add a comment
Know the answer?
Add Answer to:
Language: Python 3.6 Include Comments in the code - Given the following list: myList = ["Hello",...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • require python 5. You have the following list stored in variable myList [ 3, 7, -1,...

    require python 5. You have the following list stored in variable myList [ 3, 7, -1, 2, -10, 6, 8) i. Write a program that creates a new list, with the same numbers as mylist, apart from any negative numbers, which should be removed. Although you are using mylist as an example, it should work for any list of numbers. ii. Now adjust your program so that instead of deleting them, any negative numbers are replaced with a zero.

  • Consider the list myList: myList = ["a", "America", "1", [5,3,9], "3", ["Mercy"]] #1 1) The Python...

    Consider the list myList: myList = ["a", "America", "1", [5,3,9], "3", ["Mercy"]] #1 1) The Python statement __________________ returns a #2 2) The Python statement __________________ returns America #3 3) The Python statement __________________ returns Ame #4 The type of the third element is _______. #6 The Python statement __________________ returns the following: ['Mercy'] #7 The python statement temp = _______ converts the third element to integer and assigns the result to temp. #8 Consider the fourth element of myList...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • python Given a list Lst = [“bye”, “hi”, “good”, “okay”, “sad”], write codes for each of...

    python Given a list Lst = [“bye”, “hi”, “good”, “okay”, “sad”], write codes for each of the following tasks:             Add “happy” to the end of the list Add "nice" to the beginning of the list             Replace “hi” with “hello”

  • Python 3.6 i need the code ready to copy and run with adequate indentation Write a...

    Python 3.6 i need the code ready to copy and run with adequate indentation Write a program that will calculate the cost of purchasing a meal. This program will include decisions and loops. Details of the program are as follows: Your menu items only include the following food with the accompanying price: Yum Yum Burger =.99 Grease Yum Fries =.79 Soda Yum = 1.09 Allow the user of the program to purchase any quantity of these items in one order....

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code...

    *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code function. Good answers will be rated with thumbs up! Please answer both parts. Thank you for your time. Question 3 - Suppose you have a file named numbers.csv which contains a bunch of integers, five per line of text, separated by commas. Write code below that will open the _le, read the numbers from it, and print the sum of all the even numbers...

  • 3. Write Python statements that will do the following: a) Input a string from the user....

    3. Write Python statements that will do the following: a) Input a string from the user. *** Print meaningful messages along with your output.* b) Print the length of the String. Example input: The sky is blue. Correct output: The length of the string is 16 Incorrect output: 16 c) Print the first character of the string. d) Print the last character of the string. 4. Save the program. Double-check the left edge for syntax errors or warning symbols before...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT