num=int(input("enter a number"))
if num>0:
if num % 2==0:
print("the number is positive and even.")
else:
print("the number is positive but not even.")
else:
print ("the number is not positive")
age=int(input("enter your age"))
gender=input("enter your gender")
if age>18:
if gender == "male":
print("you are an adult male")
elif gender == "female":
print("you are an adult female")
else:
print("invalid gender input")
else:
print("you are not an adult")
for i in range(1,6):
print(i*i)#print sq of nos fron 1-5
#take 7 numbers input from user and print their squares
for i in range(7):
num=int(input("enter a number:"))
square=num*num
print("the square is",square)
#sum of even nos from 1-10
sum=0
for i in range(1,11,2):
sum=sum+i
print("the sum is",sum)
#print nos till 5
i = 1
while i <= 5:
print(i)
i = i + 1
#input no from the user until they enter 0
num = int(input("Enter a number (0 to stop): "))
while num != 0:
print("You entered:", num)
num = int(input("Enter another number (0 to stop): "))
print("Loop finished.")
#Take a number input from the user and print its multiplication table using while
loop (up to 10)
num=int(input("enter a number"))
while i<=10:
i=1
print(num,"x",i,"=",num*i)
i=i+1
#print sum of nos till 10
i=1
sum=0
while i<=10:
sum=sum+i
i=i+1
print("the sum is",sum)
#take nos as input until the user enters 0
num=int(input("enter a number"))
total=0
while num!=0:
total=total+num
num=int(input("enter another number"))
print("the total is",total)
num=int(input("enter a number"))
count=0
if num==0:
count=1
else:
while num!=0:
num=num//10
count=count+1
print("the number of digits are",count)
import csv
with open ("practical.csv","w",newline="")as file:
writer=csv.writer(file)
writer.writerow(["name","class","age"])
writer.writerow(["ayush",10,34])
writer.writerow(["rina",11,84])
import csv
with open ("practical.csv","r")as file:
reader=csv.reader(file)
for row in reader:
print (row)
import csv
with open ("practical.csv","a",newline="")as file:
writer=csv.writer(file)
writer.writerow(["arya",56,90])
print("hello! I am your chatbot")
while True:
user=input("you:")
user=user.lower()
if user =="hi" or user=="hello":
print("bot:hello deepika.How are you?")
elif user=="i am fine"or user=="i am good":
print("bot:nice to hear that")
elif user== "Bye":
print("bot:Bye!have a nice day!")
break
else:
print("bot:sorry,i didn't understand")