Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions Tanya Tandon/linux assignment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Assignment - 1
Q-1 when we create a user ,some hidden files are genrated in the directory of the same user at that time . how is it done ?
A-1 ls -a cmd use for to see the hidden file in linux
. / .. it is show that folders are hidden or not.
Q-2 make subdirectories inside a parent directory by using single mkdir command .
A- mkdir a/b/v

Q-3 tac & cat cmd
A- The word tac is reverse of the word cat.
The tac command functionality is also reverse of the cat command.
cat command prints the file. tac command prints the file in reverse order with the last line first


Assignment - 2
q-1 Chnge the Umask value for any user permanently.
A. man -k umask
sudo gedit /etc/login.defs
chng umask value
if usergroups_enab = yes , chnage into no
then change the umask value

Q-2 addd a new user without using adduser & useradd cmd
A- add a new user
#vim /etc/passwd
then press insert key and add user

Q-3 can we change the umask value to 0888.
A- No, we can't change the umask value to 0888.
highest value is 0777
-rwx have h 777 value

Q-4 how to add a new user with a unique user id &check out the unique id of that user.
A- #useradd jass
#usermod jass
#id jass
#sudo usermod -u 1345 jass

Q-5 how to change the group of any folder.
A- 1)
In kali we can't change the root.
In other o.s. we chnage folder
2)
#chgrp jass file.txt
go to jass then #ll to see jass group is make or not.



Assignment -3
Q-1 create & compress the file with bzip2
A- #bzip2 jass
#bunzip2 jass

Q-2 what should be the argument to be given to unzip that file .
A- #gzip jass
#gunzip jass
#unzip jass

Q-3 read a file & show the data on terminal using file input & output redirection.
A- #cat < jass > file.txt

Q-4 how to change the shell of user to "/bin/sh" at the time of adding the user.
A- firstly check the type of shell
#sudo cat /etc/shells
#/etc/shells
aftr
#sudo chsh -s /bin/bash jass
jass is new usr
#sudo nano /etc/passwd
37 changes: 37 additions & 0 deletions Tanya Tandon/pyth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#Python Class 3:
#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
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")

#2Let’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
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
my_str = 'hello this world @2020!!!'
no_punct = ""
for char in my_str:
if char not in punctuations:
no_punct = no_punct + char
print(no_punct)

# 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?
o =['Apple', 'banana', 'cat', 'REGEX','apple']
o.sort()
print(o)
38 changes: 38 additions & 0 deletions Tanya Tandon/python assignment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
python class 1
1)what is jpython and cpython?
ans.-cypthon is both the compiler as well as the interpreter. it will convert the written python code into the byte code before interpreting it.
it is the default and most widely used implementation of the language.
jpython-it is the implementation of python working on the java platform.

2) basic difference between pyhton2 and pyhton3.
ans.- in python2 it takes the user input and default storing os string is in the ASCII code.whereas in python3 we take only input and default storing of string is in unicode.

3)difference between ASCII Code and unicode.
ans-
Unicode and ASCII both are standards for encoding texts
ASCII CODE-ASCII is a character-encoding scheme and it was the first character encoding standard.ASCII uses 7 bits to represent a character. It has 128 code points, 0 through 127. It is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127.

UNICODE-Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages. It assigns each character a unique number, or code point.


1) what will be the output of 3+4**6-9*10/2
ans- exponent>multiplication=division>addition=subtraction
=3+4**6-9*5
=3+4096-45
=4099-45=4054
so by this the answer will be 4054.

2)lets say i have a string "hello this side regex". count the total no. of vowels present in the string.
ans-
string=input("Enter string:")
vowels=0
for i in string:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
vowels=vowels+1
print("Number of vowels are:",vowel)

