Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation. Its language constructs as well as its object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects. Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented and functional programming. Python is often described as a "batteries included" language due to its comprehensive standard library.
This line of code prints My name is Yash Vardhan. Print command displays the text which is there in " " (double quotes). We give brackets after print command because it is the syntax of python programming language. Python displays text when we will write text in double quotes otherwise it will give an error.
Output
ADDING, SUBTRACTING, MULTIPLICATING AND DIVIDING TWO OR MORE NUMBERS
To add, subtract, multiply and divide two or more numbers also we use print command but here to calculate two or more number we don't use " " (double quotes) because if we will use double quotes the it will display the numbers that we want to calculate.
Example
Code
Output
To add two or more numbers we will remove the double quotes.
Adding Two Numbers
Code
Output
Here, we are able to write code without double quotes because the value of these numbers is known. If you want to add three or four numbers then add them.
Example
Output
Subtracting Two Numbers
Code
Output
Multiplicating Two Numbers
Output
Dividing Two Numbers
Code
Output
Adding Comments
We can add comments to our code when we are giving our code to anyone else so that he can understand that what is the work of a particular function. Comments are lines that we write in our code but are not displayed in our code. In python We write comments by giving a #. There are two types of comments:-
- Single lined comments : These are written by giving # symbols
- Multi lined comments : These are written by giving ''' ''' symbols
Example
Single Lined Comment
Multi Lined Comment
Storing Values In Variables
We can store values in variables. It is useful when we have to define something and get the value.
Here a = 2 and b = 3 so a+b = 2+3
Output
Questions
- Write a program to calculate the sum of 6725 and 6256.
- Make a program and in that make any two variables and in that store any two valued and add them.
0 Comments