C 173 Programming Notes PDF

Title C 173 Programming Notes
Author Kent Dorfman
Course Scripting and Programming - Foundations
Institution Western Governors University
Pages 16
File Size 594.5 KB
File Type PDF
Total Downloads 62
Total Views 155

Summary

Notes from Programming...


Description

* Required

I want to print 6 exclamation points. Which is the most efficient way to do this? * print "!" + "!" + "!" + "!" + "!" + "!" return "!" * 6 print "!" * 6 return "!" + "!" + "!" + "!" + "!" + "!"

What type of programming language runs using an .exe (executable) file? * compiled functional Python interpreted

What is the main difference between compiled and interpreted code? * Which editor is used to write the code How the code is converted to machine language When the code is converted to machine language Why the code is converted to machine languge

What is a final value that cannot be reduced further? * non-terminal terminal operator

How do you create a variable with a value of 6 in Python? * def var myvar = 6 myvar = 6 var myvar = 6 myvar: 6

If I have a variable with the value of 6, how do you change that value to read six instead? * myvar = six def myvar = "six" myvar = "six" myvar: "six"

How would you display only the word Python from this code? * print myVar[6:]

print myVar[0:] print myVar['Python'] print myVar[0:6]

Using the following code, how would you join the variables into a sentence? *

print subject + " " + verb + " " + adjective + " " + object print subject + verb + adjective + object print sentence print sentence = subject + verb + adjective + object

* Required

Basic Constructs of Programming What would this code print? *

True False

What would this code print? *

True False

What would this code print? *

True False

What type of loop is best suited to continually check a test expression? * while for def if...else

I want to notify all students who scored 35 points or better on a quiz that they have passed and let anyone who scored less than 35 points know that they did not pass. What type of statement is best suited for this? * def for if...else while

How many times can you call a function to run? * once ten times, and then you must reload the script as many times as you want to

What would this code print? *

True False

What would this code print? *

True False

What is the difference in a procedure and a function? * Trick question, they are both the same thing! Functions can take inputs, procedures do not Procedures return a value, functions do not Procedures can take inputs, functions do not Functions return a value, procedures do not

What would this code print? *

True False

What happens if you define a function but do not invoke it? * The script will return an error The function will automatically execute when you load the script Nothing. The code will simply remain in memory but will not execute.

What would this code print? *

True False

What would this code display? *

JessicaandConnieare friends. Nothing Jessica and Connie are friends.

What would this code print? *

True False

What is the difference in an input, an argument, and a parameter? * input does not have to have a value, an argument and parameter do argument does not have to have a value, an input and parameter do parameter does not have to have a value, an argument and input do Trick question, they are all the same thing!

What is the final value of this expression: 5 + 4 * (4 + 4 / 2) * 29 18

10 20

What would this code print? *

True False

What would this code print? *

True False

How do you get outputs from a function? * by listing them within the () when you define the function. Ex. def myfunction(outputs) Using the return keyword You do not need to define outputs, they are handled automatically by Python. By saving the output to a variable name within the function

Using Built-in Objects How would you mutate the list so that it only contains the values red, yellow, blue, green, and orange. * myColors[1:] myColors.append('purple') myColors[1:5] myColors.pop()

How would you properly begin a loop that would cycle through each element from the list? * for list:myColors: for color in myColors: list color in myColors: for myColors list:

How would you add a new value to the end of the list for black? * myColors.pop("black") myColors.append("black") myColors[5] = "black" myColors.add("black")

How would you create a new list that uses the values of myColors, but contains only blue and green. * myColors2 = myColors[:4] myColors2 = myColors[2:] myColors2 = myColors[2:4] myColors2 = myColors['blue','green']

How would you construct a for loop to execute a block once for each element in this list? *

for(favColors): for color in favColors: for favColors in list: for favColors:

How would you display only the color red? *

print myColors[:] print myColors['red'] print myColors[0] print myColors[1]

How would you select and print the value "yellow"? *

print favColors[1:1] print favColors['yellow'] print favColors[2][2] print favColors[1][1]

How would you change the value of "blue" to "royal blue"? * myColors[2] = "royal blue" myColors['blue'] = "royal blue" myColors[1] = "royal blue" myColors[3] = "royal blue"

How would you select and print the value "ginger"? *

print favColors[3][0] print favColors[4][1] print favColors['ginger']

print favColors[3:0]

What programming principal am I applying if my object, myCustomer, borrows properties from your class, myPerson? * abstraction polymorphism inheritance encapsulation

What is the difference in an object and a class? * An object is written in Python, a class is not. A class must be part of a separate subroutine, an object does not. A class describes what that object will be, but it isn't the object itself. An object describes what the class will be, but it isn't the class itself.

What is the proper syntax for declaring a class in Python named "myClass" that inherits from the base class "myObject"? * class myClass(myObject): class __init__ myObject(myClass): class __init__ myClass(myObject): class myObject(myClass):

