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

Python Coding

The document contains several Python coding examples demonstrating basic input/output operations, arithmetic calculations, conditional statements, and loops. It includes examples for capturing user input for name and age, calculating the area of a shape, determining if a number is even or odd, grading based on marks, and printing numbers in ascending and descending order. Each example is followed by sample input and output results.
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 views3 pages

Python Coding

The document contains several Python coding examples demonstrating basic input/output operations, arithmetic calculations, conditional statements, and loops. It includes examples for capturing user input for name and age, calculating the area of a shape, determining if a number is even or odd, grading based on marks, and printing numbers in ascending and descending order. Each example is followed by sample input and output results.
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 CODING

1. name=input("Enter your name")

age=input("Enter your age")

print("your name is",name,"your age is",age)

result

Enter your name aliza

Enter your age 17

your name is aliza your age is 17

2. length=int(input("enter the length of your shape"))

width=int(input("enter the width of your shape"))

area=length*width

print("the area of your shape is:",area)

results

enter the length of your shape 2

enter the width of your shape 2

the area of your shape is: 4

3. number=int(input("enter a number:"))

if number&1==0:

print("even")

else:

print("odd")

result

enter a number:5

odd
4. marks=int(input("enter your mark"))

if marks>=80 and marks<=100:

print("you have passed","A")

elif marks>=70:

print("good try","B")

elif marks>=60:

print("work harder","C")

elif marks>=50:

print("really","D")

else:

print("you failed","F")

result

enter your mark 99

you have passed A

5. for i in range(1, 11):

print(i)

result

10
5. for i in range(5, 0, -1):
print(i)

results
5
4
3
2
1

You might also like