3)find out the area of the triangle . you have to take the value from the user about the base and the height.
ans-
h=int(input("enter the height of the triangle=))
b=int(input("enter the base of the triangle=))
print("area of the traingle is=",(1/2)*b*h)
24 changes: 24 additions & 0 deletions Tanya Tandon/python2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#1 what will be the output of 3+4**6-9*10/2
#ans- exponent>multiplication=division>addition=subtraction
#=3+4**6-9*5
#=3+4096-45
#=4099-45=4054
#so by this the answer will be 4054.
print(3+4**6-9*10/2)


#2)lets say i have a string "hello this side regex". count the total no. of vowels present in the string.
#ans-
string=input("Enter string:")
vowels=0
for i in string:
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
vowels=vowels+1
print("Number of vowels are:",vowels)


#3)find out the area of the triangle . you have to take the value from the user about the base and the height.
#ans-
h=int(input("enter the height of the triangle="))
b=int(input("enter the base of the triangle="))
print("area of the traingle is=",(1/2)*b*h)
37 changes: 37 additions & 0 deletions Tanya Tandon/python3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#Python Class 3:
#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
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")

#2Let’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
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
my_str = 'hello this world @2020!!!'
no_punct = ""
for char in my_str:
if char not in punctuations:
no_punct = no_punct + char
print(no_punct)

# 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?
o =['Apple', 'banana', 'cat', 'REGEX','apple']
o.sort()
print(o)
79 changes: 79 additions & 0 deletions Tanya Tandon/python4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#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”]
#Sol.
LIST_STATES = ["GOA","RAJASTHAN","KARNATAKA","GUJRAT","MANIPUR", "MADHYA PRADESH"]
for i in LIST_STATES:
print(i[0])


#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' ]
#Sol.
LIST=['GAnga', 'Tapti', 'Kaveri', 'Yamuna', 'Narmada' ]
k=0
for i in LIST:
j=0
sum_=0
for j in i:
sum_=sum_ + ord(j)
LIST[k]=sum_
k+=1
print(LIST)


#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
#sol)


#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.
tuple = ('a','l','g','o','r','i','t','h','m')
print(tuple[0:])

tuple = tuple[:2] + tuple[3:]
print(tuple)

#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 greator then 20
#- then print those numbers those are less then 10 or equal to 10
#- store these above two list in two different list.
#Sol.
REGex=[1,2,3,4,5,6,7,8,9,0,77,44,15,33,65,89,12]
list1=[]
list2=[]
for i in REGex:
if i> 20:
list1.append(i)
if i<= 10:
list2.append(i)
print(list1)
print(list2)

#6. Execute standard LINUX Commands using Python Programming
#Sol.
import os
cmd = 'wc -l my_text_file.txt > out_file.txt'
os.system(cmd)

#7. Revise *args and **kwargs Concepts
#Sol.
def totalSum(*args):
result = 0
for x in args:
result += x
return result

def concStr(**kwargs):
result = ""
for arg in kwargs.values():
result += arg
return result

print(totalSum(1, 2, 3))
print(concStr(a="This", b="is", c="a", d="Python", e="Program"))
69 changes: 69 additions & 0 deletions tanya tandon/LINUX ASSIGNMENTS/linux assignment.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
linux assignment
Assignment - 1
Q-1 when we create a user ,some hidden files are genrated in the directory of the same user at that time . how is it done ?
A-1 ls -a cmd use for to see the hidden file in linux
. / .. it is show that folders are hidden or not.
Q-2 make subdirectories inside a parent directory by using single mkdir command .
A- mkdir a/b/v

Q-3 tac & cat cmd
A- The word tac is reverse of the word cat.
The tac command functionality is also reverse of the cat command.
cat command prints the file. tac command prints the file in reverse order with the last line first


Assignment - 2
q-1 Change the Umask value for any user permanently.
A. man -k umask
sudo gedit /etc/login.defs
chng umask value
if usergroups_enab = yes , change into no
then change the umask value

Q-2 addd a new user without using adduser & useradd cmd
A- add a new user
#vim /etc/passwd
then press insert key and add user

Q-3 can we change the umask value to 0888.
A- No, we can't change the umask value to 0888.
highest value is 0777
-rwx have h 777 value

Q-4 how to add a new user with a unique user id &check out the unique id of that user.
A- #useradd jass
#usermod jass
#id jass
#sudo usermod -u 1345 jass

Q-5 how to change the group of any folder.
A- 1)
In kali we can't change the root.
In other o.s. we can change the folder
2)
#chgrp jass file.txt
go to jass then #ll to see jass group is make or not.



Assignment -3
Q-1 create & compress the file with bzip2
A- #bzip2 jass
#bunzip2 jass

Q-2 what should be the argument to be given to unzip that file .
A- #gzip jass
#gunzip jass
#unzip jass

Q-3 read a file & show the data on terminal using file input & output redirection.
A- #cat < jass > file.txt

Q-4 how to change the shell of user to "/bin/sh" at the time of adding the user.
A- firstly check the type of shell
#sudo cat /etc/shells
#/etc/shells
aftr
#sudo chsh -s /bin/bash jass
jass is new usr
#sudo nano /etc/passwd
Loading