DBMS

Wednesday, October 2, 2019

Biwise Shifting Techniques and Data Conversion Formats

Arithmetic Shift Vs. Logical Shift

Arithmetic Shift operates on the data, it considers data as signed integer and does not shift the signed bit. (in both cases: either left or right shift)
In case of logical shift, sign of the data is not important, and data is shifted left of right without worring about the sign.

Impact

If during shift operation, overflow occurs then both arithmetic and logical shift may produce different results i.e. arithmetic shift do not allow overflow but the logical shift allows to occur.
Example
Before shift data is
10101001
After 1 bit logical left shift
01010010    #sign changed
After 1 bit arithmetic left shift
11010010    #sign unchanged

Rotation or Cyclic Shift

In the cylic shift, each bit is rotated (depending upon left or right rotation) without loosing the bits. In this process each bit can come at the sign bit location (LSB) which helps to identify the sign of the data.
Every shift operation is performed by ALU with the help of the transfer instructions.

Conversion into Binary Coded Decimal (BCD) Format

In BCD Conversion, each decimal digit is converted into four bits. It is send in Packed Decimal or Unpacked Decimal Format. The digit 0 is converted into 0000, 1 as 0001, ...,9 is represented as 1001. BCD convertion takes equal to or more number of bits than a normal binary conversion. In Packed decimal 8 bits are transferred with bad at 4 LSBs and few unimportant bits at MSBs, whereas in packed decimal, two numbers are simultaneously managed at 4 LSBs and 4 MSBs.

Conversion into International Reference Alphabet (IRA) Format

In IRA conversion, each decimal number is represented in four bits considering 011 as prefix. so 0 is represented as 0110000, and 9 is represented as 0111001.

Conversion into American Standard Code for Information Interchange (ASCII) Format

For ASCII conversion, each character is given 7 bit code. The most significant bit is filled with o or 1 depending upon the type of parity (even or odd parity) maintained for data transfer.

Conversion into Extended Binary Coded Decimal Interchange Code (EBCDIC) Format

Similar to IRA coding, EBCDIC coding also converts each and every bit in four bits. The only difference is, it use 1111 as prefix, i.e. 0 is represented as 11110000 and 9 is represented as 11111001.

Tuesday, October 1, 2019

Operations on List Containers in Python

List 

As discussed in previous blog, the list is container which is mutable i.e. the elements in the list can be modified, added or deleted, etc.
Let the given list is 
L = [1, 4, "Arjun"]
print(L)
Output>>>
[1, 4, 'Arjun']
To add element in the list following:
L = L.append("Karna")
print(L)
Output>>>
[1, 4, 'Arjun', 'karna']
Typically, element is added in the last. To insert element at any specific index number, do following:
L=[1, 4, 'Arjun', 'Karna']
L.insert(2,'Dronacharya')
print(L)
Output>>>
[1, 4, 'Dronachayra', 'Arjun', 'Karna']
To delete specific element from the list, do following:
L.remove("Arjun")
print(L)
Output>>>
[1, 4, 'Karna']
To remove last element from of the list, do following:
L=[1, 4, 'Arjun', 'Karna']
L.pop()
print(L)
Output>>>
[1, 4, 'Arjun']
To clear all the element from the list, do following:
L=[1, 4, 'Arjun', 'Karna']
L.clear()
Output>>>

[]
To delete the whole list including container, do following:
L=[1,4,'Arjun','Karna']
del(L)
print(L) #get error as L is not existing now. 💭
To copy content of one list to another list
L1 = [1,4,"Arjun", "Karna"]
print(L1)
L2 = L1.copy()
print(L2)
L1.append("Dronacharya")
print(L1)
print(L2)
Output>>>
[1,4, "Arjun", "Karna"] [1,4, "Arjun", "Karna"] [1,4, "Arjun", "Karna", "Dronacharya"] [1,4, "Arjun", "Karna"]
If we use L2=L1, L2 will create only reference of L1 (nothing else) and all the changes made in L1 will be reflected in L2 i.e. L2 will be dependent on L1 that we don't require everytime.
L1=[1,4, "Arjun", "Karna"]
L2=list1 L1.append("Dronacharya") print(L1) print(L2)
Output>>>
[1,4, "Arjun", "Karna", "Dronacharya"]
[1,4, "Arjun", "Karna", "Dronacharya"]
To concatenate two strings
L1 = ["Ram", "Shyam", "Mohan"]
L2 = [10, 20, 30]
L3 = L1 + L2
print(L3)
Output>>>
['Ram', 'Shyam', 'Mohan', 10, 20, 30]
or, we can do concatenation of two lists using for loop also, as follows:
L1 = ["Ram", "Shyam", "Mohan"]
L2 = [10, 20, 30]
for index in L2:
    L1.append(index)
