0% found this document useful (0 votes)
31 views8 pages

Unit 1.3

Uploaded by

Ishan Dipte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views8 pages

Unit 1.3

Uploaded by

Ishan Dipte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Subject

Introduction to Python
Unit 1.3

Prof. M. V. Tiwari

(B. E. in Electronics & Telecommunication Engineering, H.V.P.M., C.O.E.T., Amravati, 2009.)


(M. Tech. in Electronic System & Communication, An Autonomous Institute of GCOE, Amravati, 2013.)
(Pursuing Ph.D. from P.G. Department of Applied Electronics, S.G.B.A.U. under the guidance of Dr. S. V.
Dudul, Head PGDAE.)

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Module 3 : Python Input / Output


input :
•To accept input from keyboard we can use input () function which returns string.
•To convert
➢String into integer we can use int()
➢String into float we can use float().

output :
•To print the output or results Python provides print() function.
•print () will print the values and then the cursor goes to the next line.

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Q1) What is the output when following code is executed ?

print(“D”)
print(“C”)
print(“B”)
print(“A”)

A)DCBA B) A, B, C, D
C) D C B A D) D, C, B, A will be displayed on four lines.

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Q2) Select all options that print

Hello – how – are – you

A)print(‘hello’, ‘how’, ‘are’, ‘you’)


B) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-’)
C) print(‘hello –’ + ‘how – are – you’)
D) print(‘hello’ + ‘ –’ + ‘how’ + ‘-’ + ‘are’ + ‘–’ + ‘you’)

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Q3) What function do you use to read a string ?

A)input(“Enter a string”) B) int(“Enter a string”)


C) enter(“Enter a string”) D) string(“Enter a string”)

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Q4) You develop a Python application for your company. You need to accept
input from the user and print information to the user screen. You have started
with the following code. Line numbers are included for reference only.

01 print(“What is your name ?”)


02
03 print(name)

A) name = input B) input(“name”)


C) input(name) D) name = input()

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Q5) The ABC company has hired you as an intern on the coding team that
creates e – commerce applications. You must write a script that asks the user
for a value. The value must be used as a whole number in calculation, even if
the user enters a decimal number. You need to write the code to meet the
requirements. Which code segment should you use ?

A)totalItems = input(“How many items would u like ?”)


B) totalItems = float(input(“How many items would u like ?”))
C) totalItems = str(input(“How many items would u like ?”))
D)totalItems = int(input(“How many items would u like ?”))

DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari


2SAEKNT : Introduction to Python P R M I T & R ,B A D N E R A

Q 6) You are an intern for ABC electric cars company. You must create a
function that calculates the average velocity of their vehicles on a 1320 foot
(1/4 mile) track. The output must be as precise as possible. How should you
complete the code ?

01. Distance =_____ (input(‘enter distance travelled in feet’ ))


02. distance_miles = distance 5280 # convert to miles.
03. time =______(input(“enter time elapsed in seconds”))
04. time_hours = time / 3600 # convert to hours
05. velocity = distance_miles / time_hours
A) 01. float and 03. float
B) 01. str and 03. float
C) 01. int and 03. str
D) 01. str and 03. str
DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING PROF. M. V. Tiwari

You might also like