Type "help", "copyright", "credits" or "license" for more information.
>>> print "Hello Word!"
Hello Word!
>>> if(foo)
File "", line 1
if(foo)
^
SyntaxError: invalid syntax
>>> f=true
Traceback (most recent call last):
File "", line 1, in
NameError: name 'true' is not defined
>>> f=1
>>> if f:
... print "f is 1"
...
f is 1
>>> if f:
... print "f is 1"
... else:
... print "i don't know"
...
f is 1
>>> """
... multi
... line
... comment
... """
'\nmulti\nline\ncomment\n'
>>> d = None
>>> numbers = [1,2,3,4]
>>> len(numbers)
4
>>> numbers[0]
1
>>> person={}
>>> person["name"]="ikbhal"
>>> person.update({
... "favourites":[42,"food"],
... "gender":"male"
... })
>>> person
{'gender': 'male', 'favourites': [42, 'food'], 'name': 'ikbhal'}
>>> person[(44.47, -73)]= "coordinates"
>>> person
{'gender': 'male', 'favourites': [42, 'food'], 'name': 'ikbhal', (44.47, -73): 'coordinates'}
>>> p2= {"name":'Ikbhal', 'gender':'Male'}
>>> p2
{'gender': 'Male', 'name': 'Ikbhal'}
>>> p2.get('name','Anonymous')
'Ikbhal'
>>> p2.values()
['Male', 'Ikbhal']
>>> p2.items()
[('gender', 'Male'), ('name', 'Ikbhal')]
>>> is_python=True
>>> is_python=bool("any object")
>>> is_python
True
>>> animals = "Cats " + "Dogs"
>>> animals += "Rabbits"
>>> name = '%(first)s %(last)s' % {
... 'first':'Ikbhal',
... 'last':'Shaik'}
>>> name
'Ikbhal Shaik'
>>> grade = 82
>>> if grade >= 90:
... print "A or A+"
... elif grade >= 80:
... print "B"
... else:
... print "F"
...
B
>>> class User(object):
... pass
...
>>> class Student(object):
... def __init__(self, name='Anyonmous')
File "", line 2
def __init__(self, name='Anyonmous')
^
SyntaxError: invalid syntax
No comments:
Post a Comment