Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
#18 Python Tutorial for Beginners | User input in Python | Command Line Input
Play lesson

Python for Beginners (Full Course) | Programming Tutorial - #18 Python Tutorial for Beginners | User input in Python | Command Line Input

Unlock Python Mastery: Dive into 75+ Engaging Tutorials and Transform Your Programming Skills with Telusko Today!

5.0 (1)
23 learners

What you'll learn

Understand and set up Python development environments using PyCharm and Jupyter Notebook.
Learn to work with various Python data types, variables, and operators.
Master Python programming fundamentals, including loops, conditional statements, and functions.
Gain proficiency in file handling, error management, and utilizing Python libraries like NumPy for data manipulation.

This course includes

  • 17.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

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/udemyteluskospring 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/udemyteluskopython Git : https://go.telusko.com/udemyteluskogit Docker : https://go.telusko.com/udemyteluskodocker Instagram : https://www.instagram.com/navinreddyofficial/ Linkedin : https://in.linkedin.com/in/navinreddy20 TELUSKO Android App : https://go.telusko.com/TELUSKOAPP TELUSKO IOS App : https://apple.co/3SsgmU2 Discord : https://discord.gg/D8hWe9BqfF 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

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere