Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Function of Python

Rating
-
Sold
-
Pages
27
Uploaded on
06-03-2025
Written in
2023/2024

This notes provide knowledge about function use in python and some mathematical programs write using function

Institution
Course

Content preview

User input:
It is the most important feature for every software language where a user can input s
and the software or function return a value.
For example we have calculated height of an object at time 0.2s with initial velocity
m/s and g = 9.81 m/s2. But I have an wish to find out the height at any time I want.
should I do?
If the process of changing value of the time and write the whole program again and ag
better to quit the use of python and seek for other language.
No, I don’t give this opportunity to you.
There is a command ‘input()’ which serve the purpose.
But we have to follow the steps.
i) Goto start menu and find IDLE Shell 3.9.7 for Python 3.9.7 version and run the programme.
ii) Go to file and select new file and save it with a name.
iii) Right click on the file and select edit with IDEL
iv) Delete all the written words and start freshly your program.

,Exercise- Find out height of an object at a given time and initial speed.
# user input for morethan one variable
Ans.
u= input('initial speed in m/s ')
u=float(input('initial speed = ')) g=9.81
a = input ('acceleration in m/s^2 ')
t=float(input('enter the time ')) h=u*t -
0.5*g*t*t # type conversion is necessary t= input ('time in s ')
for run the program. v=u+a*t
print('height at time %1.2f s is %2.2f Traceback (most recent call last):
m'%(t,h))
File "<pyshell#36>", line 1, in <module>
now save the commands and run the program
v=u+a*t
and you will get result as
TypeError: can't multiply sequence by non-int o
initial speed = 5.0
u=float(u);a=float(a);t=float(t)
enter the time 0.5
v=u+a*t; h=u*t+0.5*a*t**2
height at time 0.50 s is 1.27 m
print ("Speed at %2.1f s is %3.2g m/s and hight
name = input("enter your name ") %(t,v,h))
enter your name Subhayan output
last= input ("enter your last name ") initial speed in m/s 5.0
enter your last name Biswas acceleration in m/s^2 2.1
print (“I know you\’r Mr. %s %s" time in s 1.25
%(name,last))
Speed at 1.2 s is 7.6 m/s and hight is 7.89 m
I know you’r Mr. Subhayan Biswas

, Compound statements in Python:
In general, Python code is a sequence of statements. A simple statement is a single l
doesn't end in a colon.
A compound statement is so called because it is composed of other statements (simple
compound).
Compound statements typically span multiple lines and start with a one-line header en
colon, which identifies the type of statement.
Together, a header and an indented suite of statements is called a clause. A compound
consists of one or more clauses:
Exercise: Type a number and check it is even or
enter your number
it is odd
operator Meaning
enter your number
== Is equal to
it is even
!= Not equal to
< Less than
> Greater than
<= Less than or equals to
>= greater than or equals to
and Both are true
or One or the other is true
not Is not true

Written for

Institution
Course

Document information

Uploaded on
March 6, 2025
Number of pages
27
Written in
2023/2024
Type
Class notes
Professor(s)
Sb
Contains
All classes

Subjects

$5.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
gourabmandal

Get to know the seller

Seller avatar
gourabmandal VC
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
6
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions