unknowns so far Flashcards
compare = “Python” * 3
print (compare)
PythonPythonPython
compare = “Python” > “Java”
print (compare)
True
(Python comes first in the alphabet and is at a lower index/would come first)
compare = “Python” + “Java”
print(compare)
PythonJava
word = “python”
firstletter = word[0]
print(firstletter)
p
word = sheep
for letter in word:
print (letter)
S
H
E
E
P
compare = “Hello”
len(compare) =
5
compare = “Hello”
compare.isalpha()
True
compare = 12345
compare.isalpha()
False
compare = “Hello”
compare.upper()
HELLO
compare = 12345
compare.upper()
TypeError - The two data types conflict.
compare = 12345
compare.isalnum()
True
compare = “Hello”
compare.isalnum()
False
What is a data structure?
a container that can hold several items at the same time.
What is an array?
A data structure that can hold a number of items grouped together.
It contains a number of items grouped together, and named using a single identifier, however can only hold the same data type.
What is a syntax error?
When code written does not follow the rules of the programming language
What is a runtime error?
If something unexpected is typed in by the user, the code will crash, eg. A string where a bool/real is expected.
It occurs WHILE the program is running.
What is a type error?
TypeError = When the two data types conflict