-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
50 lines (31 loc) · 931 Bytes
/
Copy pathfunction.py
File metadata and controls
50 lines (31 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import random
# def function(greeting, name='Hello'):
# print('Inside the {} {} function'.format(greeting, name))
# # pass
# function('greeting', 'Prerit')
# def function1():
# return 5
# print(function1())
# def student_info(*args, **kwargs):
# print(args)
# print(kwargs)
# # student_info('Maths', 'Art', name='John', age=22)
# # Positional Arguments Maths, Art
# # Keyword Arguments name, age
# course = ['Maths', 'Art']
# info = {'name': 'John', 'age': 22}
# student_info(*course, **info)
# def lw() :
# for i in range(1,6):
# yield i
# for line in lw():
# print(line)
y = [i*2 for i in range(5)] # this is called list comprehension
print(y)
z = (i*2 for i in range(5)) # this is called generator comprehension this gives generator object
print(z)
x = [i*2 for i in range(5) if i!=3]
print(x)
exp = random.randint(1,10)
job = "ok" if exp>5 else "Not ok"
print(exp,job)