Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added alternate solution via list comprehension to question 6 #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 100+ Python challenging programming exercises.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down