This page contains examples of basic concepts of Python programming; List Programs; String Programs; Dictionary Programs. Tuple Programs; Searching and Sorting Programs; Pattern Printing; Date-Time Programs; More Python ...
About Me
Get link
Facebook
X
Pinterest
Email
Other Apps
I write daily BLOGS about PYTHON with "Source Code"
Python Exercise 7 --- "Snake, Water, Gun" Today's task for you guys will be to develop your first-ever Python game i.e., "Snake Water Gun." (Just like --- Rock, Paper, Scissor) Most of you must already be familiar with the game. Still, I will provide you with a brief description. This is a two-player game where each player chooses one object. As we know, there are three objects, snake, water, and gun. So, the result will be Snake vs. Water: Snake drinks the water hence wins. Water vs. Gun: The gun will drown in water, hence a point for water Gun vs. Snake: Gun will kill the snake and win. In situations where both players choose the same object, the result will be a draw. Now moving on to instructions: You have to use a random choice function that we studied in tutorial #38, to select between, snake, water, and gun. You do not have to use a print statement in case of the above function. Then you have to give input from your side. After getting ten consecutive...
Python Exercise 4: "Number Guessing Game" Q: You have to build a "Number Guessing Game," in which a winning number is set to some integer value. The Program should take input from the user, and if the entered number is less than the winning number, a message should display that the number is smaller and vice versa. Instructions: 1. You are free to use anything we've studied till now. 2. The number of guesses should be limited, i.e (5 or 9). 3. Print the number of guesses left. 4. Print the number of guesses he took to win the game. 5. “Game Over” message should display if the number of guesses becomes equal to 0. You are advised to participate in solving this problem. This task helps you become a good problem solver and helps you accept the challenge and acquire new skills. Solution: print ( "Hii! Welcome, \n " , "This a number guessing game, " "made by Saswata \n " , "Let's Start \n " ) n...
Python Tutorial 5--- "Python Lists And List Functions" This PROGRAM or TUTORIAL about Python's "Python Lists And List Functions" DOC Lists : Python lists are containers used to store a list of values of any data type. In simple words, we can say that a list is a collection of elements from any data type E.g. list1 = [ 'harry' , 'ram' , 'Aakash' , 'shyam' , 5 , 4.85 ] Copy The above list contains strings, an integer, and even an element of type float. A list can contain any kind of data i.e. it’s not mandatory to form a list of only one data type. The list can contain any kind of data in it. Remember we saw indexing in strings? List elements can also be accessed by using Indices i.e. first element of the list has 0 index and the second element has 1 as its index and so on. Note: I f you put an index which isn’t in the list i.e. that index is not there in list then you will get an error. i.e. if a list named list1 contains ...
Comments
Post a Comment