CS 1 Flashcards

1
Q

(optional, not needed)On comparing, what is 0, A, a value?

A

(optional, not needed)What has a value of 48, 65, 97?

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

What is the result of 3/4?

A

(ignore when on this side)0.75

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

explain +=, such as x += 52

A

(ignore when on this side) += means it adds upon, x = x + 52

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

How can you take the value for a variable from the user via the input

A

(ignore when on this side) input()
such as inp = input()

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

What does ', \n, \t do?

A

How do you make new line, tab, and a single quote?

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

How do you import math to import all functions directly

A

(ignore when on this side) from math import *(must use dot-notation)

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

How would you import sqrt function only directly? and what is the function for square root

A

(ignore when on this side)from math import sqrt
sqrt()

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

(optional, not needed) How do you import the random function and what is the function for random and what do you need? How do you do randomint and to pick out of a list such as “[ ]”(uses different random function)

A

(ignore when on this side) import random

print(random.randint(5, 10))
print(random.randint(5, 10))

import random
t = [1, 2, 3]
print(random.choice(t))
print(random.choice(t))

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

what keyword must you use to indicate that this is a function defintion?

A

(ignore when on this side) def

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

(optional not needed)What is another way to print quotations?

A

(ignore when on this side) (f” “) like print(f”‘GeeksforGeeks’”)

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

What does math.ceil() do?

A

What math.(function) does:Round a number upward to its nearest integer:
Such as print(math.ceil(1.4)) = 2
and print(math.ceil(-5.3)) = -5

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

What does math.floor() do?

A

What math.(function) does: Round numbers down to the nearest integer

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

What does floor division // do?

A

What rounds the result down to the nearest whole number?

Such as:
x = 15
y = 2

print(x // y)

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

What does Modulus % do?

A

What gives the remainder or the number and gives the full number if can divide it?

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

(optional, not needed)How does Modulus % work with negative numbers?

A

(ignore when on this side) For EX: What is -7 mod 5?

Solution: To find -7 mod 5, we firstly find the largest number that is less than or equal to -7 and divisible by 5. That number is -10. Now, in order to get remainder subtract -10 from -7(-7 -(-10), which gives 3 that is the remainder.

Recap: find largest divisble number of the divisor, than substact first number by that number.

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

What does evaluate mean?

A

(ignore when on this side) it doesn’t mean true. It justs means it reaches there.

17
Q

What does a runtime error mean?

A

What error is encounterd at an issue at runtime, during program execution when the sytax is right. Such as: Division by zero.
Using an undefined variable or function name.
Performing an operation on incompatible types.

18
Q

What does a semanatic error mean?

A

What error is with a program that runs without producing error messages but doesn’t do the right thing?

19
Q

What does ls() do?

List

A

What command allows you to display the list of files and folders in a
directory?