Beginner_Programming_Notes
Beginner_Programming_Notes
for i in range(6):
print(i)
# Output: 0 1 2 3 4 5
# range(6) means 0 to 5 (6 excluded)
Python: list.append()
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
# Output: [1, 2, 3, 4]
import random
print(random.randint(1, 10)) # Random int from 1 to 10
print(random.random()) # Float from 0.0 to 1.0
Python: random.random()
C: strcmp()
#include <string.h>
strcmp(str1, str2)
Returns:
- 0 if equal
- <0 if str1 < str2
- >0 if str1 > str2
Beginner Programming Notes
mv oldname.txt newname.txt
# Renames oldname.txt to newname.txt
mkdir my_folder
# Creates a new folder
python3 filename.py
# Runs the file with Python 3
import curses
def main(stdscr):
stdscr.addstr(0, 0, 'Hello from curses!')
stdscr.refresh()
stdscr.getkey()
curses.wrapper(main)