0% found this document useful (0 votes)
74 views3 pages

Eee 111 Lq1 Reviewer (Up Erg)

The document provides a cheat sheet for an EEE 111 class covering topics like flowcharts, common object types, functions, variables, and operators. It includes code samples and questions about the code with the expected output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views3 pages

Eee 111 Lq1 Reviewer (Up Erg)

The document provides a cheat sheet for an EEE 111 class covering topics like flowcharts, common object types, functions, variables, and operators. It includes code samples and questions about the code with the expected output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EEE 111 LQ1 CHEATSHEET

(UP ERG)

FLOWCHARTS COMMON OBJECT TYPES

Int Integers
Terminator: Start/End Float Rational numbers
Complex Complex numbers
String String of characters
Process: Internal processes List List of items
Bool True/False
NoneType “None”
Data: Input/output
- Numbers are int by default, except for
rational (float) and complex (complex)
Decision: Conditional statements numbers.
- Strings are anything declared within single
(‘’) or double quotes (“”).
Flow lines: Indicates direction
- Lists may contain any combination of
datatypes, including lists.
Connector: Jump/shortcut - To access an item in a list: list[item#]
- Bool values may be considered as integers
and vice versa.
- ‘True’ = 1
COMMON FUNCTIONS - Any non-zero integer = ‘True’
- ‘False’ = 0
print(output) Generates output
input(prompt) Generates prompt then VARIABLES
waits for and returns
single user input Assigned with the equals sign (=):
if condition: If condition is true, run
statement1 statement1, else run variable = value
[else:] statement2
statement2 - Named with letters, numbers, and underscores
elif condition: Shortcut for chained else only, and cannot start with numbers.
statement and if - The following cannot be used as var. names:
while condition: While condition is true, and, del, from, not, while, as, elif, global, or,
statements run statements with, assert, else, if, pass, yield, break,
except, import, print, class, exec, in, raise,
range(x,[y],{z}) Creates list of x
continue, finally, is, return, def, for, lambda,
integers from 0
try
[Creates list of int from
- To declare a global variable: global var
x to y]
{Creates list of int from USER FUNCTIONS
x to y with interval z}
for variable in Run statements using Define:
list/range: variable for each item in
statements list/range def function_name([arg1, arg2, ...]):
statements
- Colons are always followed by indents [return return_value]
- May either be a tab or four spaces
- Every indented line until the next non- Call:
indented line after a colon is “under” it
function_name([arg1, arg2, ...])
OPERATORS (ARRANGED BY PRECEDENCE)
- Functions must be defined first before being
** Exponentiation called
*/%// Multiplication, division, - When a function is called, statements will
modulo, floor division be executed, and the call statement will
+- Addition, subtraction assume the value of return_value
<= < > >= Comparison operators - Non-global variables declared outside a
<> == != Equality operators function will be “forgotten” while inside
not and or Logical operators the function, and vice versa
= %= /= //= Assignment operators
-= += *= **=
EEE 111 LQ1 SAMPLEX
(UP ERG)
Part I.
Code A: Code C:

if var==10: def func1(x,y):


print('A') x*=2
elif var==11: return x+y
print('B')
elif var!=12: def func2(z):
print('C') a=1
print('D') b=a
else: for a in range(z):
print('E') b*=(a+2)
if var==13: return str(b)
print('F')
print('G') x=3
b=5
1. What will be the output of the code if var = 10? print(func1(2,3))
2. var = 11? print(func2(4)+'x')
3. var = 12? print((func1(8,8)!=func2(3))+b)
4. var = 13?
8. What does func1 do?
5. var = 14?
9. What does func2 do?
10. What will be the output of the code?

Code B:
i=0 Part II.
while i<25:
i+=5 Draw the flowchart and then write the code (in Python3)
i-=2 for a program that gets two inputs (w and h) and prints a
i==25 filled square using backslashes (\) with width 5w and
height 3h. Valid values of w and h are positive integers
while i>0:
greater than zero but less than ten. The program should
print (i)
request for w and h until a valid value is entered.
i-=4-15//4*2+(2*3)
Sample input/output:
while i%2:
i=int(input('')) Enter width: -1
Enter width: 3
6. What will be the output of the code? Enter height: 12
7. What type of number must the user input to end Enter height: 0
Enter Height: 2
this program?
\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\

(Questions were based on past EEE 11 exams)


EEE 111 LQ1 SAMPLEX
(UP ERG)

Answer Key:
I.
1. A
2. B
3. E
4. C
D
F
G
5. C
D
6. 27
23
19
15
11
7
3

7. An even number.
8. Gets x & y and returns (2x+y)
9. Gets z and returns str((z+1)!)
10. 7
120x
6
II.
w=int(input('Enter width: '))
l=int(input('Enter length: '))

while w<1 or w>9:


w=int(input('Enter w: '))
while l<1 or l>9:
l=int(input('Enter l: '))

for num in range(l*3):


print('\\'*w*5)

(Questions were based on past EEE 11 exams)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy