- 22 students
- 41 lessons
- 0 quizzes
- 10 week duration
- Installing Anaconda and running a sample Python Program
- How to use the Print function in Python?
- Arithmetic Operations in Python
- Running a Web Server using Python in Spyder
- Input Output in Python
- Starting Plots in Python
- For loop in Python
- Installing and running DJango
- Linear and Polynomial Regression using Python
- Some Problems on Lists
- Creating Classes in Python
- Inheritance in Python
- How to implement Multiple Inheritance in Python
- Using Flask-1
- Lists in Python
- Lists in Python — 1
- Sorting of Lists
- Lists in Python — Insertions
- How to make a list in python and save it in files ……
- Importing Excel Files in Python
- Mailer in Python
- How to add a simple view to a Django site?
- Python Print and I/O questions
- Print answers
- If then else in Python
- Summation of Series
- Python Print Assignment
- Loop Assignments
- Pickle in Python
- Dictionary in Python-1
- Dictionaries in Python-2
- Python OOPs Assignment
- Operator Overloading in Python
- Equation Solving using Numpy
- Starting Numpy
- Passing Data from a Python Controller to a HTML Page
- Downloading Data from a URL in Python
- Sending a Dictionary to a HTML Template and displaying it using Flask.
- Web Scraping Library-1
- Downloading data from a remote website and displaying data in an html page
- Arithmetic Operations in Python — Assignment
Input Output in Python
Input Output in python . Let’s understand this. How does we take input and output in python . Take a name of variable of your choice assign them with sum value like if you take a variable name i.e.(A) and assign value to a is like A=5. This is how declaration of variable is done in python .
Now you have a question that can only we can assign numeric values in variable or we can assign string (means alphabet ) in variable, so answer is that yes! you can assign .
Here is code of a small program of adding of two number in python.
''' Input Output in python ''' a=5 # Declaration of 1st variable b=7 # Declaration of 2st variable c=a+b #Storing value in third variable print("This is result of adding your above declaration= ",c)
Now look at above program . There is no declaration of datatype when we are taking values in the program
Here is something different by default python put it’s all undeclared values as string type. But what in case you have to take input of desired data type. Program is below
""" Arithmetic Operators A program of Simple Interest """ p=float(input("Enter Principle Value")) t=float(input("Enter time ")) r=float(input("Enter rate of interest")) si=p*t*r/100.0 print("This is value of simple interest",si)
Have a look on “p” variable . First we declare variable than data type then input function
variable=data_type(input(“Enter Your Value”))
As default program will return value in string type if you wish to take return value in another datatype.It can be done simply (si=float(p*t*r/100.0)
Output Of above program is
Enter Principle Value1000 Enter time 1 Enter rate of interest2 This is value of simple interest 20.0
Commenting in Python
Commenting is very useful in every programming language. Commenting make clear to a non programmer that how programm is done or when you make some long program like 200-500
lines of program which you must have to comment your program . Comment sentence are not include in interpreting process. Means it is not read by by interpreter as programming command.
In Python both Single line and multiline commenting are allowed. Single line commenting are done by #
and multi line commenting are done between ( ”’ Comment ””. ). In above code of add you can see that how commenting is done.