-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.py
More file actions
40 lines (34 loc) · 1.32 KB
/
Copy pathfunctions.py
File metadata and controls
40 lines (34 loc) · 1.32 KB
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
##print(), input(), type(), int(), float(), str(), bool(), len(), range(), list(), tuple(), set(), dict(), max(), min(), sum(), abs(), round(), sorted(), enumerate()
marks=[10,20,30,40]
print("length:",len(marks)) #length:4
print("sum:",sum(marks)) #sum:100
average=sum(marks)/len(marks)
print("average:",average) #average:25.0
print("highest:",max(marks)) #highest:40
print("lowest:",min(marks)) #lowest:10
marks_str=str(marks)
print("Marks as a string:",marks_str) #string:[10,20,30,40]
for mark in marks:
print(mark,"-",type(marks)) #10,20,30,40 -list
#-------EXPLANATION--------------
#Function Purpose
#print() Display output
#input() Get user input
#type() Check data type
#int() Convert to integer
#float() Convert to float
#str() Convert to string
#len() Get length
#list() Create/convert to list
#tuple() Create/convert to tuple
#set() Create/convert to set
#dict() Create/convert to dictionary
#range() Generate sequence of numbers
#max() Largest value
#min() Smallest value
#sum() Sum of values
#sorted() Sort data
#abs() Absolute value
#round() Round numbers
#enumerate() Get index and value
#zip() Combine iterables