Chapter 13 Programming and Data Representation Flashcards

1
Q

What is python?

A

Python is a multi-paradigm programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Key characteristics of python.

A

Keywords are written in lower case

Python is case sensitive meaning Number1 <> NUMBER1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is VB.NET?

A

VB.NET is a multi paradigm, high-level programming language, implemented on the .NET Framework.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Key characteristics of VB.NET.

A

Every statement should be on a separate line. However, if necessary statements can be typed on the same line with a colon as a separator
Indentation is a good practice
Not case sensitive
Programs need to be compiled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Pascal?

A

Pascal is a multi-paradigm programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Key characteristics of Pascal.

A

Every statement must end in a semicolon (;)
Indentation is a good practice
Not case sensitive
Programs need to be compiled
Compound statements consists of a sequence of statements enclosed between the keywords begin and end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to declare variables in python, VB.NET and Pascal?

A
  • Python does not have variable declaration
  • VB.NET Dim [, identifier] As
  • Pascal var [, identifier] : ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to declare and assign values to constants in python, VB.NET and Pascal?

A
  • Python =
  • VB.NET Const =
  • Pascal Const = ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between a variable and a constant?

A

A constants value should not be changed and a variables name can be changed if so desired.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to assign values to a variable in python, VB.NET and Pascal?

A
  • Python =
  • VB.NET =
  • Pascal := ;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which are the arithmetic operators are different in pseudocode, python, VB.NET and Pascal?

A
Exponent: - Python: ^
                  - Integer division: **
                  - CB.NET: ^
                  - Pseudocode: Not available
Integer division: - Python: DIV
                  - Integer division: //
                  - CB.NET\
                  - Pseudocode: Div
Modulus: - Python: MOD
                  - Integer division: %
                  - CB.NET: Mod
                  - Pseudocode: Mod
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do the rules of precedence define?

A

The Rules of precedence define the order of the calculations to be performed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to output information on the screen in python, VB.NET and Pascal?

A
  • Python print() (Moves to next list)
    print(, end = ‘ ‘) (To avioid moving onto the next line after the output)
  • VB.NET Console.WriteLine()
    Console.Write() (To avoid moving to the next line)
  • Pascal WriteLn()
    Write() (To avoid moving to the next line)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to get an input from the user in python, VB.NET and Pascal?

A
  • Python A = input(‘Prompt: ‘)
  • VB.NET Console.Write(‘Prompt: ‘)
    A = Console.ReadLine ()
  • Pascal Write(‘Prompt: ‘)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to add comments in python, VB.NET and Pascal?

A
  • Python # this is a comment
  • VB.NET // this is a comment
  • Pascal // this is a comment
    // this is another comment
    {this is a multi-line comment if more comments have to be written}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are whole signed numbers assigned in python, VB.NET and Pascal?

A
  • Python int
  • VB.NET Integer
  • Pascal Integer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How are signed numbers with a decimal point assigned in python, VB.NET and Pascal?

A
  • Python Not available
  • VB.NET Char
  • Pascal Char
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How are strings assigned in python, VB.NET and Pascal?

A
  • Python str
  • VB.NET String
  • Pascal String
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How to write booleans in python, VB.NET and Pascal?

A
  • Python bool
  • VB.NET Boolean
  • Pascal Boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How are Monetary values assigned in python, VB.NET and Pascal?

A
  • Python Not available
  • VB.NET Decimal
  • Pascal Currency
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How are date values assigned in python, VB.NET and Pascal?

A
  • Python Not available as a built-in data type
  • VB.NET Date
  • Pascal TDateTime
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How to write equal in python, VB.NET and Pascal?

A
  • Python ==
  • VB.NET =
  • Pascal =
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How to write not equal in python, VB.NET and Pascal?

A
  • Python !=
  • VB.NET <>
  • Pascal <>
24
Q

How to write greater than in python, VB.NET and Pascal?

A
  • Python >
  • VB.NET >
  • Pascal >
25
How to write less than in python, VB.NET and Pascal?
- Python < - VB.NET < - Pascal
26
How to write greater than or equal to in python, VB.NET and Pascal?
- Python >= - VB.NET >= - Pascal >=
27
How to write less than or equal to in python, VB.NET and Pascal?
- Python <= - VB.NET <= - Pascal <=
28
How to write AND in python, VB.NET and Pascal?
- Python and - VB.NET And - Pascal AND
29
How to write OR in python, VB.NET and Pascal?
- Python or - VB.NET Or - Pascal OR
30
How to write NOT in python, VB.NET and Pascal?
- Python not - VB.NET Not - Pascal NOT
31
How to write an IF...THEN statement in python, VB.NET and Pascal?
- Python if: - VB.NET If Then End If - Pascal if : then
32
How to write an IF...THEN statement in python, VB.NET and Pascal?
- Python if: else: - VB.NET If Then Else: End If - Pascal if: then else:
33
How to write an IF...THEN statement in python, VB.NET and Pascal?
- Python if: elif: else: - VB.NET If Then Elseif: Else: End If - Pascal if: then else: if then else:
34
How to write a CASE statement in VB.NET and Pascal?
- VB.NET Select Case Case value1 Case value1, value2 Case value4 TO value5 . . . CaseElse ``` End Select - Pascal case of value1: value1, value2 value4..value5 . . . else ``` end;
35
How to iterate in Python, VB.NET and Pascal?
- Python: for in range(s, e, i): - VB.NET: For = s To e Step i Next - Pascal: for := s to e do ;
36
How to write a Post-condition statement in Python, VB.NET and Pascal?
- Python: not available - VB.NET: Do ``` Loop Until - Pascal: repeat ; until ; ```
37
How to write a Pre-condition statement in Python, VB.NET and Pascal?
- Python: while : - VB.NET: Do While Loop Do Until Loop - Pascal: while do ;
38
How to declare arrays in Python, VB.NET and Pascal?
``` - Python doesn't have arrays. The equivalent is called list and the data entered in a list doesn't have to be of the same data type because python's lists are dynamic. Example: List1 = [] List1.append("Fred") List1.append("#Jamie23") -VB:NET: Dim () As - Pascal var : array[lowerBound..upperBound] of ; ```
39
How to access a 1D array in Python, VB.NET and Pascal?
``` - Python: NList[24] = 0 - VB.NET: NList[25] = 0 - Pascal: NList[24] := 0 ```
40
How to create 2D arrays Python, in VB.NET and Pascal?
``` - Python ex.: Board = [[0 for i in range (7)] for j in range(6)] Board = [[0] * 7] * 6 - VB.NET: Dim (, ) As - Pascal: var : array[1uBound1..uBound1, 1uBound2..uBound2] of ; ```
41
How to access 2D arrays Python, in VB.NET and Pascal?
``` - Python: Board[2][3] = 0 - VB.NET: Board(3, 4) = 0 - Pascal: Board[3, 4] := 0 ```
42
How to access a single character using position P in a string in Python, in VB.NET and Pascal?
``` - Python: ThisString [P] (Counts from 0) - VB.NET: ThisString (P) (Counts from 0) - Pascal: ThisString [P] (Counts from 1) ```
43
How to return the string character associated with the specified character code from a string in Python, in VB.NET and Pascal?
``` - Python: chr(i) - VB.NET: Chr(i) - Pascal: Chr(i) ```
44
How to return an integer value representing the character code of the specified character in Python, in VB.NET and Pascal?
``` - Python: ord(ch) - VB.NET: Asc(ch) - Pascal: Ord(ch) ```
45
How to return an integer that contains the number of characters in string s in Python, in VB.NET and Pascal?
``` - Python: len(S) - VB.NET: len(S) - Pascal: Len(S) ```
46
How to return an integer that contains the number of characters in string S in Python, in VB.NET and Pascal?
``` - Python: len(S) - VB.NET: len(S) - Pascal: Len(S) ```
47
How to return a substring of length L from the left of string S in Python, in VB.NET and Pascal?
``` - Python: S[0:L] - VB.NET: Left(S, L) - Pascal: LeftStr(S, L) ```
48
How to return a substring of length L from the right of string S in Python, in VB.NET and Pascal?
``` - Python: S[-L:] - VB.NET: Right(S, L) - Pascal: RightStr(S, L) ```
49
How to return a substring of length L from position P in string S in Python, in VB.NET and Pascal?
``` - Python: S[P : P + L] - VB.NET: mid(S, P, L) - Pascal: MidStr(S, P, L) ```
50
How to join strings in Python, in VB.NET and Pascal?
``` - Python: s = S1 + S2 - VB.NET: s = S1 + S2 s = S1 & S2 - Pascal: S := Concat (S1, S2); S := S1 + S2; ```
51
How to round up or down numbers in Python, in VB.NET and Pascal?
``` - Python: round(x, ndigits) - VB.NET: Math.Round(x) - Pascal: Round(x) ```
52
How to truncate numbers in Python, in VB.NET and Pascal?
``` - Python: int(x) - VB.NET: Math.Truncate(x) - Pascal: Trunc(x) ```
53
What does truncate number x mean?
Truncate number x means that the whole number part of the real number x is returned except the decimal point
54
How to convert a string to a number in Python, in VB.NET and Pascal?
``` - Python: int(S) - VB.NET: CInt(S) - Pascal: StrToInt(S) ```
55
How to output random numbers in Python, in VB.NET and Pascal?
- Python: import random ``` value = random.randint(1, 6) print (value) - VB.NET: Dim RandomNumber As New Random Dim x As Integer x = RandomNumber.Next(1, 6) - Pascal: RandomRange (1, 6) ```