91.9k views
3 votes
Assignment 7: Random Joke Generator

User Robust
by
4.6k points

2 Answers

3 votes

Answer:

?

Step-by-step explanation:

User Albfan
by
5.6k points
3 votes

Random Joke Generator is a code in which random jokes are generated everytime a button is pressed.

Explanation :

The code is written in python and shows random jokes everytime.

c = 0

jokes = open("jokes.txt", "r")

line = jokes.readline()

while line:

c = c + 1

line = jokes.readline()

print(str(c) + " Jokes In File")

jokes.close()

jokes = open("jokes.txt")

answer = open("answers.txt")

pick = int(input("Which joke do you want to see?: "))

print("Joke #" + str(pick))

i = 0

joke =jokes.readline()

punch=answer.readline()

while joke:

i = i + 1

if(i==pick):

print(joke, end= "")

print(punch)

else:

joke= jokes.readline()

punch=answer.readline()

User Matt Pavlovich
by
5.7k points