🔒 Closed Test bot

Status
Not open for further replies.

Carl Robles

Forum Veteran
339928398_926711601874902_4596300175150776573_n.png

how to make this code your life in weeks
 
To create a program that calculates how many weeks you've lived, you can start by asking the user for their birthdate. Then, you can use Python's datetime module to calculate the number of weeks between their birthdate and the current date.

Here's an example code:

Python:
import datetime

birthdate = input("Enter your birthdate in YYYY-MM-DD format: ")
birthdate_obj = datetime.datetime.strptime(birthdate, "%Y-%m-%d")

today = datetime.datetime.today()

weeks_lived = int((today - birthdate_obj).days / 7)

print("You have lived approximately {} weeks.".format(weeks_lived))

When you run this program and enter your birthdate, it will calculate the number of weeks you've lived and print it out.
 
To create a program that calculates how many weeks you've lived, you can start by asking the user for their birthdate. Then, you can use Python's datetime module to calculate the number of weeks between their birthdate and the current date.

Here's an example code:

Python:
import datetime

birthdate = input("Enter your birthdate in YYYY-MM-DD format: ")
birthdate_obj = datetime.datetime.strptime(birthdate, "%Y-%m-%d")

today = datetime.datetime.today()

weeks_lived = int((today - birthdate_obj).days / 7)

print("You have lived approximately {} weeks.".format(weeks_lived))

When you run this program and enter your birthdate, it will calculate the number of weeks you've lived and print it out.
your life in week using java script
 
your life in week using java script
To calculate your age in weeks using JavaScript, you can use the Date object to get the current date, and then ask the user for their birthdate. You can then calculate the difference between the two dates in milliseconds and convert it to weeks.

Here is an example code:

JavaScript:
let birthdate = prompt("Enter your birthdate (YYYY-MM-DD):");
let birthdateObj = new Date(birthdate);
let today = new Date();

// Calculate the difference in milliseconds
let differenceInMs = today.getTime() - birthdateObj.getTime();

// Convert the difference to weeks
let weeksLived = Math.floor(differenceInMs / (1000 * 60 * 60 * 24 * 7));

console.log(`You have lived approximately ${weeksLived} weeks.`);

When you run this code and enter your birthdate, it will calculate the number of weeks you've lived and print it out to the console.
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 3
    Replies
  • 278
    Views
  • 1
    Participants
Last reply from:
Unknown user

Trending Topics

Online now

Members online
1,071
Guests online
1,310
Total visitors
2,381

Forum statistics

Threads
2,273,517
Posts
28,950,069
Members
1,235,789
Latest member
ZaynAaqil28
Back
Top