what is the data type
>>> example = { "FName":"John", "LName":"Doe", "Blk3":98 }
What is Dictionary?
// C program to illustrate
// syntax error
#include<stdio.h>
void main()
{
int x = 10;
int y = 15;
printf("%d", (x, y))
}
error: expected ';' before '}' token
def Add
{
@_; # special array to hold passed arguments
$sum = 0;
$counter = 0;
foreach $item (@_) # loop for each argument in array
{
$sum += $item;
print "$_[$counter] "; # unpacked argument
$counter++;
}
return $sum;
}
$num = Add(10..20);
print "= $num";
Perl does not read user defined functions with the def command.
In a flowchart, what shape is used to denote the start/end of a program?
What is a Rectangle (rounded)?
Are often used to automate repetitive tasks.
What are Scripts?
('Phase 1', 'Block')
Phase 1
('Python', 'Obj 3f', 'Python', 'Obj 3f')
('UCT', 'Phase 1', 'Block', 3, 'Python', 'Obj 3f')
File "main.py", line __, in
tuple[3] = 3
Type Error: 'tuple' object does not support item assignment
#include <stdio.h>
int main()
{
int count=1.4;
while (count <= 4);
{
printf("%f ", count);
count+;
}
return 0;
}
while (count <= 4)
printf("%d ", count);
count++;
WHAT IS THE OUTPUT?
$grade = 72;
$status = ($grade >= 70)? "Passed" : "Failed";
print "You $status\n";
ANSWER?
Output:
You Passed
Contains routines that support operations such as function definitions, input, output, etc.
What are Libraries?
A set of goals to be accomplished for the program to work.
What is a Task List?
if spam == 42
print('Hello!')
Failed to put a : at the end of if statement.
for(i=1;i<=10;i++)
sum1=sum1+i;
sum2=sum2+i*i;
printf(“%d%dn”,sum1,sum2);
What is missing {}
If the user inputs 3, what will the output be?
print "Enter a positive whole number less than 10\n"; $number= <STDIN>; chomp ($number); if ($number > 10) {
print "Try a smaller number";
}
else
{
for ($count = 1; $count<= $number; $count++) {
printf "Square of $count is %d\n", $count**2; } }
ANSWER:
"Square of 1 is 1"
"Square of 2 is 4"
"Square of 3 is 9"
ANSWER:
"Square of 1 is 1"
"Square of 2 is 4"
"Square of 3 is 9"
Standard library that includes I/O functions, extended conversions, & memory allocation
What is stdio.h?
Are scripts written on the command line in the scripting language of choice and immediately interpreted and executed; not save (nothing left behind to trace).
What are One-Liners?
if spam = 42:
print('Hello!')
Used = instead of ==
//for loop example, what does sum = ?
#include <stdio.h>
int num = 3, sum = 0;
int main()
{
// for loop terminates when n is less than count
for(int count = 1; count <= num; ++count)
{
sum += count;
}
printf("Sum = %d", sum);
return 0;
}
(answer is sum = 6)
What is the error?
@a=0;
while (@a<10)
{
print 1..@a, "\n";
@a++;
}
ANSWER: a is not an array, it is a scalar
Default file name that the compiler uses?
Gives the programmer added flexibility to write separate blocks of code for both a true or false evaluation; creates an either-or situation.
What is an "if...else" statement?
print('Hello!')
print('Howdy!')
# or
if spam == 42:
print('Hello!')
print('Howdy!')
Using the wrong amount of indentation.
include
<stdio.h>
int main()
{
float number;
printf("Enter an integer: ");
scanf("%d",&number);
if(number%2 == 0){
printf("%d is an even integer.",number);
}
else {
printf("%d is an odd integer.",(number));
}
return 0;
}
missing # in header file
number should be an int not a float
too many parenthesis in else print statement
What is the issue with the function:
$a = 11;
while( $a > 10 )
{
print "Value of a: $a\n";
$a += 1;
}
Will never meet exit conditions.
Data type for an object that does not have a value
of any of the other types.
What is Void?
Enables you to choose one course of action from a list of possible actions; requires a break statement to terminate a statement.
What is a "Switch" statement?