diff --git a/.idea/Assignments.iml b/.idea/Assignments.iml index 74d515a..cbb3ee5 100644 --- a/.idea/Assignments.iml +++ b/.idea/Assignments.iml @@ -4,7 +4,7 @@ <content url="file://$MODULE_DIR$"> <excludeFolder url="file://$MODULE_DIR$/venv" /> </content> - <orderEntry type="inheritedJdk" /> + <orderEntry type="jdk" jdkName="C:\Users\aadit\AppData\Local\R-MINI~1" jdkType="Python SDK" /> <orderEntry type="sourceFolder" forTests="false" /> </component> </module> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index aa8302e..b749013 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (Assignments)" project-jdk-type="Python SDK" /> + <component name="ProjectRootManager" version="2" project-jdk-name="C:\Users\aadit\AppData\Local\R-MINI~1" project-jdk-type="Python SDK" /> </project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 55afcd0..a8a093c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="AutoImportSettings"> + <option name="autoReloadType" value="SELECTIVE" /> + </component> <component name="ChangeListManager"> - <list default="true" id="71eccd33-7d7f-425c-ad02-4395be0f10cc" name="Default Changelist" comment="" /> + <list default="true" id="71eccd33-7d7f-425c-ad02-4395be0f10cc" name="Default Changelist" comment=""> + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> + </list> <option name="SHOW_DIALOG" value="false" /> <option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> @@ -14,16 +19,22 @@ </list> </option> </component> + <component name="Git.Settings"> + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> + </component> <component name="ProjectId" id="1ZXZuuFgkFt4QMFvsacqlysLR0X" /> <component name="ProjectViewState"> <option name="hideEmptyMiddlePackages" value="true" /> - <option name="showExcludedFiles" value="true" /> <option name="showLibraryContents" value="true" /> </component> - <component name="PropertiesComponent"> - <property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> - <property name="last_opened_file_path" value="$PROJECT_DIR$/Section_06/project_files/first_folder/second_folder" /> - </component> + <component name="PropertiesComponent"><![CDATA[{ + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "git-widget-placeholder": "master", + "last_opened_file_path": "C:/Users/aadit/OneDrive/Documents/GitHub/AaditProjects/Python Interview Challenges" + } +}]]></component> <component name="RecentsManager"> <key name="CopyFile.RECENT_KEYS"> <recent name="$PROJECT_DIR$/Section_06/project_files/first_folder/second_folder" /> @@ -40,8 +51,8 @@ <recent name="$PROJECT_DIR$/Section_001" /> </key> </component> - <component name="RunManager" selected="Python.assignment_01 (1)"> - <configuration name="Assignment_09" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <component name="RunManager" selected="Python.assignment_05 (1)"> + <configuration name="assignment_01" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <module name="Assignments" /> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -53,7 +64,7 @@ <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/Assignment_09.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_01.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> @@ -62,7 +73,7 @@ <option name="INPUT_FILE" value="" /> <method v="2" /> </configuration> - <configuration name="assignment_01 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <configuration name="assignment_02 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <module name="Assignments" /> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -70,11 +81,11 @@ <env name="PYTHONUNBUFFERED" value="1" /> </envs> <option name="SDK_HOME" value="" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Section_05" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Section_04" /> <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_05/assignment_01.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_02.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> @@ -83,7 +94,7 @@ <option name="INPUT_FILE" value="" /> <method v="2" /> </configuration> - <configuration name="assignment_01" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <configuration name="assignment_03 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <module name="Assignments" /> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -91,11 +102,11 @@ <env name="PYTHONUNBUFFERED" value="1" /> </envs> <option name="SDK_HOME" value="" /> - <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Section_06" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Section_04" /> <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_06/assignment_01.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_03.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> @@ -104,7 +115,7 @@ <option name="INPUT_FILE" value="" /> <method v="2" /> </configuration> - <configuration name="assignment_06" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <configuration name="assignment_04 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <module name="Assignments" /> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -116,7 +127,7 @@ <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_06.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_04.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> @@ -125,7 +136,7 @@ <option name="INPUT_FILE" value="" /> <method v="2" /> </configuration> - <configuration name="assignment_08" type="PythonConfigurationType" factoryName="Python" temporary="true"> + <configuration name="assignment_05 (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <module name="Assignments" /> <option name="INTERPRETER_OPTIONS" value="" /> <option name="PARENT_ENVS" value="true" /> @@ -137,7 +148,7 @@ <option name="IS_MODULE_SDK" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" /> - <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_08.py" /> + <option name="SCRIPT_NAME" value="$PROJECT_DIR$/Section_04/assignment_05.py" /> <option name="PARAMETERS" value="" /> <option name="SHOW_COMMAND_LINE" value="false" /> <option name="EMULATE_TERMINAL" value="false" /> @@ -148,11 +159,11 @@ </configuration> <recent_temporary> <list> - <item itemvalue="Python.assignment_01 (1)" /> + <item itemvalue="Python.assignment_05 (1)" /> + <item itemvalue="Python.assignment_04 (1)" /> + <item itemvalue="Python.assignment_03 (1)" /> + <item itemvalue="Python.assignment_02 (1)" /> <item itemvalue="Python.assignment_01" /> - <item itemvalue="Python.Assignment_09" /> - <item itemvalue="Python.assignment_08" /> - <item itemvalue="Python.assignment_06" /> </list> </recent_temporary> </component> @@ -168,6 +179,7 @@ </list> </option> </component> + <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SvnConfiguration"> <configuration /> </component> @@ -181,85 +193,15 @@ </task> <servers /> </component> - <component name="WindowStateProjectService"> - <state x="553" y="293" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1585078602438"> - <screen x="0" y="23" width="1680" height="961" /> - </state> - <state x="553" y="293" key="#com.intellij.fileTypes.FileTypeChooser/0.23.1680.961@0.23.1680.961" timestamp="1585078602438" /> - <state x="553" y="294" key="#com.intellij.fileTypes.FileTypeChooser/0.23.1680.963@0.23.1680.963" timestamp="1584987668869" /> - <state width="1659" height="243" key="GridCell.Tab.0.bottom" timestamp="1587848272003"> - <screen x="0" y="23" width="1680" height="963" /> - </state> - <state width="1659" height="243" key="GridCell.Tab.0.bottom/0.23.1680.956@0.23.1680.956" timestamp="1586812812978" /> - <state width="1659" height="243" key="GridCell.Tab.0.bottom/0.23.1680.958@0.23.1680.958" timestamp="1586896304281" /> - <state width="1659" height="243" key="GridCell.Tab.0.bottom/0.23.1680.960@0.23.1680.960" timestamp="1586984046743" /> - <state width="1659" height="243" key="GridCell.Tab.0.bottom/0.23.1680.961@0.23.1680.961" timestamp="1587246586020" /> - <state width="1659" height="243" key="GridCell.Tab.0.bottom/0.23.1680.963@0.23.1680.963" timestamp="1587848272003" /> - <state width="1659" height="245" key="GridCell.Tab.0.bottom/0.23.1680.965@0.23.1680.965" timestamp="1585012234423" /> - <state width="1659" height="245" key="GridCell.Tab.0.bottom/0.23.1680.966@0.23.1680.966" timestamp="1585077167974" /> - <state width="1659" height="243" key="GridCell.Tab.0.center" timestamp="1587848272002"> - <screen x="0" y="23" width="1680" height="963" /> - </state> - <state width="1659" height="243" key="GridCell.Tab.0.center/0.23.1680.956@0.23.1680.956" timestamp="1586812812977" /> - <state width="1659" height="243" key="GridCell.Tab.0.center/0.23.1680.958@0.23.1680.958" timestamp="1586896304281" /> - <state width="1659" height="243" key="GridCell.Tab.0.center/0.23.1680.960@0.23.1680.960" timestamp="1586984046743" /> - <state width="1659" height="243" key="GridCell.Tab.0.center/0.23.1680.961@0.23.1680.961" timestamp="1587246586019" /> - <state width="1659" height="243" key="GridCell.Tab.0.center/0.23.1680.963@0.23.1680.963" timestamp="1587848272002" /> - <state width="1659" height="245" key="GridCell.Tab.0.center/0.23.1680.965@0.23.1680.965" timestamp="1585012234422" /> - <state width="1659" height="245" key="GridCell.Tab.0.center/0.23.1680.966@0.23.1680.966" timestamp="1585077167973" /> - <state width="1659" height="243" key="GridCell.Tab.0.left" timestamp="1587848272002"> - <screen x="0" y="23" width="1680" height="963" /> - </state> - <state width="1659" height="243" key="GridCell.Tab.0.left/0.23.1680.956@0.23.1680.956" timestamp="1586812812977" /> - <state width="1659" height="243" key="GridCell.Tab.0.left/0.23.1680.958@0.23.1680.958" timestamp="1586896304280" /> - <state width="1659" height="243" key="GridCell.Tab.0.left/0.23.1680.960@0.23.1680.960" timestamp="1586984046743" /> - <state width="1659" height="243" key="GridCell.Tab.0.left/0.23.1680.961@0.23.1680.961" timestamp="1587246586018" /> - <state width="1659" height="243" key="GridCell.Tab.0.left/0.23.1680.963@0.23.1680.963" timestamp="1587848272002" /> - <state width="1659" height="245" key="GridCell.Tab.0.left/0.23.1680.965@0.23.1680.965" timestamp="1585012234422" /> - <state width="1659" height="245" key="GridCell.Tab.0.left/0.23.1680.966@0.23.1680.966" timestamp="1585077167973" /> - <state width="1659" height="243" key="GridCell.Tab.0.right" timestamp="1587848272003"> - <screen x="0" y="23" width="1680" height="963" /> - </state> - <state width="1659" height="243" key="GridCell.Tab.0.right/0.23.1680.956@0.23.1680.956" timestamp="1586812812978" /> - <state width="1659" height="243" key="GridCell.Tab.0.right/0.23.1680.958@0.23.1680.958" timestamp="1586896304281" /> - <state width="1659" height="243" key="GridCell.Tab.0.right/0.23.1680.960@0.23.1680.960" timestamp="1586984046743" /> - <state width="1659" height="243" key="GridCell.Tab.0.right/0.23.1680.961@0.23.1680.961" timestamp="1587246586019" /> - <state width="1659" height="243" key="GridCell.Tab.0.right/0.23.1680.963@0.23.1680.963" timestamp="1587848272003" /> - <state width="1659" height="245" key="GridCell.Tab.0.right/0.23.1680.965@0.23.1680.965" timestamp="1585012234423" /> - <state width="1659" height="245" key="GridCell.Tab.0.right/0.23.1680.966@0.23.1680.966" timestamp="1585077167973" /> - <state width="1659" height="307" key="GridCell.Tab.1.bottom" timestamp="1586984046739"> - <screen x="0" y="23" width="1680" height="960" /> - </state> - <state width="1659" height="304" key="GridCell.Tab.1.bottom/0.23.1680.956@0.23.1680.956" timestamp="1586283827002" /> - <state width="1659" height="307" key="GridCell.Tab.1.bottom/0.23.1680.958@0.23.1680.958" timestamp="1586890018078" /> - <state width="1659" height="307" key="GridCell.Tab.1.bottom/0.23.1680.960@0.23.1680.960" timestamp="1586984046739" /> - <state width="1659" height="307" key="GridCell.Tab.1.center" timestamp="1586984046738"> - <screen x="0" y="23" width="1680" height="960" /> - </state> - <state width="1659" height="304" key="GridCell.Tab.1.center/0.23.1680.956@0.23.1680.956" timestamp="1586283827001" /> - <state width="1659" height="307" key="GridCell.Tab.1.center/0.23.1680.958@0.23.1680.958" timestamp="1586890018077" /> - <state width="1659" height="307" key="GridCell.Tab.1.center/0.23.1680.960@0.23.1680.960" timestamp="1586984046738" /> - <state width="1659" height="307" key="GridCell.Tab.1.left" timestamp="1586984046738"> - <screen x="0" y="23" width="1680" height="960" /> - </state> - <state width="1659" height="304" key="GridCell.Tab.1.left/0.23.1680.956@0.23.1680.956" timestamp="1586283827001" /> - <state width="1659" height="307" key="GridCell.Tab.1.left/0.23.1680.958@0.23.1680.958" timestamp="1586890018077" /> - <state width="1659" height="307" key="GridCell.Tab.1.left/0.23.1680.960@0.23.1680.960" timestamp="1586984046738" /> - <state width="1659" height="307" key="GridCell.Tab.1.right" timestamp="1586984046739"> - <screen x="0" y="23" width="1680" height="960" /> - </state> - <state width="1659" height="304" key="GridCell.Tab.1.right/0.23.1680.956@0.23.1680.956" timestamp="1586283827002" /> - <state width="1659" height="307" key="GridCell.Tab.1.right/0.23.1680.958@0.23.1680.958" timestamp="1586890018078" /> - <state width="1659" height="307" key="GridCell.Tab.1.right/0.23.1680.960@0.23.1680.960" timestamp="1586984046739" /> - <state x="519" y="315" key="com.intellij.ide.util.TipDialog" timestamp="1585079344470"> - <screen x="0" y="23" width="1680" height="960" /> - </state> - <state x="519" y="315" key="com.intellij.ide.util.TipDialog/0.23.1680.960@0.23.1680.960" timestamp="1585079344470" /> - <state x="519" y="315" key="com.intellij.ide.util.TipDialog/0.23.1680.961@0.23.1680.961" timestamp="1585078575620" /> - <state x="519" y="317" key="com.intellij.ide.util.TipDialog/0.23.1680.967@0.23.1680.967" timestamp="1585077363934" /> - <state x="505" y="224" width="670" height="676" key="search.everywhere.popup" timestamp="1585245217225"> - <screen x="0" y="23" width="1680" height="960" /> - </state> - <state x="505" y="224" width="670" height="676" key="search.everywhere.popup/0.23.1680.960@0.23.1680.960" timestamp="1585245217225" /> + <component name="Vcs.Log.Tabs.Properties"> + <option name="TAB_STATES"> + <map> + <entry key="MAIN"> + <value> + <State /> + </value> + </entry> + </map> + </option> </component> </project> \ No newline at end of file diff --git a/Section_01/assignment_01.py b/Section_01/assignment_01.py index fa1f33a..9888798 100644 --- a/Section_01/assignment_01.py +++ b/Section_01/assignment_01.py @@ -5,8 +5,8 @@ How would you change the code to meet the requirement? """ - - +result=15%4 +print(result) diff --git a/Section_01/assignment_02.py b/Section_01/assignment_02.py index a5636d1..587ddb9 100644 --- a/Section_01/assignment_02.py +++ b/Section_01/assignment_02.py @@ -8,6 +8,8 @@ print("We have {2} small boxes, {2} large boxes, {2} medium boxes".format(10,12,12)) """ +sentence='We actually have {} small, {} large, and {} medium boxes.'.format(10,12,12) +print(sentence) diff --git a/Section_01/assignment_03.py b/Section_01/assignment_03.py index 5d312a7..3c73c8f 100644 --- a/Section_01/assignment_03.py +++ b/Section_01/assignment_03.py @@ -21,6 +21,9 @@ # Expected Result Printed: [[Cool]] # Your code below: +mid_of_chars=len(chars)//2 +result=chars[:mid_of_chars]+word+chars[mid_of_chars:] +print(result) diff --git a/Section_01/assignment_04.py b/Section_01/assignment_04.py index addb148..afcbaca 100644 --- a/Section_01/assignment_04.py +++ b/Section_01/assignment_04.py @@ -19,7 +19,8 @@ # Expected Result Printed: omputerTuck # Your code below: - +result=word1[1:]+word2[0]+word2[2:] +print(result) diff --git a/Section_01/assignment_05.py b/Section_01/assignment_05.py index d672da4..8c5b487 100644 --- a/Section_01/assignment_05.py +++ b/Section_01/assignment_05.py @@ -23,7 +23,9 @@ # Your code below: - +mid_of_char=len(chars)//2 +result=chars[:mid_of_char]+word+chars[mid_of_char:] +print(result) diff --git a/Section_02/assignment_01.py b/Section_02/assignment_01.py index 742cfa9..9889208 100644 --- a/Section_02/assignment_01.py +++ b/Section_02/assignment_01.py @@ -6,8 +6,11 @@ """ - +my_list = [{'Tom': 20000, 'Bill': 12000}, ['car', 'laptop', 'TV']] # your code below: +bill_salary=my_list[0]['Bill'] + +print(f'The Salary that {list(my_list[0].keys())[1]} earns is $ {bill_salary}') diff --git a/Section_02/assignment_02.py b/Section_02/assignment_02.py index da7812a..264d7df 100644 --- a/Section_02/assignment_02.py +++ b/Section_02/assignment_02.py @@ -10,7 +10,8 @@ """ # your code below: - +info={'Tom':{'Salary':20000,'Age':22,'owns_items':['Jacket','Car','TV']},'Mike':{'Salary':24000,'Age':27,'owns_items': + ['Bike','Laptop','Boat']}} diff --git a/Section_02/assignment_03.py b/Section_02/assignment_03.py index 5e91adb..d7d7b87 100644 --- a/Section_02/assignment_03.py +++ b/Section_02/assignment_03.py @@ -13,6 +13,10 @@ # your code below: +new_list=original_list[:3] +new_list.append(tuple(sorted(list(original_list[3])))) +print(new_list) + diff --git a/Section_02/assignment_04.py b/Section_02/assignment_04.py index c3e2a50..e2d832e 100644 --- a/Section_02/assignment_04.py +++ b/Section_02/assignment_04.py @@ -9,8 +9,12 @@ # Your Code Below: - - +third_element=list(my_list[2]) +manipulation_1=third_element[0][3]='x' +third_element=tuple(third_element) +fourth_element=my_list[3]='television' +my_list.pop(2) +my_list.insert(2,third_element) diff --git a/Section_03/assignment_01.py b/Section_03/assignment_01.py index 3688656..5d77acf 100644 --- a/Section_03/assignment_01.py +++ b/Section_03/assignment_01.py @@ -7,6 +7,10 @@ # your code below: +def merge_lists(lst1,lst2): + result= lst1+lst2 + return result + @@ -51,5 +55,5 @@ # def merge_lists(list_a, list_b): # return list_a + list_b # -# my_list = merge_lists([1,2,3],['a', 'b', 'c']) -# print(my_list) \ No newline at end of file +my_list = merge_lists([1,2,3],['a', 'b', 'c']) +print(my_list) \ No newline at end of file diff --git a/Section_03/assignment_02.py b/Section_03/assignment_02.py index 3e74ab6..2e84530 100644 --- a/Section_03/assignment_02.py +++ b/Section_03/assignment_02.py @@ -7,6 +7,8 @@ Make sure to test the function. """ # Your Code Below: +def separate(string): + return list(string) @@ -15,6 +17,10 @@ +print(separate('Aadit Jain')) +print(separate('My Lovely Sister - Rashi')) + + @@ -56,4 +62,4 @@ # def separate(str): # return list(str) # -# print(separate("hello there")) \ No newline at end of file +print(separate("hello there")) \ No newline at end of file diff --git a/Section_03/assignment_03.py b/Section_03/assignment_03.py index 0d9731f..774111c 100644 --- a/Section_03/assignment_03.py +++ b/Section_03/assignment_03.py @@ -10,6 +10,11 @@ """ # Your Code Below: +def multi_merge(lst,string): + lst=list(map(str,lst)) + string_list=list(string) + lst+=string_list + return sorted(lst) @@ -18,8 +23,7 @@ - - +print(multi_merge(['Aadit','Jain','UP','37','U','P',6,3,1,0],'UP37U6310')) @@ -56,4 +60,4 @@ # def multi_merge(list_a, str): # return list_a + str.split() + list(str) # -# print(multi_merge([1,2,3,4], "Hello My name is imtiaz")) +print(multi_merge([1,2,3,4], "Hello My name is imtiaz")) diff --git a/Section_03/assignment_04.py b/Section_03/assignment_04.py index a33876f..72e1837 100644 --- a/Section_03/assignment_04.py +++ b/Section_03/assignment_04.py @@ -13,14 +13,16 @@ """ # Your code below: +def last_list(*args): + return args[-1] - - +print(last_list([1,2,3,4,5], ['a', 'b', 'c'], ['mike', 'john'])) +print(last_list(['Aadit','Jain','UP','37','U','P',6,3,1,0])) diff --git a/Section_03/assignment_05.py b/Section_03/assignment_05.py index 425df0b..5fa4056 100644 --- a/Section_03/assignment_05.py +++ b/Section_03/assignment_05.py @@ -14,11 +14,8 @@ """ # Your Code Below: - - - - - +def key_list_items(**kwargs): + return kwargs['people'][-2] @@ -65,6 +62,6 @@ # keys = kwargs[key] # return keys[-2] # -# result = key_list_items("people", things=['book', 'tv', 'shoes'], people=['pete', 'mike', 'jan', 'tom'], -# ages=[20, 30, 40]) -# print(result) \ No newline at end of file +result = key_list_items("people", things=['book', 'tv', 'shoes'], people=['pete', 'mike', 'jan', 'tom'], + ages=[20, 30, 40]) +print(result) \ No newline at end of file diff --git a/Section_04/assignment_01.py b/Section_04/assignment_01.py index f3313a1..0e0163c 100644 --- a/Section_04/assignment_01.py +++ b/Section_04/assignment_01.py @@ -13,6 +13,16 @@ """ # Your Code Below: +def twelver(a,b): + if ( a==12 or b==12 ) or (a+b==12): + return True + return False + +print(twelver(3, 12)) + +print(twelver(4, 9)) + +print(twelver(9, 3)) diff --git a/Section_04/assignment_02.py b/Section_04/assignment_02.py index d0dc7b5..0fbf46e 100644 --- a/Section_04/assignment_02.py +++ b/Section_04/assignment_02.py @@ -18,6 +18,16 @@ """ # Your Code Below: +def pay_extra(working,hour): + if working==True and (hour>=20 or hour<=8): + return True + return False + +print(pay_extra(True, 11)) + +print(pay_extra(False, 5)) + +print(pay_extra(True, 6)) diff --git a/Section_04/assignment_03.py b/Section_04/assignment_03.py index 6d4d390..818de0a 100644 --- a/Section_04/assignment_03.py +++ b/Section_04/assignment_03.py @@ -12,6 +12,9 @@ """ # Your Code Below: +def sequence(*args): + pass +print(sequence([1, 1, 2, 3, 1])) diff --git a/Section_04/assignment_04.py b/Section_04/assignment_04.py index b5940c4..fcbd381 100644 --- a/Section_04/assignment_04.py +++ b/Section_04/assignment_04.py @@ -10,6 +10,17 @@ """ # Your Code Below: +def grow_string(string): + result_string='' + for i in range(len(string)): + result_string+=string[:i+1] + return result_string + +print(grow_string('Code')) + +print(grow_string('abc')) + +print(grow_string('ab')) diff --git a/Section_04/assignment_05.py b/Section_04/assignment_05.py index 3b61d70..a95ff8e 100644 --- a/Section_04/assignment_05.py +++ b/Section_04/assignment_05.py @@ -14,8 +14,17 @@ """ # Your Code Below: +def first3(lst): + first_four=lst[:4] + return 6 in first_four +print(first3([1, 2, 6, 3, 4])) + +print(first3([1, 2, 3, 4, 6])) + +print(first3([1, 2, 3, 4, 5])) +