Home>
I'm studying Python, but when I execute the following code, I don't get any errors and it just ends.
Where should I fix or add?
import math
def ex3_4 (vp, vs, t):
vp = 6
vs = 3
t = 2
p = (vp * vs)/(vp-vs) * t
return (p)
Supplementary information (FW/tool version, etc.)
I'm using python3.9
-
Answer # 1
-
Answer # 2
It has been calculated.
def ex3_4 (vp, vs, t) is
We just define a function called ex3_4 with vp, vs, t as variables, so we need to call that function.Please check the following additions.
import math def ex3_4 (vp, vs, t): # vp = 6 # vs = 3 # t = 2 p = (vp * vs)/(vp-vs) * t return (p) ans = ex3_4 (6,3,2) #function call print (ans) #Display result
By the way, vp, vs, t can be operated from the outside, so I commented them out.
If you give a number in ex3_4 (,,), it will return the number.
Related articles
- python 3x - i have a question about pipenv i want to set the directory location
- python - [question] about combining pandas data frames
- python 3x - i have a question about sleep in python
- i have a question about runtime errors and exception handling in python
- i have a question about git and github
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- python 3x - about downloading anaconda
- python - about the optimum angle of rotation matrix
- python - about downloading youtube videos by youtube-dl
- python - about "" "of" "" select === = "" "
- about processing to exclude the character string group specified from list in python
- python - regular expression wildcard? i have a question about
- python - what i don't understand about yolo9000 (v2)
- about batch change of file name using python
- about the python speedtest code
- about the implementation of combinations in python
- please tell me about the role of python tag = "mychr"
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
Problem 1
A python function returns a value when called.
Asuka_wataki's program only defines a function, it doesn't call it.
Problem 2
The python function arguments, in this case vp, vs and t, give the value when called.
Problem 3
When executing a program contained in a file, it will not be output unless a print statement is used.
Problem 4
This program does not require import math.
If you modify these, it will be as follows.
When executed in interactive mode, it will be as follows.
When executed in command execution mode, it will be as follows.