What is Python used for?
Python is a computer programming language often used to build websites and software, conduct data analysis, and automate tasks.
Python is a general-purpose language, which means it can be used to create various programs, and it is not specialized for any specific problems.
History and versions of Python
Python was initially created by Guido van Rossum and was first released on 20 February 1991. then it started documentation release on 25 October 1996. Python's stable version is 3.11, released on 24 October 2022. and the 3.13 version is in development.
Example
Let's start with a small example of finding the greatest number. You just need to take three numbers as input from stdin and find the greatest of them.
- Input Format: You will take three numbers as input from stdin, one on each line, respectively.
- Constraints: -100000 <= N <= 100000
- Output Format: You need to print the greatest of the three numbers to the stdout.
Example
Input
- 902
- 100
- 666
Output Should be-
902
Let's try to code to get the expected result with Python. The first thing we need to check is which library we can use to get input and which library we can use to print output.
- STDIN: To read user input. We can use input() to read input from STDIN.
- STDOUT: To print output. We can use print() to write your output to STDOUT.
Code Sample
def main():
inputA = int(input())
inputB = int(input())
inputC = int(input())
if inputA >= inputB and inputA >= inputC:
print(inputA)
elif inputB >= inputA and inputB >= inputC:
print(inputB)
else:
print(inputC)
main()
By default, input is in the string, so we need to cast to int if we need an integer conversation.
So with the above code, we can get an idea of getting input and printing output. Also, we get an idea of comparing integers and, if else, conditions using Python language.