Language Fundamentals Flashcards
what are these called?: ( )
Parentheses
what are these called?: []
Square brackets
what are these called?: {}
Curly Brackets
what are these called?: ‘ ‘ or “ “
String
What are Keywords?
Keywords are reserved words in Python. They are used to define the syntax and structure of the python language such as def or True
What are Identifiers?
An indentifier is a name given to entities like class, functions, variable.
What is a class?
A class is a code template for creating objects.
Instance = class Snake: ... pass
What is a function?
A function is defined by using the def keyword:
A function is a block of code which only runs when it is called
you can pass data, known as parameters, into a function.
Example def my function (): print ("hello from a function"
What is a statement?
Instructions that a python interpreter can execute are called statements.
For example:
a = 1 + 2 + 3
What is a variable?
A python variable is a named location used to store data in the memory.
number = 10
which can be replaced at any time
number = 11
Website = “apple.com”
print(website)
It’s best practice to use lower case for variables
What are the four different literal collections?
fruits = ["apple", "mango", "orange"] #list numbers = (1, 2, 3) #tuple alphabets = {'a':'apple', 'b':'ball', 'c':'cat'} #dictionary vowels = {'a', 'e', 'i' , 'o', 'u'} #set
print(fruits)
print(numbers)
print(alphabets)
print(vowels)
OUTPUT: ['apple', 'mango', 'orange'] (1, 2, 3) {'a': 'apple', 'b': 'ball', 'c': 'cat'} {'e', 'a', 'o', 'i', 'u'}
What is an f string?
Example:
print (f”You are {age} old {height} tall.”)