Python has been gaining momentum for quite some time now as one of the best programming languages for developers to use.
Here are a few reasons why:
Python is one of the easiest programming languages to learn because of its simple syntax and versatility.
Python is very useful in data science, artificial intelligence, and the Internet of Things.
It can be used to automate repetitive processes.
Here are a few resources that are helpful when it comes to learning how to code in Python:
FutureLearn has free & premium Python courses:
A fun coding exercise in Python is the classic rock, paper, scissors game. It includes a lot of the basics of Python programming and the code below can be run inside of any Python editor such as trinket.io.
from random import randint
#create a list of play options
t = ["Rock", "Paper", "Scissors"]
#assign a random play to the computer
computer = t[randint(0,2)]
#set player to False
player = False
while player == False:
#set player to True
player = input("Rock, Paper, Scissors?")
if player == computer:
print("Tie!")
elif player == "Rock":
if computer == "Paper":
print("You lose!", computer, "covers", player)
else:
print("You win!", player, "smashes", computer)
elif player == "Paper":
if computer == "Scissors":
print("You lose!", computer, "cut", player)
else:
print("You win!", player, "covers", computer)
elif player == "Scissors":
if computer == "Rock":
print("You lose...", computer, "smashes", player)
else:
print("You win!", player, "cut", computer)
else:
print("That's not a valid play. Check your spelling!")
#player was set to True, but we want it to be False so the loop continues
player = False
computer = t[randint(0,2)]
Comments