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
Keith_Richards [23]
3 years ago
7

Create a Python program by defining a function that calculates the year of birth of a person whose age is known to you.(You may

use an input statement to ask the user to enter their age).
Computers and Technology
1 answer:
Alchen [17]3 years ago
3 0

Answer:

  1. import datetime
  2. def get_year_of_birth():
  3.    age = int(input("Enter your age: "))  
  4.    current_year = datetime.datetime.now().year  
  5.    year_of_birth = current_year - age  
  6.    return year_of_birth  
  7. print(get_year_of_birth())

Explanation:

Firstly, we import datetime module as we need it to get the current year (Line 1).

Next, create a function named it as get_year_of_birth (Line 3). Prompt user to input age and assign it to a variable (Line 4). Next, we use now() method from datetime module to get the current date and time and extract the year component (Line 5).  At last, calculate the year of birth by subtracting the current_year with age and return it as output (Line 6-7).

You might be interested in
Assume that success is a variable of type boolean that has been declared. Assume that processor refers to an object that provide
Iteru [2.4K]
Try {
AutoFactory.shutdown();
} catch (ProductionInProgressException e) {
AutoFactory.reset();
}
6 0
3 years ago
Which are advantages of using a server operating system?
iogann1982 [59]

Answer:

Extra security features and networking services built right in

Explanation:

The major advantage of using a server operating system is that it has decent security features and networking services built right in it from the default settings

8 0
3 years ago
What are the differences between packet and circuit switching? Which is more prevalent today?
Juliette [100K]

Answer: The difference present between the packet switching and circuit switching are as follows:-

  • Packet switching i the switching in which the data packet travels through the connectionless path whereas connection oriented routes are present for circuit switching
  • Network layer uses the feature of packet switching while physical layer uses circuit switching technique
  • Data transferring is mostly preferred through packet switching and voice communication takes place through the circuit switching.
  • Packet switching is considered flexible as no already established connection is present for switching but the connection in circuit switching are already defined which makes it less flexible.

Among the packet switching and circuit switching , packet switching is preferred for the communication through the data packets because they have  flexibility and affordability.It can establish numerous connection for switching and this make it efficient.

4 0
4 years ago
How do I change the year I was born on this website? I made a mistake and now I can't fix it. Can somebody please help me?
Eddi Din [679]

Answer:

you can go to settings and try to fix it or contact the people of this website

Explanation:

8 0
4 years ago
This is the question
nikdorinn [45]

Answer:

I dont know it sorry

Explanation:

i would help u

4 0
3 years ago
Other questions:
  • A _____ captures the pattern in a _____ and sends it to the computer, where special software translates the _____ into meaningfu
    8·1 answer
  • Which option will Joan use to get a glimpse of how her presentation will look when she presents it to her audience? Joan will us
    14·2 answers
  • Apache web server is the most widely used network operating system used on web servers.
    8·2 answers
  • Universal Containers is tracking the interviewer's ratings of candidate in Salesforce. They would like to easily link the Candid
    5·1 answer
  • In computer logic what is order of instructions
    13·1 answer
  • A document format is
    11·2 answers
  • What is the difference between head header and heading in HTML​
    8·1 answer
  • What should be done if a system cannot boot from the hard drive?
    14·1 answer
  • Shane is working on a new project for the sales department. The company wants a way to allow the sales force to print orders at
    5·1 answer
  • Need help with this, will give brainliest
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!