Skip to content

Repository files navigation

Basic Git Commands

 $ git add .
$ git commit -m "write some message"
$ git push 

python-training

This repository has been created for Python Training at Instill Learning.

Built-in Data Types

  • Text Type: str
  • Numeric Types: int, float, complex
  • Sequence Type: list, tuple, range
  • Mapping Type: dict
  • Set Type: set, frozenset
  • Boolean Type: bool
  • Binary Type: bytes, bytearray, memoryview
  • None Type: NoneType

check datatype

type(variable)

Python Collections

  • List: a collection which is ordered and changable also allows duplicate items.
  • Tuple: a collection which is ordered and unchangable also allows duplicate items.
  • Set: a collection which is unordered and unchangable also not allow duplicate items.
  • Dictionary: a collection which is ordered (before python 3.6 it was unordered) and changable also Not allow duplicate items.

OBJECTIVE QUESTIONS

### Easy1.**WhichofthefollowingisavalidvariablenameinPython?**-A) `1_variable`-B) `variable_name`-C) `variable-name`-D) `None`2.**Whatdata type isthenumber`42`inPython?**-A) `float`-B) `str`-C) `int`-D) `bool`3.**WhichofthefollowingisusedtorepresentastringinPython?**-A) `{}`-B) `()`-C) `""`-D) `[]`4.**Whatwillbethedata type of`x`afterthefollowingassignment: `x = 3.14`?**-A) `int`-B) `str`-C) `float`-D) `complex`5.**WhichofthefollowingisthecorrectwaytodefineadictionaryinPython?**-A) `my_dict = [key1: 'value1', key2: 'value2']`-B) `my_dict = (key1: 'value1', key2: 'value2')`-C) `my_dict = {key1: 'value1', key2: 'value2'}`-D) `my_dict = "key1: 'value1', key2: 'value2'"`### Medium6.**WhichofthefollowingstatementsaboutPythonlistsistrue?**-A) Listsareimmutable.
-B) Listscancontainelementsofdifferentdatatypes.
-C) Listsaredefinedusingparentheses`()`.
-D) Alistcannotcontainanotherlist.
7.**Whatwillbetheresultofthefollowingoperation: `type( (1, ) )`?**-A) `int`-B) `str`-C) `list`-D) `tuple`8.**WhichfunctioncanconvertastringintoanintegerinPython?**-A) `int()`-B) `str()`-C) `float()`-D) `bool()`9.**Whatistheresultofthefollowingexpression: `bool("False")`?**-A) `True`-B) `False`-C) `""`-D) `None`10.**WhichmethodwouldyouusetoaddanelementtoasetinPython?**-A) `append()`-B) `add()`-C) `insert()`-D) `push()`### Hard11.**WhichofthefollowingisnotalegalvariablenameinPython?**-A) `_myvar`-B) `my_var`-C) `2myvar`-D) `myVar`12.**If`x = 5`and`y = "5"`, whatwill`type(x+y)`produce?**-A) `int`-B) `TypeError`-C) `str`-D) `float`13.**Whatdoesthe`is`operatortestfor?**-A) Valueequality-B) Identityequality-C) Membership-D) Sizecomparison14.**WhichofthefollowingcorrectlycreatesabytedatatypeinPython?**-A) `b = bytes(5)`-B) `b = byte[5]`-C) `b = 5b`-D) `b = "5".to_bytes()`15.**InPython, whatisthecorrectwaytodeclareacomplexnumber?**-A) `c = 1 + j2`-B) `c = 1 + 2i`-C) `c = 1 + 2j`-D) `c = complex(1,2)`------------------------------------ANSWERS::
-**1**: B) `variable_name`-**2**: C) `int`-**3**: C) `""`-**4**: C) `float`-**5**: C) `my_dict = {key1: 'value1', key2: 'value2'}`-**6**: B) Listscancontainelementsofdifferentdatatypes.
-**7**: D) `tuple`-**8**: A) `int()`-**9**: A) `True`-**10**: B) `add()`-**11**: C) `2myvar`-**12**: B) `TypeError`-**13**: B) Identityequality-**14**: A) `b = bytes(5)`-**15**: C) `c = 1 + 2j`andD) `c = complex(1,2)`

About

This repository has been created for Python Training at Instill Learning.

Resources

Stars

18 stars

Watchers

19 watching

Forks

Releases

Packages

Contributors

Languages