<jupyter_start><jupyter_text>Functions > A **function** is a named sequence of statements that performs a computation.> When defined, you specify the **name** and the sequence of statements.> Later, you **call the function** by name >> 1.  **A Python function that takes a list and returns a new list with unique elements of the first list.**<jupyter_code>def unique_list(l):
  x = []
  for a in l:
    if a not in x:
      x.append(a)
  return x

print(unique_list(input('Enter a list: ')))<jupyter_output>Enter a list Enter a list
['E', 'n', 't', 'e', 'r', ' ', 'a', 'l', 'i', 's']<jupyter_text>>> 2. **A Python function that reverses a string.**<jupyter_code>def string_reverse(str1):

    rstr1 = ''
    index = len(str1)
    while index > 0:
        rstr1 += str1[ index - 1 ]
        index = index - 1
    return rstr1
print(string_reverse(input('Enter a string: ')))<jupyter_output>Enter a string eedd
ddee<jupyter_text>>> 3.  **A Python function that checks whether a passed string is palindrome or not.**<jupyter_code>def isPalindrome(string):
    left_pos = 0
    right_pos = len(string) - 1
    
    while right_pos >= left_pos:
        if not string[left_pos] == string[right_pos]:
            return False
        left_pos += 1
        right_pos -= 1
    return True
print(isPalindrome(input('Enter a word: ')))<jupyter_output>Enter a word delete
False<jupyter_text>Class Exercises > 1. **Write a shutting down program:**>     a. First, **def** a function, **shut_down**, that takes one argument from the keyboard. >     b. Then, if the **shut_down**  function receives an argument equal to **"yes"**, it should return "Shutting down".>     c. Alternatively, elif argument is equal to **"no"**, then the function should return "Shutdown aborted". >     d. Finally, if shut_down gets anything other than those inputs, the function should return "Sorry, such argument not welcome here ". > 2. Create a function **showEmployee()** in such a way that it should accept a given number of employee name and salary as input, stores the data in a dictionary, and then save it into a csv file, if any of the following condition is met. >    a. If the salary is greater than **N1,000,000** display employ name and salary in **green color**. >    b. If the salary is greater than **N500,000** and less than N1,000,000 dispaly both employee name and salary in **blue color**. >    c. If the salary is less than **N500,000** dispaly both employee name and salary in red color.If the salary is missing in the function call display the message **"Warning: No salary structure for employee"** in **red color**. > 3. **Follow the stpes:**    >       a. First, def a function called **cube** that takes an argument called **number**.>       b. Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).>       c. Define a second function called **by_three** that takes an argument called number. if that number is divisible by 3, **by_three** should call **cube(number)** and return its result. Otherwise, **by_three should** return False. -Check if it works. > 4. Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters.  Number 1 Answer<jupyter_code>def shutdown(a):
    
    if a=="Yes":
        print("Shutting down")
    elif a=="No":
        print("Shutdown aborted")
    else:
        print("Sorry, such argument not welcome here ")
k = input("Are you going to the office:")
shutdown(k)<jupyter_output>Are you going to the office:Maybe
Sorry, such argument not welcome here<jupyter_text>Number 3 Answer<jupyter_code>def cube(number):
    print(number**3)
number = int(input("Please enter the value for w "))
cube(number)

def by_three(number):
    if number%3==0:
        return(number**3)
    else:
        return("False")
#f = int(input("Please enter the value for f "))
by_three(number)<jupyter_output>Please enter the value for w 5
125<jupyter_text>Number 4 Answer<jupyter_code>def isupper(str1):
    w = int(input("Please enter your word "))
print(w)
w = int(input("Please enter your word "))
name=str(input("enter the string"))
count=0
for i in name:
    if i.isupper():
        count=count+1
print("The number of capital letters found in the string is:-",count)<jupyter_output>enter the stringLEttER
The number of capital letters found in the string is:- 4<jupyter_text>Number 2 Answer<jupyter_code>import colorama
from colorama import Fore, Style
#import pandas
import pandas as pd
import csv

def showEmployee(c):
    m=0
    while m < c:
        n=input("Enter name: ")
        s=int(input("Enter salary:"))
        x={}
        if (s>1000000):
            print(Fore.GREEN + "Name:", n)
            print("Salary ",s)
            print(Style.RESET_ALL)
        elif (s>500000)&(s<1000000):
            print(Fore.BLUE + "Name:", n)
            print("Salary ",s)
            print(Style.RESET_ALL)
        else:
            print(Fore.RED + "Warning: No salary structure for employee")
            print(Style.RESET_ALL)
            
        field_names = ['No', 'Name', 'Salary']
        x=[{'No':m, 'Name':n, 'Salary':s}]
        with open('Name.csv', 'w') as csvfile:
            writer = csv.DictWriter(csvfile, fieldnames = field_names)
            writer.writeheader()
            writer.writerows(x)
        m+=1
        
c=int(input("Enter number of Employees:"))

showEmployee(c)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup