.feed-links {display:none !important;} -->

Syntax exemples

Python Syntax 1 / 13 – Welcome

print "hello world"

Python Syntax 2 / 13 – Variables

# Write your code below
my_variable = 10

Codecademy Python Syntax 3 / 13 – Booleans

# Set the variables to the values listed in the instructions!
my_int = 7
my_float = 1.23
my_bool = True

Python Syntax 4 / 13 – You’ve been Reassigned

# my_int is set to 7 below. What do you think
# will happen if we reset it to 3 and print the result?

my_int = 7

# Change the value of my_int to 3 on line 8!

my_int = 3

# Here's some code that will print my_int to the console:
# The print keyword will be covered in detail soon!

print my_int

Python Syntax 5 / 13 – Whitespace

def spam():
eggs = 12
return eggs
        
print spam()

Codecademy Python Syntax 6 / 13 – Whitespace means Right Space

def spam():
 eggs = 12
 return eggs
        
print spam()

Python Syntax 7 / 13 – A Matter of Interpretetion

spam = True
eggs = False

Python Syntax 8 / 13 – Single Line Comments

#hello friends this is prathap

mysterious_variable = 42

Python Syntax 9 / 13 – Multi Line Comments

""" hello friends this is prathap
today i want to show u about how to hack with python """

Python Syntax 10 / 13 – Math

# Set count_to equal to the sum of two big numbers

count_to = 400 + 200

print count_to

Python Syntax 11 / 13 – Exponetiation

#Set eggs equal to 100 using exponentiation on line 3!

eggs = 10**2

print eggs

Python Syntax 12 / 13 – Modulo

#Set spam equal to 1 using modulo on line 3!

spam = 4%3

print spam

Python Syntax 13 / 13 – Bringing It All Together

#hello this is my python program
monty = True
python = 1.234
monty_python = python ** 2

No comments:

Post a Comment