Saturday, June 22, 2019

python Object and Datastructure Basics-List Dictionaries and Methods Available,List Dictionaries and Methods Available

python Object and Datastructure Basics-List Dictionaries and Methods Available
l=[1,2,0,'abc']
l[1]
l[0]
l[3]
len(l)
type(l)
List concat:
l1=[1,2,66]
l=1+l1
l*2
[1, 2, 0, 'abc', 1, 2, 66, 1, 2, 0, 'abc', 1, 2, 66]
l[0]='changed'
['changed', 2, 0, 'abc', 1, 2, 66]
l[22]='new string'
print(l)
l.append('new element1')
l[4].lower()
l[4].capitalize()
l[:3]
['changed', 2, 0]
l[-2]
66
b=set(l)
print(b)
{0, 1, 2, 66, 'new element1', 'changed', 'abc'}
Searcing :
s='name'
l=['string','something.'name']
if s in l:
  print('its found')
else
  print('not found')
 
for x in l:
  if x==s:
    print('not found')
  esle:
    print('not found')

Nested list:
 l=[1,2,0,'string',[1,2,3]]
 l.extend([5,6,7])
 print(l)
 l.append([8,9,0])

 slice if nested list
 l[1][0]
type(l[1])

l=[1,2,3,4,4,5]
l.count(2)
l.index(1)
l.insert(0,'Starting')
print(l)
l.pop()
print(l)
l.pop(0)
l.remove(3)
print(l)
l.clear()
print(l)
import copy
new 1=copy.deepcopy(l)

Dictionary:
my_dict={'key1':'value'}
len(my_dict)
my_dict={'number':1,'string':'am a string'}
di=dict(x=5,x=6)
print(di)
my_dict['number']
my_dict['you']='some value'
my_dict.update(new_dict)
my_dict.items()
from collections import OrderedDict
dict=OrderedDict([])
my_dict.get('string','element is not present')
>>> my_dict.get('string','element is not present')
'am a string'
>>> my_dict.get('strings','element is not present')
'element is not present'

Python Object and Datastructure Basics:Tuples,Sets,Frozen sets,Comparision Operator:
Tuple is immutable
my_tuple=(1,2,'string')
my_tuple[2].upper()
print(my_tuple)
my_tuple[0]+2
my_tuple.index('string')
t=(1)  ====t(1,)-->it is called as tuple
type(t)
my_set=set()
my_set={'k1',1,1,1}
type(my_set)
set()-mutable
frozenset-immutable
frozenset
1<2 p="">String-immutable
list-mutable,It hold any type of object
dict-mutable,no slicing and indexing..we can use keys to grab the values
tuple is immutable
set()-mutable,duplicate removal
frozenset-immutable

Tuesday, June 4, 2019

MAC Shortcuts

KeyFunction
Command+ASelects all items in the active window (icon view), all items
in the column (column view), or all items in the list (cover flow
view)
Command+CCopies selected items
Command+DDuplicates the selected item(s)
Command+EEjects the selected volume
Command+FDisplays the Find dialog
Command+HHides All Finder windows
Command+IShows info for selected item or items
Command+JShows the view options for the active window
Command+KDisplays the Connect to Server dialog
Command+LCreates an alias for the selected item
Command+MMinimizes the active window
Command+NOpens a new Finder window
Command+OOpens (or launches) the selected item
Command+RShows the original for selected alias
Command+TAdds the selected item to the Sidebar
Command+VPastes items from the Clipboard
Command+WCloses the active window
Command+XCuts the selected items
Command+ZUndoes the last action (if possible)
Command+,Displays Finder Preferences
Command+1Shows the active window in icon mode
Command+2Shows the active window in list mode
Command+3Shows the active window in column mode
Command+4Shows the active window in cover flow mode
Command+[Moves back to the previous Finder location
Command+]Moves forward to the next Finder location
Command+DelMoves selected items to the Trash
Command+up-arrowShow enclosing folder
Command+`Cycles through windows
Command+?Displays the Mac OS X Help Viewer
Command+Shift+ATakes you to your Applications folder
Command+Shift+CTakes you to the top-level Computer location
Command+Shift+GTakes you to a folder that you specify
Command+Shift+HTakes you to your Home folder
Command+Shift+IConnects you to your iDisk
Command+Shift+QLogs you out
Command+Shift+NCreates a new untitled folder in the active window
Command+Shift+UTakes you to your Utilities folder
Command+Shift+DelDeletes the contents of the Trash
Command+Option+HHides all windows except the Finder’s window(s)
Command+Option+NCreates a new Smart Folder
Command+Option+THides the Finder window toolbar
Command+Option+SpaceOpens the Spotlight window
Command+SpaceOpens the Spotlight menu
F8Choose another desktop using Spaces
Control+up-arrow (or F3, depending on your keyboard model)Displays the Mission Control screen
Control+down-arrow (or Control+F3, depending on your keyboard
model)
Shows all open windows for the current application using
Mission Control
F11 (or Command+F3, depending on your keyboard model)Hides all windows to display the Desktop using Mission
Control
F12 (or F4, depending on your keyboard model)Displays your Dashboard widgets
SpaceQuick Look

STRANGE-LOOKING KEYS ON THE MACBOOK KEYBOARD


image0.jpg

Python Challenges Program

Challenges program: program 1: #Input :ABAABBCA #Output: A4B3C1 str1="ABAABBCA" str2="" d={} for x in str1: d[x]=d...