Friday, May 17, 2013
Day 2
Dear Reader,
I learn about writing variables. The different kinds of variables are:
1. Strings "Peal"
2. Float 4.5 feets
3. int 20 years
4. Boolean which is True or False
I also learned about white space and Statement, meaning the computer cannot analyze any blank space as variable and statements are not process by the computer it is only meant for the programmer or other to see it.
some results of the test
Python 2.7.3 (default, Aug 1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>>
Welcome to Python!
Here are the results of Lesson 2
Exercise 0 : Test Passed!
Exercise 1 : Test Failed!
Exercise 2 : Test Failed!
Exercise 3 : Test Failed!
>>> Print "Hellow World"
SyntaxError: invalid syntax
>>> print "Hello World"
Hello World
>>>
Welcome to Python!
Here are the results of Lesson 2
Exercise 0 : Test Passed!
Exercise 1 : Test Passed!
Exercise 2 : Test Failed!
Exercise 3 : Test Failed!
>>>
Welcome to Python!
Here are the results of Lesson 2
Exercise 0 : Test Passed!
Exercise 1 : Test Passed!
Exercise 2 : Test Passed!
Exercise 3 : Test Failed!
>>>
Welcome to Python!
7
3
Here are the results of Lesson 2
Exercise 0 : Test Passed!
Exercise 1 : Test Passed!
Exercise 2 : Test Passed!
Exercise 3 : Test Passed!
>>>
4
Here are the results of Lesson 2
Exercise 1 : Test Passed!
Exercise 2 : Test Failed!
>>>
4
Here are the results of Lesson 2
Exercise 1 : Test Passed!
Exercise 2 : Test Passed!
>>>
>>>
>>>
Comments
Are not meant for analyzing by the computer but only for the programmer and other people. This may either be warning or instruction.
Math Operators
Are those signs use for calculation in python programming/ in writing a code.
Kinds of Programs that I write today:
Variable
data
some of my practice
"""
Learning Python
Lesson 2 : Python Syntax
Variable & Data Type Exercises
Simple programming exercises from Codecademy
"""
# IGNORE THIS CODE
# ***************************************************************
my_variable = my_int = myfloat = this_int = 0
# ***************************************************************
# Exercise 0 : Variables & Data Types
"""
Ready to learn Python?
SAVE this script (File -> Save) and
RUN it (Run -> Run Module)
"""
print "Welcome to Python!"
# Exercise 1 : Variables
"""
Create a variable called my_variable
Set my_variable to the value 10
SAVE & RUN
"""
my_variable = 10
# Exercise 2 : Data Types
"""
Set the following variables to the corresponding values:
my_int to the value 7
my_float to the value 1.23
my_bool to the value True
"""
my_int = 7
my_float = 1.23
my_bool = True
# Exercise 3 : Reassigning Variables
"""
UNCOMMENT the code below
this_int is set to 7 below.
What do you think will happen if we reset it to 3 and print the result?
Change the value of this_int from 7 to 3.
"""
this_int = 7
print this_int
# Change the value this_int from 7 to 3 BELOW
this_int = 3
print this_int
# ************************************************************
# TESTS : DO NOT MODIFY THESE
# ************************************************************
print("")
print("Here are the results of Lesson 2")
print("Exercise 0 : Test Passed!")
if my_variable == 10: print("Exercise 1 : Test Passed!")
else: print("Exercise 1 : Test Failed!")
if my_int == 7 and my_float == 1.23 and my_bool == True: print("Exercise 2 : Test Passed!")
else: print("Exercise 2 : Test Failed!")
if this_int == 3: print("Exercise 3 : Test Passed!")
else: print("Exercise 3 : Test Failed!")
"""
Learning Python
Lesson 2 : Python Syntax
Comments
Simple programming exercises from Codecademy
"""
# Exercise 0 : Single Line Comments
"""
Write a comment below. Make sure it starts with #
It can say anything you like.
"""
# I am really foing to learn this course
# Exercise 1 : Multi-Line Comments
"""
Write a multi-line comment in the editor.
Include whatever text you want!
"""
'''
I love to
work with python
'''
# ************************************************************
# TESTS : DO NOT MODIFY THESE
# ************************************************************
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment