From 79a4455e681930b867015763f1f455c173c27861 Mon Sep 17 00:00:00 2001 From: ppalemarak <67029956+ppalemarak@users.noreply.github.com> Date: Tue, 9 Feb 2021 21:31:23 -0500 Subject: [PATCH] Update 100+ Python challenging programming exercises.txt --- ... Python challenging programming exercises.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/100+ Python challenging programming exercises.txt b/100+ Python challenging programming exercises.txt index 97af5aaf..a4d116ff 100644 --- a/100+ Python challenging programming exercises.txt +++ b/100+ Python challenging programming exercises.txt @@ -172,6 +172,22 @@ print ','.join(value) #----------------------------------------# #----------------------------------------# +Alternate Solution to Question 6 +import math + +print ("This is a program that calculates and prints the value according to the given formula :Q = Square root of [(2 * C * D)/H]") +print("These are the fixed values of C and H:C is 50. H is 30.") +print("D is the variable whose values will be input to the program in a comma-separated sequence.") + +Dvalues = input ("What are the values of D you would like to use ? Please use positive integers separated by comma such as 100,150,180:") + +Q_list = [] +D_list = Dvalues.split(",") + +print("Through list comprehension method : ") +Q_list_2 = [round(math.sqrt((2*50*int(n))/30)) for n in D_list ] +print(Q_list_2) +#----------------# Question 7 Level 2