print(L1)
Output>>>
['Ram', 'Shyam', 'Mohan', 10, 20, 30]
or, we can do the concatenation two lists using extend funciton:
L1 = ["Ram", "Shyam", "Mohan"]
L2 = [10, 20, 30]
L1.extend(L2)
print(L1) 
Output>>>
['Ram', 'Shyam', 'Mohan', 10, 20, 30]
To sort the elements of the given list, do following:
L1 = ["Ram", "Shyam", "Mohan"]
L1.sort()

print(L1)
Output>>>
['Mohan', 'Ram', 'Shyam']
To count total number of items of similar type, do following:
L1 = ["Ram", "Shyam" , "Mohan", 'Ram']
print(L1.count("Ram"))
Output>>>
2
To count total number of items in list:
L1 = ["Ram", "Shyam" , "Mohan", 'Ram']
print(len(L1))
Output>>>
4
To count length of each and every item in list:
L1 = ["Ram", "Shyam" , "Mohan", 'Ram']
for index in L1:

    print(len(index))
Output>>>
3 5 5 3

Sunday, September 29, 2019

English Grammar Tips

English Grammar

In English, we make many common mistakes which must be avoided everytime. Many times, we write grammatically correct but depending upon whether its formal or informal place to write (what kind of literature it is), your correct grammar may also be wrong.

Wrong Vs. Right   (Wrong / Right)         

  • Very Crowded / Bustling 
  • Very Sad / Sorrowful
  • Very Funny / Hilarious
  • Very Serious / Grave
  • Very Rich / Wealthy
  • Very poor / Destitute
  • Very Easy / Effortless
  • Very Slow / Sluggish
  • Very Quick / Rapid
  • Very Stupid / Idiot
  • Very Intelligent / Genius
  • Very Simple / Basic
  • Very Shy / Timid
  • Very Open / Transparent
  • Very Quite / Hushed
  • Very Sharp / Keen
  • Very Scary / Chilling
  • Very Painful / Excruciating
  • Very Pale / Ashen
  • Very Old / Ancient or Antique
  • Very Perfect / Flawless
  • Very Scarred / Petrified
  • Very Shiny / Gleaming
  • Very Short / Brief
  • Very Long / Extensive
  • Very Noisy / Deafening
  • Very Clear / Obvious
  • Very Rainy / Pouring

Informal Vs. Formal  (Novel / Text Book) 

  • Thanks a lot / I appreciate your assistance
  • Reminder / I would like to remind you that
  • Heard from him lately? / Have you heard from him lately?
  • I think / In my opinion that
  • Bacause / In the light of the fact that
  • Worried about / Concerned about
  • As soon as you can / At your earliest convenience
  • Say hello to / Give my regards to
  • Nice to meet you / It is a pleasure to meet you
  • At any rate / In any case
  • Catch up / See you later
  • Hit me up / Write me
  • It's on me / I pay for it
  • Not in my books / Disagree
  • Take it easy / By for now
  • Okay by me / It's fine
  • What;s up buddy? / How are you?
  • Play it by ear / go with the flow
  • Sleep on it / Think about it
  • Beats me / I have no idea
  • Give me a break / Leave me alone
  • Not my cup of tea / Not interested
  • Its a piece of cake / It is easy to do
  • What's up or hows life? / How do you do.   
  • Generally / Typically
  • Ultimately / Eventually
  • Maybe / Perhaps
  • But / However   
  • So / Therefore
  • Looking for / Searching
  • This is why / Therefore
  • Given / Provided
  • In exchange of / In lieu of
  • Buy / Purchase
  • Choose / Select
  • Need / Requirement

Common Mistakes (Wrong / Right) 

  • Who is in the phone? / Who is on the phone?
  • I deeply regret for my mistakes. / I deeply regret my mistakes.
  • Ram is so different than his brother. / Ram is so different from his brother.
  • She is afraid from dark. / She is afraid of dark.
  • Sun rises from the east. / Sun rises in the East.
  • Keep the left please. / Keep to the left, please.
  • Ram is absent from friday. / Ram is absent since friday.
  • The high tea consist from coffee and tea. / The high tea consist of coffee and tea.
  • He insisted to carry his own bag. / He insisted on carrying his own bag.
  • Vegetables are eatable. or Vegetables are eatible. / Vegetables are edible.
  • I prefer tea than coffee. / I prefer tea to coffee.