From a571c89424616a08f8f9be73c22db2daa8b3637d Mon Sep 17 00:00:00 2001 From: rakesh kumar Date: Sat, 23 Jan 2021 15:19:43 +0530 Subject: [PATCH] practical file --- PracticalFileQuestion/Q12.py | 9 ++ PracticalFileQuestion/Q13.py | 11 ++ PracticalFileQuestion/Q14.py | 19 ++++ PracticalFileQuestion/Q15.py | 15 +++ PracticalFileQuestion/Q16.py | 14 +++ PracticalFileQuestion/Q17.py | 15 +++ PracticalFileQuestion/Q18.py | 20 ++++ PracticalFileQuestion/Q18_pre.py | 17 +++ PracticalFileQuestion/Q19_stack.py | 38 +++++++ PracticalFileQuestion/Q20_queue.py | 39 +++++++ .../Q21_csv_file_handling.py | 55 ++++++++++ PracticalFileQuestion/Q22_binary_file.py | 102 ++++++++++++++++++ PracticalFileQuestion/binary.dat | Bin 0 -> 63 bytes PracticalFileQuestion/book.dat | Bin 0 -> 182 bytes PracticalFileQuestion/diary.txt | 4 + PracticalFileQuestion/student.csv | 4 + PracticalFileQuestion/tempCodeRunnerFile.py | 1 + 17 files changed, 363 insertions(+) create mode 100644 PracticalFileQuestion/Q12.py create mode 100644 PracticalFileQuestion/Q13.py create mode 100644 PracticalFileQuestion/Q14.py create mode 100644 PracticalFileQuestion/Q15.py create mode 100644 PracticalFileQuestion/Q16.py create mode 100644 PracticalFileQuestion/Q17.py create mode 100644 PracticalFileQuestion/Q18.py create mode 100644 PracticalFileQuestion/Q18_pre.py create mode 100644 PracticalFileQuestion/Q19_stack.py create mode 100644 PracticalFileQuestion/Q20_queue.py create mode 100644 PracticalFileQuestion/Q21_csv_file_handling.py create mode 100644 PracticalFileQuestion/Q22_binary_file.py create mode 100644 PracticalFileQuestion/binary.dat create mode 100644 PracticalFileQuestion/book.dat create mode 100644 PracticalFileQuestion/diary.txt create mode 100644 PracticalFileQuestion/student.csv create mode 100644 PracticalFileQuestion/tempCodeRunnerFile.py diff --git a/PracticalFileQuestion/Q12.py b/PracticalFileQuestion/Q12.py new file mode 100644 index 0000000..8af6611 --- /dev/null +++ b/PracticalFileQuestion/Q12.py @@ -0,0 +1,9 @@ +# Write a program in python, to create two number lists a and b . +# Swap and display all elements of both lists. + +list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 20] +list2= [13,14,15,18,34,45,56,768,89,890,78] + +list1, list2 = list2,list1 +print(list1) +print(list2) diff --git a/PracticalFileQuestion/Q13.py b/PracticalFileQuestion/Q13.py new file mode 100644 index 0000000..766ee4e --- /dev/null +++ b/PracticalFileQuestion/Q13.py @@ -0,0 +1,11 @@ +# Write a UDF in python, it will take two arguments list +# (sequence of elements) and its size . +# Replace and display first half elements with second half elements of a list. +# For example: list elements are: 1 2 3 4 5 +# Output is: 4 5 3 1 2 + +list1 = [1,2,3,4,5] +n = len(list1) +for i in range(n//2): + list1[i],list1[n//2+1+i]= list1[n//2+1+i],list1[i] +print(list1) diff --git a/PracticalFileQuestion/Q14.py b/PracticalFileQuestion/Q14.py new file mode 100644 index 0000000..40bed2e --- /dev/null +++ b/PracticalFileQuestion/Q14.py @@ -0,0 +1,19 @@ +# Write a UDF in python, it will take two arguments list(sequence of elements) +# and its size. Function arrange and display elements in ascending order. +# Using selection sort. + +def insertion_sort(list1): + n = len(list1) + for i in range(1,n): + temp = list1[i] + j = i-1 + while j>=0 and tempD KY*NTtss{kX?hUK} literal 0 HcmV?d00001 diff --git a/PracticalFileQuestion/book.dat b/PracticalFileQuestion/book.dat new file mode 100644 index 0000000000000000000000000000000000000000..1de514d0a5eb3f1c95394f594ebc3bada5e0312c GIT binary patch literal 182 zcmZo*t}SHHh+t!2U`Wc(&(6y)Wb|f?;DmDH^AdAY3z;H#f&84*5{1lSg@VeGjQqSp z=2E=|ELxc`wDJJ8dZgy$