lab_1_learning_python
.py
keyboard_arrow_up
School
University of Texas, Rio Grande Valley *
*We aren’t endorsed by this school
Course
2350
Subject
Civil Engineering
Date
Apr 3, 2024
Type
py
Pages
3
Uploaded by suckmyassbuddy
"""
**CIVE 2350: Numerical Methods for Civil Engineers** **Lab A: Learning Python**
"""
# %% Question `area_triangle`
"""
Write a program to return the area of a triangle with sides `a` and `b`.
Example:
Input : 2, 3
Output : 3
"""
def area_triangle(a, b):
area = (a * b)/2
return area
# Test the function
area_triangle(2, 10)
# %% Question `swap_list`
"""
Write a program to swap first and last element of a list.
Examples:
Input : [12, 35, 9, 56, 24]
Output : [24, 35, 9, 56, 12]
Input : [1, 2, 3]
Output : [3, 2, 1]
"""
def swap_list(input_list):
output_list = input_list.copy()
output_list [0] = input_list[-1]
output_list[-1] = input_list[0]
return output_list
# Test the function
swap_list([1, 2, 3, 4, 5])
# %% get_max
'''
Define a function max() that takes two numbers as arguments and returns
the largest of them. Use the if-then-else construct available in Python.
(It is true that Python has the max() function built in, but writing it
yourself is nevertheless a good exercise.)
'''
def get_max(m,n):
if m < n:
return n
else:
return m
get_max(6,5)
# %%
'''
Define a function reverse() that computes the reversal of a string. For example, reverse("I am testing")
should return the string "gnitset ma I".
'''
def get_reverse_string(input):
output = input [::-1]
return(output)
get_reverse_string('I am testing')
# %%
"""
With a given integer number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included).
Example:
Input: 8
Output: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
"""
def get_dict_series(x):
my_num = int(x)
my_dict = dict()
for elem in range(1,my_num+1):
my_dict[elem] = elem*elem
return(my_dict)
get_dict_series(8)
# %%
"""
Write a function that accepts a sentence and returns the number of letters and digits as a string with format "x letters and x digits"
Hint: You can use `.isalpha()` and `.isdigit()`
Example:
Input: "hello world! 123"
Output: "10 letters and 3 digits"
"""
def count_letters_and_digits(x):
letters = 0
numbers = 0
strl = str(x)
for i in strl:
if i.isalpha():
letters+=1
elif i.isdigit():
numbers+=1
else:
pass
return (str(letters) + ' letters ' + 'and ' + str(numbers) + ' digits') count_letters_and_digits("hello world! 123")
#%%
"""
Write a method which takes 2 digits, X,Y as input and generates a 2-dimensional
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Note: Kindly provide a solution pls. The answer is already provided. Thank you!
1.3 A circle (radius = 14 cm.) is inscribed in a 10-sided regular polygon. What is the area(cm^2) of the regular polygon that is outside of the circle?
Ans: 21.09
arrow_forward
A moodle.unizwa.edu.om
The cross-sectional dimensions of
the T-beam is shown in figure
below. To Determine the location of
centroid (x,y); tick any correct
sentences from the following:
Given Data:
a = 25 mm
b = 250 mm
c = 50 mm
d = 150 mm
arrow_forward
Do not give answer in image and hand writing
arrow_forward
COMPLETE SOLUTION WITH FIGURES. BOX YOUR FINAL ANSWERUSE 3 DECIMAL PLACES IN EVERY SOLVED VALUES
arrow_forward
Please show all of your work and solve the problem in the picture. Show your answer in pictures please do not type it please.
arrow_forward
Determine the area and the location of the
centroid of the figure shown below.
Note: Grid lines are 4 units apart in both
directions.
OK
arrow_forward
For situation 3, the plastic section modulus, Zx of the section is closest to:
a.2561 x 10^3 mm^3
b.5482 x 10^3 mm^3
c.6543 x 10^3 mm^3
d.7980 x 10^3 mm^3
arrow_forward
Determine the centroid x and y
arrow_forward
Please write the solutions legibly. Good feedback will be given. Use 4 decimal places.
arrow_forward
Fluid mechanics
This is not an assignmen. Give me right solution
How you use conservation laws to calculate flow parameter?please give equations
arrow_forward
ind the centroid of the area bounded by x=x^2 and y=9
There is no more information... Please please help me urgent
arrow_forward
Locate the centroid in the 'x' and'y direction of the object below, Submit
your answer below, *
5 points
3 in
S in
arrow_forward
When are the singularity functions used?
arrow_forward
I need help with Problem 14.6 in the first picture. Table 14.1 is the second picture.
arrow_forward
please
brifly describe
Discuss the importance of boundary layer approximation in finding the solution of fluid flow problems.
arrow_forward
Calculate the following:
xbar (location of the centroid along x axis), in
Total area of the figure, in²
arrow_forward
What matrix is this?
Scalar even odd or identity
arrow_forward
Locate the centroid C(x, y) of the plane area shown below. Arrange your calculations in a
tabular form and enter them in the table given below.
Segment
30 mm
54 mm
A [mm²]
54 mm
x [mm]
72 mm
ỹ [mm]
X
48 mm
xA [mm³]
ỹA [mm³]
arrow_forward
for question(b),could u pls write it more clearly?\
arrow_forward
8 + (230 x 10^-3) compute the following, express answer in engineering notation
arrow_forward
Determine the internal moments at B and C and the support reactions due to the loads and
support settlements of 8 mm at B and 25 mm at C. Assume the supports at B and C are rollers
and A and D are pins. El is constant.
12 kN/m
12 kN/m
A
B.
4 m
6 m-
4 m
FRAMES WITHOUT SIDESWAY
Use slope deflection method to determine the reactions for the frame shown.
36 kN/m
A
4 m
4 m
4 m
Solve Problem 6 due to the given loads and a support settlement of 5 mm at B.
Determine the member end moments and reactions for the frames shown by using the slope-
deflection method.
7
8.
Note: Use the 100 kN · m acting at joint C for Equilibrium Equation at the joint, not on FEM's.
18 kN/m
B
100 kN · m
5 m
El = constant
A
E = 200 GPa
I = 1,360 (106) mm4
5 m
5 m
arrow_forward
Find the D10,D30 & D60 from the given graph,where the blue line represents the cumulative distribution while X-axis dimensions are in logarithmic scale.
arrow_forward
2. Please give the right answer.
arrow_forward
Find ȳ and x̄.
arrow_forward
Engineering Computation. Please show all work! EI=2,900,000k-in^2
arrow_forward
Surveying lab
arrow_forward
None
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Residential Construction Academy: House Wiring (M...
Civil Engineering
ISBN:9781285852225
Author:Gregory W Fletcher
Publisher:Cengage Learning
Engineering Fundamentals: An Introduction to Engi...
Civil Engineering
ISBN:9781305084766
Author:Saeed Moaveni
Publisher:Cengage Learning
Related Questions
- Note: Kindly provide a solution pls. The answer is already provided. Thank you! 1.3 A circle (radius = 14 cm.) is inscribed in a 10-sided regular polygon. What is the area(cm^2) of the regular polygon that is outside of the circle? Ans: 21.09arrow_forwardA moodle.unizwa.edu.om The cross-sectional dimensions of the T-beam is shown in figure below. To Determine the location of centroid (x,y); tick any correct sentences from the following: Given Data: a = 25 mm b = 250 mm c = 50 mm d = 150 mmarrow_forwardDo not give answer in image and hand writingarrow_forward
- COMPLETE SOLUTION WITH FIGURES. BOX YOUR FINAL ANSWERUSE 3 DECIMAL PLACES IN EVERY SOLVED VALUESarrow_forwardPlease show all of your work and solve the problem in the picture. Show your answer in pictures please do not type it please.arrow_forwardDetermine the area and the location of the centroid of the figure shown below. Note: Grid lines are 4 units apart in both directions. OKarrow_forward
- For situation 3, the plastic section modulus, Zx of the section is closest to: a.2561 x 10^3 mm^3 b.5482 x 10^3 mm^3 c.6543 x 10^3 mm^3 d.7980 x 10^3 mm^3arrow_forwardDetermine the centroid x and yarrow_forwardPlease write the solutions legibly. Good feedback will be given. Use 4 decimal places.arrow_forward
- Fluid mechanics This is not an assignmen. Give me right solution How you use conservation laws to calculate flow parameter?please give equationsarrow_forwardind the centroid of the area bounded by x=x^2 and y=9 There is no more information... Please please help me urgentarrow_forwardLocate the centroid in the 'x' and'y direction of the object below, Submit your answer below, * 5 points 3 in S inarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Residential Construction Academy: House Wiring (M...Civil EngineeringISBN:9781285852225Author:Gregory W FletcherPublisher:Cengage LearningEngineering Fundamentals: An Introduction to Engi...Civil EngineeringISBN:9781305084766Author:Saeed MoaveniPublisher:Cengage Learning
Residential Construction Academy: House Wiring (M...
Civil Engineering
ISBN:9781285852225
Author:Gregory W Fletcher
Publisher:Cengage Learning
Engineering Fundamentals: An Introduction to Engi...
Civil Engineering
ISBN:9781305084766
Author:Saeed Moaveni
Publisher:Cengage Learning