Check out our courses:
Java Spring Boot AI Live Course: https://go.telusko.com/JavaSpringBootAI
Coupon: TELUSKO20 (20% Discount)
AI Powered DevOps with AWS - Live Course :- https://go.telusko.com/AIDevOps-AWS
Coupon: TELUSKO20 (20% Discount)
Master Java Spring Development : https://go.telusko.com/masterjava
Coupon: TELUSKO20 (20% Discount)
For More Queries WhatsApp or Call on : +919008963671
website : https://courses.telusko.com/
Udemy Courses:
Spring: https://go.telusko.com/udemyteluskosp...
Java:- https://go.telusko.com/udemyteluskojava
Java Spring:- https://go.telusko.com/Udemyjavaspring
Java For Programmers:- https://go.telusko.com/javaProgrammers
Python : https://go.telusko.com/udemyteluskopy...
Git : https://go.telusko.com/udemyteluskogit
Docker : https://go.telusko.com/udemyteluskodo...
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : https://go.telusko.com/TELUSKOAPP
TELUSKO IOS App : https://apple.co/3SsgmU2
Discord : / discord
In this lecture we are discussing about:
How to get user input
input function
printing input message
Type of input data
When to use index value
eval function
Passing values from command line
Argument line input
#1 How to get user input
-- Getting user input in Python is straightforward. You can use the input() function
to get input from the user. The input function takes a single argument, which is the
prompt message displayed to the user.
e.g
name = input("Please enter your name: ")
x=input("Enter first number: ");
y=input("Enter second number: ");
z=x+y;
print(z);
#2 input function
-- In Python, the input() function is used to accept user input from the command line or console.
name=input("Enter your name:");
print(name);
-- In this example, the input() function prompts the user to enter their name. Whatever the user types
in response is stored in the name variable.
-- Note that the input() function always returns a string, so if we want to use the user's input as a number,
we'll need to convert it using the appropriate type-casting function (e.g., int() for integers or float() for
floating-point numbers).
#3 Types of input data
-- The input() function always returns a string, regardless of what the user enters.
we may need to convert the input to a different data type if you want to perform calculations or other operations on it.
e.g
x=input("Enter first number: ");
a=int(x);
the input entered by the user is converted to an integer using the int() function in this example.
#4 when to use index value
-- If you want to get a single character from the user, we can use the input() function and index the result.
e.g
ch=input('enter a character: ');
print(ch[0])
ch=input('enter a character: ')[0];
print(ch);
#5 eval function
eval function
-- The eval() function in Python is used to evaluate an expression entered by the user as a string.
The eval() function returns the result of the expression as a value.
e.g
x=eval(input("Enter an expression: "));
typeOf = type(x);
print(typeOf);
#6
Passing values from command line
-- sys module provides access to any command-line arguments via the sys.argv list.
we can pass arguments to a Python script from the command line using the sys.argv list.
The first argument in the list is always the name of the script itself.
suppose we have a file named Mycode.py
in file we have written code
import sys # without this line you will get error
x=sys.argv[1];
y=sys.argv[2];
z=x+y;
print(z);
in command line we have to run this file
#python3 Mycode.py 9 5
0 1 2
Note: Mycode is count as 0th argument
9 is count as 1st argument
5 is count as 2nd argument
Github :- https://github.com/navinreddy20/Python-
Python for Beginners :- http://bit.ly/3JOLQhl
Editing Monitors :
https://amzn.to/2RfKWgL
https://amzn.to/2Q665JW
https://amzn.to/2OUP21a.
Java:- https://bit.ly/JavaUdemyTelusko
Spring:- https://bit.ly/SpringUdemyTelusko
More Learning :
Java :- https://bit.ly/3x6rr0N
Python :- https://bit.ly/3GRc7JX
Django :- https://bit.ly/3MmoJK6
JavaScript :- https://bit.ly/3tiAlHo
Node JS :- https://bit.ly/3GT4liq
Rest Api :-https://bit.ly/3MjhZwt
Servlet :- https://bit.ly/3Q7eA7k
Spring Framework :- https://bit.ly/3xi7buh
Design Patterns in Java :- https://bit.ly/3MocXiq
Docker :- https://bit.ly/3xjWzLA
Blockchain Tutorial :- https://bit.ly/3NSbOkc
Corda Tutorial:- https://bit.ly/3thbUKa
Hyperledger Fabric :- https://bit.ly/38RZCRB
NoSQL Tutorial :- https://bit.ly/3aJpRuc
Mysql Tutorial :- https://bit.ly/3thpr4L
Data Structures using Java :- https://bit.ly/3MuJa7S
Git Tutorial :- https://bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
https://www.telusko.com
Auf dieser Seite können Sie das Online-Video #18 Python Tutorial for Beginners | User input in Python | Command Line Input mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Telusko 10 Juli 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 1,520,672 Mal angesehen und es wurde von 23 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!