1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Archy [21]
3 years ago
11

The function below takes one parameter: a string (date_string) containing a date in the mm/dd/year format. Complete the function

to return a list containing integers for each of the date components in month, day, year order. For example, if given the string '06/11/1930', your code should return the list [6, 11, 1930].
Computers and Technology
1 answer:
Natalija [7]3 years ago
8 0

Answer:

The solution code is written in Python 3.

  1. def convertDate(date_string):
  2.    date_list = date_string.split("/")
  3.    for i in range(0, len(date_list)):
  4.        date_list[i] = int(date_list[i])
  5.    return date_list  
  6. print(convertDate('06/11/1930'))

Explanation:

Firstly, create a function convertDate() with one parameter, <em>date_string</em>. (Line 1).

Next, use the Python string <em>split()</em> method to split the date string into a list of date components (month, day & year) and assign it to variable <em>date_list</em>. (Line 3) In this case, we use "/" as the separator.

However, all the separated date components in the <em>date_list</em> are still a string. We can use for-loop to traverse through each of the element within the list and convert each of them to integer using Python<em> int() </em>function. (Line 5 - 6)

At last return the final date_list as the output (Line 8)

We can test our function as in Line 11. We shall see the output is as follow:

[6, 11, 1930]

You might be interested in
What is the difference between websites and web page​
gogolik [260]

Answer:

webpage is a single document on internet under a unique URL. Website is a collection of multiple webpages in which information on related topics or subject is linked together.

4 0
3 years ago
What is the best way to improve the following code fragment? if ((counter % 10) == 0) { System.out.println("Counter is divisible
Nataly_w [17]

Answer:

The correct code to the given question is

if ((counter % 10) == 0)  // check the condition

{

System.out.println("Counter is divisible by ten: " + counter);  // display

}

else  // check the condition

{

System.out.println("Counter is not divisible by ten: "  +counter); // display the //value

}

counter++; // increment the value of counter

Explanation:

Following are the description of code

  • In the given question we have to check the condition that the given number is divisible by 10 or not .
  • In the if block if the number is divisible by 10 then it print the value of number and increment the value of counter .
  • In the else block if the number is not divisible by 10 then it print the value of number and increment the value of counter .
  • It means the value of counter is increases in the if block as well as in the else block .So we have to remove the counter statement from there and place outside the if and else block .

6 0
3 years ago
Which of the following explains why computers can be used in accounts payable? Computers can use random steps to identify the du
Sphinxa [80]

Answer:

Its A buddy

Explanation:

that what it was on ingenuity

4 0
3 years ago
Read 2 more answers
You can use this area to create your resume.
Svetach [21]

Answer:

what area?

Explanation:

if you need help creating a resume lmk :)

all you really need is

your skill set

-what you're good at

-what you can do

-what are you certified at like

excel, Microsoft office etc.

let me know and I'll send an example

3 0
3 years ago
Why did Constantine establish a new capital of the Roman Empire in Byzantium?
mestny [16]

Answer:

Explanation:

For to stablish with more power his new empire based on christianity.

5 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) _____ of an class is where the services or behaviors of the class is defined. (Points : 6) operation
    6·1 answer
  • To extend the bottom border of a hyperlink across the complete width of a navigation list, change the ____ property of each hype
    9·1 answer
  • What are three things to consider in programming design?
    14·1 answer
  • The Warn-on-Forecast has been developed by the National Weather Service to help predict hazardous weather earlier. Which of the
    10·2 answers
  • Which part of the cpu accepts data?
    15·1 answer
  • Seeing her Daughter graduate from college is most likely a short term goal for a person of which of these ages ? A) 24 years old
    10·1 answer
  • What goals do you set for yourself while studying?
    9·2 answers
  • Which element is represented by the electron configuration in example B? Example B: 1s22s22p63s23p64s1 Aluminum Cesium Potassium
    12·2 answers
  • Which of the following is a characteristic of a college savings plan
    6·2 answers
  • A salesman has been traveling to different businesses all day to give a sales presentation. Each time, he was starts up his lapt
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!