Python Forum
How to Use Python for solving the following physics question. Python Code required
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Use Python for solving the following physics question. Python Code required
#1
How to Use Python for solving the following physics question. Python Code and procedure required
A car of mass 1600kg moving with an initial velocity of 18ms-1 (ms power -1) hits another stationary car of mass 1400kg and they lock together. With what velocity do they move after an elastic collision?
Data Given;
m1=1600 kg
m2= 1400 kg
u1= 18 ms-1
u2= 0
v1=v2=v
to find v=?

Formula: m1u1+m2u2=m1v1+m2v2

Solution:
m1u1+m2u2=m1v1+m2v2
1600x18+1400x0=1600+1400v
28800+0=3000v
v=28800/3000
v=9.6 ms-1 Answer
Reply
#2
If they lock together, the collision is not elastic. Besides that, why do you need python if you already computed the result by hand?
Reply
#3
Thanks! But i want to express in python code
Reply
#4
(Dec-17-2019, 10:44 AM)ishahid Wrote: But i want to express in python code
In this case, open your favourite IDE and start writing code. You know how to solve it by hand, now transform this into python code. If you face difficulties - post your code in python tags, full traceback if you get any - in error tags and ask specific questions.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
I am a beginner . Please help for transforming in python code Thanks
Reply
#6
If we write it for you, you will always stay a beginner
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
Here's a beginning, leaving some blanks for you to fill in and figure out:
# Data
m1=1600 
m2= 1400 
u1= 18
u2= 0

#momentums
mom1=m1*u1
#put similar formula for the second object initial momentum here, call it mom2
mom3=mom1+mom2#combined momentum

#solution
velociraptor = mom3/(#the sum of the masses)
print(velociraptor)
Reply
#8
Hi jefsummers , Thanks for Help.!
Reply
#9
Hi @ishahid,

There are many ways to solve this physics question. but among this i found best way to solve this.

# Use input() method to gather given information
#Example:
m1 = input() # After running the code, the executioner will ask for the value

# Use print() to show the steps and working:
print('Formula used: m1u1 + m2u2 = (m1 + m2)v1')

# print final answer:
print('v = ' + str(v1))
If your question is even more fundamental for how to use Python, read here:
w3schools - Python

Hope this helps.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner Python Question: FIzz Buzz using while loop camoyn13 2 1,778 Sep-20-2022, 09:00 AM
Last Post: deanhystad
  Missing 1 required positional argument in python code edwinostby 7 9,866 Jan-19-2021, 12:52 PM
Last Post: Serafim
  Need help with this Python Interview Question hannah 7 3,581 Sep-11-2020, 03:02 PM
Last Post: ndc85430
  question on list in Python spalisetty06 1 2,035 Jun-30-2020, 09:03 AM
Last Post: pyzyx3qwerty
  python question strekasz 1 1,348 Mar-17-2020, 04:08 PM
Last Post: jefsummers
  Question about Python Code Than999 10 4,172 Nov-05-2019, 11:59 PM
Last Post: Than999
  Python Homework Question OrcDroid123 1 2,364 Sep-01-2019, 08:44 AM
Last Post: buran
  [Guidance needed] Python def question PieTurn 4 2,444 Aug-04-2019, 08:12 AM
Last Post: ichabod801
  Python Question Smhbugra 2 2,298 May-27-2019, 06:19 PM
Last Post: calvinpdaw
  Beginner Python Homework Question (Calculate Gross Pay) matchamochi7 4 5,672 Nov-02-2018, 01:06 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020