This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
a = random.randint(1, 9) | |
i = 0 | |
def main(): | |
b = int(input("Guess the number\n")) | |
global i | |
if a < b: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Date: 25/06/2021 Time: 12:12pm | |
# Question: Arpasland has surrounded by attackers. A truck enters the city. The driver claims the load | |
# is food and medicine from Iranians.Arun is one of the soldiers in Arpasland. He doubts about | |
# the truck, maybe it's from the siege. He knows that a tag is valid if the sum of every two | |
# consecutive digits of it is even and its letter is not a vowel. | |
# Determine if the tag of the truck is valid or invalid. | |
# Consider the letters A, E, I, O, U, Y to be vowels for this problem. | |
tag = input("Enter the tag\n") | |
number = [] | |
word = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(): | |
import random | |
a = ["rock", "paper", "sissors"] | |
b = random.choice(a) | |
c = int(input("Enter your choice of play\n For ROCK enter 1\n For PAPER enter 2\n For SISSORS enter 3\n")) | |
if b == "rock" and c == 1: | |
print("It's a DRAW") | |
elif b == "rock" and c == 2: | |
print("Congratulation's, you won") | |
elif b == "rock" and c == 3: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Question 1: Given a list of numbers, write a list comprehension that produces a copy of the list in reverse. | |
# [1, 2, 3, 4, 5] | |
a = [1, 2, 3, 4, 5] | |
b = a[::-1] | |
print("Solution for Question 1 \n Que: " + str(a) + "\n Ans: " + str(b)) | |
# Question 2: Given a list of numbers, write a list comprehension that produces a list of each number doubled. | |
# [2, 4, 6, 8, 10] | |
a1 = [2, 4, 6, 8, 10] | |
b1 = [] | |
for element in a1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number = int(input("Enter a random number\n")) | |
Check = range(2, 11) | |
empty = [] | |
for element in check: | |
if number % element == 0: | |
empty.append(element) | |
print("The number" + ' ' + str(number) + ' ' + "you entered" | |
" is a divisor of this number(s)" + ' ' + str(empty)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1, 1, 2, 3, 5, 8, 4, 3, 13, 21, 34, 55, 89, 4] | |
b = [] | |
for element in a: | |
if element < 5: | |
b.append(element) | |
print(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number = int(input("Enter a Random Number\n")) | |
check = Number % 2 | |
if check == 0: | |
print("The number you choose" + ' ' + str(Number) + ' ' + "is even") | |
else: | |
print("The number you choose" + ' ' + str(Number) + ' ' + "is odd") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = input ("What's your name ?\n") | |
age = input ("What's your age?\n") | |
age = int(age) | |
x=100 - age | |
year=2021+x | |
print ("If you survive from the apolocalypse, and make it to 100th year of your age | |
" it will be in the year"+' '+str(year)+' '+"that you're gonna make your " | |
" CENTURY.") |