0% found this document useful (0 votes)
5 views

Exercise 1_Assignment (1)

Work

Uploaded by

anuoluwa2051
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)
5 views

Exercise 1_Assignment (1)

Work

Uploaded by

anuoluwa2051
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/ 1

In [2]:

# Class Number: 109


# Date of task: 19/09/2024
# Date of submission: 23/09/2024
# Matric: 21/1773
# Program of study: computer science
# Introduction to python programming

# Variable declarations
first_name = "Dana"
last_name = "Scott"
full_name = first_name + " " + last_name
country = "USA"
city = "New York"
age = 25
year = 2024
is_married = False
is_true = True
is_light_on = True

# Multiple variable declarations on one line


x, y, z = 1, 2, 3

# Checking data types of all variables


print(type(first_name))
print(type(last_name))
print(type(full_name))
print(type(country))
print(type(city))
print(type(age))
print(type(year))
print(type(is_married))
print(type(is_true))
print(type(is_light_on))
print(type(x), type(y), type(z))

#keywords in python
help('keywords')

#finding the length of first name


print(len(first_name)

# Comparing the length of first name and last name


print(len(first_name) == len(last_name))

num_one = 5
num_two = 4

total = num_one + num_two


diff = num_one - num_two
product = num_one * num_two
division = num_one / num_two
remainder = num_two % num_one
exp = num_one ** num_two
floor_division = num_one // num_two

print("Total:", total)
print("Difference:", diff)
print("Product:", product)
print("Division:", division)
print("Remainder:", remainder)
print("Exponentiation:", exp)
print("Floor Division:", floor_division)

# Calculating area and circumference of a circle with a fixed radius of 30 meters


radius = 30
pi = 3.14159
area_of_circle = pi * radius ** 2
circum_of_circle = 2 * pi * radius

print("Area of circle:", area_of_circle)


print("Circumference of circle:", circum_of_circle)

# Taking user input for radius and calculating the area


radius_input = float(input("Enter the radius of the circle: "))
area_of_circle_input = pi * radius_input ** 2
print("Area of circle with user input:", area_of_circle_input)

# Taking user input for first name, last name, country, and age
user_first_name = input("Enter your first name: ")
user_last_name = input("Enter your last name: ")
user_country = input("Enter your country: ")
user_age = input("Enter your age: ")

print(f"User details: {user_first_name} {user_last_name}, {user_country}, {user_age} years old.")

<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
<class 'int'>
<class 'int'>
<class 'bool'>
<class 'bool'>
<class 'bool'>
<class 'int'> <class 'int'> <class 'int'>

Here is a list of the Python keywords. Enter any keyword to get more help.

False break for not


None class from or
True continue global pass
__peg_parser__ def if raise
and del import return
as elif in try
assert else is while
async except lambda with
await finally nonlocal yield

False
Total: 9
Difference: 1
Product: 20
Division: 1.25
Remainder: 4
Exponentiation: 625
Floor Division: 1
Area of circle: 2827.431
Circumference of circle: 188.4954
Enter the radius of the circle: 4
Area of circle with user input: 50.26544
Enter your first name: Anu
Enter your last name: Victor
Enter your country: Nigeria
Enter your age: 50
User details: Anu Victor, Nigeria, 50 years old.

You might also like