0% found this document useful (0 votes)
141 views3 pages

Machine Problem 1 - CS158 - 1L

The document contains 8 coding tasks involving operations like calculating powers, splitting strings into lists, string formatting, accessing nested lists and dictionaries, defining functions, and conditional logic. The tasks require writing code to perform the operations and outputting the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views3 pages

Machine Problem 1 - CS158 - 1L

The document contains 8 coding tasks involving operations like calculating powers, splitting strings into lists, string formatting, accessing nested lists and dictionaries, defining functions, and conditional logic. The tasks require writing code to perform the operations and outputting the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Filename: SURNAME_FIRSTNAME_MP1

Answer the questions or complete the tasks outlined in bold


below, use the specific method described if applicable.

1. What is 34 to the power of 4?


#Write your code here

#Output
1336336

2. Split this string: into a list

s = "Hi there Nicole! Miss you much"

#Write your code here

#Output
['Hi', 'there', 'Nicole!', 'Miss', 'you', 'much']

3. Given the example variables:

team = "Warriors"
standing = “2nd in Western Conference”

Use .format() to print the following string: The standing of


Warriors is 2nd in Western Conference.

#Write your code here

#Output
The standing of Warriors is 2nd in Western Conference.

4. Given this nested list, use indexing to catch the word "Mapua"

lst = [3,2,[1,4],[6,[100,900,['Mapua']],33,11],1,7]
#Write your code here

#Output
'Mapua'
5. Given this nested dictionary display the word "Artificial
Intelligence".

d = {'k1':[4,2,3,{'ML':['DL','IOT','VR',{'AR':[3,2,3,'Artificial
Intelligence']}]}]}
#Write your code here

#Output
'Artificial Intelligence'

6. What is the main difference between a tuple and a list?


#type your answer here

7. Write a function that will get the email website domain from a
string in the form:

[email protected]

For example, passing "[email protected]" would return: domain.com

#write your code here

getDomain('[email protected]')

#Output
'mapua.edu.com'

8. You drive fast along EDSA, and an officer stops you. Write a
function to return one of 3 possible results: "No credential,"
"Small credential," or "Big credential." If your acceleration
is 60 or less, the result is "No credential" if speed is
between 61 and 80, "Small Ticket" results. Assume speed is 81
or more, "Big credential" results. Unless it is your birthday
(encoded as a boolean value in the function's parameters) --
on your birthday, your speed can be five higher in all cases.

#write your code here


caught_by_MMDA(81,True)
#Output 1
Small credential
caught_by_MMDA(81,False)
#Output 2
Big credential

Rubrix:
 Correct PDF Format – 10pts
 Correct Answer – 90 pts

You might also like