Skip to content

Instantly share code, notes, and snippets.

View Just-Simple-59's full-sized avatar

PRASHANTH V Just-Simple-59

View GitHub Profile
@Just-Simple-59
Just-Simple-59 / Guessing game.py
Created June 26, 2021 16:33
Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. Keep track of how many guesses the user has taken, and when the game ends, print this out.
import random
a = random.randint(1, 9)
i = 0
def main():
b = int(input("Guess the number\n"))
global i
if a < b:
@Just-Simple-59
Just-Simple-59 / List Comprehension2.py
Created June 25, 2021 14:56
Considering integers and alphabets in a list and solving a given condition.
# 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 = []
@Just-Simple-59
Just-Simple-59 / rock_paper_sissors.py
Last active June 26, 2021 07:03
Make a player vs computer Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game)
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:
@Just-Simple-59
Just-Simple-59 / List Comprehension.py
Last active June 23, 2021 15:52
List comprehension practice programs. (14 Question)
# 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:
@Just-Simple-59
Just-Simple-59 / Divisor.py
Last active June 22, 2021 18:11
Create a program that asks the user for a number and then prints out a list of all the divisors of that number.
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))
@Just-Simple-59
Just-Simple-59 / Lists.py
Last active June 22, 2021 18:11
Take a list and write a program that prints out all the elements of the list that are less than 5.
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)
@Just-Simple-59
Just-Simple-59 / Even and Odd.py
Last active June 22, 2021 18:10
Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user.
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")
@Just-Simple-59
Just-Simple-59 / Name and Age.py
Last active June 22, 2021 18:09
Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
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.")