0% found this document useful (0 votes)
25 views2 pages

Beginner Programming Notes

This document provides beginner programming notes covering Python and C programming concepts. It includes examples of Python's for loop, list manipulation, random number generation, and terminal commands for file management. Additionally, it explains the C function strcmp and provides a simple example using the curses library in Python.

Uploaded by

sidharth amrutha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Beginner Programming Notes

This document provides beginner programming notes covering Python and C programming concepts. It includes examples of Python's for loop, list manipulation, random number generation, and terminal commands for file management. Additionally, it explains the C function strcmp and provides a simple example using the curses library in Python.

Uploaded by

sidharth amrutha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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)

You might also like