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)
32 views
ALgorithm
Uploaded by
Dana Sobh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save ALgorithm For Later
Download
Save
Save ALgorithm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
32 views
ALgorithm
Uploaded by
Dana Sobh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save ALgorithm For Later
Carousel Previous
Carousel Next
Save
Save ALgorithm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 17
Search
Fullscreen
1) Write an algorithm to exchange the values of two variables A and B, regardless of their prior content. output("Enter 2 numbers") input num1 input num2 num3 <-- numi num1 <-- num2 num2 <-- num3 output("The new values are", num1, num2 )2) Write an algorithm for transferring to B the value of A, to C the value of B and to A the value of C (always regardless of the prior contents of these variables). . OUTPUT("Enter 3 values ") Input A Input B Input C B<--A C<--B A<--C output("The values are", A, B, C )3) Write an algorithm that performs the reading of the time t in seconds, and it displays the time t in days, hours, minutes, seconds. Example: if t= 21,020 seconds the algorithm will cepa O days 5 hours 50 minutes and 20 seconds. output("Enter a time of seconds") input seconds output("It will display d=",d,"h=",h,"m=",m,"s=",s) & ve xGa x60 a ee (anaer x 69) W qe © / (Ge a) oe ch (toxés) me v¢ /0 S — 7.64) Write an algorithm and draw a flowchart that will find and print the product of 3 numbers. output("Enter first number") input num1 output("Enter second number") input num2 output("Enter third number") input num3 product = num1* num2* num3 output("The product of these three numbers is" , product)5) Write an algorithm and draw a flowchart to calculate the average of 5 numbers output("Enter five numbers") input num1 input num2 input num3 input num4 input numS sum = num1+num2+num3+num4+nums. av =sum/S output("The average is ", av)6. Write an algorithm that calculate and print the result of 1/x° +" fora given x and y. Trace the algorithm with the following values (x=12, y=5). output("Enter the value of x') input x output("Enter the value of y") input y sum = x*x + y*y result = sqrt(sum) output("The answer is ", result)7) Write an algorithm that asks the user to enter his country and then display his language Ex: USA, UK : English Lebanon: Arabic Paris: Francais output("Enter your country") input country if country = USA or country = UK then: output("English") else if country = Lebanon then: output("Arabic") else if country = Paris then: 1 ‘output("Not a valid country") ave tf ase ih else.solving the previous ex using switch output("Enter your country") input country switch country do: case "US) case "UK"; — Ss output("English") break case "Lebanon": output("Arabic") break case "Paris": output("French") break Cotnepsise output("Not a valid country") _————_——8) Write pseudocode to generate the first N numbers in the Fibonacci sequence. ot 2 => ort Ot Nae oN NR sae a 2 as —o Th 32> o!|z222\" co. tna > 8abt) = ele) +oib[s\= © Gb) = eb (sY +€ib (4) : =% Rife COI + CB) eco) Neh & Exb() sei (a)=* avin © /) bls) a Fib (\ eeili}= . ae. (Se 4) abl) = LO a Cib(at abl\c4 dow coker, Bele!) 4 Cres) ciblo) =e cables ifF(n-2) F(n-3) F(n-2) F(n-3) F(n-3)F(n-4) F(n-4)F(n-5) F(n-3) F(n-4) F(a) F(n-5)rite pseudocode for a function that takes a number as an argument and eturns "Fizz", "Buzz" or "FizzBuzz". If the number is a multiple of 3 the output should be "Fizz". If the number given is a multiple of 5, the output should be "Buzz". If the number given is a multiple of both 3 and 5, the output should be "FizzBuzz". If the number is not a multiple of either 3 or 5, the number should be output nits own as shown in the examples below. he output should always be a string even if it is not a multiple of 3 or 5. Examples izz_buzz(3) — "Fizz" fizz_buzz(5) > "Buzz" izz_buzz(15) — "FizzBuzz" fizz_buzz(4) 7 "4"A four-digit number is called Lucky if RN keen CRN mL RCs ole Vem arm ual eed eee aa anor oar The number Ko MU Waal eL-Te ale} AUN sealed reat asta a BNI 2A [19 028A = 3HO_ AZ [Ao “4 S) a 5g =3)\ PALO —> mH gan ct Sa hlo > FR oa [to ~@e® } plese 1, a) tee? U7input num d4=num/10 r4=num%10 3 d3 =d4/10 r3=d4%10 4 d2=d3/10 ->3 r2=d3% 10» sumFirstTwoDigits = d2 + r2 3 +r4 if sumFirstTwoDigits = sumLastTwoDigits then: sumLast TwoDigit: output("This is a lucky number") else output("This is not a lucky number")QUESTION Write a function that simulates a coin head or tails game. An array should be used to save the two possible options the computer can randomly select from. The user should be able to enter their choice or head or tails. If the user guesses correctly the function outputs ‘Congratulations! You guessed correctly, otherwise outputs ‘Sorry, you guessed wrong’-declare tails heads : string function tailsOrheads() return string outcomes = ["head","tail"] tailsOrheads = random_number (outcomes) output ("Guess if it is| heads or tails ™) input tails heads if tails_heads = tailsOrheads then: output ("Congratulations! ") else: output ("Your guess is wrong ", tailsOrheads) end function //call the function tailsOrheads ()Write a Python function generate_lottery_numbers that generates a list of 6 unique random numbers between 1 and 49, simulating a lottery ticket. Output the numbers outside of the function. function generate_lottery_numbers() return integer lottery_numbers = [] while length(lottery_numbers) <6 random_int = random_number(1, 49) if random_int not in lottery_numbers add_to_list(lottery_numbers, random_int) //call the function lottery_ticket =generate_lottery_numbers() output("Lottery numbers are", lottery_ticket)
You might also like
Theory Workbook Answers
PDF
92% (13)
Theory Workbook Answers
71 pages
Cambridge Primary Parent Guide 2022
PDF
100% (1)
Cambridge Primary Parent Guide 2022
20 pages
Pseudocode Practice For Loop
PDF
0% (1)
Pseudocode Practice For Loop
2 pages
python lab
PDF
No ratings yet
python lab
8 pages
Algorithmic Thinking with python-Assignment 1
PDF
No ratings yet
Algorithmic Thinking with python-Assignment 1
3 pages
Grade 11 - CP 4 Introduction To Problem Solving
PDF
No ratings yet
Grade 11 - CP 4 Introduction To Problem Solving
10 pages
NCRT Questions Chapter Wise 11
PDF
No ratings yet
NCRT Questions Chapter Wise 11
6 pages
New Microsoft Word Document
PDF
No ratings yet
New Microsoft Word Document
14 pages
Cse Assignment 3
PDF
No ratings yet
Cse Assignment 3
10 pages
Python programming lab
PDF
No ratings yet
Python programming lab
25 pages
Python Lab Manual
PDF
No ratings yet
Python Lab Manual
10 pages
Info Tech
PDF
No ratings yet
Info Tech
6 pages
PF Assignment
PDF
No ratings yet
PF Assignment
5 pages
XII Practical File New-1
PDF
No ratings yet
XII Practical File New-1
29 pages
Python Example
PDF
No ratings yet
Python Example
43 pages
10200123031_Md Kaif Sardar
PDF
No ratings yet
10200123031_Md Kaif Sardar
21 pages
Psuedocode Questions PRC
PDF
No ratings yet
Psuedocode Questions PRC
120 pages
Python Codes For Grade 8
PDF
No ratings yet
Python Codes For Grade 8
6 pages
Practical File
PDF
No ratings yet
Practical File
22 pages
Python manual
PDF
No ratings yet
Python manual
10 pages
ECE-C CSE102 - Computer Programming Assignment-1
PDF
No ratings yet
ECE-C CSE102 - Computer Programming Assignment-1
3 pages
Ncert Solutions
PDF
No ratings yet
Ncert Solutions
14 pages
Zoho Questions
PDF
No ratings yet
Zoho Questions
15 pages
shreya gaur python 50 projects
PDF
No ratings yet
shreya gaur python 50 projects
22 pages
Lab Manual 1st Year (Updated)
PDF
No ratings yet
Lab Manual 1st Year (Updated)
35 pages
AI PRACTICAL FILE-1
PDF
No ratings yet
AI PRACTICAL FILE-1
21 pages
AaaaaaaaaaaaL101 Midterm Project
PDF
No ratings yet
AaaaaaaaaaaaL101 Midterm Project
3 pages
Practical File AI X.docx_20250120_073156_0000
PDF
No ratings yet
Practical File AI X.docx_20250120_073156_0000
13 pages
Python Record
PDF
No ratings yet
Python Record
96 pages
SC Lab Record
PDF
No ratings yet
SC Lab Record
82 pages
2_Exercises_Data Structures and Iteration
PDF
No ratings yet
2_Exercises_Data Structures and Iteration
7 pages
FOR & WHILE LOOPS
PDF
No ratings yet
FOR & WHILE LOOPS
25 pages
Assesed HW
PDF
No ratings yet
Assesed HW
3 pages
Xii CS 2023 Practical Programs
PDF
No ratings yet
Xii CS 2023 Practical Programs
58 pages
Diwali Assignment Unit-1 20BAI10214
PDF
No ratings yet
Diwali Assignment Unit-1 20BAI10214
9 pages
python updated questions
PDF
No ratings yet
python updated questions
8 pages
ACFrOgAq5EYCrQ5nXqJWrcQ4yzz5-NYV8_T7zj_b4jkY2vsDrV9CN3dzoxP6wQYbyN2G78mB7nxysG1hV1pHTxhGW15Zo_vxTlzrDG9ZSNllZH0GtDC2l6pEs-x2O2lANvTEXofxZ9mFy4jWt7PI
PDF
No ratings yet
ACFrOgAq5EYCrQ5nXqJWrcQ4yzz5-NYV8_T7zj_b4jkY2vsDrV9CN3dzoxP6wQYbyN2G78mB7nxysG1hV1pHTxhGW15Zo_vxTlzrDG9ZSNllZH0GtDC2l6pEs-x2O2lANvTEXofxZ9mFy4jWt7PI
34 pages
Python Lab End Exam Questions CSE5
PDF
No ratings yet
Python Lab End Exam Questions CSE5
14 pages
Assesed HW
PDF
No ratings yet
Assesed HW
3 pages
Programming in Python 4639304
PDF
50% (2)
Programming in Python 4639304
41 pages
CS Practical File
PDF
No ratings yet
CS Practical File
32 pages
CS Practical File Class XI
PDF
No ratings yet
CS Practical File Class XI
4 pages
CPS LAB MANUAL - 1-1
PDF
No ratings yet
CPS LAB MANUAL - 1-1
82 pages
CIT 101 Py Lesson 9 Final
PDF
No ratings yet
CIT 101 Py Lesson 9 Final
10 pages
Practice Pseudocode Questions
PDF
No ratings yet
Practice Pseudocode Questions
7 pages
Divya Kapoor Python Pratical File
PDF
No ratings yet
Divya Kapoor Python Pratical File
26 pages
Python Manual
PDF
No ratings yet
Python Manual
22 pages
AI Practical Assignments
PDF
No ratings yet
AI Practical Assignments
12 pages
1635446991862_PF-Worksheet1-Fall 2021
PDF
No ratings yet
1635446991862_PF-Worksheet1-Fall 2021
4 pages
Python Lab 2024
PDF
No ratings yet
Python Lab 2024
19 pages
Artificial Intelligence Lab
PDF
No ratings yet
Artificial Intelligence Lab
28 pages
C-Lab internal exam20 (2)
PDF
No ratings yet
C-Lab internal exam20 (2)
4 pages
Python Programs
PDF
No ratings yet
Python Programs
5 pages
Cs practical file class 11 th
PDF
No ratings yet
Cs practical file class 11 th
10 pages
GRADE 11-A_Holiday Homework_Savio_Martin_Computer Science Vacation HW
PDF
No ratings yet
GRADE 11-A_Holiday Homework_Savio_Martin_Computer Science Vacation HW
13 pages
Artificial-Intelligence
PDF
No ratings yet
Artificial-Intelligence
27 pages
Python Lab Manual - III BCA (1 To 10)
PDF
No ratings yet
Python Lab Manual - III BCA (1 To 10)
23 pages
18CSC207J APP Lab Manual
PDF
No ratings yet
18CSC207J APP Lab Manual
89 pages
Python Practical
PDF
No ratings yet
Python Practical
7 pages
Python Assignments
PDF
100% (1)
Python Assignments
7 pages
Statistics
PDF
No ratings yet
Statistics
18 pages
Algo Bann
PDF
No ratings yet
Algo Bann
48 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
Theory Workbook Answers
PDF
Theory Workbook Answers
Cambridge Primary Parent Guide 2022
PDF
Cambridge Primary Parent Guide 2022
Pseudocode Practice For Loop
PDF
Pseudocode Practice For Loop
python lab
PDF
python lab
Algorithmic Thinking with python-Assignment 1
PDF
Algorithmic Thinking with python-Assignment 1
Grade 11 - CP 4 Introduction To Problem Solving
PDF
Grade 11 - CP 4 Introduction To Problem Solving
NCRT Questions Chapter Wise 11
PDF
NCRT Questions Chapter Wise 11
New Microsoft Word Document
PDF
New Microsoft Word Document
Cse Assignment 3
PDF
Cse Assignment 3
Python programming lab
PDF
Python programming lab
Python Lab Manual
PDF
Python Lab Manual
Info Tech
PDF
Info Tech
PF Assignment
PDF
PF Assignment
XII Practical File New-1
PDF
XII Practical File New-1
Python Example
PDF
Python Example
10200123031_Md Kaif Sardar
PDF
10200123031_Md Kaif Sardar
Psuedocode Questions PRC
PDF
Psuedocode Questions PRC
Python Codes For Grade 8
PDF
Python Codes For Grade 8
Practical File
PDF
Practical File
Python manual
PDF
Python manual
ECE-C CSE102 - Computer Programming Assignment-1
PDF
ECE-C CSE102 - Computer Programming Assignment-1
Ncert Solutions
PDF
Ncert Solutions
Zoho Questions
PDF
Zoho Questions
shreya gaur python 50 projects
PDF
shreya gaur python 50 projects
Lab Manual 1st Year (Updated)
PDF
Lab Manual 1st Year (Updated)
AI PRACTICAL FILE-1
PDF
AI PRACTICAL FILE-1
AaaaaaaaaaaaL101 Midterm Project
PDF
AaaaaaaaaaaaL101 Midterm Project
Practical File AI X.docx_20250120_073156_0000
PDF
Practical File AI X.docx_20250120_073156_0000
Python Record
PDF
Python Record
SC Lab Record
PDF
SC Lab Record
2_Exercises_Data Structures and Iteration
PDF
2_Exercises_Data Structures and Iteration
FOR & WHILE LOOPS
PDF
FOR & WHILE LOOPS
Assesed HW
PDF
Assesed HW
Xii CS 2023 Practical Programs
PDF
Xii CS 2023 Practical Programs
Diwali Assignment Unit-1 20BAI10214
PDF
Diwali Assignment Unit-1 20BAI10214
python updated questions
PDF
python updated questions
ACFrOgAq5EYCrQ5nXqJWrcQ4yzz5-NYV8_T7zj_b4jkY2vsDrV9CN3dzoxP6wQYbyN2G78mB7nxysG1hV1pHTxhGW15Zo_vxTlzrDG9ZSNllZH0GtDC2l6pEs-x2O2lANvTEXofxZ9mFy4jWt7PI
PDF
ACFrOgAq5EYCrQ5nXqJWrcQ4yzz5-NYV8_T7zj_b4jkY2vsDrV9CN3dzoxP6wQYbyN2G78mB7nxysG1hV1pHTxhGW15Zo_vxTlzrDG9ZSNllZH0GtDC2l6pEs-x2O2lANvTEXofxZ9mFy4jWt7PI
Python Lab End Exam Questions CSE5
PDF
Python Lab End Exam Questions CSE5
Assesed HW
PDF
Assesed HW
Programming in Python 4639304
PDF
Programming in Python 4639304
CS Practical File
PDF
CS Practical File
CS Practical File Class XI
PDF
CS Practical File Class XI
CPS LAB MANUAL - 1-1
PDF
CPS LAB MANUAL - 1-1
CIT 101 Py Lesson 9 Final
PDF
CIT 101 Py Lesson 9 Final
Practice Pseudocode Questions
PDF
Practice Pseudocode Questions
Divya Kapoor Python Pratical File
PDF
Divya Kapoor Python Pratical File
Python Manual
PDF
Python Manual
AI Practical Assignments
PDF
AI Practical Assignments
1635446991862_PF-Worksheet1-Fall 2021
PDF
1635446991862_PF-Worksheet1-Fall 2021
Python Lab 2024
PDF
Python Lab 2024
Artificial Intelligence Lab
PDF
Artificial Intelligence Lab
C-Lab internal exam20 (2)
PDF
C-Lab internal exam20 (2)
Python Programs
PDF
Python Programs
Cs practical file class 11 th
PDF
Cs practical file class 11 th
GRADE 11-A_Holiday Homework_Savio_Martin_Computer Science Vacation HW
PDF
GRADE 11-A_Holiday Homework_Savio_Martin_Computer Science Vacation HW
Artificial-Intelligence
PDF
Artificial-Intelligence
Python Lab Manual - III BCA (1 To 10)
PDF
Python Lab Manual - III BCA (1 To 10)
18CSC207J APP Lab Manual
PDF
18CSC207J APP Lab Manual
Python Practical
PDF
Python Practical
Python Assignments
PDF
Python Assignments
Statistics
PDF
Statistics
Algo Bann
PDF
Algo Bann