This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> // for string build in function, strlen | |
int main() | |
{ | |
const int firstNumber = 30; | |
const int secondNumber = 50; | |
const int day = 2; | |
const int myNumbers[] = {4, 6, 9, 20, 5, 10}; | |
const char *myLanguages[] = {"C", "C++", "Java", "C#", "PHP", "Python", "Ruby", "JavaScript", "Rust", "Go", "Swift", "R", "Kotlin"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main(void) { | |
const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
char firstText[50] = "Hello "; | |
const char secondText[] = "World!"; | |
const int alphabetLength = strlen(alphabet); | |
const int alphabetByte = sizeof(alphabet); | |
const char firstStr[] = "Happy"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
/* | |
* Run: | |
* gcc -Wall -pedantic -Werror -Wextra -std=c99 c-programming/input.c -o c-programming/output | |
* gcc c-programming/input.c -o c-programming/output | |
* c-programming/output | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
printf("Hello, World!\n"); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python as calculator | |
x, y = 9, 3 | |
print(x + y) # Addition | |
# 12 | |
print(x - y) # Subtraction | |
# 6 | |
print(x * y) # Multiplication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Complex function conversion | |
# A different data type can be converted to a complex number | |
# Conversion of integer numbers to a complex number | |
# You can provide an argument to a complex() function | |
z = complex(10, 20) | |
print(z) | |
# (10+20j) | |
complex('10', '20') | |
# Traceback (most recent call last): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
z = 2 + 17.6j | |
print(z) | |
# (2 + 17.6j) | |
print(z.real) | |
# 2.0 | |
print(z.imag) | |
# 17.6 | |
print(z.conjugate()) | |
# (2-17.6j) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Number - Integer, Float, Complex | |
# Integer | |
Integer in Python are numbers without decimal e.g 20 | |
# A different data type can be converted to an integer | |
# Integer conversion is done with the int() function | |
book_price = 20 | |
print(book_price) | |
# 20 | |
book_price = '30' | |
print(int(book_price)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Primitive Data Structures (Types) | |
# All Primitive Data Types are Immutable Objects | |
int_ = 5 # int - Immutable Object | |
float_ = 5.25 # float - Immutable Object | |
complex_ = 2 + 7.25j # complex - Immutable Object | |
str_ = 'This is a text' # str - Immutable Object | |
bool_ = False # bool - Immutable Object | |
type(int_) # int - Integer Numbers | |
# <class 'int'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isinstance('Hello', (float, int, str, list, dict, tuple)) | |
# True |
NewerOlder