0% found this document useful (0 votes)
2 views4 pages

Programming in Python Assignment 1

This document is an assignment in Python programming by Joycelyn Darkwah Odame, detailing various coding examples. It includes explanations of flags, input handling, decision structures, and calculations involving amounts, speed, points, and time conversions. The assignment demonstrates the use of conditional statements and user input to perform different computations.

Uploaded by

binglemc
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)
2 views4 pages

Programming in Python Assignment 1

This document is an assignment in Python programming by Joycelyn Darkwah Odame, detailing various coding examples. It includes explanations of flags, input handling, decision structures, and calculations involving amounts, speed, points, and time conversions. The assignment demonstrates the use of conditional statements and user input to perform different computations.

Uploaded by

binglemc
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

PROGRAMMING IN PYTHON ASSIGNMENT 3

NAME: JOYCELYN DARKWAH ODAME


INDEX NUMBER: 052520760219
CLASS: DIT 1B

1. A flag is a variable(usually boolean) used to signal whether a


condition is true or false.

2. #get input and store it in variable "x"


x = int(input("enter the number:"))
if x < 100:
y = 20
z = 40
3. #get input and assign to variable "a"
a = int(input("enter the number:"))
if a < 10:
b=0
c=1
4. #get input and assign to variable "a"
a = float(input("enter the number:"))
if a < 10:
b=0
else:
b = 99
5.#A NESTED DECISION STRUCTURE THAT COMPUTES AND
DISPLAY AN AMOUNT
amount1 = float(input("enter any amount:"))
amount2 = float(input("enter any amount:"))
if amount1 > 10 and amount2 < 100:
if amount1 > amount2:
print("amount1")
else:
print("amount2")
else:
print("Conditions not satisfied")
[Link] = float(input("Enter the speed: "))

if speed >= 24 and speed <= 56:


print("The speed is normal")
else:
print("The speed is abnormal")

7. points = float(input("Enter the points: "))

if points < 9 or points > 51:


print("Invalid points")
else:
print("Valid points")
8.# This Program Determines If Month * Day Equals Year

# get input from the user


month = int(input("Enter month: "))
day = int(input("Enter day: "))
year = int(input("Enter two-digit year: "))

# Checking if month*date gives year


if month*day == year:
print("The date is magic")
else:
print("The date is not magic")

9.# This Program Shows Days,Hours,Minutes Based On


Seconds

# Get the seconds


seconds = int(input("Enter seconds: "))

base_seconds = seconds

# calculate days,hours,minutes and seconds


days = seconds//86400
seconds %= 86400

hours = seconds//3600
seconds %= 3600

minutes = seconds//60
seconds %= 60

# Display the results


if days > 0:
print(f"{base_seconds}seconds = {days}days, {hours}hours,
{minutes}minutes, {seconds}seconds")
elif hours > 0:
print(f"{base_seconds}seconds = {hours}hours,
{minutes}minutes, {seconds}seconds")
elif minutes > 0:
print(f"{base_seconds}seconds = {minutes}minutes,
{seconds}seconds")
else:
print(f"{base_seconds}seconds = {seconds}seconds")

You might also like