Exercise For Py
Exercise For Py
# Integer variable
age = 24
# String variable
name = ("name : David")
# Float variable
height = 5.9
# Boolean variable
cyberprober = True
# Exercise :2
# Simple Calculator
# Task: Create a simple calculator that adds two numbers.
# Exercise :3
# Get user input for the number
number = int(input("Enter a number: ")) # Convert input to integer
# reversed method
try:
number = int(input("Enter a number: "))
if number % 2 != 0:
print(number, "is odd")
else:
print(number, "is even")
except ValueError:
print("That's not a valid number. Please enter an integer.")
# or
# This program calculates the sum and average of a list of numbers
voters = int(input ("plz, how old are you ? Numbers only. "))
if voters <= 17:
print("SO sorry, plz wait until 18 years old")
else:
print("congratulations our beloved voter !! ")
# or
# This program checks if a user is eligible to vote
# For user input your can assinge your function to user input.