1# Hash Function
2# SHA hash algorithms.
3
4import hashlib
5
6# initializing string
7str = "TYCS"
8
9# encoding TYCS using encode()
10# then sending to SHA1()
11result = hashlib.sha1(str.encode())
12
13# printing the equivalent hexadecimal value.
14print("The hexadecimal equivalent of SHA1 is : ")
15print(result.hexdigest())
16
17# encoding TYCS using encode()
18# then sending to SHA224()
19result = hashlib.sha224(str.encode())
20
21# printing the equivalent hexadecimal value.
22print("The hexadecimal equivalent of SHA224 is : ")
23print(result.hexdigest())
24
25# encoding TYCS using encode()
26# then sending to SHA256()
27result = hashlib.sha256(str.encode())
28
29# printing the equivalent hexadecimal value.
30print("The hexadecimal equivalent of SHA256 is : ")
31print(result.hexdigest())
32
33# initializing string
34str = "TYCS"
35
36# encoding TYCS using encode()
37# then sending to SHA384()
38result = hashlib.sha384(str.encode())
39
40# printing the equivalent hexadecimal value.
41print("The hexadecimal equivalent of SHA384 is : ")
42print(result.hexdigest())
43
44# initializing string
45str = "TYCS"
46
47# initializing string
48str = "TYCS"
49
50# encoding TYCS using encode()
51# then sending to SHA512()
52result = hashlib.sha512(str.encode())
53
54# printing the equivalent hexadecimal value.
55print("The hexadecimal equivalent of SHA512 is : ")
56print(result.hexdigest())
1#Make a varible called score
2#Make inputs
3#Make answers and update scores
4#Show total score at the end
5score=0
6q1=(input("What is 1+1? : "))
7if q1 == "2" :
8 print ("CORRECT")
9 score=(score+1)
10else:
11 print ("INCORRECT")
12q2=(input("""The capital city of England is...
13
14a/Birmingham
15b/London
16c/Cardiff
17
18Enter your answer: """))
19if q2 == "b" :
20 print ("CORRECT")
21 score=(score+1)
22else:
23 print ("INCORRECT")
24q3=(input("7÷2="))
25if q3 == "3.5":
26 print ("CORRECT")
27 score=(score+1)
28else:
29 print ("INCORRECT")
30print ("You got", score, "out of 3!!!")
1# In python they are called dictionarys
2dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
3
4name = dict["Name"] # Zara
1# hash for integer unchanged
2print('Hash for 181 is:', hash(181))
3# hash for decimal
4print('Hash for 181.23 is:',hash(181.23))
5# hash for string
6print('Hash for Python is:', hash('Python'))
7
1Hashing implementation at this link:
2
3https://github.com/shreyasvedpathak/Data-Structure-Python/tree/master/Hashing