0% found this document useful (0 votes)
20 views2 pages

Chapter 4 Challenges

Uploaded by

Vasu Goyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Chapter 4 Challenges

Uploaded by

Vasu Goyal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#challenge1

print("give me any 2 numbers and ill count between them")


start = int(input("Enter the starting number: "))
end = int(input("Enter the ending number: "))
count_by = int(input("Enter the amount by which to count: "))

while start <= end:


print(start, end=' ')
start += count_by

#challenge2
message=input("type a message and ill reverse it:")
reverse=message[::-1]
print(reverse)

#challenge3
import random

words = ['hello', 'salutation', 'laptop', 'sofa']


word = random.choice(words)
new_word = ''

while word:
position = random.randrange(len(word))
new_word += word[position]
word = word[:position] + word[position + 1:]

# Print the jumbled word outside the loop


print("the jumbled word", new_word)

hint = int(input('Tell what word you don\'t understand (1-4): '))

if hint == 1:
print('hi synonym')
elif hint == 2:
print('greet synonym')
elif hint == 3:
print('computer synonym')
elif hint == 4:
print('living room essential')
else:
print('You don\'t need any hint')

score=0
if hint=none:
score=score+10
else:
score=score-10

guess = input("Tell your guess: ")

if guess == new_word:
print('You are correct! with a score of", score)
else:
print(f'Wrong guess. The correct word is {word}. with a score of', score)

#challenge4
import random

words = ['sofa', 'laptop', 'pizza', 'salutation']


word = random.choice(words)
length = len(word)
tries = 0
print('no of letters in word', length)
while tries < 3:
print(words)

guess = input("guess a letter:")


if guess in word:
print("yes")
else:
("no")
tries += 1
final_guess = input("take a final guess of whole word")
if final_guess == word:
print("congrats")
else:
print('u failed')

You might also like