Skip to content
Closed
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
79 changes: 79 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep-1,2
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> print ('hello world')
hello world
>>> print('this is the INTERACTIVE SHELL and the new file gives u the FILE EDITOR')
this is the INTERACTIVE SHELL and the new file gives u the FILE EDITOR
>>> print ('INTSHELL gives output of the code put line by line and FEDITOR enables u to write the complete code then finally give the out put')
INTSHELL gives output of the code put line by line and FEDITOR enables u to write the complete code then finally give the out put
>>> 2+2
4
>>> print ('the above is an expression')
the above is an expression
>>> 2
2
>>> 5-3
2
>>> 3*7
21
>>> 22/7
3.142857142857143
>>> print ('BDMAS rule is applied')
BDMAS rule is applied
>>> 8/2
4.0
>>> -2.0
-2.0
>>> '-2.0 is a floating point val-->floats'
'-2.0 is a floating point val-->floats'
>>> alice
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
alice
NameError: name 'alice' is not defined
>>> 'alice'+'bob'
'alicebob'
>>> 'bob'^2
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
'bob'^2
TypeError: unsupported operand type(s) for ^: 'str' and 'int'
>>> 'bob'*4
'bobbobbobbob'
>>> 'hey'+'!'*5
'hey!!!!!'
>>>
>>>
>>>
>>>
>>>
>>> spam=42
>>> 'spam egg bacon ham---> famous var names'
'spam egg bacon ham---> famous var names'
>>> spam
42
>>> spam='ollo'
>>> spam+'world'
'olloworld'
>>> spam+' world'
'ollo world'
>>> spam='bye'
>>> spam
'bye'
>>>
>>>
>>>
>>>
>>> spam=2+2
>>> spam
4
>>> spam=10
>>> spam++
SyntaxError: invalid syntax
>>> spam+1
11
>>> 'spam=10 is a statement amd spam+1 is an expression'
'spam=10 is a statement amd spam+1 is an expression'
>>> '2 ep ended'
'2 ep ended'
>>>
22 changes: 22 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#This program says hello and asks for name
print ('hey')
print('ur name?')



myname=input()
print ('nice to meet u, '+myname)
#print ('namelength='+len(myname))
print('name length is:')
print(len(myname))

print ('enter ur age')
myage=input()
print ('u will be '+str(int(myage)+1)+ ' in an year')
print(len('al')*10)
#str(26)
#int('3.14')
#float('ad')
'cant concatinate sting with int'
#uppar waali cheez execute nhi hoti

77 changes: 77 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> true
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
true
NameError: name 'true' is not defined
>>> True
True
>>> False
False
>>> spam=True
>>> spam
True
>>> 2!=3
True
>>> 42<100
True
>>>
>>> 24>4
True
>>> 22<44
True
>>> 44 = '44'
SyntaxError: cannot assign to literal
>>> 44=='44'
False
>>> myage=20
>>> myage <22
True
>>> 42.0=42
SyntaxError: cannot assign to literal
>>> 42.0==42
True
>>> True and True
True
>>> False and Flase
False
>>> False and False
False
>>> true or False
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
true or False
NameError: name 'true' is not defined
>>> False or true
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
False or true
NameError: name 'true' is not defined
>>> False or True
True
>>>
>>> not True
False
>>>
>>> myAge=20
>>> myPet='dog'
>>> myAge>18 and myPet =='dog'
True
>>> 'not and or are the boolean operators '
'not and or are the boolean operators '
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
44 changes: 44 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep5,6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
##name='bob'
#if name =='alice':# : imp h
# print ('hey alice')
#print('done')
#indentation decides the blocks
#new block ki shuruvat is denoted by a ':'

name='bob'
age=30
if name =='alice':
print('HiAlice')
elif age<12:
print('not alice')
elif name=='bob':
print('heeyyyy alice')

##print ('enter your name')
#name = input()
#if name:
# print('Thenks')
#else:
# print('not entered any name')
#bool('')-->False
#bool('hey')-->True
#bool(0.0)-->False

spam=0
while spam<5:
print('hello world')
spam=spam+1

name=''
while name!='your name':
print('please type your name')
name=input()
print('thenks')

##for an infinite loop to interrupt it in b/w press 'ctrl+c'






18 changes: 18 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep7.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
print ('Myname is')
for i in range(5):
print ('jimmy'+str(i))
#i starts from 0 goes till 4
total=0
for num in range (101):
total=total+num
print(total)

for i in range(12,16):
print ('jimmy'+str(i))
#starts at 12 and ends at 15

for i in range(5,0,-1):#steps can be given so
print ('jimmy '+str(i))
#starts from 5 goes back to 1 cuz of step of -1 there


10 changes: 10 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep8-phew!.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> "hey"
'hey'
>>> import pyperclip
>>> pyperclip.copy("hello")
>>> pyperclip.paste()
'hello'
>>> #bhot mehnat lgi pyperclip install krne me
>>>
31 changes: 31 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 'buit-in fns'
'buit-in fns'
>>> len('hey')
3
>>> input()

''
>>> 'modules need to be imported'
'modules need to be imported'
>>> import random
>>> random.randint(1,10)#random int can be from 1 to 10 both included
5
>>> random.randint(1,10)
4
>>> random.randint(1,10)
5
>>> import random,sys,os,math
>>> from random import *
>>> 'the above is an alternative form of an import statement'
'the above is an alternative form of an import statement'
>>> 'but it has fayda that random. need not bre written any more'
'but it has fayda that random. need not bre written any more'
>>> randint(1,10)
10
>>> import sys
>>> sys.exit
<built-in function exit>
>>> sys.exit()
>>>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def hello():
print('howdy')
print('hoowwddyy')
print('hellow')
hello()
hello()
hello()


def hello(name):
print('Hello '+name);
hello('Alice')
hello('bob')

'Hello has '+str(len('hello'))+' letters in it'
#the above statement doesnt affect the output anyway

def plusone(no):
return no+1
newno=plusone(5)
print(newno)
17 changes: 17 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep9-print.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
print('Hello')
print('hey')
#the above prints on diff lines

print('hillu',end=' ')
print('wurld')
#it prints on same line with a space given in end

print('spam','donut','hole')
#prints with a space in between

print('spam','donut','hole',sep='LOL')
#the seperating keyword becomes LOL

print('hillu',end='o ')
print('wurld')
#makes first string end with o and makes the next string come in the same line
21 changes: 21 additions & 0 deletions beginner_python/Automate the boring stuff with python/ep9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 'Hello'
'Hello'
>>> print('Hello')
Hello
>>> none
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
none
NameError: name 'none' is not defined
>>> None
>>> None
>>> #the above is the value that print() returns by default
>>> spam=print()

>>> spam
>>> spam==None
True
>>> #every function has a return value