Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
8 views
3 pages
Lab - Week 4 (2021)
İTÜ BIL100E notları
Uploaded by
erdemsimsek234
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Lab_Week 4 (2021) For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
8 views
3 pages
Lab - Week 4 (2021)
İTÜ BIL100E notları
Uploaded by
erdemsimsek234
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Lab_Week 4 (2021) For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Lab_Week 4 (2021) For Later
You are on page 1
/ 3
Search
Fullscreen
Repetition Structures Int lab session, you are going to learn; Repetition structures, including: © Condition-controlled loops © Count-controlled loops © Nested loops * Infinite loops and how they can be avoided range function as used in for loops. © Calculating a running total and augmented assignment operators 1) Consider following while statements and see the results. Infinite loop, exit with Ctr1+c while True: print(“Hello Python") Hanile Loop count = @ while (count < 9): print(‘The count is:', count) count = count +1 print ("6ood bye!") #unile loop with else mycount. while mycount < 5: print(mycount, "is less than 5") mycount = mycount + 1 else: print(mycount, " is not less than S")2) This problem averages test scores. It asks the user for the number of students and the number of test scores per student. # Get the number of students. num_students = int(input('How many students do you have? *)) # Get the number of test scores per student. nun_test_scores = int(input(‘How many test scores per student? ')) # Determine each student's average test score. for student in range(num_students): # Initialize an accumulator for test scores. total = 0.0 # Get a student's test scores. print('Student number’, student + 1) print(* ) for test_num in range(nun_test_scores): print (‘Test nunber', test_num + 1, end= float(input(": *)) score = # Add the score to the accumulator. total += score # Calculate the average test score for this student. average = total / num_test_scores # Display the average print('The average for student number’, student + 1, 'is:', average) print()3) Consider following for statement and see the results. For loop for letter in ‘Python’: print(‘Current Letter :', letter) fruits = [‘banana’, ‘apple’, ‘mango ] for fruit in fruits print(‘Current fruit :', fruit) print("éood bye!") 4) Consider following examples about nested loops and see the results. Nested for loop, the multiplication table for x in range(1, 11): for y in range(1, 11. print('d * Xd = xd" % (x, y, xty)) ‘Nested while loop x= -20 y= 20 while x <= yz print ("X is now: 2x) x=x+1 while x < @: print ("X is negative") xexed
You might also like
Python Lab Manual (I BCA) 2023-2024 Final (1) - 8-23
PDF
No ratings yet
Python Lab Manual (I BCA) 2023-2024 Final (1) - 8-23
16 pages
5-Intro To Python - Loop
PDF
No ratings yet
5-Intro To Python - Loop
64 pages
AQA GCSE CompSci Paper 2 Section B
PDF
No ratings yet
AQA GCSE CompSci Paper 2 Section B
19 pages
Python - Control Structures
PDF
No ratings yet
Python - Control Structures
37 pages
CSP1150 Lecture 3 Data Structures and Loops
PDF
No ratings yet
CSP1150 Lecture 3 Data Structures and Loops
47 pages
Lecture 4
PDF
No ratings yet
Lecture 4
40 pages
Revision Tour XI - Strings - Loops HH
PDF
No ratings yet
Revision Tour XI - Strings - Loops HH
50 pages
Chapter05. List and Loop Statements
PDF
No ratings yet
Chapter05. List and Loop Statements
47 pages
Python 03 Ly Reduced
PDF
No ratings yet
Python 03 Ly Reduced
29 pages
CO1003 - Chapter 5 - Repetition Statements
PDF
No ratings yet
CO1003 - Chapter 5 - Repetition Statements
43 pages
Module 3
PDF
No ratings yet
Module 3
39 pages
Chapter 4
PDF
No ratings yet
Chapter 4
35 pages
Week 3 - Introduction To Python #2
PDF
No ratings yet
Week 3 - Introduction To Python #2
29 pages
04 Python Lecture Updated
PDF
No ratings yet
04 Python Lecture Updated
35 pages
Week 5
PDF
No ratings yet
Week 5
28 pages
Lecture 6
PDF
No ratings yet
Lecture 6
33 pages
04 - Chapter 04
PDF
No ratings yet
04 - Chapter 04
26 pages
Python Class PRG
PDF
No ratings yet
Python Class PRG
54 pages
Week 3
PDF
No ratings yet
Week 3
40 pages
Chapter5 Repetition LoopStatements
PDF
No ratings yet
Chapter5 Repetition LoopStatements
39 pages
Lec 04
PDF
No ratings yet
Lec 04
54 pages
ProgFund Lect Week 6
PDF
No ratings yet
ProgFund Lect Week 6
26 pages
Lecture Module 4 - Repeating Parts
PDF
No ratings yet
Lecture Module 4 - Repeating Parts
31 pages
Week 5 (Repetition Structures)
PDF
No ratings yet
Week 5 (Repetition Structures)
28 pages
Data Science Lab
PDF
No ratings yet
Data Science Lab
22 pages
Lec 07 Iteration Loop
PDF
No ratings yet
Lec 07 Iteration Loop
20 pages
Nested Loops
PDF
No ratings yet
Nested Loops
19 pages
09 Iteration2
PDF
No ratings yet
09 Iteration2
21 pages
CO Lab 3
PDF
No ratings yet
CO Lab 3
29 pages
Introduction To Python (Part II)
PDF
No ratings yet
Introduction To Python (Part II)
29 pages
Loop Control Statements
PDF
No ratings yet
Loop Control Statements
20 pages
05 Repetition Structures
PDF
No ratings yet
05 Repetition Structures
40 pages
Programming and Data Structures: Control Flow: Looping
PDF
No ratings yet
Programming and Data Structures: Control Flow: Looping
55 pages
Chapter 2 - Loops & Functions - Python Programming For Data Science
PDF
No ratings yet
Chapter 2 - Loops & Functions - Python Programming For Data Science
22 pages
Lab#5
PDF
No ratings yet
Lab#5
7 pages
Unit - 2
PDF
No ratings yet
Unit - 2
39 pages
PP Lab Manual
PDF
No ratings yet
PP Lab Manual
36 pages
ICS103: Programming in C: 5: Repetition and Loop Statements
PDF
No ratings yet
ICS103: Programming in C: 5: Repetition and Loop Statements
38 pages
Looping Constructs
PDF
No ratings yet
Looping Constructs
23 pages
Lab #5
PDF
No ratings yet
Lab #5
12 pages
CP104 - Chapter 4 - Repetition Structures
PDF
No ratings yet
CP104 - Chapter 4 - Repetition Structures
5 pages
Section 6
PDF
No ratings yet
Section 6
11 pages
ICT LAB 12, EEE-018 - Merged
PDF
No ratings yet
ICT LAB 12, EEE-018 - Merged
9 pages
Exp 4 and 5
PDF
No ratings yet
Exp 4 and 5
9 pages
Lab-11-Loops in Python
PDF
No ratings yet
Lab-11-Loops in Python
9 pages
Control Structure-Repetition: FOR Loop
PDF
No ratings yet
Control Structure-Repetition: FOR Loop
15 pages
Chapter 4 - Program Control: Outline
PDF
No ratings yet
Chapter 4 - Program Control: Outline
29 pages
X 6 Qy 8 VBM JDNP D5 DT
PDF
No ratings yet
X 6 Qy 8 VBM JDNP D5 DT
11 pages
Exp 6 and 7
PDF
No ratings yet
Exp 6 and 7
7 pages
File - 1728537674 - Practice Questions 5
PDF
No ratings yet
File - 1728537674 - Practice Questions 5
5 pages
Lab-11-Loops in Python
PDF
No ratings yet
Lab-11-Loops in Python
4 pages
Week 6
PDF
No ratings yet
Week 6
4 pages
Python - Control Structures
PDF
No ratings yet
Python - Control Structures
37 pages
Starting Out With Python 4e (Gaddis) Chapter 4 Repetition Structures
PDF
No ratings yet
Starting Out With Python 4e (Gaddis) Chapter 4 Repetition Structures
7 pages
Unit-II DS Using Python
PDF
No ratings yet
Unit-II DS Using Python
12 pages
Programming Summary of While and For Loops Python
PDF
No ratings yet
Programming Summary of While and For Loops Python
2 pages
TP10
PDF
No ratings yet
TP10
2 pages
PRO511-Chapter 4 Lecture Notes
PDF
No ratings yet
PRO511-Chapter 4 Lecture Notes
3 pages
Tutorial - Sec2 CS Tay Za Win Tun
PDF
No ratings yet
Tutorial - Sec2 CS Tay Za Win Tun
3 pages