100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Summary

Computer Science 114 Summary

Rating
3.0
(1)
Sold
2
Pages
5
Uploaded on
10-08-2023
Written in
2023/2024

Complete summary and guide to Computer Science 114, 1st year, 1st semester module. Includes a summary of all content covered as well as important pieces of code which are examined. The ultimate summary to succeed in computer science.

Show more Read less
Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
August 10, 2023
Number of pages
5
Written in
2023/2024
Type
Summary

Subjects

Content preview

Computer Science Notes CS 114
Strings
General

string[x] - returns the character at that position in the string.

string[0:2] - returns the 1st and 2nd characters [incl. : excl.]

string[1:len(string)-1] - returns the middle of the string

len(string) - returns the length of the string. (cat = 3)

+ - concatenate string.

== - checks if the strings are the same.

.contains(str) - checks if a string contains a certain string

.index(str) - returns the position of the character in the string



Manipulative Methods

.upper() - converts the string to uppercase

.lower() - converts the string to lowercase

.casefold() - converts string to lowercase, includes additional characters

.replace(old, new, count) - replaces certain characters in a string with the new input




Ethan Ganz 1

, Arithmetic
Functions

+ - addition

- - subtraction

/ - normal division ( = 2.5)

// - floor division (5 // 2 = 2)

* - multiplication

**2 - to the power of 2 (**5 = to the power of 5)

Note: - Considers order of operation

print(str(x) + ‘ ‘ + str(y)) - prints “x y” (x and y are integers or floats)



Methods

max(a, b, c) - returns the variable with the largest value.

min(a, b, c) - returns the variable with the smallest value.

abs(x) - returns the absolute value of x.

abs(x) % 10 - returns the last digit of the number.



Math class

math.sqrt() - returns the square root of a float

math.exp(a) - e to the power of a

math.log(a, b) - log a with base b

math.pi - pie

math.e -e (2.718281828459045…)



Random class

random.random - random float between [0, 1)

random.uniform(a, b) - random float between [a, b] (or [a, b) )

random.int(a, b) - random int between [a, b]

random.range(a, b, c) - random int between [a, b) within the increment c

random.shuffle(a) - shuffles array a randomly (works with 1D or 2D array)

random.gauss(a, b) - Gaussian distribution (a = mu, b = sigma)


Ethan Ganz 2
$4.92
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
ethanganz
3.0
(1)

Reviews from verified buyers

Showing all reviews
1 year ago

3.0

1 reviews

5
0
4
0
3
1
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
ethanganz Stellenbosch University
Follow You need to be logged in order to follow users or courses
Sold
2
Member since
3 year
Number of followers
1
Documents
2
Last sold
8 months ago

3.0

1 reviews

5
0
4
0
3
1
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions