Flashcards
Programming Flashcards
Cards in this deck (17)
- 1operators are:+ addition
- subtraction
* multiplication
/ division
// integer division
** power
% modulo - 2Basic calculationsprint( 15+4 )
print( 15-4 )
print( 15*4 )
print( 15/4 )
print( 15//4 )
print( 1 5* *4 )
print( 15%4 ) - 3The modulo operator (%)takes the remainder of a division
- 4a statementexample: print( 15+4 )
- 5Strings"A string is a text, consisting of zero or more characters."
fix error: 'I can\'t stand it' - 6Data Typesstring""
Integer (whole number)
Float ( a number with a decimal point.) - 7An expressioncombination of one or more values (such as strings, integers, or floats) using operators,
which result in a new value - 8String expressionsprint( "hello"+"world" )
print( 3* "hello" )
print( "goodbye" *3 ) - 9Type castingchange the data type of a value into a different data type.
- 10The three main type casting functions• int() will return the value between the parentheses as an integer (rounding down if
necessary)
• float() will return the value as a float (adding .0 if necessary)
• str() will return the value as a string - 11Variable name rules:1.Must start with a letter or underscore_
2.Consist of Letters, Digits or Underscores
3.Cannot be a reserved word - 12Programmer Conventions*Choose variable meaningful to code
*Only use lowercase letters (avoid confusion)
*put underscore between words
*don't choose names that start with underscore. - 13constantsvalues assigned to a variable which can no longer be changed after the value has been first assigned.
- 14Boolean ValuesTrue and False
- 15False ValuesFalse
0 numerical values
"none"
("empty string") - 16Comparisons==
- 17in operatortests if the value to the
left side of the operator is found in a “collection” to the right side of the operator.
Information
- Description
- Computer Science Flashcards on Programming Flashcards, created by Vera Wu on 19/09/2019.
- Created by
- Vera Wu
- Views
- 5
- History
-
- Created by Vera Wu · Sep 19, 2019
- Copied by Vera Wu · Sep 19, 2019
- Rating