100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSC1015F Summary notes of whole course $5.34
Add to cart

Summary

CSC1015F Summary notes of whole course

4 reviews
 638 views  11 purchases
  • Course
  • Institution
  • Book

Summarized notes for the CSC1015F course at UCT. Notes are a summary of lectures, course material & textbook. I achieved a 90% for this course, with these notes. Detailed summary with examples, and explains everything you will need to know for any assignments/tests/exams.

Preview 6 out of 39  pages

  • Yes
  • May 6, 2021
  • 39
  • 2020/2021
  • Summary

4  reviews

review-writer-avatar

By: zuleighhhhha • 3 year ago

review-writer-avatar

By: caleblester • 3 year ago

review-writer-avatar

By: julietyacoubi01 • 3 year ago

review-writer-avatar

By: Jontycohen • 3 year ago

These notes were an absolute lifesaver! Set out really well and very comprehensive, covered every topic of the course and helped me understand everything

avatar-seller

Available practice questions

Flashcards 34 Flashcards
$2.81 1 sales

Some examples from this set of practice questions

1.

What is an algorithm?

Answer: An algorithm is a set of steps to accomplish a task.

2.

Algorithms must be precise so that they are: A. Ambiguous B. Can be executed by different people C. Repeatable D. Have a predictable outcome (write down all that are correct)

Answer: B, C, D

3.

A function _________. A. must always have a return statement to return a value B. may have no parameters C. must have at least one parameter D. must always have a return statement to return multiple values

Answer: B

4.

Does the function call in the following function cause syntax errors? import math def main(): math.sin(math.pi) main()

Answer: No

5.

Which of the following should be defined as a non return function? A. Write a function that returns a random integer from 1 to 100. B. Write a function that prints integers from 1 to 100. C. Write a function that checks whether a number is from 1 to 100. D. Write a function that converts an uppercase letter to lowercase.

Answer: B

6.

Consider the following incomplete code: def f(number): # Missing function body print(f(5)) The missing function body should be ________. A. print(\"number\") B. return number C. print(number) D. return \"number\"

Answer: B

7.

Given the following function header: def f(p1, p2, p3, p4) Which of the following are correct to invoke it? A. f(p1 = 1, p2 = 2, p3 = 3, 4) B. f(p1 = 1, 2, 3, 4) C. f(1, 2, 3, 4) D. f(p1 = 1, p2 = 2, p3 = 3, p4 = 4)

Answer: C, D

8.

Given the following function: def nPrint(message, n): while n > 0: print(message) n -= 1 What will be displayed by the call nPrint(\'a\', 4)? A. aaaa B. aaa C. infinite loop D. aaaaa

Answer: A

9.

A variable defined inside a function is referred to as __________. A. a global variable B. a local variable C. a block variable D. a function variable

Answer: B

10.

What will be displayed by the following code? x = 1 def f1(): y = x + 2 print(y) f1() print(x) A. 3 1 B. 1 3 C. The program has a runtime error because x is not defined. D. 1 1

Answer: A

Introduction to computing


Importance of computing:
- Forecasting natural disasters
- Computer Aided Tomography scans
- Finding and distributing information (internet)
- Entertainment (games, instant messaging)
- E-commerce (online shopping)


What is Computer Science?


The study of:
- Computer software
- Algorithms, abstraction & efficiency
- Theoretical foundations for computation


Problem solving


1. Understand the problem
2. Plan – how to solve the problem
3. Carry out the plan – write the program
4. Assess result
5. Describe what you have learnt
6. Document the solution


Algorithms


Algorithm: set of steps to accomplish a task


Must be precise so that they:
- Are repeatable
- Have a predictable outcome
- Can be executed by different people

,Elements of an algorithm:


- Sequence – each step is followed by another step
- Selection – a choice may be made among other alternatives
- Iteration – a set of steps may be repeatecd


Programming process


- Input – get information from the real world
- Process – process the data internally
- Output – send the computed data back to the real world


Python Basics


Definitions


Program: set of instructions given to a computer, corresponding to an algorithm to
solve a problem
Programming: the act of writing a program
Integrated Development Environment (IDE): graphical interface with menus and
windows
Literals: actual data values written into a program
Function: block of code


Syntax


- Every statement starts on a new line (generally)
- Statements are case sensitive (ie: STUFF vs stuff)


Comments
- Everything after a # is a comment (ie: for humans)
- Brief description: author & date at top of program
- Purpose of each function (if more than one function)
- Short explanation of non-obvious part of code

,Syntax Errors


Syntax error when the program does not conform to the structure required


Program will not run if there is a syntax error
Examples of syntax errors:
- print spelt incorrectly


Logic errors


Logic errors when the program runs but does not work as expected
You must test your program to make sure there are no logic errors


Escape sequences


Escape sequences: special characters that cannot be represented easily in the
program


\a : bell (beep)
\b : backspace
\n : newline
\t : tab
\' : single quote
\" : double quote
\\ : \ character


Numeric Data Types
Numbers have 2 primitive types:
- Integer
- Floating point number

,Integer: whole number with no fractional part
Floating point number: number with fraction part (stores only an approximation to
real number)
- Example: 0,5


Integer Operations


“+” (plus)
“-” (minus)
“/” (divide)
“*” (multiply)
“%” (mod – returns the remainder)
“//” (integer division)
“**” (a**b : a b)


Order of precedence of operations:


- High: ()
- Middle: * / %
- Low: + -


Identifiers


Identifier: used to name parts of the program
Examples: “celcius”, “temperature”, “Temperature”


Naming conventions:
- Start with a letter or underscore (_)
- Separate words with underscore
- Can’t have spaces
- Case sensitive

,Variables


Variables: sections of memory where data can be stored
Most variables have names (identifiers) by which they can be referred
Variables are defined by assigning an initial value to them




Assignment/Input & Output


Output variables just like you output literals
Can output both on one line
a = 1 # assigning the value of 1 to the variable “a”
print (“The value of a is ”, a)


Output: print


print: a built-in function with rules for how it works


General format:
- print(<expression1>, <expression2>, …, <expression_n>)
- print()


By default: print displays the value of each expression, separated by blank spaces,
followed by a carriage return (moving to the next line)
- Sep = “ ”
- End = “\n” (carriage return)

, Input


The input function always gives us a string
Used to get text/string from the user
- input(<prompt>)
If you are going to do math: you must convert the string to a number:
- eval()
eval(): a python function that converts a string into a number
- int() #truncates a float
- float()


Other useful numerical syntax


Increment/decrement operators
+= , -= , *= , /=


Implicit type conversions
Conversions/casting: when one type of value is converted to another
If there is a type mismatch: the narrower range value is prompted up
- Can’t automatically convert down


Explicit type conversions
Typecast methods: methods that cast (convert) a value to another type
Use typecast methods to convert strings to numbers
Use math.ceil, math.floor, round methods for greater control on floating-point
numbers
Use eval(), int(), float() to convert strings to numbers.


math Module
Module: a collection of useful functions

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller jessrosie. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $5.34. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

53340 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$5.34  11x  sold
  • (4)
Add to cart
Added