What is the output of the code shown below if the system date is: 6/19/2017?tday=datetime.date.today()tdelta=datetime.timedelta(days=10)print(tday+tdelta)
Question
What is the output of the code shown below if the system date is: 6/19/2017?tday=datetime.date.today()tdelta=datetime.timedelta(days=10)print(tday+tdelta)
Solution
The code you provided is written in Python and it's used to manipulate and calculate dates. Here's a step-by-step explanation:
-
tday=datetime.date.today()- This line of code gets the current date from your system and assigns it to the variabletday. -
tdelta=datetime.timedelta(days=10)- This line of code creates a time delta of 10 days and assigns it to the variabletdelta. -
print(tday+tdelta)- This line of code adds the time delta (10 days) to the current date and prints the result.
So, if the system date is 6/19/2017, adding 10 days to this date will result in 6/29/2017. Therefore, the output of the code will be: 2017-06-29.
Similar Questions
What will be the output of the code shown below if the system date is 18th June, 2017?tday=datetime.date.today()bday=datetime.date(2017,9,18)till_bday=bday-tdayprint(till_bday)
What will be the output when the following code is executed?public class Product {public static void main(String[] args) { LocalDate startLocalDate = LocalDate.of(2016, Month.JUNE, 01);LocalDate tempLocalDate = startLocalDate;startLocalDate.plusDays(10);System.out.println(tempLocalDate);}} 2016-06-0101-06-20162016-06-1111-06-2016
Test time left: 47:16 Choose the Correct Answer(s) What does the following statements do? from datetime import * print(datetime.today().strftime('%B')) Options Displays the full weekday name Displays the full month name Displays the abbreviated day name Displays the abbreviated month name
1234567from datetime import datep = input("dob in ddmmyyyy format: ")l = input("today's date in ddmmyyyy format: ")g = date(int(p[4:]), int(p[2:4]), int(p[:2]))t = date(int(l[4:]), int(l[2:4]), int(l[:2]))dsb = (t-g).daysprint("days since birthday:",dsb)Close
What will be the output of the following program? Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 7); cal.set(Calendar.MONTH, 4); cal.set(Calendar.YEAR, 2015); System.out.println("Week of month " + cal.get(Calendar.WEEK_OF_MONTH)); System.out.println("Day of week in month " + (cal.get(Calendar.DAY_OF_WEEK_IN_MONTH))); System.out.println("Day " + cal.get(Calendar.DAY_OF_MONTH)); System.out.println("Month " + (Calendar.MAY == cal.get(Calendar.MONTH) ? "May" : "April"));
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.