Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode.
Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, as if you were at 1,000 feet above your presentation.
f(x)=x*x
y(x)=x*x
y=x*x
y(10)=100
----OR-----
f(x)=x*x
f(x){
return x*x
}
outputType f(inputType x){
return x*x
}
#include <iostream>
void hello() // function
{ // {
// ... function body
// }
std::cout << "hello world" << std::endl;
}
int main(){
hello(); // the calling of the function hello()
return 0;
}
import ...
def hello(): # function
# {
# ... function body
# }
print("hello world")
def main():
hello()
if __name__ == "__main__":
main()
#include <iostream>
int main(){ // function main() // output type is int
std::cout << "hello world" << std::endl;
return 0; // returns int 0 value
}
#include <iostream>
int main(){
std::cout << "The game for 4 players:" << endl;
std::cout << "Enter the names of you friends:" << endl;
// Data block
char player1[100];
// Input block
std::cout << "Player 1: ";
std::cin >> player1;
// Data block
char player2[100];
// Input block
std::cout << "Player 2: ";
std::cin >> player2;
// Data block
char player3[100];
// Input block
std::cout << "Player 3: ";
std::cin >> player3;
// Data block
char player4[100];
// Input block
std::cout << "Player 4: ";
std::cin >> player4;
return 0;
}
#include <iostream>
int main(){
int array1[5] = {1,2,3,4,5}; // Array 1
for(int i = 0; i < 5; i++){
std::cout << "Array1[" << i+1 << "]: " << array1[i] << "\n";
}
int array2[7] = {1, 2, 3, 4, 5, 6, 7}; // Array 2
for(int i = 0; i < 5; i++){
std::cout << "Array2[" << i+1 << "]: " << array1[i] << "\n";
}
int array3[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Array 3
for(int i = 0; i < 5; i++){
std::cout << "Array3[" << i+1 << "]: " << array1[i] << "\n";
}
return 0;
}
#include <iostream>
int main(){
condition = true;
int number = condition ? 42 : 13
}
condition = True
number = 42 if condition else 13
print(number)
# Fish Tanks Volume
def calculateFishTanks():
# Only here we use function 5 times, so make it lambda
pass
volume = lambda x, y, z, type="cm^3": "Volume: " + str(x * y * z) + " " + type
print(volume(10, 15, 20))
data = ["rabbit", "chuck", "Joe", "duck", "rock", "joke", "docker", "hope"]
listfilter = list(filter(lambda x: ('k' in x), data))
# Prints ['chuck', 'duck', 'rock', 'joke', 'docker']
print(listfilter)
int* a = new int[10]{1,2,3,4,5,6,7,8,9,10};
a+sizeof(int)*index
# list comprehension
doublesGen = (2 * n for n in range(50))
# same as the list comprehension above
doublesList = list(2 * n for n in range(50)) # 0 - 49
def first_n(n):
'''Build and return a list'''
num, nums = 0, []
while num <= n:
nums.append(num)
num += 1
return nums
sum_of_first_n = sum(first_n(100))
print(sum_of_first_n)
num, nums = 0, []
nums.append(num)
yield
def simpleGeneratorFun():
yield 1
yield 2
yield 3
# Python Generator Function with Multiple Yield
def testGen():
x = 1
print('First yield')
# Generator function has many yield statements
yield x
x *= 2
print('Second yield')
yield x
x *= 3
print('Last yield')
yield x
# Call the generator
iter = testGen()
# Invoke the first yield
next(iter)
# Invoke the second yield
next(iter)
# Invoke the last yield
next(iter)
# a generator that yields items instead of returning a list
def firstn(n):
num = 0
while num <= n:
yield num
num += 1
def csv_reader(file_name):
for row in open(file_name, "r"):
yield row
def infinite_sequence():
num = 0
while True:
yield num
num += 1