0% found this document useful (0 votes)
3 views4 pages

Python Basics Prog

The document provides a basic overview of Python programming concepts, including data types such as integers, floats, and strings, along with examples of input and output commands. It demonstrates how to perform arithmetic operations, check for even or odd numbers, and handle multiple inputs. Additionally, it includes links to an online Python compiler for practice.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Python Basics Prog

The document provides a basic overview of Python programming concepts, including data types such as integers, floats, and strings, along with examples of input and output commands. It demonstrates how to perform arithmetic operations, check for even or odd numbers, and handle multiple inputs. Additionally, it includes links to an online Python compiler for practice.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Basics

Python complier link


[Link]
int() → integer input ( int is used to store whole numbers)
float() → decimal input
input() → takes input as string
print() → output command

Integer (int) Example


a = 10
b = 20
print(a + b)

Float Example
x = 10.5
y = 2.5
print(x + y)

String Example
name = "Python"
print(name)

Input Command (String Input)


name = input("Enter your name: ")
print(name)

Input Command (Integer Input)


a = int(input("Enter a number: "))
print(a)

Input Command (Float Input)


x = float(input("Enter a float number: "))
print(x)

Integer + Float Example


a = int(input())
b = float(input())
print(a + b)

Multiple Inputs in One Line


a, b = map(int, input().split())
print(a, b)

Output with Text


age = 20
print("Age is", age)

Type Checking
a = 10
b = 2.5
c = "Hello"

print(type(a))
print(type(b))
print(type(c))

Print Hello World


Input :
print("Hello World")
Output:
Hello World
Add Two Numbers
a = int(5)
b = int(3
print(a + b)
out put : 8

Check Even or Odd


n = int(5)

if n % 2 == 0:
print("Even")
else:
print("Odd")
output:
odd
**************************************************
Add Two Numbers
a = int(4)
b = int(2)
print(a + b)

Output: 6

You might also like