0% found this document useful (0 votes)
0 views2 pages

VIII Computer Science Python Code

Uploaded by

farhanahsan4296
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

VIII Computer Science Python Code

Uploaded by

farhanahsan4296
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Handout – 01(Python Code) Session: 2024-25

Name: Class: VIII Section: Roll No:


Subject: Computer Science, Practical Teacher: Md. Shahinur Alam Shadhin Date:

Uses of variables
x=10
print(x)
x=30 + 1 + x
print(x)

name= "Alice"
print(name)

print(name, "age is ", x)

Input
num1 = int(input("Give me a number"))
num2 = int(input("Give me another number"))

print ("Your first number is", num1 + num2)


print ("Your second number is", num2

a = input("what is your age")


print (a)
b = input("what is your age?")
print("your age is ",b)

Sum of two numbers


num1 = int(input("give me a number"))
num2 = int(input("another number please"))

print("your 1st number is", num1)


print("your 2nd number is", num2)

total = num1 + num2


print("sum of 2 is",total)

Mathematical operation num1 =int(input("give another number"))


num2 =int(input("another number please"))

print("first number is",a)


print("second number is",b)

addition = num1 + num2


subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2

print("sum is" , addition )


print("difference of two number is" , subtraction )
print("product is" , multiplication )
print("division is" , division )
Total and Average
num1 = int(input("give me a number"))
num2 = int(input("another number please"))
num3 = int(input("one more number please"))

addition = num1 + num2 + num3


average = addition / 3

print("Total is", addition)


print("The average of 3 numbers is", average)

Condition / Selection
num1 = int(input("Enter a number"))

if num1>0:
print("number is Positive")
elif num1 == 0:
print("number is Neutral")
else:
print("number is Negative")

Large number between 2 a = int(input("give me a number"))


b = int(input("another number"))
numbers
if a > b:
print(a,"is greater")
else:
print (b,"is greater")

Decide pass or fail


Mark = int(input("how many marks you got"))
Question: Write an algorithm if Mark < 0:
to take student mark as input print("Error: mark cannot be less than 0")
and decide given mark is elif Mark > 100:
print("Error: mark cannot be more than 100")
passed or fail. Pass mark is 50
elif a>=50:
out of 100. Also show an print("you passed")
error message for invalid or else:
unexpected input. print("you failed")

You might also like