Posts

Showing posts from January, 2018

Hotel Room Booking Project

In this mini project, we have multiple options for the user to select the different type of Rooms (VVIP, VIP or Normal). Each room has different charges. Here we can set manually user balance and check user balance on each type of room option charges. - If user_balance => room_charges then room has been granted to user - else user_balance will check on each stage (VIP and Normal) - If still user_balance is < room_charges then message prompted "You don't have enough balance, Thank You" # ----------------------- CODE -------------------- from random import randint import time def displayintro():     print()     print()     print("+++++++++++++++++++")     print("___________________")     print("WELCOME TO PC HOTEL")     print("Lahore, Pakistan")     print("________________")     print() def useroption():     option = ""     while option != "1" and option != "2" and

TextBased Adventure Rooms Game

def Introduction():     print("TextBased Adventure Room Game")     print("By Usman")     print("Python Basic Coding")     print() def userinput():     option = ""     while option != "1" and option != "2":         option = input("Please select your room ('1' or '2'): ")         if option == "1":             print("Welcome to room ",option, ", this is the VIP Room")             option1 = input("Do you want to move ahead type 'yes' to quit type 'q'")             if option1 == "yes" or option1 == "y":                 option11 = input("Please select your room in Option One ('3' or '4'): ")                 if option11 == "3":                     print("Welcome to room ", option11, ", this is the VIP 3 Room")                     break                 if optio

TextBased Adventure Game 1

TextBased Adventure Game One: from random import randint import time def displayintro():     print("Line 1: Its just for the introduction about this project")     print("This is the textbased adventure mini game")     print("Here user have 2 options to select option 1 or option 2")     print()     def choosepath():     path = ""     while path != "1" and path != "2":         path = input("Which path will you choose? ('1' or '2'): ")             return path def checkpath(choosepath):     print(choosepath)     print("You have done with path")     time.sleep(2)     print("Welcome to the world of Dreams ")     time.sleep(2)     print("World of Art is a long established series of art books from the publisher Thames & Hudson, now comprising over 150 titles.")     time.sleep(2)         correctpath = randint(1,2)     print("random value is:

Mad Libs Generator

The Goal: Inspired by  Summer Son’s Mad Libs project  with Javascript. The program will first prompt the user for a series of inputs a la Mad Libs. For example, a singular noun, an adjective, etc. Then, once all the information has been inputted, the program will take that data and place them into a premade story template. You’ll need prompts for user input, and to then print out the full story at the end with the input included. Concepts to keep in mind: Strings Variables Concatenation Print A pretty fun beginning project that gets you thinking about how to manipulate userinputted data. Compared to the prior projects, this project focuses far more on strings and concatenating. Have some fun coming up with some wacky stories for this! _______________________________________________________ a = str(input("Enter Your Name: ")) x = str(input("Enter Country Name: ")) y = str(input("Enter Bird Name: ")) print("Throw a party to celebra

Guess The Number Game

The Goal: Similar to the first project, this project also uses the random module in Python. The program will first randomly generate a number unknown to the user. The user needs to guess what that number is. (In other words, the user needs to be able to  input  information.) If the user’s guess is wrong, the program should return some sort of indication as to how wrong (e.g. The number is too high or too low). If the user guesses correctly, a positive indication should appear. You’ll need functions to check if the user input is an actual number, to see the difference between the inputted number and the randomly generated numbers, and to then compare the numbers. Concepts to keep in mind: Random function Variables Integers Input/Output Print While loops If/Else statements Jumping off the first project, this project continues to build up the base knowledge and introduces user-inputted data at its very simplest. With user input, we start to get into a little bit of variab

Turtle Race Game

# Please use below link for live demo #  https://trinket.io/python/513ddc86ec #!/bin/python3 from turtle import * from random import randint speed(0) penup() goto(-140, 140) for step in range(15):   write(step, align='center')   right(90)   forward(10)   pendown()   forward(150)   penup()   backward(160)   left(90)   forward(20) ada = Turtle() ada.color('red') ada.shape('turtle') ada.penup() ada.goto(-160, 100) ada.pendown() bob = Turtle() bob.color('blue') bob.shape('turtle') bob.penup() bob.goto(-160, 70) bob.pendown() usman = Turtle() usman.color('black') usman.shape('turtle') usman.penup() usman.goto(-160, 40) usman.pendown() ali = Turtle() ali.color('yellow') ali.shape('turtle') ali.penup() ali.goto(-160, 10) ali.pendown() for turn in range(100):   ada.forward(randint(1,5))   bob.forward(randint(1,5))   usman.forward(randint(1,5))   ali.forward(randin

Dice Rolling Simulator Version 2

The Goal: Like the title suggests, this project involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or whatever other integer you prefer — the number of sides on the die is up to you.) The program will print what that number is. It should then ask you if you’d like to roll again. For this project, you’ll need to set the min and max number that your dice can produce. For the average die, that means a minimum of 1 and a maximum of 6. You’ll also want a function that randomly grabs a number within that range and prints it. Concepts to keep in mind: Random Integer Print While Loops A good project for beginners, this project will help establish a solid foundation for basic concepts. And if you already have programming experience, chances are that the concepts used in this project aren’t completely foreign to you. Print, for example, is similar to Javascript’s console.log. ___________________________

Dice Rolling Simulator Mini Project

####################################################### from random import randint def functionDice(x,y):     print("Here x is: ",x," Here y is: ",y)     if int(x) < 7:         while True:             if int(x) == int(y):                 print("You Won")                 break             elif int(x) != int(y):                 x = input("Please enter int between 1 to 6: ")                 functionDice(x,randint(1,2))     else:         print("Value is greater than 6") while True:     x = input("Please enter int between 1 to 6: ")     y = randint(1,6)     print("Here y is: ",y," Here x is: ",x)     functionDice(x,y)