Chapter1-3 Flashcards
Checking python version?
ust type python on command line , u will see the version
How to start python on terminal?
start terminal
ii. Type python to start python
Write ur program
best way to name python variable ?
- The Python variables you’re using at this point should be lowercase. You won’t get errors if you use uppercase letters, but it’s a good idea to avoid using them for now.
What is python traceback?
A traceback is a record of where the interpreter ran into trouble when trying to execute your code. e.g Traceback (most recent call last):
u File “hello_world.py”, line 2, in v print(mesage)
wNameError: name ‘mesage’ is not defined
What does name error means?
A name error usually means we either forgot to set a variable’s value before using it, or we made a spelling mistake when entering the variable’s name.
A string
you can use single or double quotes around strings
This exibility allows you to use quotes and apostrophes within your strings:
whet is title() function?
title() function convert first letter if each word in string to capital
how to strip whitespaces?
u strip whitespce using rstrip() e.g avorite_language = ‘python ‘ . favorite_language.rstrip() remove the whitespace after n
lstrip()?
strip whitespace from the left side of a strin
how to strip whitespace from both sides?
use strip()
What is syntax error?
A syntax error: A syntax error occurs when Python doesn’t recognize a section of your pro- gram as valid Python code. For example, if you use an apostrophe within single quotes, you’ll produce an error.
print in python 2 and 3 ? what is relation?
In python 2 , printing is not necessary u can type print “isa Musa”. In python 3 , some code u will see print with parenthesis some without parenthesis
does python concatenate numbers with string?
Pyhon don’t concatinate numbers with string unless u change the numbers to string
error
Integers in Python 2 ?
result to an integer
Division of integers in Python 2 results in an integer with the remainder truncated. Note that the result is not a rounded integer; the remainder is simply omitted.3/2 in python returen 1 make sure to use float
How to comment in python?
Comments using #