diff --git a/Pramit Vishwakarma/Linux-01.txt b/Pramit Vishwakarma/Linux-01.txt deleted file mode 100644 index 3804473..0000000 --- a/Pramit Vishwakarma/Linux-01.txt +++ /dev/null @@ -1,19 +0,0 @@ - Linux Assignment-01 - Answers - - -1) When we create a user, some hidden files are generated in the directory of the same user at that time. How is it done ? -Ans.It is done because these files are in the folder /etc/skel and whichever files we place in this folder those files will be - made available in the home directory of all the users which we create afterwards. - For reference following are some commands to create a file in /etc/skel and creating and listing files in /home/user - files - -> cd /etc/root - -> touch TestFile - -> useradd RedhatUser - -> ls /home/RedhatUser - Now you'll find the TestFile document in this folder which is the proof that whichever files we put in the folder - /etc/skel will be available to all the users created after it. - - -2)Make sub directories inside a parent directory by using single mkdir command. -Ans. mkdir -p A/B/C (-p for parent directoy option). \ No newline at end of file diff --git a/Pramit Vishwakarma/Linux-03.txt b/Pramit Vishwakarma/Linux-03.txt deleted file mode 100644 index 1fcd8f1..0000000 --- a/Pramit Vishwakarma/Linux-03.txt +++ /dev/null @@ -1,15 +0,0 @@ - Linux Assignment-03 - Answers - - -1) Create & compress the file with bzip2. -Ans. ->tar -cvzf ContentFile.tar.bz2 content.txt. - -2)What should be the argument to be given to unzip that file. -Ans. ->bzip2 -d filename.bz2 (-d specifies Decompress). - -3) Read a file & show the data on terminal using file input & output redirection -Ans. ->cat < file. - -4) How to change the shell of user to “/bin/sh” at the time of adding the user -Ans. ->useradd -s /bin/sh username. diff --git a/Pramit Vishwakarma/Python-01.txt b/Pramit Vishwakarma/Python-01.txt deleted file mode 100644 index c86482a..0000000 --- a/Pramit Vishwakarma/Python-01.txt +++ /dev/null @@ -1,24 +0,0 @@ - Python Assignment-01 - Answers - - -1) What is JPython & CPython? -Ans.-> Jython is a Python interpreter implemented in Java. It can be fully integrated into existing Java applications; - alternatively, Python applications can be compiled into a collection of Java classes. Python programs running on - the Jython virtual machine have full access to the Java classes and APIs. - - ->CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the - default and most widely used implementation of the language. CPython can be defined as both an interpreter and a compiler as it compiles - Python code into bytecode before interpreting it. It has a foreign function interface with several languages including C, in which one must explicitly write bindings in a language other than Python. - - -2) Basic difference between Python2 & python3. -Ans. This is the most well-known change. In this, the print keyword in Python 2 is replaced by the print() function - in Python 3. - In Python 2 implicit str type is ASCII. But in Python 3 implicit str type is Unicode. - Function take fata from the user (user_input) in the python 2, but in the python 3 (input()) fucntion is use. - - -3) Difference between ASCII & unicode. -Ans. ASCII defines 128 characters, which map to the numbers 0–127. Unicode defines (less than) 221characters, which, similarly, map to numbers 0–221 (though not all numbers are currently assigned, and some are reserved). Unicode is a superset of ASCII, and the numbers 0–128 have the same meaning in ASCII as they have in Unicode. For example, the number 65 means "Latin capital 'A'". - \ No newline at end of file diff --git a/Pramit Vishwakarma/Python-02.txt b/Pramit Vishwakarma/Python-02.txt deleted file mode 100644 index c403ff5..0000000 --- a/Pramit Vishwakarma/Python-02.txt +++ /dev/null @@ -1,40 +0,0 @@ - Python Assignment-02 - Answers - - - -1) What should be the output? - ( 3 + 4 ** 6 - 9 * 10 / 2 ) - -Ans.4054.0 - - - -2) Let say I have, some string "hello this side regex" - Find out the count of the total vowels - vowels - ['a','e','i','o','u']. -Ans. string = "hello this side regex" - temp = [] - for i in range(len(string)): - if string[i]=='a' or string[i]=='e' or string[i]=='i' or string[i]=='o' or string[i]=='u': - if(string[i] not in temp): - temp.append(string[i]) - c = string.lower().count(string[i]) - print(f"{string[i]} : {c} ") - - -3) Find out the area of triangle - - 1/2 * b * h (formula of area) - - You have to take value from user about the base, & the height -Ans. b, h = input("Enter the value of base and height of the trianhle space seprated : ").split(" ") - print(f"Area of Triangle : {1/2 * int(b) * int(h)} ") - - - -4) Print the calendar on the terminal. If you give the year. - - Allow the user to input the year. - - Then should that calendar of that year -Ans. import calendar - y = input("enter the year : ") - for i in range(1,13): - print(calendar.month(int(y),i)) \ No newline at end of file diff --git a/Pramit Vishwakarma/Python-03.txt b/Pramit Vishwakarma/Python-03.txt deleted file mode 100644 index a475df4..0000000 --- a/Pramit Vishwakarma/Python-03.txt +++ /dev/null @@ -1,43 +0,0 @@ - Python Assignment-03 - Answers - - - - -1) Find the Armstrong Number between the two numbers which are input by user? - Armstrong number : 153 -> 1*1*1 + 5*5*5 + 3*3*3 -Ans. n = int(input("Enter any no. : ")) - temp = n - sum = 0 - while (n > 0): - r = n % 10 - sum = sum + (r*r*r) - n = n//10 - - if sum == temp: - print("Number is armstrong") - else: - print("Number is not armstrong") - - - -2) Let’s say you have a string “hello this world @2020!!! ” - Remove the punctuation like [“@!#$%&*()”] from the string - Final output should be without the punctuation - “hello this world 2020” - -Ans. s = "hello this world @2020!!!" - for i in range(len(s)): - if ((s[i] >= 'a' and s[i] <= 'z') or (s[i] >= '0' and s[i] <= '9') or (s[i] == ' ')): - print(s[i],end="") - - - -3) You have a list with words - [“Apple”, “banana”, “cat”, “REGEX”,”apple”] - Sort words in Alphabetical order - If you get output, like [Apple, apple, banana] - How has it happened? - -Ans. l = ['Apple', 'banana', 'cat', 'REGEX','apple'] - l.sort() - print(l) \ No newline at end of file diff --git a/Pramit Vishwakarma/Python-04.txt b/Pramit Vishwakarma/Python-04.txt deleted file mode 100644 index e0f7eba..0000000 --- a/Pramit Vishwakarma/Python-04.txt +++ /dev/null @@ -1,94 +0,0 @@ - Python Assignment-04 - Answers - - - - -1) Write a Program to print new list which contains all the first Characters of strings present in a list..... - LIST_STATES = ["GOA","RAJASTHAN","KARNATAKA","GUJRAT","MANIPUR","MADHYA PRADESH"] -Ans. LIST_STATES = ["GOA","RAJASTHAN","KARNATAKA","GUJRAT","MANIPUR","MADHYA PRADESH"] - l = [] - for i in range(len(LIST_STATES)): - l.append(LIST_STATES[i][0]) - print(l) - - - -2) Write a program to replace each string with an integer value in a given list of strings. - The replacement integer value should be a sum of AScci values of each character of type - corresponding string........ - LIST: ['GAnga', 'Tapti', 'Kaveri', 'Yamuna', 'Narmada' ] -Ans. river = ['GAnga', 'Tapti', 'Kaveri', 'Yamuna', 'Narmada' ] - r = [] - for i in range(len(river)): - sum = 0 - for j in river[i]: - sum = sum + ord(j) - r.append(sum) - print(r) - - -3) You have to run your Program at 9:00am. Date: 14th April 2020. - HINT: - You have to use datetime Module or time module.. - You have to convert your output in #LIST_FORMAT - [ '2020-04-13' , '17:11:01.952975' ] - you can use this with the helf of IF/Else statement -Ans. This program will run at 09am - import time - while True: - if(time.ctime() == 'Tue Apr 14 09:00:00 2020'): - print('hello') - break - - - -4) Give a tuple: - tuple = ('a','l','g','o','r','i','t','h','m') - 1. Using the concept of slicing, print the whole tuple. - 2. delete the element at the 3rd Index, print the tuple..? -Ans. tuple = ('a','l','g','o','r','i','t','h','m') - print(tuple[:]) - print(tuple[0:3]+tuple[4:]) - - -5) Take a list REGex=[1,2,3,4,5,6,7,8,9,0,77,44,15,33,65,89,12] - - print only those numbers greater then 20 - - then print those numbers those are less then 10 or equal to 10 - - store these above two list in two different list. -Ans. REGex=[1,2,3,4,5,6,7,8,9,0,77,44,15,33,65,89,12] - greater = [] - less = [] - for i in REGex: - if i > 20: - greater.append(i) - if i <= 10: - less.append(i) - print(greater) - print(less) - - -6) Revise *args and **kwargs Concepts? - -Ans. ->*args : arbitart argument -> when we don't no the no. of argument we pass - def a(*args): - print(*args) - a(1,2,3) - a('Hello', 'World') - - ->**kwargs is use for key value pair - def a(**kwargs): - print("name is : "+kwargs["name1"]) - a(name1="hello",name2="world") - - - - - - - - - - - - diff --git a/Pramit Vishwakarma/linux-02.txt b/Pramit Vishwakarma/linux-02.txt deleted file mode 100644 index a318465..0000000 --- a/Pramit Vishwakarma/linux-02.txt +++ /dev/null @@ -1,36 +0,0 @@ - Linux Assignment-02 - Answers - - -1) change the Umask value for any user permanently. -Ans.To change the default Umask value to anything, -write a new Umask value in your shell’s configuration file (~/.bashrc for Bash) or in the /etc/profile file. - - -2) add a new user without using adduser & useradd command? -Ans.Step 1 : add an entry for user in /etc/passwd file - Step 2 : add an entry for group in /etc/group file - Step 3 : create home directory for added user with mkdir command - Step 4 : set new user password using passwd command - - -3) Can we change the Umask value to 0888.If yes, then how. If no then why ? -Ans. No,We cannot change the umask value to 0888 as the maximum umask value is can be 0666 as the binaries & scripts in linux have execute permissions. - - -4) how to add a new user with a Unique user id (e.g 1345) & check out the unique Id of that user. -Ans. In useradd command, Use the -u(--uid)option to create a user with a specific UID. ->>sudo useradd -u 1350 username. -We can also verify the user's id using id command: ->>id -u username -1350. - - -5) How to change the group of any folder -Ans. chgrp grpname directoryname. - -5(a) After this checkout the group name of the files present in that folder. -Ans. group of files present in the directory will not change only thr group of directory is changed. - -5(b) Try to change the group of the folder & the files present in the same folder using a single command? -Ans. chgrp -R grpname directoryname. \ No newline at end of file