Beginner Programming Notes
Python: for loop with range(6)
for i in range(6):
print(i)
# Output: 0 1 2 3 4 5
# range(6) means 0 to 5 (6 excluded)
Python: [Link]()
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
# Output: [1, 2, 3, 4]
Python: random module
import random
print([Link](1, 10)) # Random int from 1 to 10
print([Link]()) # Float from 0.0 to 1.0
Python: [Link]()
[Link]() returns a float between 0.0 and 1.0.
You can scale it:
value = 10 + (20 - 10) * [Link]()
C: strcmp()
#include <string.h>
strcmp(str1, str2)
Returns:
- 0 if equal
- <0 if str1 < str2
- >0 if str1 > str2
Beginner Programming Notes
Terminal: Rename a file
mv [Link] [Link]
# Renames [Link] to [Link]
Terminal: Create folder
mkdir my_folder
# Creates a new folder
Terminal: Open Python file
python3 [Link]
# Runs the file with Python 3
Python: curses example (simplified)
import curses
def main(stdscr):
[Link](0, 0, 'Hello from curses!')
[Link]()
[Link]()
[Link](main)