Unit 2 : Python - Introduction Flashcards

1
Q

What does user see computer as?

A
  1. As a set of tools ( Word Processor, Map )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What can we do as a programmer ? ( 3 )

A
  1. Learn the programming languages
  2. Use tools to build new tools ( VS Code to develop Apps )
  3. Write tools to automate task
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a code called when it was executale?

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

What should we add at the end of out python file?

A
  1. .py ( main.py )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What should we do when naming variables? ( 4 )

A
  1. Create a meaningful name ( radius , practice_number )
  2. Contain letters, numbers and underscore
  3. Underscore can be used for multi-word variable name ( student_name )
  4. Use _ when the next was letter ( num1 not num_1 )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What should we not do when naming variable ? ( 2 )

A
  1. Cannot begin with a number
  2. Cannot use the keywords and the reserved words
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Is variable name case-sentive?

A
  1. Yes ( radius is not the same as Radius )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is code?

A
  1. A set of instructions that reflects human intelligence and problem-solving ability
  2. Can also be seen as a form of creative expression, especially when attention is given to how users interact with the program ( UX )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does software allows us to do?

A
  1. Package and share this intelligence with others, helping them accomplish tasks without having to solve the underlying problems themselves
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Interactive?
( Interactive Python )

A
  1. Using the interpreter or shell, we can type in commands to get immediate results
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is script?

A
  1. Save the code into single file ( .py in python )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between interactive vs script ?

A
  1. Interactive
    • You type directly to Python one line at a time and it responds
  2. Script
    • You enter a sequence of statements (lines) into a file using a text editor and tell Python to
      execute the statements in the file
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is constants? What are the valued stored inside constant ?

A
  1. Fixed Values
  2. Numbers, letters and strings
  • String constants uses single-quote ( ‘ ) or double-quotes ( “ )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a variable ?

A
  1. A named place in the memory where a programmer can store data and later retrieve the data using the variable “name”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When should we use assignment operator? What is the symbol of assignment operator?

A
  1. When we assign a value to a variable
  2. =
  • It consists an expression on the right hand side and variable name to store the result
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List out the symbols in numeric expressions ( 6 )

A
    • ( Called Asterisk )
  1. /
  2. ** ( Called Power )
  3. % ( Called Modulus / Modulas )
17
Q

What is the noun for the term programming languges must know which expressions to do first?

A
  1. Operator Precedence
18
Q

What are the rules of operator precedence rules ? From top to bottom ( 5 )

A
  1. Parenthesis () is always respected
  2. Exponentation ( Raise to power ** )
  3. Multiplication, Division and Remainder ( * , / , % )
  4. Addition and Subtraction ( + , - )
  5. Left to Right
19
Q

What is the term concatenate means?

A
  1. Put together
20
Q

What does python variables, literals and constants have?

A
  1. Type
  • type ‘str’
    type ‘int’
21
Q

How can we know the type in python?

A

e = “hello”

type(e) # shows type’str’

22
Q

List out the type of number

A
  1. Integers
  2. Floating Points
23
Q

What will happen when we put an integer and floating together? ( What type will get )

A
  1. Float
24
Q

How can we change the type if available?

A

e = 1

e = str(e) # Use this code to change from int to str

  • It will contain error when the string does not contain numeris characters
25
Q

What does the input function returns?

A
  1. String
26
Q

How can we input value from python?

A

name = input(“Please enter your name : “)

print(name)

  • When converting the str input to int
    age = int(input(“Age : ”))
27
Q

List out the 2 types of comments

A
  1. Single-line comment ( # )
  2. Multiline comment ( “”” - Start and End )
28
Q

Why should we use comments? ( 3 )

A
  1. Describe what is going to happen in a sequence of code
  2. Document who wrote the code or other ancillary information
  3. Turn off a line of code ( perhaps temporarily )
29
Q

What is program steps ( program flow ) like ?

A
  1. Like a recipe or installation instructions, a program is a sequence of
    steps to be done in order
30
Q

What are the steps? ( 3 )

A
  1. Some steps are conditional - they may be skipped
  2. Sometimes a step or group of steps are to be repeated
  3. Sometimes we store a set of steps to be used over and over as needed in several places throughout the program