Module_3
- Angela Porcelli
- Jan 31, 2021
- 3 min read
Updated: Mar 12, 2021
1.1 Write a function that takes in a person's name and prints out a greeting.
The following code will ask the user to enter their name before returning a three line greeting that includes the provided name. I ran this code using the names 'Angela', 'Giulietta', and Guinevere.

1.1.Bonus
First I put the three names into a list creating an iterable. I then instructed Python to run the iterable for 'Names' in a for loop until all three names have been used.

1.2. Full Name
Relying on the code syntax from 1.1, users will be prompted to enter their full name resulting in the return "Hello (full name), it's nice to meet you." I ran this code using the names Guinevere Porcelli, Giulietta Schutte, and Angela Porcelli.

1.3. Addition Calculator
Using the same input function as with the names, I have written a code that ask the user to supply two numbers and then returns the sum of those numbers in a sentence. Since there is no way of knowing what number the user will return, a float function is used to accommodate any integers using a decimal point. As you can see in the screenshot, I ran this code using whole numbers, decimals, and negative numbers.

2. Square Root
The code pow(16,(1/2)) does not need to be changed in order to correctly return 4 as the square root of 16, however, it does need to be assigned to a variable to meet Python syntax requirements. Python recognizes 1/2 as 0.5, which is the required exponential argument for returning a square root using Python's pow() function.

3. Lists and Tuple
x=[1, 2, 3, 4, 5]
y=[11, 12, 13, 14, 15]
z=(21, 22, 23, 24, 25)
(a) What is the value of 3*x?
This is asking Python to multiply every element of list x by 3 returning the values [3,6,9,12,15].
(b) What is the value of x+y?
This concatenates listx and listy returning the values [1,2,3,4,5,11,12,13,14,15]
(c) What is the value of x-y?
This is asking for the difference between listx and listy which is [1,2,3,4,5,11,12,13,14,15].
(d) What is the value of x[1]?
This is asking for the second element of listx which is 2.
(e) What is the value of x[0]?
This is asking for the first element of listx which is 1.
(f) What is the value of x[-1]?
This is asking for the first element from the right in listx which is 5.
(g) What is the value of x[:]?
This is asking for all of the elements in listx returning [1,2,3,4,5]
(h) What is the value of x[2:4]?
This is asking for third and fourth elements of listx which returns [3,4].
(i) What is the value of x[1:4:2]?
This is asking for the second through fourth elements of listx using increments of 2 which returns [2,4]
(j) What is the value of x[:2]?
This is asking for the first two elements in listx returning [1,2].
(k) What is the value of x[::2]?
This is stating start at the beginning of listx and go to the end of listx using increments of 2 which returns [1,3,5].
(l) What is the result of the following two expressions?
x[3]=8
print x
This is stating that the fourth element of listx should be changed to 8 and returns [1,2,3,'8',5]
(m) What is the result of the above pair of expressions if the list x were
replaced with the tuple z?
All elements in a tuple are set in their assigned positions and cannot be changed or altered. The previous expression would result in an error message for tuplez.



Comments