Latest Awards
Complete 10 python programs which focus on loops.

morgan

Score over 100 points in total

vincebanter10

Complete any 5 python programs

vincebanter10

Complete 3 python list based tasks

vincebanter10

Complete 5 python list based tasks

vincebanter10

Complete 10 python list based tasks

dman12

Score over 1000 points in total

april-logan

Complete any pygame task

april-logan

Complete any 3 pygame tasks

april-logan

You have to complete 5 pygame tasks

april-logan

Score over 500 points in total

sam-edmund

Complete any pygame task

sam-edmund

Complete any 3 pygame tasks

sam-edmund

You have to complete 5 pygame tasks

sam-edmund

Complete any pygame task

12wrigleyf

Complete any 3 pygame tasks

12wrigleyf

You have to complete 5 pygame tasks

12wrigleyf

Score over 500 points in total

jhoughton12

Complete any 10 python prograns

jhoughton12

Complete 10 python programs which focus on loops.

jhoughton12

Python Score
tasks = 0
achivements = 0
freestyle = 0
Total = 0
Top 5 Scores
114gilo 3500
2joss-nolan-2 2530
3alexdawkins 2515
4byrnebrian 2080
512wattsl 1750
Click to view all scores
Who else completed this task?
No one has completed this task yet. Be the first!

Binary logic using IF

Syntax

if
a
<
0
and
a
>
10
:
 
print 'True block'
else
:
 
print 'False block'

About binary logic and IF

Binary logic uses AND, OR and NOT to link together conditions in if statements and loops. Understanding binary logic is crucial if you want to use if statements effectivly.


Below is the sample code from the video.

age = int(raw_input("Enter your age"))
if age >0 and age <120:
	print "age OK"
else:
	print "not ok"

Key term

Binary logic – Using true and false statements to control a program.

Helpful links

Basics of binary logic 

Logic in python

PWNict logic in python and further logic 

Test your skill

1. To ensure a number is between 1 and 10 you can use the code below. What should replace the ???

num = int(raw_input("enter a number - "))
if num >=1 ???? num <=10:
   print "ok"
Task 1: Answer SelectShow

2. Write a simple program, using just print, to display the logic tables for and, or and not.

Task 2: Answer SelectShow

3. Write a single if statement which will say “game on” if the user has more than 1 life left and has not won, otherwise it will say “stop game”. Use the variables below to get started –

gameWon = False
lives = 10
Task 3: Answer SelectShow

Leave a Reply

You must be logged in to post a comment.