C++ vs Python Flashcards

(19 cards)

1
Q

cout

A

print(“Hello World”,end = “\n”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

int some_variable = 17 ;

A

some_variable = 17

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

;

A

(no need)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

int a;

cout &laquo_space;a;

A

a=input(“Enter any number : “)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

cout &laquo_space;some_int &laquo_space;” is the answer” &laquo_space;endl;

A

print(some_int, “ is the answer”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

//this is a comment

A

this is a comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
/*
this 
is 
multi-lined
comment
*/
A
#this
#is
#multi-lined
#comment
#(python does not support multi-lined comments)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
void some_function(string a , int b)
{
//code
}
A
def some_function(a,b)
    #code
#(OR)
def some_function(*args)
    a , b = args 
    #code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

cout &laquo_space;“My name is “ &laquo_space;name &laquo_space;surname &laquo_space;endl ;

A
print(f"My name is {name} {surname}")
#OR
print("My name is {} {}".format(name , surname))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

string name = “Happy”;

string x = “My name is “ + name ;

A
name = "Happy"
x = f"My name is {name}"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

for(int i = 1 ; i < 100 ; i++)cout<

A
print("cool"*99)
#had you guessed 99 correctly ?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

cout &laquo_space;“line 1 “ &laquo_space;endl &laquo_space;“line2” &laquo_space;end &laquo_space;“line3” &laquo_space;endl;

A
print("""line1
line2
line3"""
)
#note that this doesn't work
#print(""" ....will add a blank line
#line1 
#line2
#line3....will add a blank line
#""")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

string divided_egg = “Hello I am d\i\v\i\d\e\d egg “;

A

divided_egg = “Hello I am d\i\v\i\d\e\d egg “

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
#include 
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile.close();
A

my_file = open(“example.txt” , “r+”)

myfile. write(“Writing to this file.\n”)
myfile. close()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

my_file.is_open()

A

exists(my_file)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

|| //OR used in cpp

19
Q

!=

A

<>
#OR
!=
#both are same