Nothing Special   »   [go: up one dir, main page]

Python Quick Reference Poster

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Python Quick Reference

Description Example Code


Output text print(Some text)
Text input name=input(What is your name? )
Number input num=int(input(Enter a number: ))
Join text and a variable
together
print(Your score is,score)
IF statement
if num == 4:
print(Well done)
else:
print(Try again)
Generate a random
number
import random
num=random.randint(1,10)
For loop
for x in range(0,10):
print(Python Rocks)
While loop
while password!=python:
password=input(Enter your password: )
== Is equal to
> Is greater than
!= Is not equal to
< Is less than
>= Is greater than or equal to
<= Is less than or equal to
and And
or Or
Logical Operators Example Code

You might also like