<jupyter_start><jupyter_text>LEVEL 1 PROBLEMSOLD MACDONALD: Write a function that capitalizes the first and fourth letters of a nameold_macdonald('macdonald') --> MacDonaldNote: 'macdonald'.capitalize() returns 'Macdonald'<jupyter_code>#Using .upper()

#Method used is to split the word to be able to manipulate the desired letter(s)
#change to upper case
#then concatenate
def oldMacdonald(name):

    firstLetter = name[0]
    inBetween = name[1:3]
    fourthLetter = name[3]
    remainder =name[4:]
    
    return firstLetter.upper() + inBetween + fourthLetter.upper() + remainder
# Check
oldMacdonald('macdonald')
#Using .capitalize()

def oldMacdonald(name):

    stringOne = name[:3]
    stringTwo = name[3:]

    return stringOne.capitalize() + stringTwo.capitalize()
# Check
oldMacdonald('macdonald')<jupyter_output><empty_output><jupyter_text>MASTER YODA: Given a sentence, return a sentence with the words reversed    master_yoda('I am home') --> 'home am I'    master_yoda('We are ready') --> 'ready are We'Note: The .join() method may be useful here. The .join() method allows you to join together strings in a list with some connector string. For example, some uses of the .join() method:>>> "--".join(['a','b','c'])>>> 'a--b--c'This means if you had a list of words you wanted to turn back into a sentence, you could just join them with a single space string:>>> " ".join(['Hello','world'])>>> "Hello world"<jupyter_code>#Strings can be reversed using slicing. To reverse a string, 
#we simply create a slice that starts with the length of the string, and ends at index 0.

def master_yoda(txt):
    wordlist = txt.split()
    reversedString = wordlist[::-1]
    return reversedString
#check
master_yoda('I am home')
#check
master_yoda('We are ready')
#***********************************
#To return the words to a string
mylist = ['o''m''g']
''.join(mylist)
#***********************************
def master_yoda(txt):
    wordList = txt.split()
    reversedString = wordList[::-1]

    return reversedString
#check
master_yoda('I am home')
#check
master_yoda('We are ready')<jupyter_output><empty_output><jupyter_text>ALMOST THERE: Given an integer n, return True if n is within 10 of either 100 or 200    almost_there(90) --> True    almost_there(104) --> True    almost_there(150) --> False    almost_there(209) --> TrueNOTE: abs(num) returns the absolute value of a number<jupyter_code>#Absolute Values - No Negatives!
#In practice "absolute value" means to remove any negative sign in front of a number, and to 
#think of all numbers as positive (or zero).
#A number can be an integer, a floating point number or a complex number

def almost_there(n):
    return ((abs(100 - n) <= 10) or (abs(200 - n) <= 10))
# Check
almost_there(90)
# Check
almost_there(110)
# Check
almost_there(104)
# Check
almost_there(150)
# Check
almost_there(209)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14028403186698996, 'fraction_numerical': 0.018704537582265326, 'mean_word_length': 4.82258064516129, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '579334', 'license': 'MIT', 'n_tokens_mistral': 960, 'n_tokens_neox': 894, 'n_words': 322, 'path': '[Self Help] Python/Notes - Learning Resources/Functions & Methods/[Section 6] Function Practice Exercises - Level One {Code Along} .ipynb', 'repo_name': 'amuganda/MacOS_Repository_Restructured', 'size': '2887'}