No video

#18 Python Tutorial for Beginners | User input in Python | Command Line Input

  Рет қаралды 1,404,445

Telusko

Telusko

Күн бұрын

Check out our courses:
Enterprise Java Spring Microservices: go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : go.telusko.com...
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Spring: go.telusko.com...
Java:- go.telusko.com...
Java Spring:- go.telusko.com...
Java For Programmers:- go.telusko.com...
Python : go.telusko.com...
Git : go.telusko.com...
Docker : go.telusko.com...
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusk...
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
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 :- github.com/nav...
Python for Beginners :- bit.ly/3JOLQhl
Editing Monitors :
amzn.to/2RfKWgL
amzn.to/2Q665JW
amzn.to/2OUP21a.
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com

Пікірлер: 1 200
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 47 МЛН
Can This Bubble Save My Life? 😱
00:55
Topper Guild
Рет қаралды 85 МЛН
Чёрная ДЫРА 🕳️ | WICSUR #shorts
00:49
Бискас
Рет қаралды 6 МЛН
Before VS during the CONCERT 🔥 "Aliby" | Andra Gogan
00:13
Andra Gogan
Рет қаралды 10 МЛН
#20 Python Tutorial for Beginners | While Loop in Python
12:43
Telusko
Рет қаралды 1,6 МЛН
Join us LIVE for DEVEXDAYS24
GitKraken
Рет қаралды
Python Tutorial for Absolute Beginners #1 - What Are Variables?
24:38
#23 Python Tutorial for Beginners | Printing Patterns in Python
7:56
#21 Python Tutorial for Beginners | For Loop in Python
7:27
Telusko
Рет қаралды 1,3 МЛН
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 47 МЛН