Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2b68872

Browse files
Updated
1 parent 2ce5c5e commit 2b68872

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#opening text file.
2+
file=open("text.txt","r")
3+
read=file.read()
4+
5+
#Creating a list of 256 elements
6+
list=[]
7+
for a in range (256):
8+
list.append(0)
9+
10+
#Converting Characters into ASCII codes.
11+
for i in read:
12+
convert=ord(i)
13+
list[convert] += 1
14+
15+
#Converting ASCII codes into characters
16+
for b in range (256):
17+
if list[b] != 0:
18+
reconvert=chr(b)
19+
print (reconvert, list[b])

‎Frequency Calculation/text.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Write the text you want to calculate the frequency of.

‎Rock Paper Scissor/rockPaperScissor.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import random
2+
3+
#Evaluating results
4+
def gamewin (user , comp):
5+
if comp == user:
6+
print ("This game is a tie")
7+
8+
elif comp == 'r':
9+
if user == 'p':
10+
return False
11+
elif user == 's':
12+
return True
13+
14+
elif comp == 'p':
15+
if user == 's':
16+
return False
17+
elif user == 'r':
18+
return True
19+
20+
elif comp == 's':
21+
if user == 'r':
22+
return False
23+
elif user == 'p':
24+
return True
25+
26+
27+
user = input("Your Turn: Rock(r) Paper(p) or Scissor(s)?")
28+
29+
#Computer's choice
30+
rand=random.randint(1,3)
31+
if rand == 1:
32+
comp = 'r'
33+
elif rand == 2:
34+
comp = 'p'
35+
else:
36+
comp = 's'
37+
38+
39+
final = gamewin(comp, user)
40+
#Printing computer's choice
41+
print(f"Computer chose {comp}")
42+
#Printing user's choice
43+
print(f"You chose {user}")
44+
45+
46+
#Printing results
47+
if final == None:
48+
print("This game is a tie")
49+
elif final== True:
50+
print("you win")
51+
else:
52+
print("you lose")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /