#Problem 1 print('\“I don’t care,” she said. “What do you think?\”') #Problem 2 first = "Thomas" last = "Hinchliffe" print(first, last) #Problem 3 does not require coding. #Problem 3 will display "The value is num" because the coder placed the variable name 'num' in quotation marks. Demonstrated below. num = 113 print(‘The value is’, ‘num’) #Problem 4 does not require coding/ #Problem 4 will display (a) the letter x, (b) the letter x, (c) the number 97, (d) the phrase 'x + 1' and... #...(e) will yield a syntax error because of the misplaced quotes. Demonstrated below (error display is hard-coded). x = 97 print(“x”) print(‘x’) print(x) print(“x + 1”) print('ERROR') #Problem 5 does not require coding. #Problem five contains the following data types: val1 = 15.00 #Float print(type(val1)) val2 = 9 #Integer print(type(val2)) val3 = ‘7’ #String print(type(val3)) val4 = 3.7 #Float print(type(val4)) val5 = ‘abc’ #String print(type(val5)) #Problem 6 pi = 3.14 radius = 8.1 peri_circle = 2 * pi * radius print(peri_circle) #Problem 7 dist_mi = 500 dist_km = dist_mi * 1.6 print(dist_km) #Problem 8 radius_cyl = float(input("What is the radius of your cylinder?\n") length_cyl = float(input("What is the length (height) of your cylinder?\n") area_cyl = pi * radius_cyl ** 2 print("The area of your cylinder is:", area_cyl) vol_cyl = area_cyl * length_cyl print("The volume of your cylinder is:", vol_cyl)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question