Question

In: Computer Science

Use python There is a revenue list, how to covert it from string to int? Here...

Use python

There is a revenue list, how to covert it from string to int?

Here is the list

['$8,120,000,000', '$8,085,200,000', '$7,703,000,000', '$7,000,000,000', '$5,410,000,000', '$4,212,000,000', '$3,741,400,000', '$3,500,000,000', '$3,000,000,000', '$2,800,000,000', '$2,800,000,000', '$2,529,000,000', '$2,087,600,000', '$2,000,000,000', '$1,900,000,000', '$1,520,000,000', '$1,500,000,000', '$1,500,000,000', '$1,350,000,000', '$1,300,000,000', '$1,400,000,000', '$1,400,000,000', '$1,395,000,000', '$1,200,000,000', '$1,000,000,000', '$1,000,000,000', '$842,000,000', '$887,000,000', '$860,000,000', '$825,000,000', '$799,000,000', '$757,000,000', '$751,000,000', '$701,600,000', '$660,000,000', '$600,000,000', '$577,000,000', '$559,000,000', '$540,000,000', '$532,000,000', '$518,400,000', '$500,000,000', '$500,000,000', '$437,000,000', '$400,000,000', '$350,000,000', '$300,000,000', '$277,000,000'].

Solutions

Expert Solution

Answer:-

Program:-

revenue_list=['$8,120,000,000', '$8,085,200,000', '$7,703,000,000', '$7,000,000,000', '$5,410,000,000', '$4,212,000,000', '$3,741,400,000', '$3,500,000,000', '$3,000,000,000', '$2,800,000,000', '$2,800,000,000', '$2,529,000,000', '$2,087,600,000', '$2,000,000,000', '$1,900,000,000', '$1,520,000,000', '$1,500,000,000', '$1,500,000,000', '$1,350,000,000', '$1,300,000,000', '$1,400,000,000', '$1,400,000,000', '$1,395,000,000', '$1,200,000,000', '$1,000,000,000', '$1,000,000,000', '$842,000,000', '$887,000,000', '$860,000,000', '$825,000,000', '$799,000,000', '$757,000,000', '$751,000,000', '$701,600,000', '$660,000,000', '$600,000,000', '$577,000,000', '$559,000,000', '$540,000,000', '$532,000,000', '$518,400,000', '$500,000,000', '$500,000,000', '$437,000,000', '$400,000,000', '$350,000,000', '$300,000,000', '$277,000,000']
print ("Original list is : " + str(revenue_list))
  for i in range(0, len(revenue_list)):
value= revenue_list[i].replace(',','')
  value=value[1:]
revenue_list[i]=int(value)

print ("Modified list is : " + str(revenue_list))

Output:-

Original list is : ['$8,120,000,000', '$8,085,200,000', '$7,703,000,000', '$7,000,000,000', '$5,410,000,000', '$4,212,000,000', '$3,741,400,000', '$3,500,000,000', '$3,000,000,000', '$2,800,000,000', '$2,800,000,000', '$2,529,000,000', '$2,087,600,000', '$2,000,000,000', '$1,900,000,000', '$1,520,000,000', '$1,500,000,000', '$1,500,000,000', '$1,350,000,000', '$1,300,000,000', '$1,400,000,000', '$1,400,000,000', '$1,395,000,000', '$1,200,000,000', '$1,000,000,000', '$1,000,000,000', '$842,000,000', '$887,000,000', '$860,000,000', '$825,000,000', '$799,000,000', '$757,000,000', '$751,000,000', '$701,600,000', '$660,000,000', '$600,000,000', '$577,000,000', '$559,000,000', '$540,000,000', '$532,000,000', '$518,400,000', '$500,000,000', '$500,000,000', '$437,000,000', '$400,000,000', '$350,000,000', '$300,000,000', '$277,000,000']
Modified list is : [8120000000, 8085200000, 7703000000, 7000000000, 5410000000, 4212000000, 3741400000, 3500000000, 3000000000, 2800000000, 2800000000, 2529000000, 2087600000, 2000000000, 1900000000, 1520000000, 1500000000, 1500000000, 1350000000, 1300000000, 1400000000, 1400000000, 1395000000, 1200000000, 1000000000, 1000000000, 842000000, 887000000, 860000000, 825000000, 799000000, 757000000, 751000000, 701600000, 660000000, 600000000, 577000000, 559000000, 540000000, 532000000, 518400000, 500000000, 500000000, 437000000, 400000000, 350000000, 300000000, 277000000]

