Haec [bls] Posted March 24, 2018 Report Share Posted March 24, 2018 # 1/usr/bin/env python3 import random number = random.randint(1, 10) tries = 1 uname = input ("What is your username?") print("Hello", uname + ".", ) question = input ("Lets play a game? [Yes/No] ") if question == "No": print("Unfortunate, Goodbye!") if question == "Yes": print("I'm thinking of a number between 1 & 10") guess = int(input("Take a guess: ")) if guess > number: print("Wrong, guess lower...") if guess < number: print ("Wrong, guess higher...") while guess != number: tries += 1 guess = int(input("Try again: ")) if guess < number: print("Guess higher") if guess > number: print("Guess lower") if guess == number: print("Correct!, You've won $10000000! The numer was", number, \ "and it only took", tries, "tries!") For anybody looking to make a start in Python3 you are welcome to take a peak at this sample code used to make an extremely basic text based game. You insert your username (can be anything), type Yes or No to if you'd like to play or not and then proceed to guess a randomly generated number between 1,10. This is seen at the very top - number = random.randit (1, 10). Of course this number could be changed but the difficulty would increase. Simple code like this could be modelled to make your very own text based adventure game, you know those ones popular when your parents were born. DropBox, Instagram, Spotify, Reddit, even Google all use python in their code! Whatever you can think up you can pretty much create in python which is why its such a great starting language. Of course there are better languages for different requirements but after you have learnt one language it is a lot easier to make that conversion and it is widely known that Python is one of the easiest languages to pick up. If you're new to coding and this looks completely foreign to you then not to worry! Like all things, coding takes time to understand but it is not difficult and anybody can learn it with enough motivation and perseverance. Here are a list of websites in which you can both start and practice learning python completely free! (and various other languages) https://www.codecademy.com/learn/python https://www.codementor.io/community/topic/python https://developers.google.com/edu/python/?hl=en http://www.pythonforbeginners.com/ Paid alternatives that are great for development are https://www.udemy.com/complete-python-bootcamp/ and https://teamtreehouse.com/library/topic:python If you're a student you're in luck! JetBrains offers PyCharm to students completely free which is an incredibly professional piece of software in which you can create Python projects. https://www.jetbrains.com/student/ APPLY HERE for your student membership. Have a great day and happy coding! Haec Link to comment Share on other sites More sharing options...
Moderators Fafnir Posted March 24, 2018 Moderators Report Share Posted March 24, 2018 This is something that is definitely interesting to me. I will have to take a closer look in the near future. For now I would just like to thank you for putting this out here, I appreciate it! Link to comment Share on other sites More sharing options...
Administrators Ejay Posted March 24, 2018 Administrators Report Share Posted March 24, 2018 This is nice. Thanks! Link to comment Share on other sites More sharing options...
mozila80 Posted October 2, 2018 Report Share Posted October 2, 2018 python more simple than c ? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.