Question

In Python Create a function called sum_string ( csv_string ) Where csv_string is a string of comma - separated values. intege

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

// Screenshot of the code

X csv_string.py C:/Users/Lenovo/AppData/Local/Programs/Python/Python37-32/csv_string.py (3.7.0) Run Options Window Help File
// Sample output

Python 3.7.0 Shell X File Edit Shell Debug Options Window Help Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v
// code to copy

csv_string.py

def sum_string(str):
total = 0
for i in str.split(','):
i=int(i)
total +=i
return total

Add a comment
Know the answer?
Add Answer to:
In Python Create a function called sum_string ( csv_string ) Where csv_string is a string of...
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
  • Write a Python function, called counting, that takes two arguments (a string and an integer), and...

    Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...

  • I am using Python 3.5.2 2. Create a function called is_interesting that, given a string, returns...

    I am using Python 3.5.2 2. Create a function called is_interesting that, given a string, returns the Boolean value True if the number of vowels (a e i o u) in the string is a prime number (assume that the strings are always passed as lower-case letters to simplify). The function header should be as follows: def is_interesting(a_string) For example is_interesting(“yien”) returns True, is_interesting(“wang”) returns False

  • Create a function called countWords(string): That will count words in given string by user. Use Python...

    Create a function called countWords(string): That will count words in given string by user. Use Python 3.6 If user inputs "Mary had a little lamb" it should return 5

  • Python: Using chr() and ord() write a function called en_crypt() that takes into input a string...

    Python: Using chr() and ord() write a function called en_crypt() that takes into input a string and returns a new encrypted version of the input string. Example: "atwOta@0202" should return "fy|TyfE5757", then write a function de_crypt() so that "fy|TyfE5757" returns "atwOta@0202"

  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

  • USING PYTHON! The second function you will write should be called ‘varOrd’. Your function should take...

    USING PYTHON! The second function you will write should be called ‘varOrd’. Your function should take two (2) arguments, an integer and a string. The function should return one (1) integer calculated as follows. If the input integer is 1, the function should return the sum of the return value of the ord() function on each character of the string (e.g., varOrd(1, ‘cat’) should return the result of ord(‘c’) + ord(‘a’) + ord(‘t’)). If the input integer is 2, the...

  • Programming in C (using only #include <stdio.h>) 1. Create and use a new function called average....

    Programming in C (using only #include <stdio.h>) 1. Create and use a new function called average. 2. Average will accept two integer arguments, (here I will name them sum and n). n is the count of values included in sum. 3. The function will return the integer average of sum. 4. Define and use a function that checks an integer to see if it is positive (returns true if the integer is positive) Note: Choosing proper definition attributes (names, arguments,...

  • In python Write a function called removeExtensión that is given the name of a file as...

    In python Write a function called removeExtensión that is given the name of a file as a string and returns the same string without the extension (the last "" and any following characters); if the given string has no extension, return the given string without changing it. For example, removeExtension"Chapter 3.9.txt") should return "Chapter 3.9" while removeExtension("Hello") should return "Hello"

  • I am trying to create a program called Count.java that contains a single method called compute...

    I am trying to create a program called Count.java that contains a single method called compute with a string parameter called value. The method should count the number of newlines, words (any sequence of characters separated with whitespace), and characters in a given string and return an array of the three integer values. Use a Scanner to count the number of words in a string. The Scanner.next() method returns the next word, ignoring whitespace.

  • Define a function called AddEvenPosDigs(string), which takes a string (with symbols and characters) as an argument,...

    Define a function called AddEvenPosDigs(string), which takes a string (with symbols and characters) as an argument, and returns an integer. This function should add the digits of a string that are in an even position. If there are no digits, the function should return -1. As an example, the following code fragment: string = "a12b056jk"; result=AddEvenPosDigs(string); print(result) should produce the output: 8

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