0% found this document useful (0 votes)
8 views7 pages

Lab 07

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

Lab 07

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIVERSITY OF KARACHI

ASSIGNMENT
Lab # 07

Name: Muhammad Haris Tariq


Class: BS (CS) 1 Year (Evening)
Major
Department of Computer Science -UBIT
Department:
Section: A
Serial No: 25
Form No: 676234
Course Title: Programing Fundamentals (Lab)
Course: 351
Submitted to: Sir Tauseef Mobeen
Exercise

Error:
The function definition is incorrect. In Python, you need to use the def keyword to define a function, and
the function body should be properly indented. Also, the arguments should be enclosed in
parentheses.In Python, after defining a function or starting a loop or conditional statement (if, while,
for), you should use a colon (:) to indicate the start of the block. Python uses indentation to define
blocks of code, such as function bodies, loops, and conditional statements. The content of the function
should be indented. The return statement should also be properly indented inside the function.

Corrected Code:

Output:

Er
ror:
The function definition is missing the def keyword to properly define a function in Python. After
defining a function in Python, you should use a colon (:) to indicate the start of the function body. String
concatenation should be done using + correctly, with spaces added where necessary for readability.
Corrected Code:

Output:

3. Code:

Error:
The condition i // 2 == 0 checks if i divided by 2 equals 0. This condition will always be False for
any integer because it checks if i is even, rather than if the remainder when i is divided by 2 is 0 (which
indicates evenness).

Corrected Code:
Output:

Output:

Output:
Output:

Source Code:

Output:
Source Code:

Output:

Source Code:

Output:
Source Code:

Output:

You might also like