If this answer is helpful to you Please Upvote,Thankyou


Related Solutions

C++ bool exists_trio(int*,int); (it must use this line here) I was not sure how to utilize...
C++ bool exists_trio(int*,int); (it must use this line here) I was not sure how to utilize this line because I made code that works but not with this line specifically. //Input:    //an integer array (param 1) and its size (param 2) //Output:    //True or false //Behavior:    //Returns true is there exists    //a sequence of 3 *consecutive* values in the array    //such that the sum of the first two elements    //is equal to the third...
Write a Python loop that goes through the list and prints each string where the string...
Write a Python loop that goes through the list and prints each string where the string length is three or more and the first and last characters of the strings are the same. Test your code on the following three versions of the list examples: examples = ['abab', 'xyz', 'aa', 'x', 'bcb'] examples = ['', 'x', 'xy', 'xyx', 'xx'] examples = ['aaa', 'be', 'abc', 'hello'].
Using the Python Program. Can an array hold a mixture of types i.e. int, float, string,...
Using the Python Program. Can an array hold a mixture of types i.e. int, float, string, array within the same array? Show a code segment to remove the last element from a 15 element array named myStuff[]. Please explain the code.
Write a Python function that takes a list of string as arguments. When the function is...
Write a Python function that takes a list of string as arguments. When the function is called it should ask the user to make a selection from the options listed in the given list. The it should get input from the user. Place " >" in front of user input. if the user doesn't input one of the given choices, then the program should repeatedly ask the user to pick from the list. Finally, the function should return the word...
Here is a list of miscellaneous revenue sources received by governments. Categorize them as best as...
Here is a list of miscellaneous revenue sources received by governments. Categorize them as best as you can as (1) user charge, (2) license tax, (3) franchise fee or (4) Fiscal monopoly, using the standards established in the chapter. Explain your logic. What are the incentive impacts of each one of the revenue sources? A fee for disposal of used ties. A fee to reserve books at the library. A charge for processing the arrest of a convicted drunk driver....
HOW DO I ACCESS THE HEAD OF A LINKED LIST FROM INT MAIN () WHEN IT'S...
HOW DO I ACCESS THE HEAD OF A LINKED LIST FROM INT MAIN () WHEN IT'S IN ANOTHER CLASS. HERE IS MY CODE FOR MY MAIN AND HEADER FILES. HEADER FILE: #ifndef HANOISTACK_H #define HANOISTACK_H #include <iostream> using namespace std; class HanoiStack { //class private: struct Disc{ //linked list for towers int num; Disc* next; }; Disc* head; public: HanoiStack(){ //constructor head = nullptr; }; //HanoiStack operator+=(const Disc&); //HanoiStack operator<<(const Disc&); void push(int); //push function int pop(); //pop function void...
Use Python Write a function that takes a mobile phone number as a string and returns...
Use Python Write a function that takes a mobile phone number as a string and returns a Boolean value to indicate if it is a valid number or not according to the following rules of a provider: * all numbers must be 9 or 10 digits in length; * all numbers must contain at least 4 different digits; * the sum of all the digits must be equal to the last two digits of the number. For example '045502226' is...
Use Python Return a password string constructed with the following rules: (1) If there are only...
Use Python Return a password string constructed with the following rules: (1) If there are only 0 or 1 numeric among 3 parameters, concatenate the string form of all parameters directly. (2) If there are 2 numeric parameters, calculate the sum of 2 numeric values if they are both int, or calculate the product of them and round to 2 decimal places if any of them is float. Finally, append this sum/product to the string parameter. You may assume that...
In Python Write a function to read a Sudoku board from an input string. The input...
In Python Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5 385...
Use python write a function that translates the input string into Pig Latin. The translation should...
Use python write a function that translates the input string into Pig Latin. The translation should be done word by word, where all words will be separated by only one space. You may assume that each word must have at least one vowel (a,e,i,o,u and uppercased counterparts), and there will be no punctuation or other special characters in the input string. The Pig Latin rules are as follows: For words that begin with consonants, all letters before the initial vowel...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT