jagomart
digital resources
picture1_Python Fundamentals Pdf 187122 | Chapter   2 Python Fundamentals Sub Topic Input Output In Python  Part 3


 188x       Filetype PDF       File size 0.23 MB       Source: garhara.kvs.ac.in


File: Python Fundamentals Pdf 187122 | Chapter 2 Python Fundamentals Sub Topic Input Output In Python Part 3
chapter 2 python fundamentals sub topic input output in python part 3 bimlendu kumar pgt computer sc kendriya vidyalaya garhara sample input and output python allows to get input interactively ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
           CHAPTER -2 
       PYTHON FUNDAMENTALS
   SUB TOPIC –INPUT OUTPUT IN PYTHON –PART 3
                 Bimlendu Kumar
                 PGT Computer Sc.
            Kendriya Vidyalaya Garhara
     SAMPLE INPUT AND OUTPUT
  Python allows to get input interactively using built-in function
  input(). The function input is used in the following manner
  variable_to_hold_input= input(“Prompt to be displayed”)
  example
  >>>name=input(“Enter your name:- ”)
  Output
  Enter your name:- Raj Kumar
  >>>age=input(“Enter your age :- “)
  output
  Enter your age:- 25
       checking input type using buitin function TYPE()
     Note: The input function always returns a value of string type. It can be
     checkedbyusingbuilt-in-function type( ).
     >>>type(name)
     output
     <‘class str’>
     >>>type(age)
     <‘class str’>
     wecannotmakearithmeticcalculationwithageatthismoment.
     >>>age=age+1
     TypeError: mut be str, not int  
     TypeError is the error when we try to perform arithmetic operation with
     data type not suitable for operation.
                     reading numbers using input()
      To read numbersusinginputfunctionweneedtodothefollowing
      1.  Readinthevalueusinginput()function
      2.  Andthenuseint()orfloat( ) function with the read value to change the type
          of input value to int or float respectively.
      >>>age=input(“Enterage:- “)
      output
      Enter age:- 25
      >>>age=int(age)
      >>>type(age)      #typeofagechangedfromstrtointusingexplicittypecasting
      output
      <‘class int’>
      age=age+10         #valid
The words contained in this file might help you see if this file matches what you are looking for:

...Chapter python fundamentals sub topic input output in part bimlendu kumar pgt computer sc kendriya vidyalaya garhara sample and allows to get interactively using built function the is used following manner variable hold prompt be displayed example name enter your raj age checking type buitin note always returns a value of string it can checkedbyusingbuilt wecannotmakearithmeticcalculationwithageatthismoment typeerror mut str not int error when we try perform arithmetic operation with data suitable for reading numbers read numbersusinginputfunctionweneedtodothefollowing readinthevalueusinginput andthenuseint orfloat change or float respectively enterage typeofagechangedfromstrtointusingexplicittypecasting valid...

no reviews yet
Please Login to review.