What three things describe an object in object-oriented programming languages? * encapsulation polymorphism attributes sequence diagram identity behaviors

What programming principal allows us to work with objects created from different classes? * polymorphism encapsulation abstraction inheritance

I have an object named "myCarClass" that has properties for number of doors, color, and style. How would I access the color of my object? * attribute.myCarClass.color

myCarClass(color) myCarClass.attribute = color myCarClass.color

What programming principal applies to objects by restricting access to the object's properties and behaviors? * polymorphism abstraction encapsulation inheritance

What is another term for information hiding, or data hiding? * encapsulation polymorphism inheritance abstraction

I have 3 entries that I am going to place in a hash table: Jessica, John, and Paul. Explain the 2 major things that will happen to enter these in a hash table. * Nothing - you need more than three entries for a hash table Sorted, indexed, and put into buckets Assigned an index and sorted Assigned a key and sorted into buckets

What resources should you consider in the cost of an algorithm? * Memory and Input Time and Input CPU and Memory Time and Memory

What is this code is an example of? *

Recursion Infinite Loop Neither recursion nor circular

What is the cost of an algorithm primarily related to? * How long it takes to run out of memory Time and Input Run time The size of the input

What three rules must a recursive algorithm obey? * Must have a base case It must change state in any direction It must call itself It must change state towards the base case It must move backwards

What is time.clock used for in relation to algorithm efficiency? * Shows system clock to the user Shows when code starts Shows when code both starts and ends to provide benchmarking Shows when code ends

Which option is best to search for "Ed Johnson" in an online phonebook * Linear Search Hash Search

Which option is best for searching for your best run times for the past month on your running app? * Linear Search Hash Search

What is the difference in a hash table and a dictionary? * One is scalable, the other is not One is a list, the other a definition Nothing They require different data types

Which is true of procedures and algorithms? * Neither is required to return a value An algorithm must return a value A procedure must return a value Both must return a value

What is the difference between a function and an algorithm? * A function must return a value A function may or may not return a value Neither will return a value An algorithm will not return a value

What is this code is an example of? *

Infinite Loop Operational Definition None of the above Recursive Definition

What is this code an example of? *

Recursive Definition Infinite Loop None of the above

Operational Definition

Which search method is quicker? * Hashed Linear Indexed Definition

A hash table consists of these two concepts ... * Attributes, Values Buckets, Keys Keys, Attributes Buckets, Attributes

Which option is best to locate a batting average of your baseball teams last game? * Linear Search Hash Search

Which option is best to find a book on amazon? * Linear Search Hash Search

Design Process, UML Is an entity required to complete scenario successfully? * Yes No

In which step of the UML Design Process would you create a use case diagram? * Identify the main objects Create a class diagram Describe the interactions between objects Gather Requirements Describe the Application

Visual Representation of actors and use cases * Choose

Deliverable of step 2 - Describe the application * Choose

Steps to accomplish goal * Choose

This needs to be a system * Choose

How actors and use cases interact * Choose

Illustrates inheritance and polymorphism * Choose

Narrative of how people will use app * Choose

Defines the goal * Choose

Who wants the goal * Choose

In which step of the UML Design Process would you create a use case? * Create a class diagram Describe the Application Describe the interactions between objects Gather Requirements Identify the main objects

Needed to start coding * Use Case

In which step of the UML Design Process would you create a class diagram? * Describe the interactions between objects Create a class diagram Gather Requirements Describe the Application Identify the main objects

Camel Case * Use Case

No coding allowed * All three

Place the following UML Design Processes in order from first to last starting with 1. * 1 2 3 4 5 Gather Requirements Identify the main objects Create a class diagram Describe the interactions between objects Describe the Application

Other Languages Which language is best suited for android mobile applications? * Objective-C Java C

Which language is best suited for creating apps for an iPhone? * Objective-C C Java

Which of these are programming library functions we have used in this course? * (Check all that apply)

.push() .submit() .pop() .index()

Which language(s) is/are best suited for web applications? * Java, Ruby C, Ruby Python, Ruby

What is the main difference between an object-oriented language and a non object-oriented (procedural/functional language)? * One is concerned with objects the other uses some objects but not all Nothing they are the same One is centered on objects while the other is centered around actions One is easy to learn the other hard

Which language(s) is/are best suited for creating utilities within an operating system? * C, Ruby Java, Python Java, Ruby

What are some benefits of using a programming library? * (Select all that apply)

Pre-built code One library for all programming languages Easy to learn Quicker to use

Which language(s) is/are best suited for cross-platform applications? *

Java, C, Objective-C Java, Ruby, Python Objective-C, Ruby, Python

What language covered in the learning resources is not objectoriented? * Objective-C Java C...


Similar Free PDFs