Misc CS Flashcards

1
Q

How to get the last digit of an integer without converting it to a string first

A

modulo 10

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

How to get all digits but the last of an integer, without converting it to a string first

A

python

floor division by 10

Python
~~~
2013 // 10
# 201
~~~

Javascript
~~~
Math.floor(2013 / 10)
# 201
~~~

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