0% found this document useful (0 votes)
11 views

4 Class Input Funtion

The document discusses how to read input from the keyboard in Python and Java. It explains how to use the input() function in Python and BufferedReader in Java to get user input and convert it to different data types like int and set. It also covers string handling in Python like creating strings using single quotes/double quotes, slicing strings using indexes and positive/negative indexing.

Uploaded by

Umarani vanamala
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

4 Class Input Funtion

The document discusses how to read input from the keyboard in Python and Java. It explains how to use the input() function in Python and BufferedReader in Java to get user input and convert it to different data types like int and set. It also covers string handling in Python like creating strings using single quotes/double quotes, slicing strings using indexes and positive/negative indexing.

Uploaded by

Umarani vanamala
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Reading the data from keyboard and print in python console:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Input Function" is a predefined function which is present inside of default module
( or ) builtin module in python.

*)By using input() we can read the data from keyboard dynamically.

*)input() is a predefined function,which is used to read the data from keyboard.

*)If we want read the data in the form of our own format we can use type conversion
functions.

-------------------------PYTHON---------------------------------
example:-a=int(input("enter the data of a="))
b=int(input("enter the data of b="))
print(a+b)

--------------------JAVA---------------------------------------------
import java.io.*;
class Test
{
public static void main(String[] args) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter a value");
int a=Integer.parseInt(br.readLine());
System.out.println("enter b value");
int b=Integer.parseInt(br.readLine());
System.out.println("addition is:"+(a+b));
}
}

--------------------------------------------------------
SET type convertion:-
--=-=-=-=-=-=-=-=-=--
In set type converstion accepts only set type and results will be displayed in
"{}"(flower brackets).
**output will be "UNORDERED".

a=set(input("enter the data of a="))


b=set(input("enter the data of b="))
print(a,b)
output:-{'a','c','b'}{'d','f','e'}

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=-=-=-=-=-=-=-=-=-=
str handling:
-=-=-=-=-=-=-
*)Group of characters or sequence of characters is also known as a str.
*)Group of characters or sequence of characters can be stored in str class object.
*)We can create str class object in 2 ways:

a)by using '' or ""(we can represent only line of str)


b)by using ''' or """(we can represent more than one line of str)

*)Every character in str class object can be represented with unique index starting
with
zero.
*)if str supports indexes then it automatically supports slicing concept also.

*)strs supports both positive and negative indexing concept.

*)postive indexing starts with zero and negative


indexing starts with -1.

You might also like