Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

CODING IN PYTHON: Please help with Python I want to see written code, not screen shots, please..

1. Write a Python program that will convert your height from feet and inches, to centimeters. Be sure to explain to possible users what the program will do.

2. Write a Python program to print the calendar of a given month and year.

NOTE: Use 'calendar' module.

3. Write a Python program that will take a number of feet being input by a user, and convert the feet to inches, yards, and miles. The results of this conversion will be displayed when the program is run.

Expert Solution
Check Mark
Step 1

PYTHON CODE:

# getting the data from the user
data=input("Enter your height in feet and inches(e.g 5 5 ,sep by space):")

# checking for valid data
if data:

# splitting the data by spaces
t=data.split()

# converting string into float
feet=float(t[0])
inches=float(t[1])
cm=0

# calculating the cm
cm=feet * 30.48 + inches * 2.54

# printing the result
print("%s Feet,%s Inches equivalent to %.2f cm" %(str(feet),str(inches),cm))

else:
print("There is no data to process.")

Enter your height in feet and inches (e.g 5 5 ,sep by space)
6.0 Feet,2.0 Inches equivalent to 187.96 cm


2. PYTHON CODE:

import calendar

# getting the month and year
m=int(input("Enter the month: "))
y=int(input("Enter the year: "))

# printing the calendar
print(calendar.month(y,m))

 

Enter the month: 2
Enter the year: 2018
February 2018
Mo Tu We Th Fr Sa Su
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20

3. PYTHON CODE:

# getting the input
feet=float(input("Enter the feet: "))

# converting the feet to inches
inches=feet * 12

# converting the feet to yards
yards= feet * 0.333333

# converting the feet to miles
miles= feet * 0.000189393939

print("Feet: ",feet)
print("Inches: ",inches)
print("Yards: ",yards)
print("Miles: ",miles)


SCREENSHOT FOR OUTPUT:

Enter the feet: 5
Feet: 5.0
Inches 60.0
Yards: 1.666665
Miles: 0.000946969695

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education